/// <summary> /// Handles new shots by players and broadcasts that to all other <see cref="Player"/>s. /// </summary> /// <param name="incomingMessage"></param> 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); }
protected override void Shoot(Byte shotSlot, Vector2 initialPosition, Single rotation, Vector2 initialVelocity, bool local) { // send out the shot begin packet right away NetOutgoingMessage shotBeginMessage = World.ServerLink.CreateMessage(); MsgBeginShotPacket shotBeginPacket = new MsgBeginShotPacket(shotSlot, initialPosition, rotation, initialVelocity); shotBeginMessage.Write((Byte)shotBeginPacket.MsgType); shotBeginPacket.Write(shotBeginMessage); World.ServerLink.SendMessage(shotBeginMessage, NetDeliveryMethod.ReliableUnordered, 0); base.Shoot(shotSlot, initialPosition, rotation, initialVelocity, local); }