Past wave 3 a third of ratbots are gun throwers

This commit is contained in:
2024-10-27 19:01:57 -07:00
parent e3a96303bc
commit 2908b53812
2 changed files with 30 additions and 6 deletions

View File

@@ -165,7 +165,7 @@ Rigidbody2D:
m_UseFullKinematicContacts: 0 m_UseFullKinematicContacts: 0
m_UseAutoMass: 0 m_UseAutoMass: 0
m_Mass: 0.5 m_Mass: 0.5
m_LinearDamping: 10 m_LinearDamping: 15
m_AngularDamping: 0.05 m_AngularDamping: 0.05
m_GravityScale: 1 m_GravityScale: 1
m_Material: {fileID: 0} m_Material: {fileID: 0}

View File

@@ -4,8 +4,16 @@ public class GameState : MonoBehaviour
{ {
public State state; public State state;
public uint wave; public uint wave;
public GameObject ratbot;
public GameObject shop; public GameObject shop;
public GameObject ratbot;
public GameObject gunThrower;
int[] counts = new int[2];
enum CountIndex : uint {
ratbot = 0,
gunThrower = 1
}
void Start() { void Start() {
OpenShop(); OpenShop();
} }
@@ -20,7 +28,9 @@ public class GameState : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if (GameObject.FindGameObjectsWithTag("Ratbot").Length == 0 && state == State.Wave) { if (GameObject.FindGameObjectsWithTag("Ratbot").Length == 0
&& state == State.Wave
) {
OpenShop(); OpenShop();
} }
} }
@@ -34,16 +44,30 @@ public class GameState : MonoBehaviour
// Spawn ratbots around the player // Spawn ratbots around the player
// Amount, health, and damage scale with waves // Amount, health, and damage scale with waves
state = State.Wave; state = State.Wave;
Vector3 playerPosition = GameObject.FindGameObjectWithTag("Player").transform.position; Vector3 playerPosition
= GameObject
.FindGameObjectWithTag("Player")
.transform
.position;
for (uint _ = 0; _ <= wave; _++) { for (uint _ = 0; _ <= wave; _++) {
GameObject newRatbot = Instantiate( GameObject newRatbot = Instantiate(
ratbot, SpawnRatbot(),
Random.insideUnitCircle.normalized*20, Random.insideUnitCircle.normalized*20,
Quaternion.identity Quaternion.identity
); );
newRatbot.GetComponent<Ratbot>().damageStrength = 5+wave*5; newRatbot.GetComponent<Ratbot>().damageStrength
= 5+wave*5;
newRatbot.GetComponent<Ratbot>().health = 5+wave*2; newRatbot.GetComponent<Ratbot>().health = 5+wave*2;
} }
wave++; wave++;
} }
public GameObject SpawnRatbot() {
if (counts[(uint)CountIndex.gunThrower] < wave/3
&& wave > 3
) {
counts[(uint)CountIndex.gunThrower]++;
return gunThrower;
}
return ratbot;
}
} }