From db72c6a7072d9c35cfe6968c2c8d6456c7687808 Mon Sep 17 00:00:00 2001 From: Piegames <14054505+piegamesde@users.noreply.github.com> Date: Mon, 23 Apr 2018 19:11:12 +0200 Subject: [PATCH] Kill Player on win --- Assets/Scenes/CodeDEV.unity | 2 +- Assets/Scripts/Entities/Player.cs | 2 +- Assets/Scripts/GameController.cs | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Assets/Scenes/CodeDEV.unity b/Assets/Scenes/CodeDEV.unity index e34dc74..21c0de8 100644 --- a/Assets/Scenes/CodeDEV.unity +++ b/Assets/Scenes/CodeDEV.unity @@ -976,7 +976,7 @@ Prefab: - target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2} propertyPath: m_AnchoredPosition.x - value: 65.89836 + value: 63.233368 objectReference: {fileID: 0} - target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2} diff --git a/Assets/Scripts/Entities/Player.cs b/Assets/Scripts/Entities/Player.cs index 64309da..57a20b0 100644 --- a/Assets/Scripts/Entities/Player.cs +++ b/Assets/Scripts/Entities/Player.cs @@ -55,6 +55,6 @@ public class Player : Mob { protected override void Death() { Debug.Log("Player died..."); Destroy(this.gameObject); - GameController.instance.ChangeState(GameController.GameState.ENDED); + GameController.instance.EndGame(GameController.EndedCause.DIED); } } diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index f125a51..239720f 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -300,7 +300,8 @@ public class GameController : MonoBehaviour { cam.GetComponent().GameOverBgm(); ui.GetComponent().ShowGameOverUI(); } else if(endCause == EndedCause.WIN) { - //cam.GetComponent().SfxPlay(2); + //cam.GetComponent().SfxPlay(2); + player.InflictDamage(int.MaxValue/2); ui.GetComponent().ShowWinUI(); } } else { @@ -325,6 +326,8 @@ public class GameController : MonoBehaviour { } public void EndGame(EndedCause cause) { + if (endCause != null && state == GameState.ENDED) + return; // Already ended game endCause = cause; ChangeState(GameState.ENDED); }