コード例 #1
0
ファイル: Board.cs プロジェクト: allanx2000/TicTacToe
        /// <summary>
        /// Places a token and evaluates the board
        /// </summary>
        /// <param name="location"></param>
        /// <param name="token"></param>
        /// <returns>Whether a token was placed</returns>
        public bool PlaceToken(Location location, PlayerToken token)
        {
            if (GameOver || IsBoardFull()) //TODO: Draw?
            {
                throw new GameOverException(Winner);
            }

            if (!IsEmpty(location))
            {
                return(false);
            }
            else
            {
                board[location.Row, location.Column] = token;

                if (!moves.ContainsKey(token))
                {
                    moves.Add(token, new List <Location>());
                }

                moves[token].Add(location);

                EvaluateBoard();

                return(true);
            }
        }
コード例 #2
0
        public CreateJoinRoom()
        {
            var response = new ChannelResponse().Get(new Error()
            {
                ErrorCode = (int)ErrorCode.UnsupportedMethod
            });

            this.Post[$"/api/{Channel}"] = _ => {
                var createJoinRoomArgs   = Serializer.Deserialize <CreateJoinRoomArgs>(this.Request.Body);
                var createJoinRoomOutput = new CreateJoinRoomOutput();

                var playerToken = PlayerToken.Decode(this.Request.Headers["playertoken"].FirstOrDefault());
                switch (playerToken.State)
                {
                case PlayerTokenState.Invalid: return(new ChannelResponse().Get(new Error()
                    {
                        ErrorCode = (int)ErrorCode.InternalError, Message = "The specified PlayerToken is invalid."
                    }));

                case PlayerTokenState.Expired: return(new ChannelResponse().Get(new Error()
                    {
                        ErrorCode = (int)ErrorCode.InternalError, Message = "The specified PlayerToken has expired."
                    }));
                }

                createJoinRoomOutput.JoinKey   = new JoinKey(playerToken.ConnectUserId, createJoinRoomArgs.ServerType, createJoinRoomArgs.RoomId).Encode();
                createJoinRoomOutput.Endpoints = new[] { new ServerEndpoint()
                                                         {
                                                             Address = "127.0.0.1", Port = 8184
                                                         } };

                return(new ChannelResponse().Get(createJoinRoomOutput, this.Request.Headers["playertoken"].First()));
            };
        }
コード例 #3
0
 public void playerSelectsDock(Vector2Int gridPos, Vector2Int wallDir)
 {
     if (board.tryAddDock(gridPos, wallDir))
     {
         board.RpcAddDock(gridPos, wallDir);
         GameObject  playerPosGO = board.getOpenTokenPosition(gridPos, true);
         PlayerToken playerToken = spawnToken(PlayerPrefab, pm.getPlayerColor(currentPlayersTurn)) as PlayerToken;
         playerToken.transform.position = playerPosGO.transform.position;
         playerToken.setPlayerData(pm.getPlayerData(currentPlayersTurn));
         board.updateTokenPosition(playerToken, gridPos, playerPosGO);
         NetworkServer.Spawn(playerToken.gameObject);
         if (board.docks.Count >= pm.Count)
         {
             //Go to the next phase
             infoText = "Game On";
             board.RpcResetExteriorWallsColor();
             board.setCheckTileMouseDown(false);
             spawnDrones();
             triggerSelectActions();
             return;
         }
         changePlayerTurnExits(currentPlayersTurn, false);
         currentPlayersTurn = playerTurnOrder[(playerTurnOrder.IndexOf(currentPlayersTurn) + 1) % playerTurnOrder.Count];
         changePlayerTurnExits(currentPlayersTurn, true);
     }
 }
