GlobalGameJame/Assets/Scripts/BarricadeManager.cs

46 lines
970 B
C#
Raw Normal View History

2020-01-31 21:32:05 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BarricadeManager : MonoBehaviour
{
2020-01-31 23:53:03 +00:00
public int health = 0;
public List<GameObject> barricadePlanks = new List<GameObject>();
2020-01-31 21:32:05 +00:00
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
2020-01-31 23:53:03 +00:00
viewHealthAsPlanks();
}
public void addPlank()
{
if (health < (barricadePlanks.Count * 10)) {
health += 10;
}
}
void viewHealthAsPlanks()
{
if (barricadePlanks.Count > 0)
{
for (int i = 0; i < barricadePlanks.Count; i++)
{
if (i < (health / 10)) {
barricadePlanks[i].SetActive(true);
}
else
{
barricadePlanks[i].SetActive(false);
}
}
}
2020-01-31 21:32:05 +00:00
}
}