Exemplo n.º 1
0
        private void HandleDropFlag(NetworkMessage msg)
        {
            MsgDropFlag df = msg as MsgDropFlag;

            var          owner = PlayerList.GetPlayerByID(df.PlayerID);
            FlagInstance flag  = FindFlagByID(df.FlagID);

            if (owner != null)
            {
                owner.SetFlag(null);
            }

            if (flag != null)
            {
                flag.Owner  = null;
                flag.Status = FlagStatuses.FlagInAir;
                if (owner != null)
                {
                    flag.CurrentPosition = owner.Position;
                }

                if (FlagDropped != null)
                {
                    FlagDropped.Invoke(this, flag);
                }
            }
        }
Exemplo n.º 2
0
        public void DropFlag(ServerPlayer player)
        {
            if (player == null || player.Info.CariedFlag == null)
            {
                return;
            }

            if (player.Info.CariedFlag.Flag == FlagTypeList.Identify)
            {
                player.SendMessage(new MsgNearFlag());  // send them an empty ID message to clear out the display
            }
            FlagInstance flag = player.Info.CariedFlag;

            ComputeFlagDrop?.Invoke(player, flag);

            MsgDropFlag drop = new MsgDropFlag();

            drop.FlagID   = flag.FlagID;
            drop.PlayerID = player.PlayerID;
            drop.Data     = flag;

            player.Info.CariedFlag = null;
            flag.Owner             = null;

            Players.SendToAll(drop, false);

            lock (CarriedFlags)
            {
                if (CarriedFlags.ContainsKey(flag.FlagID))
                {
                    CarriedFlags.Remove(flag.FlagID);
                }
            }

            lock (WorldFlags)
                WorldFlags.Add(flag.FlagID, flag);

            FlagDropped?.Invoke(this, flag);
        }