コード例 #4
0
    // create a player for a connection
    // note: connection can be null
    static MultiplayerPlayerObject CreatePlayer(BoltConnection connection, PlayerToken playerData)
    {
        MultiplayerPlayerObject player;

        // create a new player object, assign the connection property
        // of the object to the connection was passed in
        player            = new MultiplayerPlayerObject();
        player.connection = connection;

        // if we have a connection, assign this player
        // as the user data for the connection so that we
        // always have an easy way to get the player object
        // for a connection
        if (player.connection != null)
        {
            player.connection.UserData = player;
        }

        if (playerData != null)
        {
            player.playerColor  = playerData.playerColor; //new Color(Random.value, Random.value, Random.value);
            player.playerNumber = players.Count + 1;      // lets hope this works.. PlayerNumber = the count of the players. If someone exits middle of the game, we have to keep it in mind.
            player.playerName   = playerData.playerName;  //"Player_" + players.Count+1;
        }
        else                                              // There should never be null playerData.
        {
            player.playerColor  = Color.black;
            player.playerNumber = players.Count + 1;
            player.playerName   = "player_" + players.Count + 1;
        }
        // add to list of all players
        players.Add(player);

        return(player);
    }
コード例 #5
0
    public void updateTokenPosition(Token token, Vector2Int newPosition, GameObject tilePositionGO)
    {
        if (!hasTileAt(newPosition) && token.spaceRounds == 0)
        {
            return;
        }

        if (hasTileAt(token.boardPosition))
        {
            getTileAt(token.boardPosition).removeToken(token);
        }
        if (hasSpaceAt(token.boardPosition))
        {
            spaceTiles[token.boardPosition].removeToken(token);
        }
        token.setBoardPosition(newPosition, tilePositionGO);
        if (hasTileAt(newPosition))
        {
            getTileAt(newPosition).addToken(token);
        }
        if (hasSpaceAt(newPosition))
        {
            spaceTiles[newPosition].addToken(token);
        }

        if (token is PlayerToken)
        {
            PlayerToken pt = (PlayerToken)token;
            if (pt.getPlayer() != null && pt.getPlayer().hasLoot)
            {
                LootToken.setBoardPosition(newPosition);
            }
        }
    }
コード例 #6
0
    public void Init()
    {
        if (entity.IsControllerOrOwner)
        {
            _camera.gameObject.SetActive(true);
        }

        if (entity.HasControl)
        {
            _sceneCamera = GameObject.FindGameObjectWithTag("GameController").GetComponent <PlayerSetupController>().SceneCamera.transform;
            _sceneCamera.gameObject.SetActive(false);
            Cursor.lockState = CursorLockMode.Locked;
        }
        else
        {
            PlayerToken pt = (PlayerToken)entity.AttachToken;
            _textMesh.text = pt.name;
            _meshRenderer.gameObject.SetActive(true);

            if (_playerMotor.IsEnemy)
            {
                _meshRenderer.material.color = _enemyColor;
                _textMesh.gameObject.SetActive(false);
            }
            else
            {
                _textMesh.gameObject.SetActive(true);
                _meshRenderer.material.color = _allyColor;
            }
        }
    }
コード例 #7
0
        public void GivenTokenIsOnBoard_WhenDiceRolledAndNoRejection_TokenMovedDiceResult(int diceResult, int initialSquare = 1, int winnerSquare = 100)
        {
            // Arrange
            var playerToken1 = new PlayerToken();
            var board        = new Board(new List <IPlayerToken> {
                playerToken1
            });

            var gameSettings = new GameSettings {
                InitialSquare = initialSquare, WinnerSquare = winnerSquare
            };

            var mockDice = new Mock <IDice>();

            mockDice
            .Setup(x => x.Roll())
            .Returns(diceResult);

            var game = new Game(board, mockDice.Object, gameSettings);

            game.Start();

            // Act
            var moveResult = game.Move(playerToken1);

            // Assert
            Assert.AreEqual(initialSquare + diceResult, playerToken1.GetCurrentSquare());
            Assert.AreEqual(initialSquare + diceResult, moveResult.NewSquare);
            Assert.AreEqual(MoveStatus.Moved, moveResult.Status);
        }
