예제 #1
0
        private void DigBlock(int x, int y, IPlayer player, float digStrength, bool mining, bool explosion = false)
        {
            if (digHardness == null)
                resetDigHardness();

            if (!(x > 0 && y > 0 && x < bot.Room.Width && y < bot.Room.Height))
                return;

            if (digHardness[x, y] <= 0)
                return;

            IBlock block = bot.Room.getBlock(0, x, y);
            int blockId = -1;
            float blockXp = 0;

            DigPlayer digPlayer = null;
            if (player != null)
            {
                if (!player.HasMetadata("digplayer"))
                    player.SetMetadata("digplayer", new DigPlayer(player));

                 digPlayer = (DigPlayer)player.GetMetadata("digplayer");
            }

            if (mining)
            {
                InventoryItem temp = ItemManager.GetItemFromOreId(block.Id);
                if (temp != null)
                {
                    Ore ore = ItemManager.GetOreByName(temp.Name);
                    blockId = 414;

                    if (digPlayer.digLevel >= Convert.ToInt32(ore.LevelRequired))
                    {
                        if (digHardness[x, y] <= digStrength)
                        {
                            digHardness[x, y] = 0F;

                            InventoryItem newsak = new InventoryItem(temp);

                            digPlayer.Inventory.AddItem(newsak, 1);
                            int oldLevel = digPlayer.digLevel;
                            digPlayer.digXp += Convert.ToInt32(ore.XPGain);
                            int newLevel = digPlayer.digLevel;
                            if (newLevel > oldLevel)
                                player.Reply("You have leveled up to level " + newLevel + "!");
                        }
                    }
                    else
                    {
                        return;
                    }

                }
            }

            if (explosion)
                blockId = 414;

            switch (block.Id)
            {
                case BlockIds.Blocks.Sand.BROWN:
                    blockId = 414;
                    blockXp = 0.08f;
                    break;

                case BlockIds.Blocks.Sand.GRAY:
                    blockId = 414;
                    blockXp = 0.1f;
                    break;

                case 1022: // gray bricks
                    blockId = 414;
                    blockXp = 0.2f;
                    break;

                case BlockIds.Blocks.JungleRuins.BLUE:
                    blockId = BlockIds.Action.Liquids.WATER;
                    blockXp = 0.1f;
                    break;

                case 21:
                    blockId = 369; //BlockIds.Action.Liquids.MUD;
                    blockXp = 0.1f;
                    break;

                default:
                    if (blockId == -1)
                        return;
                    else
                        break;
            }

            digHardness[x, y] -= digStrength;

            if (digHardness[x, y] <= 0)
            {
                digHardness[x, y] = 0f;

                bot.Room.setBlock(x, y, new NormalBlock(blockId));
                lock (dugBlocksToPlaceQueueLock)
                    dugBlocksToPlaceQueue.Enqueue(new BlockWithPos(x, y, block));

                if (blockXp > 0 && digPlayer != null)
                    digPlayer.digXp += blockXp;
            }
        }
예제 #2
0
 public void Load(SaveFile file)
 {
     Dictionary<string, Node> nodes = file.Nodes;
     if (nodes.ContainsKey("inventory"))
     {
         Node inventory = nodes["inventory"];
         //For each item in inventory
         foreach (KeyValuePair<string, Node> item in inventory.Nodes)
         {
             IInventoryItem inventoryItem = new InventoryItem(item.Key);
             int amount = int.Parse(item.Value.Nodes["amount"].Value);
             //For each data entry in item
             foreach (KeyValuePair<string, Node> data in item.Value.Nodes)
             {
                 if (data.Key.Equals("amount"))
                     continue;
                 inventoryItem.SetData(data.Key, data.Value.Value);
             }
             AddItem(inventoryItem, amount);
         }
     }
 }
예제 #3
0
 public bool Equals(InventoryItem item)
 {
     return item.Name == Name;
 }
예제 #4
0
 public InventoryItem(InventoryItem item)
 {
     this.data = item.data;
     _name = item.Name;
 }
예제 #5
0
 public bool Equals(InventoryItem item)
 {
     return(item.Name == Name);
 }
예제 #6
0
 public InventoryItem(InventoryItem item)
 {
     this.data = item.data;
     _name     = item.Name;
 }