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(); }
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(); } }
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); }
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(); } }
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); }