public Scoreboard(Sprite2D Red, Sprite2D Blue, Vector2 ScreenScaleFactor) { this.RedPlayerImage = Red; this.BluePlayerImage = Blue; RedCount = TextBox.CreateTextBox(Red.Left + Red.Width + 10, 30, ScreenScaleFactor, null, 0.6f, 0, 0, true); RedCount.InitTextBox(); RedCount.SetFont("ScoreFont"); RedCount.SetColor(Color.WhiteSmoke); BlueCount = TextBox.CreateTextBox(Blue.Left + Blue.Width + 10, 110, ScreenScaleFactor, null, 0.6f, 0, 0, true); BlueCount.InitTextBox(); BlueCount.SetFont("ScoreFont"); BlueCount.SetColor(Color.WhiteSmoke); Result = TextBox.CreateTextBox(-50, 190, ScreenScaleFactor, null, 0.6f, 0, 0, true); Result.InitTextBox(); Result.SetFont("WinFont"); Result.SetColor(Color.WhiteSmoke); Notify = TextBox.CreateTextBox(-70, -60, ScreenScaleFactor, null, 0.6f, 0, 0, true); Notify.InitTextBox(); Notify.SetFont("WinFont"); Notify.SetColor(blue); AddChild(Red); AddChild(Blue); AddChild(RedCount); AddChild(BlueCount); AddChild(Result); AddChild(Notify); }
public override void Update(GameTime gameTime) { var map = Global.thisGame.hexMap; if (map == null) { return; } RedCount.SetText("x" + Convert.ToString(map.ScoreRed)); BlueCount.SetText("x" + Convert.ToString(map.ScoreBlue)); Result.SetText(""); if (map.winState == HexagonMap.WinState.Blue) { Result.SetText("Team Blue Wins!"); } else if (map.winState == HexagonMap.WinState.Red) { Result.SetText("Team Red Wins!"); } Notify.SetText(""); if (Global.thisGame.gameMode == Game1.GameMode.Multiplayer) { var connectionState = Global.thisGame.connectionState; var turnState = Global.thisGame.turnState; switch (connectionState) { case Game1.ConnectionState.Connected: if (turnState == Game1.TurnState.Ready) { Notify.SetText("Your turn..."); Notify.SetColor(blue); } else { Notify.SetText("Their turn..."); Notify.SetColor(red); } break; case Game1.ConnectionState.DuplicateID: Notify.SetText("Username exists"); Notify.SetColor(red); break; case Game1.ConnectionState.OtherDisconnected: Notify.SetText("The other quit!"); Notify.SetColor(red); break; case Game1.ConnectionState.NotConnected: Notify.SetText("Connecting..."); Notify.SetColor(red); break; case Game1.ConnectionState.RoomFull: Notify.SetText("Room is full!"); Notify.SetColor(red); break; case Game1.ConnectionState.Waiting: Notify.SetText("Waiting for others!"); Notify.SetColor(red); break; } } base.Update(gameTime); }
// 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; } } }