private void OnFactionRequestEvent(int deviceId, FactionType factionType, bool selectType) { PlayerFactionLinkItem ft = _conPlayerFactions.GetLinkItemForFaction(factionType); RegisteredPlayer playerOfId = _conPlayers.GetRegisteredPlayerById(deviceId); if (selectType) { if (ft.Player != null) { return; } _conPlayerFactions.UnassignPlayerFromItsFaction(playerOfId); _conPlayerFactions.AssignPlayerToFaction(playerOfId, factionType); } else { if (ft.Player != playerOfId) { return; } _conPlayerFactions.UnassignPlayerFromItsFaction(playerOfId); } if (_conPlayerFactions.GetTakenFactions().Length == _conPlayers.GetCurrentlyRegisteredPlayers(false).Length) { GoToGameScene(); return; } SendUpdateFactions(); }
/// <summary> /// This will set the ready state of the given player. /// </summary> /// <param name="value">Ready state</param> /// <param name="deviceId">DeviceID of player</param> private void ChangeReadyValue(bool value, int deviceId) { JoinTab jt = GetJoinTabDisplaying(deviceId); if (jt == null) { return; } jt.ToggleReady(value); SetGlobalText(); if (GetAmountOfTabsReady() == _conPlayers.GetCurrentlyRegisteredPlayers(true).Length&& GetAmountOfTabsReady() >= 2) { StarCountDown(); } else { StopCountDown(); } }
public void SetCurrentPhase(GamePhase gamePhase) { CurrentGamePhase = gamePhase; if (!_conPlayers.IsReadyToUse) { return; } // It will be send to the players on the ready event. RegisteredPlayer[] allPlayersConnected = _conPlayers.GetCurrentlyRegisteredPlayers(true); for (int i = 0; i < allPlayersConnected.Length; i++) { UpdatePhaseInfoForPlayer(allPlayersConnected[i]); } }