コード例 #8
0
    public IEnumerator ShowWin(PlayerToken player)
    {
        StartCoroutine(BackgroudFade(0.6f, 0.4f));

        winTitle.SetActive(true);
        resultButton.SetTextColor(player.GetCharacter().color);
        winCharacter.sprite = player.image.sprite;
        winText.transform.GetChild(0).GetChild(0).GetComponent <TextMeshProUGUI>().color = player.GetCharacter().color;

        if (LocalizationManager.instance.Alphabet == Alphabet.Arabic)
        {
            winText.SetText(LocalizationManager.instance.GetLocalizedValue(player.GetCharacter().name, true));
        }
        else
        {
            winText.SetLocalizedFormatedText(new string[1] {
                LocalizationManager.instance.GetLocalizedValue(player.GetCharacter().name)
            });
        }

        float duration = 0.4f;
        float t        = 0;

        while (t < duration)
        {
            t += Time.deltaTime;
            t  = t > duration ? duration : t; //Bound t to duration

            float x = Easing.EaseOutCubic(t, 0f, 1, duration);
            winTitle.GetComponent <RectTransform>().localScale = new Vector2(x, x);
            yield return(null);
        }
    }
コード例 #9
0
    public void Spawn()
    {
        if (!character)
        {
            // assign the colors/numbers etc for the player.
            var playerToken = new PlayerToken();
            playerToken.playerNumber = playerNumber;
            playerToken.playerColor  = playerColor;
            playerToken.playerName   = playerName;

            character = BoltNetwork.Instantiate(BoltPrefabs.PlayerMultiplayer, playerToken);

            if (IsServer)
            {
                character.TakeControl();
            }
            else
            {
                character.AssignControl(connection);
            }

            // move entity to random spawn position
            character.transform.position = GamemanagerNetwork.instance.RandomSpawnPoint();
        }
    }
コード例 #10
0
    public void OnButtonPressed()
    {
        PlayerToken token = new PlayerToken();

        token.playerName     = randoms;
        InkOverlord.IO.token = token;
        UnityEngine.SceneManagement.SceneManager.LoadScene("Intro");
    }
コード例 #11
0
        private static void SetSpace(int playerID, int spaceID)
        {
            PlayerToken token = BoardController.Instance.playerTokens[playerID];
            var         space = BoardController.boardSpaces[spaceID];

            token.currentSpace = space;
            token.Position     = space.screenPosition;
        }
コード例 #12
0
    // public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
    // {
    //  BoltConsole.Write("Connecting request", Color.red);
    //  var playerToken = token as PlayerToken;
    //  if(playerToken != null)
    //  {
    //      BoltConsole.Write("Token received", Color.red);
    //      BoltNetwork.Accept(endpoint, playerToken);
    //  } else {
    //      BoltConsole.Write("No tokens", Color.red);
    //      BoltNetwork.Accept(endpoint);
    //  }
    // }

    public override void Connected(BoltConnection connection)
    {
        BoltLog.Error("ServerCallBack: Client player are being made, connection: " + connection.ToString());
        PlayerToken playerToken = connection.ConnectToken as PlayerToken;

        //BoltConsole.Write(playerToken.playerName + " ja " + playerToken.playerNumber, Color.magenta);
        MultiplayerPlayerRegistery.CreateClientPlayer(connection, playerToken);
    }
コード例 #13
0
 /// <summary>
 /// The default constructor
 /// </summary>
 /// <param name="token">The token player will be playing as</param>
 /// <param name="gameBoard">The game board to play on</param>
 public GradePlayer(PlayerToken token, GameBoard gameBoard)
     : base(token, gameBoard)
 {
     // Build chain grades
     chainGrades = new int[GameBoard.ConnectionLength + 1];
     for (int i = 0; i <= GameBoard.ConnectionLength; i++)
     {
         chainGrades[i] = GameBoard.ConnectionLength * i / (GameBoard.ConnectionLength - i + 1);
     }
 }
コード例 #14
0
        public void AimAtPlayerToken(PlayerToken playerToken)
        {
            const float DistanceToPlayerX = 0.3f;
            const float DistanceToPlayerY = 4.16f;
            const float DistanceToPlayerZ = -1.6f;

            var x = playerToken.transform.position.x + DistanceToPlayerX;
            var y = playerToken.transform.position.y + DistanceToPlayerY;
            var z = playerToken.transform.position.z + DistanceToPlayerZ;

            _camera.transform.position = new Vector3(x, y, z);
        }
