summaryrefslogtreecommitdiff
path: root/GameCode/TowerUnlockManager.cs
blob: d96b9d54195997c5b18bbebd21d0872d4c03c0c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Collections.Generic;
using UnityEngine;

public class TowerUnlockManager : MonoBehaviour
{
	public static TowerUnlockManager instance;

	[SerializeField]
	private List<GameObject> unlockedTowers = new List<GameObject>();

	[SerializeField]
	private List<GameObject> unlockedBuildings = new List<GameObject>();

	private void Awake()
	{
		instance = this;
	}

	private void Start()
	{
		DisplayButtons();
	}

	public void UnlockTower(GameObject towerUIObject, bool isTower)
	{
		towerUIObject.SetActive(value: true);
		if (isTower)
		{
			unlockedTowers.Add(towerUIObject);
		}
		else
		{
			unlockedBuildings.Add(towerUIObject);
		}
		DisplayButtons();
	}

	private void DisplayButtons()
	{
		int num = 0;
		int num2 = ((unlockedBuildings.Count > 0) ? 1 : 0);
		foreach (GameObject unlockedTower in unlockedTowers)
		{
			unlockedTower.transform.localPosition = new Vector3(num * 100 - unlockedTowers.Count * 50 + 50, 100 * num2, 0f);
			num++;
		}
		num = 0;
		foreach (GameObject unlockedBuilding in unlockedBuildings)
		{
			unlockedBuilding.transform.localPosition = new Vector3(num * 100 - unlockedBuildings.Count * 50 + 50, 0f, 0f);
			num++;
		}
	}
}