private ShowPanels showPanels; //Reference to ShowPanels script on UI GameObject, to show and hide panels void Awake() { //Get a reference to ShowPanels attached to UI object showPanels = GetComponent <ShowPanels> (); //Get a reference to PlayMusic attached to UI object playMusic = GetComponent <PlayMusic> (); // **** ver se é o local correto; showPanels.HideGameplayPanel(); showPanels.ShowIntro(); showPanels.HideMenu(); showPanels.HideEndGamePanel(); }
public void DecreaseGlobalResources(float[] res) { RectTransform rt; Image img; float perc; availableResource[0] -= res[0]; availableResource[1] -= res[1]; availableResource[2] -= res[2]; availableResource[3] -= res[3]; if (totalResource[0] != 0) { availableResourcePercent[0] = 100.0f * availableResource[0] / totalResource[0]; } if (totalResource[1] != 0) { availableResourcePercent[1] = 100.0f * availableResource[1] / totalResource[1]; } if (totalResource[02] != 0) { availableResourcePercent[2] = 100.0f * availableResource[2] / totalResource[2]; } if (totalResource[03] != 0) { availableResourcePercent[3] = 100.0f * availableResource[3] / totalResource[3]; } // atualizar interface com valores reduzidos TextResourceValue0.text = availableResourcePercent[0].ToString("N1"); TextResourceValue1.text = availableResourcePercent[1].ToString("N1"); TextResourceValue2.text = availableResourcePercent[2].ToString("N1"); TextResourceValue3.text = availableResourcePercent[3].ToString("N1"); rt = ImageResource0.rectTransform; rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 120f * availableResourcePercent[0] / 100); rt = ImageResource1.rectTransform; rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 120f * availableResourcePercent[1] / 100); rt = ImageResource2.rectTransform; rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 120f * availableResourcePercent[2] / 100); rt = ImageResource3.rectTransform; rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 120f * availableResourcePercent[3] / 100); img = ImageResource0.GetComponent <Image>(); perc = availableResourcePercent[0]; if (perc >= 50f && perc < 75.0f) { img.color = new Color(1, 0.92f, 0.016f, 1); // yellow } else if (perc < 50f) { img.color = new Color(1, 0, 0, 1); // red } img = ImageResource1.GetComponent <Image>(); perc = availableResourcePercent[1]; if (perc >= 50f && perc < 75.0f) { img.color = new Color(1, 0.92f, 0.016f, 1); // yellow } else if (perc < 50f) { img.color = new Color(1, 0, 0, 1); // red } img = ImageResource2.GetComponent <Image>(); perc = availableResourcePercent[2]; if (perc >= 50f && perc < 75.0f) { img.color = new Color(1, 0.92f, 0.016f, 1); // yellow } else if (perc < 50f) { img.color = new Color(1, 0, 0, 1); // red } img = ImageResource3.GetComponent <Image>(); perc = availableResourcePercent[3]; if (perc >= 50f && perc < 75.0f) { img.color = new Color(1, 0.92f, 0.016f, 1); // yellow } else if (perc < 50f) { img.color = new Color(1, 0, 0, 1); // red } if (availableResourcePercent[0] < 50.0f) { if (availableResourcePercent[1] < 50.0f) { if (availableResourcePercent[2] < 50.0f) { if (availableResourcePercent[3] < 50.0f) { //Debug.Log("Planeta destruido!!"); showPanels.HideGameplayPanel(); EndGameMessage("Planet Dead"); //showPanels.ShowEndGamePanel("Planet Dead"); } } } } }