public void applyPowerUpOnOthers(Player player, PowerUp powerUp) { List <Player> allPlayers = new List <Player>(playersSpawner.GetAllPlayers()); allPlayers.Remove(player); allPlayers.ForEach((Player otherPlayer) => applyPowerUp(otherPlayer, powerUp)); }
public void playerIsDead(Player player) { deadPlayers.Add(player); int numOfDeadPlayers = deadPlayers.Count; int numOfPlayers = scoreMap.Count; int additionalScore = (numOfDeadPlayers) * 10; // set score int oldScore = scoreMap[player.id]; scoreMap[player.id] = oldScore + additionalScore; playerScoreList.updateScoreBoard(); // if numOfDeadPlayers is totalPlayer -1, it means there is one player left, kill him. if (numOfDeadPlayers == numOfPlayers - 1) { PlayersSpawner playersSpawner = FindObjectOfType <PlayersSpawner>(); List <Player> allPlayers = playersSpawner.GetAllPlayers(); foreach (Player p in allPlayers) { if (!deadPlayers.Contains(p)) { p.kill(); } } } // If numOfDeadPlayers is equal to number of players, end game. if (numOfDeadPlayers == numOfPlayers) { FindObjectOfType <GameManager>().EndMatch(); } }