202 lines
3.1 KiB
C#
202 lines
3.1 KiB
C#
using System.Collections.Generic;
|
|
|
|
using Framework;
|
|
|
|
using Framework.Wrapper;
|
|
|
|
using Gameplay.Character;
|
|
|
|
using Gameplay.Level;
|
|
using Gameplay.Unit;
|
|
using PhxhSDK;
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
|
|
using Utils;
|
|
|
|
|
|
|
|
public class UIDebugShowIDController : UIWindow
|
|
|
|
{
|
|
|
|
|
|
|
|
public class UIInfos : UIGameObjectWrapper
|
|
|
|
{
|
|
|
|
public TextMeshProUGUI Text_ID;
|
|
|
|
public TextMeshProUGUI Text_State;
|
|
|
|
public UIInfos(GameObject go) : base(go)
|
|
|
|
{
|
|
|
|
Text_ID = GetItem<TextMeshProUGUI>("Text_ID");
|
|
|
|
Text_State = GetItem<TextMeshProUGUI>("Text_State");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private Dictionary<uint, UIInfos> _idInfos = new Dictionary<uint, UIInfos>(16);
|
|
|
|
private Stack<UIInfos> _infoPool = new Stack<UIInfos>(16);
|
|
|
|
private GameObject _template;
|
|
|
|
|
|
|
|
private HashSet<uint> _tempRemoveSet = new HashSet<uint>(16);
|
|
|
|
|
|
|
|
public override void OnAwake()
|
|
|
|
{
|
|
|
|
_template = FindObj("TemplateRoot");
|
|
|
|
_template.SetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
var characterManager = GameUnitManager.instance.characterManager;
|
|
|
|
if (characterManager == null)
|
|
|
|
{
|
|
|
|
HideWindow();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------
|
|
|
|
_tempRemoveSet.Clear();
|
|
|
|
foreach (var info in _idInfos)
|
|
|
|
{
|
|
|
|
if (characterManager.Get(info.Key) == null)
|
|
|
|
{
|
|
|
|
_tempRemoveSet.Add(info.Key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach (var id in _tempRemoveSet)
|
|
|
|
{
|
|
|
|
RecycleInfoGo(_idInfos[id]);
|
|
|
|
_idInfos.Remove(id);
|
|
|
|
}
|
|
|
|
//-------------------
|
|
|
|
|
|
|
|
characterManager.ForEach(delegate(Character character)
|
|
|
|
{
|
|
|
|
var id = character.GetID();
|
|
|
|
if (!_idInfos.ContainsKey(id))
|
|
|
|
{
|
|
|
|
_idInfos.Add(id, CreateInfo(id));
|
|
|
|
}
|
|
|
|
var infos = _idInfos[id];
|
|
|
|
|
|
|
|
var pos = PhxhSDK.Utils.WorldPos2ScreenPos(character.transData.pos, CameraManager.Instance.MainCamera);
|
|
|
|
pos = PhxhSDK.Utils.ScreenPos2WorldPos(pos, CameraManager.Instance.UICamera);
|
|
|
|
pos = new Vector3(pos.x, pos.y, 0);
|
|
|
|
infos.SetPosition(pos);
|
|
|
|
infos.Text_State.text = $"{character?.downFSM?.currentState?.GetType().Name}" +
|
|
|
|
$", {character?.upFSM?.currentState?.GetType().Name}" +
|
|
|
|
$", {character?.fullFSM?.currentState?.GetType().Name}";
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void RecycleInfoGo(UIInfos info)
|
|
|
|
{
|
|
|
|
if (info != null)
|
|
|
|
{
|
|
|
|
info.SetActive(false);
|
|
|
|
}
|
|
|
|
_infoPool.Push(info);
|
|
|
|
}
|
|
|
|
|
|
|
|
private UIInfos CreateInfo(uint id)
|
|
|
|
{
|
|
|
|
if (!_infoPool.TryPop(out var infos))
|
|
|
|
{
|
|
|
|
infos = new UIInfos(GameObject.Instantiate(_template, _template.transform.parent));
|
|
|
|
}
|
|
|
|
infos.SetActive(true);
|
|
|
|
infos.Text_ID.text = $"ID:{id:000000}";
|
|
|
|
infos.Text_State.text = $"State:{EDownState.None}";
|
|
|
|
return infos;
|
|
|
|
}
|
|
|
|
}
|
|
|