public void Die(NetIncomingMessage incomingMessage)
{
MsgDeathPacket incomingDeathPacket = MsgDeathPacket.Read(incomingMessage);
// create our death message and packet
NetOutgoingMessage deathMessage = gameKeeper.Server.CreateMessage();
MsgDeathPacket deathPacket = new MsgDeathPacket(this.Slot, incomingDeathPacket.Killer);
// write to the message
deathMessage.Write((Byte)deathPacket.MsgType);
deathPacket.Write(deathMessage);
// send the death message to everyone except the player who reported it
gameKeeper.Server.SendToAll(deathMessage, this.Connection, NetDeliveryMethod.ReliableOrdered, 0);
// update our score
this.Score.Losses++;
// update killer's score, but only if the killer wasn't myself
if (this.Slot != incomingDeathPacket.Killer)
{
Player killer = gameKeeper.GetPlayerBySlot(incomingDeathPacket.Killer);
if (killer != null)
{
killer.Score.Wins++;
gameKeeper.Server.SendToAll(killer.GetMsgScore(), null, NetDeliveryMethod.ReliableOrdered, 0);
}
}
// broadcast our score
gameKeeper.Server.SendToAll(this.GetMsgScore(), null, NetDeliveryMethod.ReliableOrdered, 0);
// update our last died time
lastDiedTime = DateTime.Now;
// we're now dead as far as we're concerned
state = PlayerState.Dead;
}