From 2908b53812ca2d2955bba3f7c32d7b2fd6fb4dc1 Mon Sep 17 00:00:00 2001 From: ProtoSharkk Date: Sun, 27 Oct 2024 19:01:57 -0700 Subject: [PATCH] Past wave 3 a third of ratbots are gun throwers --- Assets/Enemy/Ratbot.prefab | 2 +- Assets/Scripts C#/GameState.cs | 34 +++++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Assets/Enemy/Ratbot.prefab b/Assets/Enemy/Ratbot.prefab index 9182b9f..cdb3677 100644 --- a/Assets/Enemy/Ratbot.prefab +++ b/Assets/Enemy/Ratbot.prefab @@ -165,7 +165,7 @@ Rigidbody2D: m_UseFullKinematicContacts: 0 m_UseAutoMass: 0 m_Mass: 0.5 - m_LinearDamping: 10 + m_LinearDamping: 15 m_AngularDamping: 0.05 m_GravityScale: 1 m_Material: {fileID: 0} diff --git a/Assets/Scripts C#/GameState.cs b/Assets/Scripts C#/GameState.cs index 49e6ec8..d994bdc 100644 --- a/Assets/Scripts C#/GameState.cs +++ b/Assets/Scripts C#/GameState.cs @@ -4,8 +4,16 @@ public class GameState : MonoBehaviour { public State state; public uint wave; - public GameObject ratbot; public GameObject shop; + public GameObject ratbot; + public GameObject gunThrower; + + int[] counts = new int[2]; + enum CountIndex : uint { + ratbot = 0, + gunThrower = 1 + } + void Start() { OpenShop(); } @@ -20,7 +28,9 @@ public class GameState : MonoBehaviour // Update is called once per frame void Update() { - if (GameObject.FindGameObjectsWithTag("Ratbot").Length == 0 && state == State.Wave) { + if (GameObject.FindGameObjectsWithTag("Ratbot").Length == 0 + && state == State.Wave + ) { OpenShop(); } } @@ -34,16 +44,30 @@ public class GameState : MonoBehaviour // Spawn ratbots around the player // Amount, health, and damage scale with waves state = State.Wave; - Vector3 playerPosition = GameObject.FindGameObjectWithTag("Player").transform.position; + Vector3 playerPosition + = GameObject + .FindGameObjectWithTag("Player") + .transform + .position; for (uint _ = 0; _ <= wave; _++) { GameObject newRatbot = Instantiate( - ratbot, + SpawnRatbot(), Random.insideUnitCircle.normalized*20, Quaternion.identity ); - newRatbot.GetComponent().damageStrength = 5+wave*5; + newRatbot.GetComponent().damageStrength + = 5+wave*5; newRatbot.GetComponent().health = 5+wave*2; } wave++; } + public GameObject SpawnRatbot() { + if (counts[(uint)CountIndex.gunThrower] < wave/3 + && wave > 3 + ) { + counts[(uint)CountIndex.gunThrower]++; + return gunThrower; + } + return ratbot; + } }