private void Start() { //get the text objects that show the score //this is so stupid but the only way to keep this all static Text[] textComps = new Text[4]; textComps = GetComponentsInChildren <Text>(); foreach (var text in textComps) { if (text.name.Equals("GScore")) { gryffScore = text; } else if (text.name.Equals("SScore")) { slythScore = text; } } _gryffScoreInt = 0; _slythScoreInt = 0; UpdateInGameUI(); _lastScoringTeam = PlayerBase.Team.Null; _boardIsHidden = false; }
public static void IncrementScore(PlayerBase.Team team) { int scoreInc = 1; if (team == _lastScoringTeam) { scoreInc++; } switch (team) { case PlayerBase.Team.Gryffindor: _gryffScoreInt += scoreInc; _lastScoringTeam = PlayerBase.Team.Gryffindor; break; case PlayerBase.Team.Slytherin: _slythScoreInt += scoreInc; _lastScoringTeam = PlayerBase.Team.Slytherin; break; default: break; } if (_gryffScoreInt >= 100) { GameManager.GameOver(PlayerBase.Team.Gryffindor); } if (_slythScoreInt >= 100) { GameManager.GameOver(PlayerBase.Team.Slytherin); } if (!_boardIsHidden) { UpdateInGameUI(); } }
//event for end of game public static void GameOver(PlayerBase.Team winningTeam) { _winScreen.SetActive(true); _winScreen.GetComponentInChildren <Text>().text = winningTeam.Equals(PlayerBase.Team.Gryffindor) ? "Gryffindor Wins!" : "Slytherin Wins!"; }