public void DoEndGame() { ////Set isPaused to true //isPaused = true; ////Set time.timescale to 0, this will cause animations and physics to stop updating //Time.timeScale = 0; //call the ShowPausePanel function of the ShowPanels script mainCanvasGroup.alpha = 1f; showPanels.ShowEndGamePanel(); }
public void EndGame() { Pause(); ShowPanels obj = FindObjectOfType <ShowPanels>(); if (obj) { obj.ShowEndGamePanel(); } else { Debug.Log("EndGame: no ShowPanels obj found"); } }
void EndGameMessage(string endType) { Text auxText; GameObject textEndGame1 = PanelEndGame.transform.Find("TextEndGame1").gameObject; GameObject textEndGame2 = PanelEndGame.transform.Find("TextEndGame2").gameObject; GameObject textEndResource0 = PanelEndGame.transform.Find("TextEndResource0").gameObject; GameObject textEndResource1 = PanelEndGame.transform.Find("TextEndResource1").gameObject; GameObject textEndResource2 = PanelEndGame.transform.Find("TextEndResource2").gameObject; GameObject textEndResource3 = PanelEndGame.transform.Find("TextEndResource3").gameObject; GameObject textEndGame3 = PanelEndGame.transform.Find("TextEndGame3").gameObject; float pcdestr0 = 100f - availableResourcePercent[0]; float pcdestr1 = 100f - availableResourcePercent[1]; float pcdestr2 = 100f - availableResourcePercent[2]; float pcdestr3 = 100f - availableResourcePercent[3]; switch (endType) { case "Planet Dead": { strEndGameText1 = "You didn't defeat your enemy."; strEndGameText2 = "And your war has also destroyed: "; strEndGameResourceText0 = pcdestr0.ToString("N1") + "% of world population"; strEndGameResourceText1 = pcdestr1.ToString("N1") + "% of water supplies"; strEndGameResourceText2 = pcdestr2.ToString("N1") + "% of total vegetation"; strEndGameResourceText3 = pcdestr3.ToString("N1") + "% of economic activities"; strEndGameText3 = "Planet is ruined..."; } break; case "Win": { strEndGameText1 = "Congrats! You defeated your enemy. "; strEndGameText2 = "BUT, your war has also destroyed: "; strEndGameResourceText0 = pcdestr0.ToString("N1") + "% of world population"; strEndGameResourceText1 = pcdestr1.ToString("N1") + "% of water supplies"; strEndGameResourceText2 = pcdestr2.ToString("N1") + "% of total vegetation"; strEndGameResourceText3 = pcdestr3.ToString("N1") + "% of economic activities"; strEndGameText3 = "Planet is damaged..."; } break; case "Lose": { strEndGameText1 = "You were defeated by your enemy."; strEndGameText2 = "and, by the way, your war has also destroyed: "; strEndGameResourceText0 = pcdestr0.ToString("N1") + "% of world population"; strEndGameResourceText1 = pcdestr1.ToString("N1") + "% of water supplies"; strEndGameResourceText2 = pcdestr2.ToString("N1") + "% of total vegetation"; strEndGameResourceText3 = pcdestr3.ToString("N1") + "% of economic activities"; strEndGameText3 = "Planet is damaged..."; } break; } Debug.Log("txt2= " + strEndGameText2); auxText = textEndGame1.GetComponent <Text>(); auxText.text = strEndGameText1; auxText = textEndGame2.GetComponent <Text>(); auxText.text = strEndGameText2; auxText = textEndResource0.GetComponent <Text>(); auxText.text = strEndGameResourceText0; auxText = textEndResource1.GetComponent <Text>(); auxText.text = strEndGameResourceText1; auxText = textEndResource2.GetComponent <Text>(); auxText.text = strEndGameResourceText2; auxText = textEndResource3.GetComponent <Text>(); auxText.text = strEndGameResourceText3; auxText = textEndGame3.GetComponent <Text>(); auxText.text = strEndGameText3; showPanels.HideGameplayPanel(); showPanels.ShowEndGamePanel(endType); }