protected override void OnClientConnected(Player client) { // Set new player's info client.Index = (byte)(Clients.Count() - 1); client.PlayerName = PBEUtils.Sample(new string[] { "Sasha", "Nikki", "Lara", "Violet", "Naomi", "Rose", "Sabrina", "Nicole" }); // Send all already connected players to this client foreach (Player player in Clients) { player.Send(new PBEPlayerJoinedPacket(player == client, client.Index, client.PlayerName)); if (player != client) { client.Send(new PBEPlayerJoinedPacket(false, player.Index, player.PlayerName)); } } Console.WriteLine($"Client connected ({client.Id} {client.Index} {client.PlayerName})"); if (battlers == null && Clients.Count() == 2) { Console.WriteLine("Two players connected!"); state = ServerState.WaitingForParties; Console.WriteLine("Waiting for parties..."); battlers = Clients.OrderBy(c => c.Index).Take(2).ToArray(); battle.Teams[0].TrainerName = battlers[0].PlayerName; battle.Teams[1].TrainerName = battlers[1].PlayerName; SendTo(battlers, new PBEPartyRequestPacket()); } }
public void SetBattleView(BattleView battleView) { this.battleView = battleView; string s; switch (battleView.Client.Battle.BattleFormat) { case PBEBattleFormat.Single: s = PBEUtils.Sample(new string[] { "1_S", "2_S", "3_S", "4_S", "5_S", "6_S", "8_S" }); break; case PBEBattleFormat.Double: s = PBEUtils.Sample(new string[] { "1_D", "6_D", "7_D" }); break; case PBEBattleFormat.Triple: s = PBEUtils.Sample(new string[] { "1_T", "4_T", "5_T", "8_T" }); break; case PBEBattleFormat.Rotation: s = PBEUtils.Sample(new string[] { "1_R", "2_R" }); break; default: throw new ArgumentOutOfRangeException(nameof(battleView.Client.Battle.BattleFormat)); } BG.Source = ImageSource.FromResource($"Kermalis.PokemonBattleEngineMobile.BG.BG_{s}.png"); }
public void SetBattleView(BattleView battleView) { this.battleView = battleView; string s; switch (battleView.Client.Battle.BattleFormat) { case PBEBattleFormat.Single: s = PBEUtils.Sample(new string[] { "1_S", "2_S", "3_S", "4_S", "5_S", "6_S", "8_S" }); break; case PBEBattleFormat.Double: s = PBEUtils.Sample(new string[] { "1_D", "6_D", "7_D" }); break; case PBEBattleFormat.Triple: s = PBEUtils.Sample(new string[] { "1_T", "4_T", "5_T", "8_T" }); break; case PBEBattleFormat.Rotation: s = PBEUtils.Sample(new string[] { "1_R", "2_R" }); break; default: throw new ArgumentOutOfRangeException(nameof(battleView.Client.Battle.BattleFormat)); } BGSource = Utils.UriToBitmap(new Uri($"resm:Kermalis.PokemonBattleEngineClient.BG.BG_{s}.png?assembly=PokemonBattleEngineClient")); OnPropertyChanged(nameof(BGSource)); }