第一次提交
This commit is contained in:
68
Assets/Scripts/UI/UIRelivesPanel.cs
Normal file
68
Assets/Scripts/UI/UIRelivesPanel.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
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ʧ<62><CAA7>");
|
||||
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ʧ<62><CAA7>");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user