Great timeline system (Age of AI WON)
This commit is contained in:
1 parent
2ce0391c16
commit
e312131725
182 files changed
+380070
-470221
No files matched your search
@@ -4,53 +4,59 @@ using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.UI;
|
||||
using Code.OfficeGame.BattleMode.Actions;
|
||||
using Code.OfficeGame.BattleMode.Health.UI;
|
||||
using Code.OfficeGame.BattleMode.Timeline;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using R3;
|
||||
using Reflex.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Health
|
||||
{
|
||||
public class HealthPanelsHolder : IDisposable
|
||||
{
|
||||
public List<EntityHealthPanel> PanelList;
|
||||
public List<EntityHealthPanel> PanelList { get; private set; } = new();
|
||||
private readonly List<(EntityHealthPanel Panel, EntityId EntityId)> _bindings = new();
|
||||
|
||||
[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)
|
||||
|
||||
public async UniTask SpawnHealthBars(IUIFactory factory, List<EntityProperties> entities)
|
||||
{
|
||||
PanelList = new List<EntityHealthPanel>();
|
||||
_bindings.Clear();
|
||||
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
var healthBarTarget = entity.GetComponentInChildren<HealthBarTarget>();
|
||||
|
||||
if(!healthBarTarget) continue;
|
||||
|
||||
var panel = (EntityHealthPanel) await factory.LoadPanel(UIPanelType.EntityHealthBar, false);
|
||||
if (!healthBarTarget) continue;
|
||||
|
||||
var panel = (EntityHealthPanel)await factory.LoadPanel(UIPanelType.EntityHealthBar, false);
|
||||
panel.SetTarget(healthBarTarget.transform);
|
||||
|
||||
panel.SubscribeHealthPanel(entity.EntityHealth);
|
||||
|
||||
|
||||
PanelList.Add(panel);
|
||||
_bindings.Add((panel, entity.GetEntityId()));
|
||||
}
|
||||
}
|
||||
|
||||
public IDisposable BindToTimeline(BattleTimeline timeline)
|
||||
{
|
||||
var bag = new DisposableBag();
|
||||
foreach (var (panel, entityId) in _bindings)
|
||||
{
|
||||
panel.BindToTimeline(timeline, entityId).AddTo(ref bag);
|
||||
}
|
||||
return bag;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var panel in PanelList)
|
||||
foreach (var panel in PanelList)
|
||||
panel.Dispose();
|
||||
PanelList.Clear();
|
||||
_bindings.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user