public void ResetScore() { _results = new int[2]; _sets = new TenisSet[maxSets]; _setNumber = 0; _currentSet = new TenisSet(GamesPerSet); _sets[_setNumber] = _currentSet; _winnerId = 0; _referee = null; }
private ScoreManager() { _results = new int[2]; _sets = new TenisSet[maxSets]; _setNumber = 0; _currentSet = new TenisSet(GamesPerSet); _sets[_setNumber] = _currentSet; _winnerId = 0; _difficulty = 1;// default difficulty _twoPlayers = false; }
/** * When a point is scored. Updates scores. * returns true if team won the game */ public bool OnPoint(int teamNumber) { if (_referee.GetIsServing() && _referee.GetServiceTimes() == 0) { _referee.IncreaseServiceTimes(); } else if (_currentSet.AddPoint(teamNumber, _referee)) { // Won set _referee.ResetServiceTimes(); _results[teamNumber - 1]++; if (_results[teamNumber - 1] > maxSets / 2) { // Won match AudioManager.Instance.PlaySound((int)SoundId.SOUND_WIN); AudioManager.Instance.PlaySound((int)SoundId.SOUND_WOW_CLAP); BallLogic.Instance.ResetConfig(); _winnerId = teamNumber; CalloutScript.Instance.TriggerCallout($"Game, set and match {GetTeamName(teamNumber)}!"); return(true); } // Advance to next set _currentSet = new TenisSet(GamesPerSet); _setNumber++; _sets[_setNumber] = _currentSet; CalloutScript.Instance.TriggerCallout($"Set {GetTeamName(teamNumber)}"); } else { // Won point, show score _referee.ResetServiceTimes(); int[] points = _currentSet.GetCurrentGameResults(); SayScore(points[0], points[1]); AudioManager.Instance.PlaySound((int)SoundId.SOUND_CLAP); } // Reset ball and server BallLogic.Instance.ResetConfig(); _referee.MakePlayerServe(GetServingTeam()); TriggerCallout(); return(false); }