Пример #1
0
        public void NewGame()
        {
            board.gameObject.SetActive(true);
            board.Clear();
            board.SetPlayer(Seed.Cross);
            CurrentState = GameState.Playing;

            if (NetworkService.IsConnected)
            {
                if (NetworkService.IsMaster)
                {
                    Player1.Name = NetworkService.PlayerName;
                    Player2.Name = NetworkService.OpponentName;

                    Player1.Type = Seed.Cross;
                    Player2.Type = Seed.Nought;
                    board.SetPlayer(Seed.Cross);

                    NetworkService.SendNewGameStarted();
                }
                else
                {
                    Player1.Name = NetworkService.OpponentName;
                    Player2.Name = NetworkService.PlayerName;

                    Player1.Type = Seed.Nought;
                    Player2.Type = Seed.Cross;
                    board.SetPlayer(Seed.Empty);
                }
            }

            OnGameStartSignal.Dispatch(this);
        }