public void LeavePlayer(EPlayerID playerID) { if ((IS_KEY_CONTAINED(partyStatusMap, playerID)) && (IS_TRUE(partyStatusMap[playerID].HasJoined))) { // Destroy Player if (ActivePlayers.ContainsKey(playerID)) { DestroyPlayer(playerID); } // Reset controller to Spectator EControllerID controllerID = partyStatusMap[playerID].ControllerID; if (IS_KEY_CONTAINED(ControllersMap, controllerID)) { ControllersMap[controllerID] = EPlayerID.SPECTATOR; } // Reset entry of playerID in party status partyStatusMap[playerID] = new PlayerJoinStatus(EControllerID.NONE); // Trigger global event BEventsCollection.PLAYERS_PlayerLeft.Invoke(new BEHandle <EPlayerID, EControllerID>(playerID, controllerID)); // Are the rest of the joined players ready? CheckIfAllPlayersAreReady(); } }
public bool HasPlayerJoined(EPlayerID playerID) { foreach (KeyValuePair <EPlayerID, PlayerJoinStatus> pair in partyStatusMap) { PlayerJoinStatus playerJoinStatus = pair.Value; if ((playerID == pair.Key) && (playerJoinStatus.HasJoined == true)) { return(true); } } return(false); }
public List <EPlayerID> GetJoinedPlayers() { List <EPlayerID> result = new List <EPlayerID>(); foreach (KeyValuePair <EPlayerID, PlayerJoinStatus> pair in partyStatusMap) { PlayerJoinStatus playerJoinStatus = pair.Value; if (playerJoinStatus.HasJoined == true) { result.Add(pair.Key); } } return(result); }
private EPlayerID GetNextNotJoinedPlayerID() { foreach (var pair in partyStatusMap) { EPlayerID playerID = pair.Key; PlayerJoinStatus playerJoinStatus = pair.Value; if (playerJoinStatus.HasJoined == false) { return(playerID); } } return(EPlayerID.NONE); }
private EPlayerID JoinNextAIPlayer(EControllerID controllerID) { foreach (var pair in partyStatusMap) { EPlayerID playerID = pair.Key; PlayerJoinStatus playerJoinStatus = pair.Value; if (playerJoinStatus.HasJoined == false) { JoinPlayer(playerID, controllerID); return(playerID); } } return(EPlayerID.NONE); }