diff --git a/theProject/Assets/Scenes/SpartaqS.unity b/theProject/Assets/Scenes/SpartaqS.unity index edf6d631..3f417989 100644 --- a/theProject/Assets/Scenes/SpartaqS.unity +++ b/theProject/Assets/Scenes/SpartaqS.unity @@ -154,15 +154,19 @@ MonoBehaviour: m_EditorClassIdentifier: mapSize: {x: 10, y: 10} WORLD_SPACE_OFFSET: {x: 0.5, y: 1, z: 0.5} + allyBaseCoord: {x: 0, y: 0} soldierStartingPositions: - {x: 0, y: 0} - {x: 1, y: 2} + enemyBaseCoord: {x: 0, y: 0} enemyStartingPositions: - {x: 2, y: 0} - {x: 9, y: 5} tilemap: {fileID: 1853262998} soldierPrefab: {fileID: 403095692180922766, guid: a87b1aa46b0ed3e0fba621e11dd4f1e2, type: 3} + basePrefab: {fileID: 6141901885681798073, guid: e79038bbfa9535f45be1d0f0ae0626ce, + type: 3} --- !u!4 &282616949 Transform: m_ObjectHideFlags: 0 diff --git a/theProject/Assets/Scripts/Soldier.cs b/theProject/Assets/Scripts/Soldier.cs index 284fc1eb..9808289d 100644 --- a/theProject/Assets/Scripts/Soldier.cs +++ b/theProject/Assets/Scripts/Soldier.cs @@ -67,7 +67,7 @@ public class Soldier : MonoBehaviour // variables not visible in inspector - [HideInInspector] public UnityEvent onDeath = new UnityEvent(); + [HideInInspector] public UnityEvent onDeath = new UnityEvent(); public SoldierType GetOwnType() { @@ -115,11 +115,15 @@ public class Soldier : MonoBehaviour TickSystem.OnTick += HandleTick; } + private void Die() + { + TickSystem.OnTick -= HandleTick; + onDeath.Invoke(this); + Destroy(gameObject); + } + private void OnDestroy() { - TickSystem.OnTick -= HandleTick; - onDeath.Invoke(); - Debug.Log("Soldier: " + ourType.ToString() + " has died", gameObject); } @@ -203,7 +207,7 @@ public class Soldier : MonoBehaviour healthPoints -= damage; if (healthPoints <= 0) - Destroy(gameObject); + Die(); UpdateHPDisplay(); Debug.Log("I took damage, oh my HP is now: " + healthPoints + " noooo!!!!", gameObject);