コード例 #15
0
        public static string GeneratePlayerToken(string username)
        {
            //Structure of a player token
            //P....-....-....-....
            //[0]: Timestamp since equinox
            //[1]: State => Number of total players
            //[2]: Username
            //[3]: Nonce

            PlayerToken playerToken = new PlayerToken(username);

            return(playerToken.ToString());
        }
コード例 #16
0
 public override void SessionListUpdated(Map <System.Guid, UdpSession> sessionList)
 {
     Debug.LogFormat("Session list updated: {0} total sessions", sessionList.Count);
     foreach (var session in sessionList)
     {
         UdpSession photonSession = session.Value as UdpSession;
         if (photonSession.Source == UdpSessionSource.Photon)
         {
             PlayerToken userData = new PlayerToken();
             userData.playerName  = playerName;
             userData.playerColor = playerColor;
             //userData.password = "******";
             BoltNetwork.Connect(photonSession, userData);
         }
     }
 }
コード例 #17
0
    // Start is called before the first frame update
    void Start()
    {
        int numPlayers      = RuleController.Instance.GetNumberOfPlayers();
        var allPlayerTokens = FindObjectsOfType <PlayerToken>();

        if (numPlayers < 4)
        {
            PlayerToken player4 = allPlayerTokens.FirstOrDefault(x => x.name == "Player4");
            player4.transform.gameObject.SetActive(false);
        }
        if (numPlayers < 3)
        {
            PlayerToken player3 = allPlayerTokens.FirstOrDefault(x => x.name == "Player3");
            player3.transform.gameObject.SetActive(false);
        }
    }
コード例 #18
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            PlayerToken token = mapController.GetPlayerToSpawn();

            if (token.IsAvailable)
            {
                Transform tokenReference = Instantiate(token.Token).transform;
                tokenReference.SetParent(transform);
                tokenReference.transform.position = Input.mousePosition;
                tokenReference.GetComponent <PlayerController>().scaleFactor = transform.parent;
                mapController.ListOfPlayersInstanced.Add(tokenReference.gameObject);
            }
        }
    }
コード例 #19
0
        private void SetPositions()
        {
            int    currCol = this.player.Field.Column;
            int    cols    = MapControl.Cols;
            double width   = MapControl.Width;
            double xPos    = ((currCol + 0.5) * (width / cols)) - 25 + (this.turn * 8);

            PlayerToken.SetValue(Canvas.LeftProperty, xPos);

            int    currRow = this.player.Field.Row;
            int    rows    = MapControl.Rows;
            double heigth  = MapControl.Height;
            double yPos    = (heigth / rows * currRow) - 5;

            PlayerToken.SetValue(Canvas.TopProperty, yPos);
        }
コード例 #20
0
        public static Farm Instantiate(Tile parentTile, PlayerToken ownerPlayerToken)
        {
            var prefabsManager = FindObjectOfType <PrefabsManager>();

            var farm = Instantiate(prefabsManager.FarmPrefab).GetComponent <Farm>();

            farm.SetParent(parentTile);

            farm.SetColor(ownerPlayerToken.Color);

            farm.PlayerId = ownerPlayerToken.PlayerId;

            farm.Start();

            return(farm);
        }
コード例 #21
0
    public void selectButtonClick()
    {
        //Tile selectedTile = this.GetComponentInParent<Tile>();

        //find all game objects tagged as 'DirectionChoice' and destroy them
        var directionChoiceGameObjects = GameObject.FindGameObjectsWithTag("DirectionChoice");

        foreach (var item in directionChoiceGameObjects)
        {
            Destroy(item);
        }

        var playerToken = PlayerToken.FindActivePlayerToken();

        playerToken.MoveToken(SelectedTile);
    }
