65 lines
1.7 KiB
C#
65 lines
1.7 KiB
C#
using HxGame.Data;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using static HxGame.Data.MapConfig;
|
|
|
|
public class UIConditionPanel : MonoBehaviour
|
|
{
|
|
public Transform itemParent;
|
|
public Button btnAdd;
|
|
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
btnAdd.onClick.AddListener(AddItem);
|
|
}
|
|
|
|
void AddItem()
|
|
{
|
|
UnityEngine.Object obj = Resources.Load("Prefabs/conditionItem");
|
|
if (obj == null)
|
|
{
|
|
UIWindow.Instance.ShowMessage("conditionItem.prefabʧ°Ü");
|
|
return;
|
|
}
|
|
|
|
GameObject go = Instantiate(obj) as GameObject; ;
|
|
go.transform.SetParent(itemParent, false);
|
|
var item = go.GetComponent<UIConditionItem>();
|
|
}
|
|
|
|
public void AddItem(ConditionConfig cc)
|
|
{
|
|
UnityEngine.Object obj = Resources.Load("Prefabs/conditionItem");
|
|
if (obj == null)
|
|
{
|
|
UIWindow.Instance.ShowMessage("conditionItem.prefabʧ°Ü");
|
|
return;
|
|
}
|
|
|
|
GameObject go = Instantiate(obj) as GameObject; ;
|
|
go.transform.SetParent(itemParent, false);
|
|
var item = go.GetComponent<UIConditionItem>();
|
|
|
|
item.dropMode.value = (int)cc.mode;
|
|
|
|
item.txtLevel.text = cc.level.ToString();
|
|
item.txtItemID.text = cc.itemId.ToString();
|
|
item.txtMoney.text = cc.money.ToString();
|
|
item.txtTime.text = cc.time.ToString();
|
|
}
|
|
|
|
public void RemoveAll()
|
|
{
|
|
int count = itemParent.childCount;
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
DestroyImmediate(itemParent.GetChild(0).gameObject);
|
|
}
|
|
}
|
|
}
|