DyatelO a6c79ba3aa Merge branch 'Alexei' into Zakhar
# Conflicts:
#	Assets/Scripts/Units/Unit.cs
#	Assets/add.cs
2022-01-08 15:07:40 +03:00

34 lines
991 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BarCanvas : MonoBehaviour
{
[SerializeField] private Image healthBar;
[SerializeField] private Image manaBar;
[SerializeField] private ShotUIView shotPrefab;
[SerializeField] private GameObject grid;
[SerializeField] private Image captureBar;
public Image HealthBar => healthBar;
public Image ManaBar => manaBar;
public ShotUIView ShotUIView => shotPrefab;
public Image CaptureBar => captureBar;
public Stack<ShotUIView> SpawnShotUI(int count)
{
Stack<ShotUIView> stack = new Stack<ShotUIView>();
List<GameObject> shots = new List<GameObject>();
for (int i = 0; i < count; i++)
{
shots.Add(Instantiate(shotPrefab.gameObject, grid.transform));
}
shots.Reverse();
shots.ForEach(shot => stack.Push(shot.GetComponent<ShotUIView>()));
return stack;
}
}