Пример #1
0
        private void OnBoardChange(Seed player, int row, int col)
        {
            Seed nextPlayer = Seed.Empty;

            if (board.HasWon(player))
            {
                switch (player)
                {
                case Seed.Cross:
                    CurrentState = GameState.CrossWin;
                    Player1.Score++;
                    break;

                case Seed.Nought:
                    CurrentState = GameState.NoughtWin;
                    Player2.Score++;
                    break;
                }

                OnGameResultSignal.Dispatch(this);
            }
            else if (board.IsDraw())
            {
                CurrentState = GameState.Draw;
                OnGameResultSignal.Dispatch(this);
            }
            else
            {
                nextPlayer = player == Seed.Cross ? Seed.Nought : Seed.Cross;
            }

            board.SetPlayer(nextPlayer);

            if (NetworkService.IsConnected && player == Player1.Type)
            {
                board.SetPlayer(Seed.Empty);
                NetworkService.SendBoardChange(player, row, col);
            }
        }