1
0
Fork 0

Kill Player on win

This commit is contained in:
Piegames 2018-04-23 19:11:12 +02:00
parent 8ffc34f2d0
commit db72c6a707
3 changed files with 6 additions and 3 deletions

View file

@ -976,7 +976,7 @@ Prefab:
- target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743, - target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743,
type: 2} type: 2}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
value: 65.89836 value: 63.233368
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743, - target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743,
type: 2} type: 2}

View file

@ -55,6 +55,6 @@ public class Player : Mob {
protected override void Death() { protected override void Death() {
Debug.Log("Player died..."); Debug.Log("Player died...");
Destroy(this.gameObject); Destroy(this.gameObject);
GameController.instance.ChangeState(GameController.GameState.ENDED); GameController.instance.EndGame(GameController.EndedCause.DIED);
} }
} }

View file

@ -300,7 +300,8 @@ public class GameController : MonoBehaviour {
cam.GetComponent<AudioControl>().GameOverBgm(); cam.GetComponent<AudioControl>().GameOverBgm();
ui.GetComponent<UIController>().ShowGameOverUI(); ui.GetComponent<UIController>().ShowGameOverUI();
} else if(endCause == EndedCause.WIN) { } else if(endCause == EndedCause.WIN) {
//cam.GetComponent<AudioControl>().SfxPlay(2); //cam.GetComponent<AudioControl>().SfxPlay(2);
player.InflictDamage(int.MaxValue/2);
ui.GetComponent<UIController>().ShowWinUI(); ui.GetComponent<UIController>().ShowWinUI();
} }
} else { } else {
@ -325,6 +326,8 @@ public class GameController : MonoBehaviour {
} }
public void EndGame(EndedCause cause) { public void EndGame(EndedCause cause) {
if (endCause != null && state == GameState.ENDED)
return; // Already ended game
endCause = cause; endCause = cause;
ChangeState(GameState.ENDED); ChangeState(GameState.ENDED);
} }