GlobalGameJame/Assets/Scripts/BarricadeManager.cs
2020-02-01 12:11:56 +01:00

57 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BarricadeManager : MonoBehaviour
{
public float health = 0;
public List<GameObject> barricadePlanks = new List<GameObject>();
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
viewHealthAsPlanks();
if (health < 0)
{
health = 0;
}
}
public void addPlank()
{
if (health < (barricadePlanks.Count * 10)) {
health += 10;
}
}
public void Damage(float damage)
{
if (health > 0) {
health -= damage;
}
}
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);
}
}
}
}
}