コード例 #22
0
        private bool RunTownMap(EncounterProg encounter, PlayerToken player, TownMap townMap, TownMapTile currentTownMapTile, ExitTile endTile)
        {
            endTile.Position[0] = 1;
            endTile.Position[1] = 1;

            player.Position[0] = 1;
            player.Position[1] = 2;

            townMap.SetEntityPosition(player);
            int[] exitTilePos = new int[2] {
                1, 1
            };
            townMap.SetTilePosition(exitTilePos, ExitTile.Value);

            townMap.BuildMapDisplay();

            List <ICharacter> townEntityPile = new List <ICharacter>();

            townEntityPile.Add(player);

            List <Tile> townSpecialTilePile = new List <Tile>()
            {
                endTile,
                new InnTile()
                {
                    Position = townMap.FindPosition(InnTile.Value)
                }
            };

            AddEntitiesAndTilesToMap(townMap, townSpecialTilePile, townEntityPile);

            var song = new Playable(new MusicPlayer(), Track.Town);

            song.Play();

            bool nextMap = RunMapGameLoop(townMap, townEntityPile, townSpecialTilePile, encounter);

            ClearMap(townMap, townEntityPile);

            song.Stop();
            player.Position[0] = currentTownMapTile.Position[0];
            player.Position[1] = currentTownMapTile.Position[1] + 1;



            return(nextMap);
        }
コード例 #23
0
        private bool RunWorldMap(EncounterProg encounter, PlayerToken player, Map map, List <Tile> specialTilePile, int randomSeed, ExitTile endTile, List <ICharacter> entityPile)
        {
            entityPile.Add(player);
            endTile.Position[0] = map.MapArrayOfArrays.Length - 2;
            endTile.Position[1] = map.MapArrayOfArrays[0].Length - 2;


            AddEntitiesAndTilesToMap(map, specialTilePile, randomSeed, entityPile);

            map.BuildMapDisplay();

            bool newMap = RunMapGameLoop(map, entityPile, specialTilePile, encounter);

            ClearMap(map, entityPile);

            return(newMap);
        }
コード例 #24
0
        private bool RunCaveMap(EncounterProg encounter, PlayerToken player, Dictionary <int, CaveMap> caveMapStorage, ExitTile endTile, Tile tile)
        {
            Random            rand            = new Random();
            int               randomEnemySeed = rand.Next(_currentLevel, (int)(_currentLevel * 1.5));
            List <ICharacter> entityCavePile  = new List <ICharacter>();

            entityCavePile.Add(player);
            endTile.Position[0] = 1;
            endTile.Position[1] = 1;
            player.Position[0]  = 1;
            player.Position[1]  = 2;

            caveMapStorage[tile.AssociationNum].SetEntityPosition(player);
            int[] exitTilePos = new int[2] {
                1, 1
            };
            caveMapStorage[tile.AssociationNum].SetTilePosition(exitTilePos, ExitTile.Value);

            List <Tile> caveSpecialTilePile = new List <Tile>()
            {
                endTile
            };

            caveMapStorage[tile.AssociationNum].BuildMapDisplay();

            if (tile.AssociationNum == 1 && (_currentLevel == _bossSeed))
            {
                placeBoss = true;
                AddEntitiesAndTilesToMap(caveMapStorage[tile.AssociationNum], caveSpecialTilePile, randomEnemySeed, entityCavePile, placeBoss);
            }
            else
            {
                AddEntitiesAndTilesToMap(caveMapStorage[tile.AssociationNum], caveSpecialTilePile, randomEnemySeed, entityCavePile);
            }

            bool nextMap = RunMapGameLoop(caveMapStorage[tile.AssociationNum], entityCavePile, caveSpecialTilePile, encounter);

            ClearMap(caveMapStorage[tile.AssociationNum], entityCavePile);


            player.Position[0] = tile.Position[0];
            player.Position[1] = tile.Position[1] + 1;

            placeBoss = false;
            return(nextMap);
        }
