2025-06-14 13:46:24 +08:00
|
|
|
|
using HxGame.Data;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
2025-07-18 22:28:40 +08:00
|
|
|
|
using System.Linq;
|
2025-06-14 13:46:24 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
|
using UnityEngine.UI;
|
2025-07-18 22:28:40 +08:00
|
|
|
|
using static HxGame.Data.MonstersConfig;
|
2025-06-22 15:21:25 +08:00
|
|
|
|
using static MapManager;
|
2025-06-14 13:46:24 +08:00
|
|
|
|
|
2025-07-18 22:28:40 +08:00
|
|
|
|
public class UIMonsterItem : UIBaseItem
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
|
|
|
|
|
public delegate void ClickItemEvent(UIMonsterItem item);
|
|
|
|
|
|
public ClickItemEvent OnClick;
|
|
|
|
|
|
|
|
|
|
|
|
//public delegate void CopyItemEvent(MonstersConfig.MonsterConfig item);
|
|
|
|
|
|
public delegate void CopyItemEvent(UIMonsterItem item);
|
|
|
|
|
|
public CopyItemEvent OnCopyItem;
|
|
|
|
|
|
|
|
|
|
|
|
public Text txtID; //<2F><><EFBFBD><EFBFBD>ID
|
|
|
|
|
|
public Text txtMonsterID; //<2F><><EFBFBD><EFBFBD>ID
|
|
|
|
|
|
public Text txtName; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
public InputField txtPos; //<2F><><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
public Button btnDel; //ɾ<><C9BE>
|
|
|
|
|
|
public Button btnCopy; //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
public Button btnHide; //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
public Button btnClickSelf; //<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
|
public List<string> paths;
|
|
|
|
|
|
//public int itemIdx;
|
|
|
|
|
|
public int pathIdx;
|
|
|
|
|
|
public int groupId;
|
|
|
|
|
|
|
|
|
|
|
|
public MonstersConfig.MonsterConfig monster;
|
|
|
|
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
|
void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
groupId = -1;
|
|
|
|
|
|
btnDel.onClick.AddListener(RemoveSelf);
|
|
|
|
|
|
paths = new List<string>();
|
|
|
|
|
|
btnClickSelf.onClick.AddListener(OnClickSelf);
|
|
|
|
|
|
btnCopy.onClick.AddListener(OnCopySelf);
|
|
|
|
|
|
btnHide.onClick.AddListener(OnHideSelf);
|
2025-06-22 15:21:25 +08:00
|
|
|
|
txtPos.onEndEdit.AddListener(OnEndEditPos);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnEndEditPos(string arg0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!UtilityClass.IsPosValidFormat(arg0))
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>ʽ x,y");
|
|
|
|
|
|
txtPos.text = $"{monster.pos.x},{monster.pos.y}";
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
monster.pos = UtilityClass.GetVector2Pos(arg0);
|
2025-07-19 01:21:40 +08:00
|
|
|
|
sceneArea?.SetAreaPos(monster.pos);
|
|
|
|
|
|
UIWindow.Instance.uiMonstersPanel.UpdateGroupInfo(this);
|
2025-06-14 13:46:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//public void SetItem(int idx, MonstersConfig.MonsterConfig m)
|
|
|
|
|
|
public void SetItem(MonstersConfig.MonsterConfig m)
|
|
|
|
|
|
{
|
|
|
|
|
|
txtID.text = m.itemIdx.ToString();
|
|
|
|
|
|
txtMonsterID.text = m.id.ToString();
|
|
|
|
|
|
txtName.text = m.id.ToString();
|
|
|
|
|
|
txtPos.text = m.pos.ToString();
|
|
|
|
|
|
paths = m.paths;
|
|
|
|
|
|
monster = m;
|
2025-07-19 01:21:40 +08:00
|
|
|
|
txtPos.enabled = m.itemIdx != -1;
|
2025-07-18 22:28:40 +08:00
|
|
|
|
txtID.gameObject.SetActive(m.itemIdx != -1);
|
2025-06-14 13:46:24 +08:00
|
|
|
|
if (m.groupId > 0)
|
|
|
|
|
|
return;
|
|
|
|
|
|
MapManager.Instance.SetMonsterPoint(m.itemIdx, monster.radius, monster.id, monster.num);
|
2025-07-18 22:28:40 +08:00
|
|
|
|
MapManager.Instance.CreateSpecialPoint(monster.pos, this);
|
|
|
|
|
|
}
|
|
|
|
|
|
internal override void SetSelectPosItem()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.SetSelectPosItem();
|
|
|
|
|
|
btnClickSelf.Select();
|
|
|
|
|
|
UIWindow.Instance.uiMonstersPanel.OnClickItem(this);
|
2025-07-19 01:21:40 +08:00
|
|
|
|
|
2025-06-14 13:46:24 +08:00
|
|
|
|
}
|
2025-07-18 22:28:40 +08:00
|
|
|
|
public override void SetItemPos(Vector2Int pos)
|
2025-06-22 18:23:47 +08:00
|
|
|
|
{
|
2025-07-18 22:28:40 +08:00
|
|
|
|
base.SetItemPos(pos);
|
|
|
|
|
|
monster.pos = pos;
|
|
|
|
|
|
txtPos.text = pos.ToString();
|
|
|
|
|
|
btnClickSelf.Select();
|
2025-07-19 01:21:40 +08:00
|
|
|
|
UIWindow.Instance.uiMonstersPanel.UpdateGroupInfo(this);
|
2025-06-22 18:23:47 +08:00
|
|
|
|
}
|
2025-06-14 13:46:24 +08:00
|
|
|
|
public void RefreshItem()
|
|
|
|
|
|
{
|
|
|
|
|
|
txtMonsterID.text = monster.id.ToString();
|
|
|
|
|
|
txtName.text = monster.id.ToString();
|
|
|
|
|
|
paths = monster.paths;
|
2025-06-22 15:21:25 +08:00
|
|
|
|
txtPos.text = monster.pos.ToString();
|
|
|
|
|
|
//ˢ<>³<EFBFBD><C2B3><EFBFBD><EFBFBD>еĶ<D0B5><C4B6><EFBFBD>
|
2025-07-19 01:21:40 +08:00
|
|
|
|
sceneArea?.RefSAreaInfo();
|
2025-06-14 13:46:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetGroup(int group)
|
|
|
|
|
|
{
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>group<75>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>á<EFBFBD><C3A1><EFBFBD><EFBFBD><EFBFBD>,ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
groupId = group;
|
|
|
|
|
|
txtID.gameObject.SetActive(false);
|
|
|
|
|
|
txtPos.gameObject.SetActive(false);
|
|
|
|
|
|
btnCopy.gameObject.SetActive(false);
|
|
|
|
|
|
btnDel.gameObject.SetActive(false);
|
|
|
|
|
|
btnHide.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RemoveSelf()
|
|
|
|
|
|
{
|
|
|
|
|
|
DestroyImmediate(transform.parent.gameObject);
|
2025-07-18 22:28:40 +08:00
|
|
|
|
UIWindow.Instance.uiMonstersPanel.monstersConfig.monsterConfigs.Remove(monster);
|
|
|
|
|
|
if (monster.itemIdx != -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.uiMonstersPanel.RemoveAllGrop(monster);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void DestoryGrop()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (monster.itemIdx != -1) return;
|
|
|
|
|
|
UIWindow.Instance.uiMonstersPanel.monstersConfig.monsterConfigs.Remove(monster);
|
|
|
|
|
|
DestroyImmediate(transform.parent.gameObject);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sceneArea == null) return;
|
|
|
|
|
|
DestroyImmediate(sceneArea.gameObject);
|
2025-06-14 13:46:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool CheckValid()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(txtID.text))
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ID");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (string.IsNullOrEmpty(txtPos.text))
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>дˢ<D0B4><CBA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClickSelf()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (OnClick == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
OnClick(this);
|
2025-07-19 01:21:40 +08:00
|
|
|
|
OnClickItemSelf();
|
2025-06-14 13:46:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnCopySelf()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (OnCopyItem == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
OnCopyItem(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnHideSelf()
|
|
|
|
|
|
{
|
|
|
|
|
|
MapManager.Instance.HideMonsterPoint(monster.itemIdx);
|
|
|
|
|
|
btnHide.transform.GetChild(0).GetComponent<Text>().text = "<22><>ʾ";
|
|
|
|
|
|
btnHide.onClick.RemoveAllListeners();
|
|
|
|
|
|
btnHide.onClick.AddListener(OnShowSelf);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnShowSelf()
|
|
|
|
|
|
{
|
|
|
|
|
|
MapManager.Instance.ShowMonsterPoint(monster.itemIdx);
|
|
|
|
|
|
btnHide.transform.GetChild(0).GetComponent<Text>().text = "<22><><EFBFBD><EFBFBD>";
|
|
|
|
|
|
btnHide.onClick.RemoveAllListeners();
|
|
|
|
|
|
btnHide.onClick.AddListener(OnHideSelf);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|