69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UIRelivesPanel : MonoBehaviour
|
|
{
|
|
[HideInInspector]
|
|
public InputField curActiveInput;
|
|
|
|
public Transform itemParent;
|
|
public Button btnAdd;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
btnAdd.onClick.AddListener(AddItem);
|
|
}
|
|
|
|
void AddItem()
|
|
{
|
|
Object obj = Resources.Load("Prefabs/reliveItem");
|
|
if (obj == null)
|
|
{
|
|
UIWindow.Instance.ShowMessage("reliveItem.prefabʧ°Ü");
|
|
return;
|
|
}
|
|
|
|
GameObject go = Instantiate(obj) as GameObject; ;
|
|
go.transform.SetParent(itemParent, false);
|
|
UIReliveItem item = go.GetComponent<UIReliveItem>();
|
|
item.reliveIdx = itemParent.childCount;
|
|
}
|
|
|
|
public void AddItem(int reliveType, int mapId, Vector2Int pos, int radius, int realMapId)
|
|
{
|
|
Object obj = Resources.Load("Prefabs/reliveItem");
|
|
if (obj == null)
|
|
{
|
|
UIWindow.Instance.ShowMessage("safeAreaItem.prefabʧ°Ü");
|
|
return;
|
|
}
|
|
|
|
GameObject go = Instantiate(obj) as GameObject; ;
|
|
go.transform.SetParent(itemParent, false);
|
|
UIReliveItem item = go.GetComponent<UIReliveItem>();
|
|
item.dropType.value = reliveType;
|
|
item.txtMapId.text = mapId.ToString();
|
|
item.txtPos.text = $"{pos.x},{pos.y}";
|
|
item.txtRadius.text = radius.ToString();
|
|
item.reliveIdx = itemParent.childCount;
|
|
|
|
if (mapId != realMapId)
|
|
return;
|
|
|
|
MapManager.Instance.SetReliveCenterPoint(item.reliveIdx, radius);
|
|
MapManager.Instance.CreateSpecialPoint(pos.x, pos.y, MapManager.EditCellType.ReliveCell);
|
|
}
|
|
|
|
public void RemoveAll()
|
|
{
|
|
int count = itemParent.childCount;
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
DestroyImmediate(itemParent.GetChild(0).gameObject);
|
|
}
|
|
}
|
|
}
|