private void AssignPlayerToTeam(EPlayerID playerID, ETeamID teamID) { // First remove from old team ETeamID oldTeamID = PlayersTeam[playerID]; if (oldTeamID != ETeamID.NONE) { Teams[oldTeamID].Remove(playerID); } Teams[teamID].Add(playerID); PlayersTeam[playerID] = teamID; }
///// <summary> Convert an int (index of spell) to an InputButton enum (1 -> CAST_SPELL_1)</summary> //public static EInputButton GetInputButtonFrom(int spellID) //{ // EInputButton result = EInputButton.NONE; // switch (spellID) // { // case 1: // result = EInputButton.SOUTH; // break; // case 2: // result = EInputButton.WEST; // break; // case 3: // result = EInputButton.EAST; // break; // } // return result; //} /// <summary> Returns the same team ID as the player ID (e.g. Player 2 -> Team 2)</summary> public static ETeamID GetIdenticPlayerTeam(EPlayerID playerID) { ETeamID result = ETeamID.NONE; switch (playerID) { case EPlayerID.PLAYER_1: result = ETeamID.TEAM_1; break; case EPlayerID.PLAYER_2: result = ETeamID.TEAM_2; break; case EPlayerID.PLAYER_3: result = ETeamID.TEAM_3; break; case EPlayerID.PLAYER_4: result = ETeamID.TEAM_4; break; } return(result); }
private void On_PLAYERS_PlayerDied(EPlayerID diedPlayerID) { if (IsRunning == false) { return; } // Update Killed Player stats TestPlayerStats killedPlayerStats = PlayerStats[diedPlayerID]; killedPlayerStats.DecrementPlayerLives(); //EventManager.Instance.Invoke_GAME_PlayerStatsUpdated(killedPlayerStats, GameModeType); // Update Killer stats if (killedPlayerStats.LastHitBy != EPlayerID.NONE) { TestPlayerStats killingPlayer = PlayerStats[killedPlayerStats.LastHitBy]; killingPlayer.IncrementNumberOfKilledPlayers(); //EventManager.Instance.Invoke_GAME_PlayerStatsUpdated(killingPlayer, GameModeType); } // Respawn Killed Player if (killedPlayerStats.RemainingLives > 0) { //PlayerManager.Instance.RespawnPlayer(diedPlayerID); } else { killedPlayerStats.SetTimeOfDeath(RemainingTime); } // Check if game over (only one player still alive) int gameOverPlayerCounter = 0; EPlayerID winnerPlayerID = EPlayerID.NONE; foreach (EPlayerID playerID in PlayerStats.Keys) { if (PlayerStats[playerID].IsGameOver == true) { gameOverPlayerCounter++; } else { winnerPlayerID = playerID; } } if (gameOverPlayerCounter == PlayerStats.Count - 1) { ETeamID winnerTeamID = PlayerManager.Instance.PlayersTeam[winnerPlayerID]; //Itirate through the the players time of death and set the ranking foreach (TestPlayerStats playerStats in PlayerStats.Values) { int counter = 0; foreach (TestPlayerStats otherPlayerStats in PlayerStats.Values) { if (playerStats != otherPlayerStats && playerStats.TimeOfDeath > otherPlayerStats.TimeOfDeath) { counter++; // Debug.Log(" Player " + Maleficus.Utils.GetIntFrom(playerStats.PlayerID) + " Time of Death = " + playerStats.TimeOfDeath + " died before Player " + Maleficus.Utils.GetIntFrom(otherPlayerStats.PlayerID) + " with a Time of Death = " + otherPlayerStats.TimeOfDeath); } } playerStats.SetRank(counter + 1); } //if ((NetworkManager.Instance.HasAuthority == true) // || (MotherOfManagers.Instance.ConnectionMode == EConnectionMode.PLAY_OFFLINE)) //{ // NetEvent_GameOver gameOverEventHandle = new NetEvent_GameOver(EClientID.SERVER, teamID); // EventManager.Instance.GAME_GameOver.Invoke(gameOverEventHandle, EEventInvocationType.TO_ALL); //} } }
public EPlayerID[] GetPlayersInTeam(ETeamID inTeamID) { return(Teams[inTeamID].ToArray()); }
private void RemovePlayerFromTeam(EPlayerID playerID, ETeamID teamID) { // TODO: Implement removing player from team }