Esempio n. 1
0
        public void Pickup(Drop drop)
        {
            if (drop.Picker == null)
            {
                try
                {
                    drop.Picker = this.Parent;

                    if (drop is Meso)
                    {
                        this.Parent.Meso += ((Meso)drop).Amount; // TODO: Check for max meso.
                    }
                    else if (drop is Item)
                    {
                        ((Item)drop).Slot = this.GetNextFreeSlot(((Item)drop).Type); // TODO: Check for inv. full.
                        this.Add((Item)drop, true);
                    }

                    this.Parent.Map.Drops.Remove(drop);

                    using (Packet showGain = drop.GetShowGainPacket())
                    {
                        this.Parent.Client.Send(showGain);
                    }
                }
                catch (InventoryFullException)
                {
                    this.NotifyFull();
                }
            }
        }
Esempio n. 2
0
        public void Pickup(Drop drop)
        {
            if (drop.Picker != null)
            {
                // Someone already picked up this drop
                return;
            }

            drop.Picker = Parent;

            switch (drop)
            {
            case Meso meso when Parent.PrimaryStats.Meso != int.MaxValue:
                Parent.PrimaryStats.Meso += meso.Amount;
                break;

            case Item item when item.OnlyOne:
                // TODO: Appropriate message.
                return;

            case Item item when IsFull(item.Type):
                NotifyFull();

                break;

            case Item item when !IsFull(item.Type):
                item.Slot = GetNextFreeSlot(item.Type);
                Add(item, true);
                break;
            }

            Parent.Map?.Drops.Remove(drop);
            drop.Picker.Send(drop.GetShowGainPacket());
        }
Esempio n. 3
0
        public void Pickup(Drop drop)
        {
            if (drop.Picker == null)
            {
                try
                {
                    drop.Picker = this.Parent;

                    if (drop is Meso)
                    {
                        long myPlusDropMesos = (long)this.Parent.Meso + (long)((Meso)drop).Amount;

                        if (myPlusDropMesos > Meso.mesoLimit)
                        {
                            this.Parent.Meso = Meso.mesoLimit;
                        }
                        else
                        {
                            this.Parent.Meso += ((Meso)drop).Amount;
                        }
                    }
                    else if (drop is Item)
                    {
                        if (((Item)drop).OnlyOne)
                        {
                            // TODO: Appropriate message.
                            return;
                        }

                        ((Item)drop).Slot = this.GetNextFreeSlot(((Item)drop).Type); // TODO: Check for inv. full.
                        this.Add((Item)drop, true);
                    }

                    this.Parent.Map.Drops.Remove(drop);
                    using (Packet oPacket = drop.GetShowGainPacket())
                    {
                        drop.Picker.Client.Send(oPacket);
                    }
                }
                catch (InventoryFullException)
                {
                    this.NotifyFull();
                }
            }
        }
Esempio n. 4
0
        public void Pickup(Drop drop)
        {
            if (drop.Picker == null)
            {
                try
                {
                    drop.Picker = this.Parent;

                    if (drop is Meso)
                    {
                        this.Parent.Meso += ((Meso)drop).Amount; // TODO: Check for max meso.
                    }
                    else if (drop is Item)
                    {
                        ((Item)drop).Slot = this.GetNextFreeSlot(((Item)drop).Type); // TODO: Check for inv. full.
                        this.Add((Item)drop, true);
                    }

                    using (Packet p = new Packet(ServerMessages.DropLeaveField))
                    {
                        p.WriteByte(2);
                        p.WriteInt(drop.ObjectID);
                        p.WriteInt(drop.Picker.ID);
                        p.WriteLong();

                        drop.Picker.Client.Send(p);
                    }

                    this.Parent.Field.Drops.Remove(drop);

                    using (Packet gain = drop.GetShowGainPacket())
                    {
                        this.Parent.Client.Send(gain);
                    }

                    this.Parent.Release();
                }
                catch (InventoryFullException)
                {
                    this.NotifyFull();
                    this.Parent.Release();
                }
            }
        }
Esempio n. 5
0
        public void Pickup(Drop drop)
        {
            if (drop.Picker == null)
            {
                try
                {
                    drop.Picker = Parent;

                    if (drop is Meso)
                    {
                        Meso mesoDrop = (Meso)drop;

                        // get total mesos
                        long myPlusDropMesos = Parent.Stats.Meso + mesoDrop.Amount;

                        // if int32 overflow reset to limit
                        if (myPlusDropMesos > Meso.mesoLimit)
                        {
                            Parent.Stats.Meso = Meso.mesoLimit;
                        }

                        // add mesos to chars mesos
                        else
                        {
                            Parent.Stats.Meso += mesoDrop.Amount;
                        }
                    }

                    else if (drop is Item)
                    {
                        Item itemDrop = (Item)drop;

                        // check if item is unique
                        if (itemDrop.OnlyOne)
                        {
                            // TODO: Check if i have such item in inventory, if so
                            // TODO: Inform looter about ownership of such unique item
                            return;
                        }

                        // try obtaining free slot for itemType of itemDrop
                        itemDrop.Slot = GetNextFreeSlot(itemDrop.ItemType);

                        if (itemDrop.Slot > 0)
                        {
                            // slot found add it into inventory
                            AddItemToInventory(itemDrop, true);
                        }
                    }

                    // remove item from map
                    Parent.Map.Drops.Remove(drop);

                    // show player his item gain
                    using (Packet oPacket = drop.GetShowGainPacket())
                    {
                        drop.Picker.Client.Send(oPacket);
                    }
                }

                // getNextFreeSlot failed to obtain slot to place item in
                catch (InventoryFullException)
                {
                    NotifyInventoryIsFull(Parent, ((Item)drop).ItemType);
                }
            }
        }