コード例 #25
0
    public void RoundReset(Team winner)
    {
        if (entity.IsOwner)
        {
            if (GameController.Current.CurrentPhase != GamePhase.Starting)
            {
                if (state.IsDead == true)
                {
                    state.IsDead = false;
                    if (GameController.Current.CurrentPhase == GamePhase.WaitForPlayers)
                    {
                        state.Energy = 1;

                        state.LifePoints = _playerMotor.TotalLife;
                        state.SetTeleport(state.Transform);
                        PlayerToken token = (PlayerToken)entity.AttachToken;
                        transform.position = FindObjectOfType <PlayerSetupController>().GetSpawnPoint(token.team);
                    }
                }
                else
                {
                    _playerWeapons.OnDeath(state.IsDead);
                }

                if (GameController.Current.CurrentPhase == GamePhase.StartRound)
                {
                    if (state.Energy < 4)
                    {
                        state.Energy += 1;
                    }

                    PlayerToken token = (PlayerToken)entity.AttachToken;

                    state.LifePoints = _playerMotor.TotalLife;
                    state.SetTeleport(state.Transform);
                    transform.position = FindObjectOfType <PlayerSetupController>().GetSpawnPoint(token.team);
                }
            }
            else
            {
                state.Energy = 0;
            }
        }
    }
コード例 #26
0
        public void GivenTokenIsOnBoard_WhenDiceRolledTwiceAndNoRejection_TokenMoveOnBothDiceResults(int[] diceResults, int initialSquare = 1, int winnerSquare = 100)
        {
            // Arrange

            if (initialSquare + diceResults.Sum() > winnerSquare)
            {
                Assert.Fail("Sum of given dice results exceeds the winner square. Please update dice results to fix that.");
            }

            var playerToken1 = new PlayerToken();
            var board        = new Board(new List <IPlayerToken> {
                playerToken1
            });

            var gameSettings = new GameSettings {
                InitialSquare = initialSquare, WinnerSquare = winnerSquare
            };

            var mockDice = new Mock <IDice>();

            mockDice
            .Setup(x => x.Roll())
            .ReturnsInOrder(diceResults);

            var game = new Game(board, mockDice.Object, gameSettings);

            game.Start();

            MoveResult moveResult = null;

            // Act
            for (int i = 0; i < diceResults.Length; i++)
            {
                moveResult = game.Move(playerToken1);
            }

            // Assert
            Assert.AreEqual(initialSquare + diceResults.Sum(), playerToken1.GetCurrentSquare());
            Assert.AreEqual(initialSquare + diceResults.Sum(), moveResult?.NewSquare);
            Assert.AreEqual(MoveStatus.Moved, moveResult?.Status);
        }
コード例 #27
0
    IEnumerator Respawn()
    {
        yield return(new WaitForSeconds(1f));

        GameController.Current.state.AlivePlayers--;
        yield return(new WaitForSeconds(15));

        state.IsDead     = false;
        state.LifePoints = _playerMotor.TotalLife;
        state.SetTeleport(state.Transform);
        PlayerToken token = (PlayerToken)entity.AttachToken;

        transform.position = FindObjectOfType <PlayerSetupController>().GetSpawnPoint(token.team);
        if (entity.HasControl)
        {
            GUI_Controller.Current.Show(true);
        }
        yield return(new WaitForSeconds(1f));

        GameController.Current.state.AlivePlayers++;
    }
コード例 #28
0
    public IEnumerator RollDiceAnimator(float animationTime, int finalResult)
    {
        int iterationsToAnimate = (int)(20 * animationTime);

        for (int i = 0; i <= iterationsToAnimate; i++)
        {
            var randomDiceNumber = Random.Range(0, 5);
            this.transform.GetChild(0).GetComponent <Image>().sprite = diceImages[randomDiceNumber];
            yield return(new WaitForSeconds(0.05f));
        }
        //after animation of random images, update to final result from rule controller
        Debug.Log($"You rolled a {finalResult}.");
        textField.text = "Moves Left: " + finalResult.ToString();
        Debug.Log($"User moved by {finalResult}. Location updated.");

        this.transform.GetChild(0).GetComponent <Image>().sprite = diceImages[finalResult - 1];

        var playerToken = PlayerToken.FindActivePlayerToken();

        playerToken.SetSpacesRemainingInMove(finalResult);
        playerToken.ChooseDirectionToMove();
    }
