public void Drop(int handId, WorldPos pos, Block block)
 {
     if (needCheckDrop)
     {
         BlockData blockData = BlockDataManager.Instance.GetBlockData((byte)block.BlockType, block.ExtendId);
         if (blockData == null)
         {
             return;
         }
         Item item = ItemManager.Instance.GetItem(handId);
         if (item != null)
         {
             SpecialIDProduction idProduction = blockData.GetSpecialIdProduction(item.id);
             if (idProduction != null)
             {
                 DropItemObj(pos, idProduction.itemId, idProduction.num);
             }
             SpecialTypeProduction typeProduction = blockData.GetSpecialTypeProduction(item.type);
             if (typeProduction != null)
             {
                 DropItemObj(pos, typeProduction.itemId, typeProduction.num);
             }
         }
         List <NormalProduction> productions = blockData.normalProductions;
         for (int i = 0; i < productions.Count; i++)
         {
             DropItemObj(pos, productions[i].itemId, productions[i].num);
         }
     }
 }
Exemple #2
0
        public BlockData(XmlElement element)
        {
            string idStr = element.GetElementsByTagName("id")[0].InnerText;

            string[] idStrArr = idStr.Split('-');
            type = Convert.ToByte(idStrArr[0]);
            if (idStrArr.Length > 1)
            {
                extendId = Convert.ToByte(idStrArr[1]);
            }
            else
            {
                extendId = 0;
            }
            id   = GetBlockId(type, extendId);
            name = element.GetElementsByTagName("name")[0].InnerText;

            string normalProductionStr = element.GetElementsByTagName("normalProduction")[0].InnerText;

            string[] normalProductionStrArr = normalProductionStr.Split(splits, StringSplitOptions.RemoveEmptyEntries);
            normalProductions = new List <NormalProduction>();
            for (int i = 0; i < normalProductionStrArr.Length; i++)
            {
                normalProductions.Add(new NormalProduction(normalProductionStrArr[i]));
            }

            string specialTypeProductionStr = element.GetElementsByTagName("specialTypeProduction")[0].InnerText;

            string[] specialTypeProductionStrArr = specialTypeProductionStr.Split(splits, StringSplitOptions.RemoveEmptyEntries);
            specialTypeProductions   = new List <SpecialTypeProduction>();
            specialTypeProductionMAP = new Dictionary <int, SpecialTypeProduction>();
            for (int i = 0; i < specialTypeProductionStrArr.Length; i++)
            {
                SpecialTypeProduction production = new SpecialTypeProduction(specialTypeProductionStrArr[i]);
                specialTypeProductions.Add(production);
                specialTypeProductionMAP.Add(production.type, production);
            }

            string specialIDProductionStr = element.GetElementsByTagName("specialIDProduction")[0].InnerText;

            string[] specialIDProductionStrArr = specialIDProductionStr.Split(splits, StringSplitOptions.RemoveEmptyEntries);
            specialIDProductions   = new List <SpecialIDProduction>();
            specialIDProductionMap = new Dictionary <int, SpecialIDProduction>();
            for (int i = 0; i < specialIDProductionStrArr.Length; i++)
            {
                SpecialIDProduction production = new SpecialIDProduction(specialIDProductionStrArr[i]);
                specialIDProductions.Add(production);
                specialIDProductionMap.Add(production.usedItemId, production);
            }

            hardness        = Convert.ToInt32(element.GetElementsByTagName("hardness")[0].InnerText);
            normalMinePower = Convert.ToInt32(element.GetElementsByTagName("normalMinePower")[0].InnerText);

            string specialTypeMinePowerStr = element.GetElementsByTagName("specialTypeMinePower")[0].InnerText;

            string[] specialTypeMinePowerStrArr = specialTypeMinePowerStr.Split(splits, StringSplitOptions.RemoveEmptyEntries);
            specialTypeMinePowers   = new List <SpecialTypeMinePower>();
            specialTypeMinePowerMap = new Dictionary <int, SpecialTypeMinePower>();
            for (int i = 0; i < specialTypeMinePowerStrArr.Length; i++)
            {
                SpecialTypeMinePower minePower = new SpecialTypeMinePower(specialTypeMinePowerStrArr[i]);
                specialTypeMinePowers.Add(minePower);
                specialTypeMinePowerMap.Add(minePower.type, minePower);
            }

            string specialIDMinePowerStr = element.GetElementsByTagName("specialIDMinePower")[0].InnerText;

            string[] specialIDMinePowerStrArr = specialIDMinePowerStr.Split(splits, StringSplitOptions.RemoveEmptyEntries);
            specialIDMinePowers   = new List <SpecialIDMinePower>();
            specialIDMinePowerMap = new Dictionary <int, SpecialIDMinePower>();
            for (int i = 0; i < specialIDMinePowerStrArr.Length; i++)
            {
                SpecialIDMinePower minePower = new SpecialIDMinePower(specialIDMinePowerStrArr[i]);
                specialIDMinePowers.Add(minePower);
                specialIDMinePowerMap.Add(minePower.itemId, minePower);
            }
        }