AngryTanks.Server.Player.Shoot C# (CSharp) Method

Shoot() public method

Handles new shots by players and broadcasts that to all other Players.
public Shoot ( NetIncomingMessage incomingMessage ) : void
incomingMessage Lidgren.Network.NetIncomingMessage
return void
        public void Shoot(NetIncomingMessage incomingMessage)
        {
            MsgBeginShotPacket incomingBeginShotPacket = MsgBeginShotPacket.Read(incomingMessage);

            // create our shot begin message and packet
            NetOutgoingMessage beginShotMessage = gameKeeper.Server.CreateMessage();

            MsgBeginShotPacket beginShotPacket =
                new MsgBeginShotPacket(this.Slot,
                                       incomingBeginShotPacket.ShotSlot,
                                       incomingBeginShotPacket.Position,
                                       incomingBeginShotPacket.Rotation,
                                       incomingBeginShotPacket.Velocity);

            // write to the message
            beginShotMessage.Write((Byte)beginShotPacket.MsgType);
            beginShotPacket.Write(beginShotMessage);

            // send the shot begin message to everyone except the player who reported it
            gameKeeper.Server.SendToAll(beginShotMessage, this.Connection, NetDeliveryMethod.ReliableUnordered, 0);
        }