示例#1
0
        public void OnInventoryDragDrop(GameMessage msga)
        {
            InventoryDragDrop msg = msga as InventoryDragDrop;

            var tar  = Player.Position.CurMap.GetObject(msg.TargetId);
            var item = Player.Inventory.GetItem(msg.Slot);

            if (tar == null || item == null)
            {
                return;
            }

            if (tar is Object.Item)
            {
                var itar = tar as Object.Item;
                if (itar._Name == "CAULDRON" || itar._Name == "ANVIL")
                {
                    if (item.Name.IndexOf("MATCH :") != -1)
                    {
                        Object.Craft crafto = null;
                        if (itar._Name == "CAULDRON")
                        {
                            crafto = new Object.Cauldron();
                        }
                        else if (itar._Name == "ANVIL")
                        {
                            crafto = new Object.Anvil();
                        }

                        crafto.Position.X      = itar.Position.X;
                        crafto.Position.Y      = itar.Position.Y;
                        crafto.Position.CurMap = itar.Position.CurMap;
                        crafto.Upgrade(itar);
                        Player.Inventory.Delete(msg.Slot, true);
                    }
                    else
                    {
                        Player.WriteWarn(string.Format("This {0} is not lit.", itar.Name));
                    }
                }
            }
            else if (tar is Object.Craft)
            {
                if ((tar as Object.Craft).DropItem(Player, item, msg.Slot))
                {
                    if ((tar is Object.Cauldron))
                    {
                        Player.Inventory.Delete(msg.Slot, false);
                    }
                    else if ((tar is Object.Anvil))
                    {
                        Player.Inventory.Delete(msg.Slot, true);
                    }
                }
            }
        }
示例#2
0
        public static void Smelt(Player.Player plyr, Object.Craft cauldron)
        {
            int XPGained = 0;
            var content  = cauldron.Contents.Skip(0).Select(xe => xe.Value).ToList();

            foreach (var itm in content)
            {
                if (itm.StackSize == 0)
                {
                    continue;
                }

                Object.Item result = null;
                int         pb     = GetPb(itm._Name);

                switch (itm._Name)
                {
                case "IRON PB":
                case "IRON PN":
                case "IRON PG":
                    result = SmeltOre(itm, "IRON BAR", pb, plyr, 0, 5, ref XPGained);
                    break;

                case "COPPER PB":
                case "COPPER PN":
                case "COPPER PG":
                    result = SmeltOre(itm, "COPPER BAR", pb, plyr, 2, 6, ref XPGained);
                    break;

                case "WAX PB":
                case "WAX PN":
                case "WAX PG":
                    result = SmeltOre(itm, "WAX BAR", pb, plyr, 4, 9, ref XPGained);
                    break;

                case "ALUMINUM PB":
                case "ALUMINUM PN":
                case "ALUMINUM PG":
                    result = SmeltOre(itm, "ALUMINUM BAR", pb, plyr, 6, 13, ref XPGained);
                    break;

                case "COPPER BAR":
                case "IRON BAR":
                    if (!AssertLevel(plyr, 1, "BRONZE BAR"))
                    {
                        return;
                    }

                    var copbar  = cauldron.Contents.Skip(0).Where(xe => xe.Value._Name == "COPPER BAR").FirstOrDefault();
                    var ironbar = cauldron.Contents.Skip(0).Where(xe => xe.Value._Name == "IRON BAR").FirstOrDefault();
                    if (copbar.Value != null && ironbar.Value != null && copbar.Value.StackSize > 0 && ironbar.Value.StackSize > 0)
                    {
                        result = SmeltBronze(ironbar.Value, copbar.Value, ref XPGained);
                        if (copbar.Value.StackSize == 0)
                        {
                            cauldron.RemoveItem(copbar.Value);
                        }
                        if (ironbar.Value.StackSize == 0)
                        {
                            cauldron.RemoveItem(ironbar.Value);
                        }
                    }

                    break;
                }

                if (result != null)
                {
                    result.Position.X      = plyr.Position.X;
                    result.Position.Y      = plyr.Position.Y;
                    result.Position.CurMap = plyr.Position.CurMap;
                    plyr.Position.CurMap.Enter(result);
                }

                if (itm is Object.Ore)
                {
                    if (itm.StackSize == 0)
                    {
                        cauldron.RemoveItem(itm);
                    }
                }
            }
            if (XPGained > 0)
            {
                plyr.State.MinerXP += XPGained;
                plyr.WriteWarn(string.Format("You have gained {0} experience.", XPGained));
            }
        }