128 lines
2.5 KiB
C#
128 lines
2.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Cysharp.Threading.Tasks;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.UIElements;
|
|
using Button = UnityEngine.UI.Button;
|
|
using Image = UnityEngine.UI.Image;
|
|
using Toggle = UnityEngine.UI.Toggle;
|
|
using ScrollView = PhxhSDK.PhxhScrollView;
|
|
using Framework;
|
|
using Gameplay.Unit;
|
|
|
|
public class UIFightTeamHPController : UIWindow
|
|
{
|
|
//UI GameObj
|
|
///Auto Gen Start///
|
|
|
|
///Auto Gen End///
|
|
|
|
// deal with input data
|
|
public static async UniTask<UIWindow> Open()
|
|
{
|
|
return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UIFightTeamHP, null,
|
|
UIManager.ECanvasRoot.Dynamic2);
|
|
}
|
|
|
|
private List<GameObject> _headList = new();
|
|
|
|
private List<uint> _displayList = new();
|
|
|
|
public override void PreLoad(object data = null)
|
|
{
|
|
|
|
}
|
|
|
|
// Use this for initialization
|
|
public override void OnInit()
|
|
{
|
|
//bind UI GameObj
|
|
UIFightTeamHPBinder.GetComponents(this);
|
|
|
|
var goFight = FindObj("UI_LiuHaiRight/UI_OnFight");
|
|
for (int i = 0; i < goFight.transform.childCount; i++)
|
|
{
|
|
var go = FindObj("UI_LiuHaiRight/UI_OnFight/Item" + i);
|
|
_headList.Add(go);
|
|
}
|
|
}
|
|
|
|
//invoke when open window
|
|
protected override void OnShowWindow(object data = null)
|
|
{
|
|
_SetData();
|
|
_Refresh();
|
|
}
|
|
|
|
//invoke when reload window
|
|
protected override void OnReloadWindow(object data = null)
|
|
{
|
|
|
|
}
|
|
|
|
//invoke when close window
|
|
protected override void OnHideWindow()
|
|
{
|
|
|
|
}
|
|
|
|
//invoke when destroy
|
|
public override void OnRelease()
|
|
{
|
|
base.OnRelease();
|
|
}
|
|
|
|
private void _SetData()
|
|
{
|
|
var fightList = FightTeamManager.Instance.GetFightIDList();
|
|
_displayList.Clear();
|
|
if (fightList != null)
|
|
{
|
|
foreach (var uid in fightList)
|
|
{
|
|
_displayList.Add(uid);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void _Refresh()
|
|
{
|
|
_RefreshItems();
|
|
}
|
|
|
|
private void _RefreshItems()
|
|
{
|
|
for (int i = 0; i < _headList.Count; i++)
|
|
{
|
|
_RefreshItem(i);
|
|
}
|
|
}
|
|
|
|
private void _RefreshItem(int index)
|
|
{
|
|
var headObj = _headList[index];
|
|
if (index >= _displayList.Count)
|
|
{
|
|
headObj.gameObject.SetActiveEx(false);
|
|
return;
|
|
}
|
|
var uid = _displayList[index];
|
|
|
|
headObj.gameObject.SetActiveEx(true);
|
|
var teamUnitInfo = FightTeamManager.Instance.GetFightTeamUnitInfo(uid);
|
|
var isInFightPool = GameUnitManager.instance.infightUnits.Contains(uid);
|
|
if (!isInFightPool)
|
|
{
|
|
return;
|
|
}
|
|
var unit = GameUnitManager.instance.infightUnits.Search(uid);
|
|
if (unit != null && teamUnitInfo != null)
|
|
{
|
|
var cmp = headObj.GetComponent<UIFightHp>();
|
|
cmp.SetData(unit);
|
|
cmp.Refresh();
|
|
}
|
|
}
|
|
} |