Пример #1
0
        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"));
            }
        }
Пример #2
0
    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);
    }
Пример #3
0
        public void HitGridNumber(int number)
        {
            PlayerTries++;
            if (number != TargetNumber)
            {
                return;
            }

            if (number == MaxNumberOnGrid)
            {
                FinishTheGame();
                OnGameFinish?.Invoke();
            }
            else
            {
                ChangeTargetNumberByRule();
                OnRightAnswer?.Invoke();
            }
        }
Пример #4
0
        public void FinishGame()
        {
            IsFinished = true;

            OnGameFinish?.Invoke();
        }
Пример #5
0
 private void GameFinish()
 {
     OnGameFinish?.Invoke();
 }