예제 #1
0
    public void ClearBallColors(int playerNum)
    {
        PlayerColorCollection player = GetPlayerCollection(playerNum);

        if (player == null)
        {
            Debug.LogError("Error clearing ball colors for player " + playerNum + ": player not found.");
            return;
        }

        player.ballColors.Clear();
        colorChangeEvent.Raise();
    }
예제 #2
0
    public void RemoveBallColor(int playerNum, BallColor ballColor)
    {
        PlayerColorCollection player = GetPlayerCollection(playerNum);

        if (player == null)
        {
            Debug.LogError("Error removing ballColor '" + ballColor.name + "' from player " + playerNum + ": player not found.");
            return;
        }

        if (player.ballColors.Contains(ballColor))
        {
            player.ballColors.Remove(ballColor);
            colorChangeEvent.Raise();
        }
    }
예제 #3
0
    public PlayerColorCollection InitializePlayer(int playerNum)
    {
        PlayerColorCollection player = GetPlayerCollection(playerNum);

        if (player == null)
        {
            player = new PlayerColorCollection()
            {
                playerNumber = playerNum
            };
            playerColors.Add(player);
        }

        player.ballColors.Clear();

        return(player);
    }
예제 #4
0
    public void AddBallColor(int playerNum, BallColor ballColor)
    {
        PlayerColorCollection player = GetPlayerCollection(playerNum);

        if (player == null)
        {
            Debug.LogError("Error adding ballColor '" + ballColor.name + "' to player " + playerNum + ": player not found.");
            return;
        }

        if (!player.ballColors.Contains(ballColor))
        {
            int ownerId = GetBallOwner(ballColor);
            if (ownerId >= 0)
            {
                RemoveBallColor(ownerId, ballColor);
            }
            player.ballColors.Add(ballColor);
            colorChangeEvent.Raise();
            blackoutState.CheckForBlackout();
        }
    }
예제 #5
0
    public PlayerColorCollection GetPlayerCollection(int playerNum)
    {
        PlayerColorCollection player = playerColors.FirstOrDefault(p => { return(p.playerNumber == playerNum); });

        return(player);
    }
 // Use this for initialization
 void Start()
 {
     playerColors = playerData.colorState.GetPlayerCollection(playerData.playerId);
 }