56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Code.Infrastructure.Camera;
|
|
using Code.Infrastructure.UI;
|
|
using Code.OfficeGame.BattleMode.Actions;
|
|
using Code.OfficeGame.BattleMode.Health.UI;
|
|
using Cysharp.Threading.Tasks;
|
|
using Reflex.Attributes;
|
|
|
|
namespace Code.OfficeGame.BattleMode.Health
|
|
{
|
|
public class HealthPanelsHolder : IDisposable
|
|
{
|
|
public List<EntityHealthPanel> PanelList;
|
|
|
|
[Inject]
|
|
private void Construct(CameraStateMachine cameraStateMachine)
|
|
{
|
|
foreach (var panel in PanelList) panel.Construct(cameraStateMachine);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Список опрокинуть в контейнер
|
|
/// </summary>
|
|
/// <param name="factory"></param>
|
|
/// <param name="entities"></param>
|
|
/// <returns></returns>
|
|
public async UniTask SpawnHealthBars(
|
|
IUIFactory factory,
|
|
List<EntityProperties> entities)
|
|
{
|
|
PanelList = new List<EntityHealthPanel>();
|
|
|
|
foreach (var entity in entities)
|
|
{
|
|
var healthBarTarget = entity.GetComponentInChildren<HealthBarTarget>();
|
|
|
|
if(!healthBarTarget) continue;
|
|
|
|
var panel = (EntityHealthPanel) await factory.LoadPanel(UIPanelType.EntityHealthBar, false);
|
|
|
|
panel.SetTarget(healthBarTarget.transform);
|
|
|
|
panel.SubscribeHealthPanel(entity.EntityHealth);
|
|
|
|
PanelList.Add(panel);
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
foreach (var panel in PanelList)
|
|
panel.Dispose();
|
|
}
|
|
}
|
|
} |