52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using Continentis.MainGame.Character;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
namespace Continentis.MainGame.UI
|
|
{
|
|
public class HUDContainer : MonoBehaviour
|
|
{
|
|
public CombatCharacterViewBase characterView;
|
|
public Dictionary<string, HUDElementBase> enablingHUDs;
|
|
|
|
public void Initialize(CombatCharacterViewBase characterView)
|
|
{
|
|
this.characterView = characterView;
|
|
this.characterView.hudContainer = this;
|
|
enablingHUDs = new Dictionary<string, HUDElementBase>();
|
|
}
|
|
|
|
public void EnableHUD(string hudName)
|
|
{
|
|
if (characterView.character.data.hudData.hudInfos.TryGetValue(hudName, out HUDInfo hudInfo))
|
|
{
|
|
var hud = hudInfo.GenerateHUD(characterView, this);
|
|
hud.OnEnableHud();
|
|
enablingHUDs.TryAdd(hudName, hud);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogWarning($"HUD Info for {hudName} not found in character's HUD data.");
|
|
}
|
|
}
|
|
|
|
public void DisableHUD(string hudName)
|
|
{
|
|
if (enablingHUDs.TryGetValue(hudName, out HUDElementBase hud))
|
|
{
|
|
hud.OnDisableHud();
|
|
Destroy(hud.gameObject);
|
|
enablingHUDs.Remove(hudName);
|
|
}
|
|
}
|
|
|
|
public void UpdateAllHUD()
|
|
{
|
|
foreach (KeyValuePair<string, HUDElementBase> hud in enablingHUDs)
|
|
{
|
|
hud.Value.UpdateHud();
|
|
}
|
|
}
|
|
}
|
|
} |