public void PlayTurn() { TurnCount++; if (!GameCanContinue()) { return; } Card player1Card = _player1.PlayCard(); Card player2Card = _player2.PlayCard(); OnTurnStart?.Invoke(this, new StartEventArgs(player1Card, player2Card)); if (player1Card.Value > player2Card.Value) { _player1.AddCards(player1Card, player2Card); OnTurnFinish?.Invoke(this, new FinishEventArgs("Player 1")); } else if (player2Card.Value > player1Card.Value) { _player2.AddCards(player2Card, player1Card); OnTurnFinish?.Invoke(this, new FinishEventArgs("Player 2")); } else { // Both cards have the same value, so they'll go to war. War(new List <Card> { player1Card }, new List <Card> { player2Card }); } if (TurnCount >= _maxTurnCount) { OnGameFinish?.Invoke(this, new FinishEventArgs("Tie")); } if (_player1.CardsLeft <= 0) { OnGameFinish?.Invoke(this, new FinishEventArgs("Player 2")); } if (_player2.CardsLeft <= 0) { OnGameFinish?.Invoke(this, new FinishEventArgs("Player 1")); } }
public void FinishGame() { Player.engineAudioSource.Stop(); AI.engineAudioSource.Stop(); effectsSource.clip = victorySound; mainAudioSource.Stop(); StopAllCoroutines(); OnGameFinish?.Invoke(); GameFinished = true; GameStarted = false; if (RemaningTime <= 0) { effectsSource.Play(); } Destroy(Player.gameObject); Destroy(AI.gameObject); }
public void HitGridNumber(int number) { PlayerTries++; if (number != TargetNumber) { return; } if (number == MaxNumberOnGrid) { FinishTheGame(); OnGameFinish?.Invoke(); } else { ChangeTargetNumberByRule(); OnRightAnswer?.Invoke(); } }
public void FinishGame() { IsFinished = true; OnGameFinish?.Invoke(); }
private void GameFinish() { OnGameFinish?.Invoke(); }