Add GameState to keep track of state and wave #

This commit is contained in:
2024-10-19 20:52:47 -07:00
parent b10d75ac29
commit 7aa325cccc
7 changed files with 95 additions and 182 deletions

36
Assets/GameState.cs Normal file
View File

@@ -0,0 +1,36 @@
using UnityEngine;
public class GameState : MonoBehaviour
{
public string state;
public uint wave = 1;
public GameObject ratbot;
void Start() {
NewWave();
}
// Update is called once per frame
void Update()
{
if (GameObject.FindGameObjectsWithTag("Ratbot").Length == 0 && state == "WAVE") {
OpenShop();
}
}
void OpenShop() {
state = "SHOP";
NewWave();
}
void CloseShop() {
}
public void NewWave() {
state = "WAVE";
Vector3 position = GameObject.FindGameObjectWithTag("Player").transform.position;
for (uint _ = 0; _ < wave; _++) {
GameObject newRatbot = Instantiate(ratbot);
newRatbot.GetComponent<Ratbot>().damageStrength = 5+wave*5;
}
wave++;
}
}