/// <summary> /// Handles end shots by players and broadcasts that to all other <see cref="Player"/>s. /// </summary> /// <param name="incomingMessage"></param> public void EndShot(NetIncomingMessage incomingMessage) { MsgEndShotPacket incomingShotEndPacket = MsgEndShotPacket.Read(incomingMessage); // create our shot end message and packet NetOutgoingMessage shotEndMessage = gameKeeper.Server.CreateMessage(); MsgEndShotPacket shotEndPacket = new MsgEndShotPacket(incomingShotEndPacket.Slot, incomingShotEndPacket.ShotSlot, incomingShotEndPacket.Explode); // write to the message shotEndMessage.Write((Byte)shotEndPacket.MsgType); shotEndPacket.Write(shotEndMessage); // send the shot end message to everyone except the player who reported it gameKeeper.Server.SendToAll(shotEndMessage, this.Connection, NetDeliveryMethod.ReliableUnordered, 0); }
public void End(bool explode) { // we are no longer moving now Velocity = Vector2.Zero; // and we are ending, if we choose to explode, or go straight to ended if (explode) state = ShotState.Ending; else state = ShotState.Ended; explosion = new AnimatedSprite(World, World.Content.Load<Texture2D>("textures/bz/explode1"), Position, new Vector2(8, 8), Rotation, new Point(8, 8), new Point(64, 64), SpriteSheetDirection.RightToLeft, false); // we only broadcast the end shot if it's a local one we're keeping track of if (Local) { NetOutgoingMessage endShotMessage = World.ServerLink.CreateMessage(); MsgEndShotPacket endShotPacket = new MsgEndShotPacket(this.Slot, explode); endShotMessage.Write((Byte)endShotPacket.MsgType); endShotPacket.Write(endShotMessage); World.ServerLink.SendMessage(endShotMessage, NetDeliveryMethod.ReliableUnordered, 0); } }