public void AddCommand(Command.Command command) { commands.Enqueue(command); switch (command.type) { case Command.Command.Type.Shoot: LightShootPlayer lightCommand = new LightShootPlayer((Shoot)command, GameEnvironment.Instance.Players.Count-1); // On client, player max-1 = server // TODO : change this ! (cf GameEnvironment) // TODO : use broadcast ? foreach (Player p in GameEnvironment.Instance.Players) { if (p != GameEnvironment.Instance.LocalPlayer) { communication.SendReliable(lightCommand, NetFrame.FrameType.shootCommandPlayer, p); } } break; } }
internal void AddShoot(LightShootPlayer lightShootPlayer) { Player p = GameEnvironment.Instance.Players.ElementAt(lightShootPlayer.playerIndex); Shoot shoot = new Shoot(p.getCharacter(), lightShootPlayer.time); commands.Enqueue(shoot); }
internal void AddShoot(Player player, LightShoot lightShoot) { Shoot shoot = new Shoot(player.getCharacter(), lightShoot.time); commands.Enqueue(shoot); int index = 0;//GameEnvironment.Instance.Players.Count-1; foreach ( Player p in GameEnvironment.Instance.Players ) { if ( p==player ) { break; } index++; } index--; // On server, player max = server | On client, player max = client, player max-1 = server // TODO : change this ! (cf GameEnvironment) Console.WriteLine(index); LightShootPlayer lsp = new LightShootPlayer(shoot, index); foreach (Player p in GameEnvironment.Instance.Players) { if (p != GameEnvironment.Instance.LocalPlayer && p != player) { communication.SendReliable(lsp, NetFrame.FrameType.shootCommandPlayer, p); } } }