2025-06-14 13:46:24 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
public class UISellAreasPanel : 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/sellAreaItem");
|
|
|
|
|
|
if (obj == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.ShowMessage("sellAreaItem.prefabʧ<62><CAA7>");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GameObject go = Instantiate(obj) as GameObject; ;
|
|
|
|
|
|
go.transform.SetParent(itemParent, false);
|
|
|
|
|
|
UISellAreaItem item = go.GetComponent<UISellAreaItem>();
|
|
|
|
|
|
item.itemIdx = itemParent.childCount;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void AddItem(Vector2Int pos, int radius)
|
|
|
|
|
|
{
|
|
|
|
|
|
Object obj = Resources.Load("Prefabs/sellAreaItem");
|
|
|
|
|
|
if (obj == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.ShowMessage("sellAreaItem.prefabʧ<62><CAA7>");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GameObject go = Instantiate(obj) as GameObject; ;
|
|
|
|
|
|
go.transform.SetParent(itemParent, false);
|
|
|
|
|
|
UISellAreaItem item = go.GetComponent<UISellAreaItem>();
|
|
|
|
|
|
item.itemIdx = itemParent.childCount;
|
|
|
|
|
|
MapManager.Instance.SetCurSellCenterPoint(item.itemIdx, radius);
|
|
|
|
|
|
item.txtPos.text = $"{pos.x},{pos.y}";
|
|
|
|
|
|
item.txtRadius.text = radius.ToString();
|
2025-07-18 22:28:40 +08:00
|
|
|
|
MapManager.Instance.CreateSpecialPoint(pos, item);
|
2025-06-14 13:46:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void RemoveAll()
|
|
|
|
|
|
{
|
|
|
|
|
|
int count = itemParent.childCount;
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
DestroyImmediate(itemParent.GetChild(0).gameObject);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|