Esempio n. 1
0
 public bool Mine(int handId, WorldPos pos, Block block)
 {
     if (needCheckMinePower)
     {
         if (sceneBlock == null || sceneBlock.blockType != (byte)block.BlockType || sceneBlock.extendId != block.ExtendId ||
             !sceneBlock.pos.EqualOther(pos))
         {
             sceneBlock = new SceneBlock(pos, (byte)block.BlockType, block.ExtendId);
         }
         Item item = ItemManager.Instance.GetItem(handId);
         if (item != null)
         {
             SpecialIDMinePower iDPower = sceneBlock.blockData.GetSpecialIDMinePower(item.id);
             if (iDPower != null)
             {
                 return(MineSceneBlock(pos, iDPower.power));
             }
             SpecialTypeMinePower typePower = sceneBlock.blockData.GetSpecialTypeMinePower(item.type);
             if (typePower != null)
             {
                 return(MineSceneBlock(pos, typePower.power));
             }
         }
         return(MineSceneBlock(pos, sceneBlock.blockData.normalMinePower));
     }
     else
     {
         return(true);
     }
 }
Esempio n. 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);
            }
        }