示例#1
0
        public static void Suck()
        {
            foreach (var entity in Entities)
            {
                var amount    = 0;
                var GoldDrops = new List <FloorItem>();
                foreach (var item in ScreenSystem.GetEntities(entity.Value))
                {
                    if (item is FloorItem)
                    {
                        var floorItem = item as FloorItem;

                        if (floorItem.Amount > 0)
                        {
                            GoldDrops.Add(floorItem);
                        }
                    }
                }
                foreach (var floorItem in GoldDrops)
                {
                    amount += floorItem.Amount;
                    floorItem.Jobs.Clear();
                    floorItem.Destroy();
                }
                FloorItemSystem.DropMoney(entity.Value, entity.Value, amount);
            }
        }
示例#2
0
 public static void SetUpFloorItemSystem()
 {
     foreach (var kvp in FloorItems)
     {
         if (kvp.Value.Jobs == null)
         {
             kvp.Value.Jobs = new List <Job>();
         }
         ScreenSystem.Create(kvp.Value);
         AddCountdown(kvp.Value);
         ScheduleDestruction(kvp.Value);
         ScheduleOwnerRemove(kvp.Value);
         GameWorld.Maps[kvp.Value.MapId].LoadInEntity(kvp.Value);
     }
 }
示例#3
0
        public static void Pickup(YiObj picker, int itemId)
        {
            if (!FloorItems.TryGetValue(itemId, out var drop))
            {
                return;
            }

            if (drop.Owner != null)
            {
                if (picker.UniqueId != drop.Owner.UniqueId)
                {
                    if (TeamSystem.MemberOfTeam(picker.UniqueId, drop.Owner.UniqueId, out var teamData2))
                    {
                        if (drop.Money > 0 && teamData2.MoneyLocked)
                        {
                            Message.SendTo(picker, $"This item belongs to {drop.Owner.Name.TrimEnd('\0')}", MsgTextType.Action);
                            return;
                        }

                        if (teamData2.ItemsLocked)
                        {
                            Message.SendTo(picker, $"This item belongs to {drop.Owner.Name.TrimEnd('\0')}", MsgTextType.Action);
                            return;
                        }
                    }
                }
            }

            if (drop.Amount > 0)
            {
                picker.Money += drop.Amount;

                AbortJobs(drop);
                drop.Destroy();
                if (drop.Amount > 2000)
                {
                    ScreenSystem.Send(picker, MsgAction.CashEffect(picker, drop.Amount), true);
                }
                picker.GetMessage(Constants.System, picker.Name, $"You've picked up {drop.Amount:##,###} gold.", MsgTextType.Top);
            }
            else if (picker.Inventory.AddItem(drop.Original))
            {
                AbortJobs(drop);
                drop.Destroy();
            }
        }
示例#4
0
 private static void QueueDrop(FloorItem drop)
 {
     YiScheduler.Instance.Do(SchedulerPriority.Medium, () =>
     {
         for (var i = 0; i < 10; i++)
         {
             if (!GameWorld.Maps[drop.MapId].ItemValid(drop.Location.X, drop.Location.Y))
             {
                 drop.Location.X += (ushort)YiCore.Random.Next(-1, 2);
                 drop.Location.Y += (ushort)YiCore.Random.Next(-1, 2);
             }
             else
             {
                 AddCountdown(drop);
                 ScheduleDestruction(drop);
                 ScheduleOwnerRemove(drop);
                 ScreenSystem.Create(drop);
                 FloorItems.AddOrUpdate(drop.UniqueId, drop);
                 GameWorld.Maps[drop.MapId].Enter(drop);
                 if (drop.Original != null && drop.Owner is Player player)
                 {
                     var packet = MsgItem.Create(drop.Original.UniqueId, drop.Original.UniqueId, drop.Original.UniqueId, MsgItemType.RemoveInventory);
                     player.Send(packet);
                 }
                 ScreenSystem.Send(drop, MsgFloorItem.Create(drop, MsgFloorItemType.Create), true);
                 drop.AddStatusEffect(StatusEffect.SuperMan);
                 return;
             }
         }
         if (drop.Original != null && drop.Owner is Player owner)
         {
             owner.Inventory.AddOrUpdate(drop.Original.UniqueId, drop.Original);
             owner.Send(new MsgItemInformation(drop.Original, MsgItemPosition.Inventory));
         }
         else
         {
             drop.Owner.Money += drop.Amount;
         }
     });
 }