public void AddCommand(Command.Command command) { commands.Enqueue(command); switch (command.type) { case Command.Command.Type.Shoot: LightShoot lightCommand = new LightShoot((Shoot)command); communication.SendReliable(lightCommand, NetFrame.FrameType.shootCommand); break; } }
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); } } }