Beispiel #1
0
    // 5) Prefab communicated to the server
    private void OnPrefabResponse(NetworkMessage netMsg)
    {
        MsgTypes.PlayerPrefabMsg msg = netMsg.ReadMessage <MsgTypes.PlayerPrefabMsg>();
        playerPrefab = spawnPrefabs[msg.prefabIndex];
        Player.PlayerColor playerColor    = (Player.PlayerColor)msg.prefabIndex;
        Vector3            playerPosition = StaticGridManager.GetSingleton().GetPlayerSpawnPosition(playerColor);
        GameObject         player         = (GameObject)Instantiate(playerPrefab, playerPosition, Quaternion.identity);

        player.GetComponent <Player>().color = playerColor;
        NetworkServer.AddPlayerForConnection(netMsg.conn, player, msg.controllerId);
    }
Beispiel #2
0
    public void mix(Player.PlayerColor other)
    {
        if (lastVisitedPlayer == null)
        {
            return;
        }
        Player.PlayerColor color = lastVisitedPlayer.color;
        int mix = (int)color + (int)other;

        Player.MixColor mixColor = (Player.MixColor)mix;
        gameObject.GetComponent <Light>().color = lastVisitedPlayer.getColor(mixColor);
        breakIntensity = false;
    }
Beispiel #3
0
    public Player GetPlayer(Player.PlayerColor playerColor)
    {
        foreach (GameObject gameObject in playerGameObjects)
        {
            Player player = gameObject.GetComponent <Player>();
            if (player.color == playerColor)
            {
                return(player);
            }
        }

        return(null);
    }
Beispiel #4
0
        public void GameOver(Player.PlayerColor color)
        {
            PrintCellGrid();

            gameOver = true;
            if (color == Player.PlayerColor.BLUE)
            {
                //Console.WriteLine("Blue player won!");
            }
            else
            {
                //Console.WriteLine("Red player won!");
            }
        }
Beispiel #5
0
        public static bool TurnMatchesColor(Player.PlayerColor color, Cell.CellState state)
        {
            if (color == Player.PlayerColor.BLUE && state == Cell.CellState.BLUE)
            {
                return(true);
            }

            if (color == Player.PlayerColor.RED && state == Cell.CellState.RED)
            {
                return(true);
            }

            return(false);
        }
Beispiel #6
0
        /// <summary>
        /// Get the image of a player
        /// </summary>
        /// <param name="playerColor"></param>
        /// <returns></returns>
        public static Image GetImage(this Player.PlayerColor playerColor)
        {
            switch (playerColor)
            {
            case Player.PlayerColor.Purple:
                return(Properties.Resources.PlayerPurple);

            case Player.PlayerColor.Yellow:
                return(Properties.Resources.PlayerYellow);

            case Player.PlayerColor.Green:
                return(Properties.Resources.PlayerGreen);

            case Player.PlayerColor.Red:
                return(Properties.Resources.PlayerRed);

            case Player.PlayerColor.Blue:
                return(Properties.Resources.PlayerBlue);
            }

            return(Properties.Resources.Center);
        }
Beispiel #7
0
        /// <summary>
        /// Get the color of a player
        /// </summary>
        /// <param name="playerColor"></param>
        /// <returns></returns>
        public static Color GetColor(this Player.PlayerColor playerColor)
        {
            switch (playerColor)
            {
            case Player.PlayerColor.Purple:
                return(Color.FromArgb(159, 0, 181));

            case Player.PlayerColor.Yellow:
                return(Color.FromArgb(255, 200, 0));

            case Player.PlayerColor.Green:
                return(Color.FromArgb(0, 137, 0));

            case Player.PlayerColor.Red:
                return(Color.FromArgb(244, 27, 0));

            case Player.PlayerColor.Blue:
                return(Color.FromArgb(25, 0, 162));
            }

            return(Color.Black);
        }
Beispiel #8
0
        /// <summary>
        /// Get the default name of a player color
        /// </summary>
        /// <param name="playerColor"></param>
        /// <returns></returns>
        public static string GetDefaultName(this Player.PlayerColor playerColor)
        {
            switch (playerColor)
            {
            case Player.PlayerColor.Purple:
                return("Beerus");

            case Player.PlayerColor.Yellow:
                return("SpaceCore");

            case Player.PlayerColor.Green:
                return("Cayde");

            case Player.PlayerColor.Red:
                return("Deadpool");

            case Player.PlayerColor.Blue:
                return("Stitch");
            }

            return("Player");
        }
Beispiel #9
0
    public Vector3 GetPlayerSpawnPosition(Player.PlayerColor playerColor)
    {
        Vector3Int cellPosition = Vector3Int.zero;

        switch (playerColor)
        {
        case Player.PlayerColor.white:
        {
            cellPosition = topLeftSpawnTile;
            break;
        }

        case Player.PlayerColor.black:
        {
            cellPosition = bottomRightSpawnTile;
            break;
        }

        case Player.PlayerColor.red:
        {
            cellPosition = bottomLeftSpawnTile;
            break;
        }

        case Player.PlayerColor.blue:
        {
            cellPosition = topRightSpawnTile;
            break;
        }

        default:
        {
            break;
        }
        }

        return(nonCollidableGroundTilemap.GetCellCenterWorld(cellPosition));
    }
Beispiel #10
0
        public void MakeTurn(Player.PlayerColor color, CellState state)
        {
            if (CellAlive(state))
            {
                if (!game.sacrifice)
                {
                    cellState         = CellState.DEAD;
                    game.finishedMove = true;
                }

                else if (Game.TurnMatchesColor(color, state))
                {
                    cellState = CellState.DEAD;

                    if (!game.newCell.halfEmpty)
                    {
                        game.newCell.halfEmpty = true;
                    }
                    else
                    {
                        game.newCell.cellState = state;
                        game.newCell.halfEmpty = false;

                        game.sacrifice    = false;
                        game.finishedMove = true;
                    }
                }
            }
            else
            {
                if (!game.sacrifice)
                {
                    if (game.currentPlayer.playerColor == Player.PlayerColor.BLUE)
                    {
                        cellState = CellState.BORN_BLUE;
                    }
                    else
                    {
                        cellState = CellState.BORN_READ;
                    }

                    game.newCell   = this;
                    game.sacrifice = true;
                }
                else
                {
                    if ((cellState == CellState.BORN_READ || cellState == CellState.BORN_BLUE) && !halfEmpty)
                    {
                        cellState      = CellState.DEAD;
                        game.sacrifice = false;
                    }
                    else if (cellState == CellState.DEAD && !game.newCell.halfEmpty)
                    {
                        game.newCell.cellState = CellState.DEAD;
                        game.newCell           = this;

                        if (game.currentPlayer.playerColor == Player.PlayerColor.BLUE)
                        {
                            cellState = CellState.BORN_BLUE;
                        }
                        else
                        {
                            cellState = CellState.BORN_READ;
                        }
                    }
                }
            }
        }
Beispiel #11
0
 //Constructor
 public Player(Player.PlayerColor _color, string _playerName)
 {
     color      = _color;
     playerName = _playerName;
 }
 // Update chosen color
 public void SetColor(UISelect select)
 {
     color = (Player.PlayerColor)select.value;
 }