コード例 #29
0
        public void GivenGameStarted_WhenTokenPlacedOnBoard_TokenOnInitialSqaure(int initalSquare)
        {
            // Arrange
            var playerToken1 = new PlayerToken();
            var playerToken2 = new PlayerToken();

            var board = new Board(new List <IPlayerToken> {
                playerToken1, playerToken2
            });

            var gameSettings = new GameSettings {
                InitialSquare = initalSquare
            };
            var game = new Game(board, null, gameSettings);

            // Act
            game.Start();

            // Assert
            Assert.AreEqual(initalSquare, playerToken1.GetCurrentSquare());
            Assert.AreEqual(initalSquare, playerToken2.GetCurrentSquare());
        }
コード例 #30
0
        public override Task <CurrentGameBoard> NewGame(PlayerToken request, ServerCallContext context)
        {
            // Initialize standard new game prompt
            string gameMsg = "\nWhere would you like to go?";
            char   playerToken;

            // Check to make sure the token provided is of type char and matches either X or O, otherwise send an error msg and reprompt for valid input
            if (Char.TryParse(request.PlayerTokenMsg, out playerToken) && (playerToken == 'X' || playerToken == 'O'))
            {
                _currGame.selectPlayerToken(char.Parse(request.PlayerTokenMsg));
            }
            else
            {
                gameMsg = "Invalid Selection: Must be X or O. Try again: ";
            }

            // Sends the starting game board and prompt for move or error msg depending on valid token selection
            return(Task.FromResult(new CurrentGameBoard
            {
                Board = _currGame.board.drawBoard(),
                GameMsg = gameMsg
            }));
        }
コード例 #31
0
    private void Awake()
    {
        characterList = GameManager.instance.GetCharacterList();

        // characterList = new List<Character>();
        // characterList.Add(new Character(0, "Steven", stevenSprite, new Color(1f, 0f, 0f)));
        // characterList.Add(new Character(1, "Peridot", peridotSprite, new Color(0f, 1f, 0f)));

        playerList = new List <PlayerToken>();
        for (int i = 0; i < characterList.Count; i++)
        {
            PlayerToken pt = Instantiate(playerTokenPrefab, new Vector2(600 + i * 220, -540), Quaternion.identity).GetComponent <PlayerToken>();
            pt.transform.SetParent(boardUI.transform, false);
            pt.SetCharacter(characterList[i]);
            playerList.Add(pt);
        }
        playerList.Shuffle();

        playerPositions = new Vector2[5]
        {
            new Vector2(125f, -125.28f), new Vector2(125f, -332.64f), new Vector2(125f, -540f), new Vector2(125f, -747.36f), new Vector2(125f, -954.72f)
        };

        boardUI.startButton.GetComponent <Button>().onClick.AddListener(delegate { StartTurnAction(); });
        boardUI.continueButton.GetComponent <Button>().onClick.AddListener(delegate { ContinueAction(); });
        boardUI.stopButton.GetComponent <Button>().onClick.AddListener(delegate { StopAction(); });

        boardUI.resultButton.GetComponent <Button>().onClick.AddListener(Results);
        boardUI.pauseButton.onClick.AddListener(Pause);

        colorPool     = new List <string>();
        colorTrashBin = new List <string>();

        music        = GetComponent <AudioSource>();
        maxVolume    = music.volume;
        music.volume = 0;
    }
コード例 #32
0
 /// <summary>
 /// The default constructor
 /// </summary>
 /// <param name="token">The token player will be playing as</param>
 /// <param name="gameBoard">The game board to play on</param>
 public HumanPlayer(PlayerToken token, GameBoard gameBoard)
     : base(token, gameBoard)
 {
 }
コード例 #33
0
 /// <summary>
 /// The default constructor
 /// </summary>
 /// <param name="row">The row where the move is played</param>
 /// <param name="column">The column where the move is played</param>
 /// <param name="play">The new content of the cell (X or O)</param>
 public Move(int row, int column, PlayerToken play)
 {
     this.Row = row;
     this.Column = column;
     this.Play = play;
 }
コード例 #34
0
 /// <summary>
 /// The default constructor
 /// </summary>
 /// <param name="token">The token player will be playing as</param>
 /// <param name="gameBoard">The game board to play on</param>
 public FillerPlayer(PlayerToken token, GameBoard gameBoard)
     : base(token, gameBoard)
 {
 }