private void SetPlayerReady(IPlayer player, bool readyAndAlive = true) { PlayerConstraints pc = playerConstraints[player]; pc.SetReadyAndAlive(readyAndAlive); playerConstraints[player] = pc; }
public AddPlayerCommandValidator() { var playerConstraints = new PlayerConstraints(); RuleFor(p => p.Nickname) .NotNull() .NotEmpty() .MaximumLength(playerConstraints.MaxNameLength); }
public void UnregisterPlayer(InputDataHolder playerInfo) { IPlayer player = playerToGuid.Forward[(Guid)playerInfo.identifier]; PlayerConstraints constraints = playerConstraints[player]; playerConstraints.Remove(player); playerToGuid.Remove((Guid)playerInfo.identifier); player.DestroyMe(); Destroy(constraints.MenuPlayer.gameObject); if (GameManager.instance.GetActiveGameScene() == GameScene.Menu) { GameManager.instance.UpdatePlayerCount(playerToGuid.GetKeys().Count); } else if (GameManager.instance.GetActiveGameScene() == GameScene.Game) { CheckRemainingPlayers(); } }
//Gets called from NetworkEventDispatcher -> definitely a client / Player instance. public void ReceivePlayerInput(InputDataHolder data) { Player player = (Player)playerToGuid.Forward[(Guid)data.identifier]; if (player != null) { PlayerConstraints constraints = playerConstraints[player]; if (GameManager.instance.GetActiveGameScene() == GameScene.Menu && ((InputDataType)data.type).Equals(InputDataType.ready)) { SetPlayerReady(player); CheckAllPlayersReady(); } else if (GameManager.instance.GetActiveGameScene() == GameScene.Game) { player.ReceiveInput((InputDataType)data.type, data.data); } } else { Debug.Log($"could not handle message of unknown client. {data.identifier}"); } }