public void RefreshUI() { if (redPointPath == "") { return; } Transform redTf = GameNode.Singleton.UIParentTf.Find(redPointPath); if (redTf == null) { //Debug.LogError("红点系统路径填写错误:" + redPointPath); return; } //红点计数为0直接设置False就行了 if (redCount == 0) { redTf.gameObject.SetActive(false); return; } redTf.gameObject.SetActive(true); if (isShowCount) { Text[] texts = redTf.GetComponentsInChildren <Text>(); if (texts.Length == 0) { Debug.LogError("无显示红点数量的组件"); } texts[0].text = RedCount.ToString(); } }
// Update is called once per frame void Update() { if (!GameActive) { return; } pauseBG.enabled = IsGamePaused; if (Input.GetButtonUp("Cancel")) { IsGamePaused = !IsGamePaused; if (!IsGamePaused) { messageBox.enabled = false; } } if (IsGamePaused) { if (!messageBox.enabled) { messageBox.enabled = true; messageBox.text = "Game Paused"; } return; } BlueCount = blueBox.HeldOre; GreenCount = greenBox.HeldOre; RedCount = redBox.HeldOre; YellowCount = yellowBox.HeldOre; BlueMax = blueBox.Capacity; GreenMax = greenBox.Capacity; RedMax = redBox.Capacity; YellowMax = yellowBox.Capacity; int numOverflowed = 0; if (blueBox.Overflow >= 10) { numOverflowed += 1; } if (greenBox.Overflow >= 10) { numOverflowed += 1; } if (redBox.Overflow >= 10) { numOverflowed += 1; } if (yellowBox.Overflow >= 10) { numOverflowed += 1; } if (numOverflowed >= 2) { TickFailTimer(); } TickNewWantTimer(); scoreText.text = "Score: " + Score.ToString("000000"); lastScoreText.text = lastScored.ToString("0000") + " PTS."; // Bins: 08/08 08/08 08/08 08/08 boxStates.text = "Bins: " + BlueCount.ToString("00") + "/" + BlueMax.ToString("00") + " " + GreenCount.ToString("00") + "/" + GreenMax.ToString("00") + " " + RedCount.ToString("00") + "/" + RedMax.ToString("00") + " " + YellowCount.ToString("00") + "/" + YellowMax.ToString("00"); refreshTimer.text = "Refresh in " + wantTimer.ToString("00.0") + "s"; multiplierUI.text = "Multiplier: " + multiplier.ToString("#0.0") + "x"; if (player.IsCarryingUpgrade) { hasUpgrade.SetActive(true); carrying[0].SetActive(false); carrying[1].SetActive(false); } else { hasUpgrade.SetActive(false); carrying[0].SetActive(true); carrying[1].SetActive(true); Ore.OreType[] whatHas = player.GetHeldOres(); Image cImg1 = carrying[0].GetComponent <Image>(); Image cImg2 = carrying[1].GetComponent <Image>(); cImg1.color = OreToColor(whatHas[0]); cImg2.color = OreToColor(whatHas[1]); } for (int i = 0; i < 4; i++) { switch (lastOres[i]) { case Ore.OreType.NONE: blips[i].color = oreColors[0].color; break; case Ore.OreType.BLUE: blips[i].color = oreColors[1].color; break; case Ore.OreType.GREEN: blips[i].color = oreColors[2].color; break; case Ore.OreType.RED: blips[i].color = oreColors[3].color; break; case Ore.OreType.YELLOW: blips[i].color = oreColors[4].color; break; } } }