Esempio n. 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);
    }
Esempio n. 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;
    }
Esempio n. 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);
    }
Esempio n. 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!");
            }
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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");
        }
Esempio n. 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));
    }
Esempio n. 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;
                        }
                    }
                }
            }
        }
Esempio n. 11
0
 //Constructor
 public Player(Player.PlayerColor _color, string _playerName)
 {
     color      = _color;
     playerName = _playerName;
 }
Esempio n. 12
0
 // Update chosen color
 public void SetColor(UISelect select)
 {
     color = (Player.PlayerColor)select.value;
 }