41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using Continentis.MainGame.Character;
|
|
using Lean.Pool;
|
|
using UnityEngine;
|
|
|
|
namespace Continentis.MainGame.UI
|
|
{
|
|
public class HUD_CharacterBuffCollection : HUDElementBase
|
|
{
|
|
public RectTransform buffContainer;
|
|
public GameObject buffIconPrefab;
|
|
public List<HUD_CharacterBuffIcon> buffIcons;
|
|
|
|
public override void UpdateHud()
|
|
{
|
|
foreach (var buffIcon in buffIcons)
|
|
{
|
|
buffIcon.UpdateIcon();
|
|
}
|
|
}
|
|
|
|
public void AddBuffIcon(CharacterBuffBase buff)
|
|
{
|
|
HUD_CharacterBuffIcon buffIcon = LeanPool.Spawn(buffIconPrefab, buffContainer).GetComponent<HUD_CharacterBuffIcon>();
|
|
buffIcon.Initialize(buff);
|
|
buffIcons.Add(buffIcon);
|
|
UpdateHud();
|
|
}
|
|
|
|
public void RemoveBuffIcon(CharacterBuffBase buff)
|
|
{
|
|
HUD_CharacterBuffIcon buffIcon = buffIcons.Find(x => x.buff == buff);
|
|
if (buffIcon != null)
|
|
{
|
|
LeanPool.Despawn(buffIcon.gameObject);
|
|
buffIcons.Remove(buffIcon);
|
|
}
|
|
UpdateHud();
|
|
}
|
|
}
|
|
} |