void Update() { if (currentState == DuelStates.PreBattle) { if (!hasDisplayedStats) { displayStats(); player1.GetComponent <Tracker>().instantiatiatePlayerPanels(player1); player2.GetComponent <Tracker>().instantiatiatePlayerPanels(player2); } if (Input.GetButtonDown("Submit")) { currentState = DuelStates.Start; battleStartUI.GetComponent <CanvasGroup>().alpha = 0.0f; readyUI.GetComponent <CanvasGroup>().alpha = 1.0f; } } else if (currentState == DuelStates.Start) {//this happens tons of times if (!hasDisplayedStart) { Invoke("displayStartUI", 1.0f); Invoke("startBattle", 1.4f); hasDisplayedStart = true; } } else if (currentState == DuelStates.Battle) { if (Input.GetButtonDown("Submit")) { currentState = DuelStates.Paused; pausedUI.GetComponent <CanvasGroup>().alpha = 1.0f; } if (player1Stats.Health.CurrentHealth <= 0 || player2Stats.Health.CurrentHealth <= 0) { KOUI.GetComponent <CanvasGroup>().alpha = 1.0f; currentState = DuelStates.Decision; } } else if (currentState == DuelStates.Decision) { float player1HealthRatio = player1Stats.Health.CurrentHealth / player1Stats.Health.TotalHealth; float player2HealthRatio = player2Stats.Health.CurrentHealth / player2Stats.Health.TotalHealth; if (player1HealthRatio == player2HealthRatio) { Invoke("displayDraw", 2f); } else if (player1HealthRatio >= player2HealthRatio) { Invoke("displayVictory", 2f); } else if (player1HealthRatio <= player2HealthRatio) { Invoke("displayDefeat", 2f); } currentState = DuelStates.End; } else if (currentState == DuelStates.End) { if (Input.GetButtonDown("Submit")) {//Do better than just loading this scene MasterGameController.control.currentState = GameStates.Overworld; SceneManager.LoadScene(1); } } else if (currentState == DuelStates.Paused) { if (Input.GetButtonDown("Submit")) { currentState = DuelStates.Start; pausedUI.GetComponent <CanvasGroup>().alpha = 0.0f; readyUI.GetComponent <CanvasGroup>().alpha = 1.0f; hasDisplayedStart = false; } } else { Debug.Log("Error in DuelController State"); } }
private void displayVictory() { KOUI.GetComponent <CanvasGroup>().alpha = 0.0f; victoryUI.GetComponent <CanvasGroup>().alpha = 1.0f; }
private void displayDraw() { KOUI.GetComponent <CanvasGroup>().alpha = 0.0f; drawUI.GetComponent <CanvasGroup>().alpha = 1.0f; }
private void displayDefeat() { KOUI.GetComponent <CanvasGroup>().alpha = 0.0f; defeatUI.GetComponent <CanvasGroup>().alpha = 1.0f; }