Beispiel #1
0
        public static Gear CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode)
        {
            int   gearID;
            Match m = Regex.Match(node.Text, @"^(\d{8})\.img$");

            if (!(m.Success && Int32.TryParse(m.Result("$1"), out gearID)))
            {
                return(null);
            }
            Gear gear = new Gear();

            gear.ItemID = gearID;
            gear.type   = Gear.GetGearType(gear.ItemID);
            Wz_Node infoNode = node.FindNodeByPath("info");

            if (infoNode != null)
            {
                foreach (Wz_Node subNode in infoNode.Nodes)
                {
                    switch (subNode.Text)
                    {
                    case "icon":
                        if (subNode.Value is Wz_Png)
                        {
                            gear.Icon = BitmapOrigin.CreateFromNode(subNode, findNode);
                        }
                        break;

                    case "iconRaw":
                        if (subNode.Value is Wz_Png)
                        {
                            gear.IconRaw = BitmapOrigin.CreateFromNode(subNode, findNode);
                        }
                        break;

                    case "sample":
                        if (subNode.Value is Wz_Png)
                        {
                            gear.Sample = BitmapOrigin.CreateFromNode(subNode, findNode);
                        }
                        break;

                    case "addition":     //附加属性信息
                        foreach (Wz_Node addiNode in subNode.Nodes)
                        {
                            Addition addi = Addition.CreateFromNode(addiNode);
                            if (addi != null)
                            {
                                gear.Additions.Add(addi);
                            }
                        }
                        gear.Additions.Sort((add1, add2) => (int)add1.Type - (int)add2.Type);
                        break;

                    case "option":     //附加潜能信息
                        Wz_Node itemWz = findNode != null?findNode("Item\\ItemOption.img") : null;

                        if (itemWz == null)
                        {
                            break;
                        }
                        int optIdx = 0;
                        foreach (Wz_Node optNode in subNode.Nodes)
                        {
                            int optId = 0, optLevel = 0;
                            foreach (Wz_Node optArgNode in optNode.Nodes)
                            {
                                switch (optArgNode.Text)
                                {
                                case "option": optId = Convert.ToInt32(optArgNode.Value); break;

                                case "level": optLevel = Convert.ToInt32(optArgNode.Value); break;
                                }
                            }

                            Potential opt = Potential.CreateFromNode(itemWz.FindNodeByPath(optId.ToString("d6")), optLevel);
                            if (opt != null)
                            {
                                gear.Options[optIdx++] = opt;
                            }
                        }
                        break;

                    case "level":     //可升级信息
                        if (subNode.Nodes["fixLevel"].GetValueEx <int>(0) != 0)
                        {
                            gear.FixLevel = true;
                        }

                        Wz_Node levelInfo = subNode.Nodes["info"];
                        gear.Levels = new List <GearLevelInfo>();
                        if (levelInfo != null)
                        {
                            for (int i = 1; ; i++)
                            {
                                Wz_Node levelInfoNode = levelInfo.Nodes[i.ToString()];
                                if (levelInfoNode != null)
                                {
                                    GearLevelInfo info = GearLevelInfo.CreateFromNode(levelInfoNode);
                                    int           lv;
                                    Int32.TryParse(levelInfoNode.Text, out lv);
                                    info.Level = lv;
                                    gear.Levels.Add(info);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }

                        Wz_Node levelCase = subNode.Nodes["case"];
                        if (levelCase != null)
                        {
                            int probTotal = 0;
                            foreach (Wz_Node caseNode in levelCase.Nodes)
                            {
                                int prob = caseNode.Nodes["prob"].GetValueEx(0);
                                probTotal += prob;
                                for (int i = 0; i < gear.Levels.Count; i++)
                                {
                                    GearLevelInfo info      = gear.Levels[i];
                                    Wz_Node       caseLevel = caseNode.Nodes[info.Level.ToString()];
                                    if (caseLevel != null)
                                    {
                                        //desc
                                        Wz_Node caseHS = caseLevel.Nodes["hs"];
                                        if (caseHS != null)
                                        {
                                            info.HS = caseHS.GetValue <string>();
                                        }

                                        //随机技能
                                        Wz_Node caseSkill = caseLevel.Nodes["Skill"];
                                        if (caseSkill != null)
                                        {
                                            foreach (Wz_Node skillNode in caseSkill.Nodes)
                                            {
                                                int id    = skillNode.Nodes["id"].GetValueEx(-1);
                                                int level = skillNode.Nodes["level"].GetValueEx(-1);
                                                if (id >= 0 && level >= 0)
                                                {
                                                    info.Skills[id] = level;
                                                }
                                            }
                                        }

                                        //装备技能
                                        Wz_Node equipSkill = caseLevel.Nodes["EquipmentSkill"];
                                        if (equipSkill != null)
                                        {
                                            foreach (Wz_Node skillNode in equipSkill.Nodes)
                                            {
                                                int id    = skillNode.Nodes["id"].GetValueEx(-1);
                                                int level = skillNode.Nodes["level"].GetValueEx(-1);
                                                if (id >= 0 && level >= 0)
                                                {
                                                    info.EquipmentSkills[id] = level;
                                                }
                                            }
                                        }
                                        info.Prob = prob;
                                    }
                                }
                            }

                            foreach (var info in gear.Levels)
                            {
                                info.ProbTotal = probTotal;
                            }
                        }
                        gear.Props.Add(GearPropType.level, 1);
                        break;

                    case "sealed":     //封印解除信息
                        Wz_Node sealedInfo = subNode.Nodes["info"];
                        gear.Seals = new List <GearSealedInfo>();
                        if (sealedInfo != null)
                        {
                            foreach (Wz_Node levelInfoNode in sealedInfo.Nodes)
                            {
                                GearSealedInfo info = GearSealedInfo.CreateFromNode(levelInfoNode, findNode);
                                int            lv;
                                Int32.TryParse(levelInfoNode.Text, out lv);
                                info.Level = lv;
                                gear.Seals.Add(info);
                            }
                        }
                        gear.Props.Add(GearPropType.@sealed, 1);
                        break;

                    case "variableStat":     //升级奖励属性
                        foreach (Wz_Node statNode in subNode.Nodes)
                        {
                            GearPropType type;
                            if (Enum.TryParse(statNode.Text, out type))
                            {
                                try
                                {
                                    gear.VariableStat.Add(type, Convert.ToSingle(statNode.Value));
                                }
                                finally
                                {
                                }
                            }
                        }
                        break;

                    case "abilityTimeLimited":     //限时属性
                        foreach (Wz_Node statNode in subNode.Nodes)
                        {
                            GearPropType type;
                            if (Enum.TryParse(statNode.Text, out type))
                            {
                                try
                                {
                                    gear.AbilityTimeLimited.Add(type, Convert.ToInt32(statNode.Value));
                                }
                                finally
                                {
                                }
                            }
                        }
                        break;

                    default:
                    {
                        GearPropType type;
                        if (Enum.TryParse(subNode.Text, out type))
                        {
                            try
                            {
                                gear.Props.Add(type, Convert.ToInt32(subNode.Value));
                            }
                            finally
                            {
                            }
                        }
                    }
                    break;
                    }
                }
            }
            int value;

            //读取默认可升级状态
            if (gear.Props.TryGetValue(GearPropType.tuc, out value) && value > 0)
            {
                gear.HasTuc       = true;
                gear.CanPotential = true;
            }
            else if (Gear.SpecialCanPotential(gear.type))
            {
                gear.CanPotential = true;
            }

            //读取默认gearGrade
            if (gear.Props.TryGetValue(GearPropType.fixedGrade, out value))
            {
                gear.Grade = (GearGrade)(value - 1);
            }

            //添加默认装备要求
            GearPropType[] types = new GearPropType[] {
                GearPropType.reqJob, GearPropType.reqLevel, GearPropType.reqSTR, GearPropType.reqDEX,
                GearPropType.reqINT, GearPropType.reqLUK
            };
            foreach (GearPropType type in types)
            {
                if (!gear.Props.ContainsKey(type))
                {
                    gear.Props.Add(type, 0);
                }
            }

            //修复恶魔盾牌特殊属性
            if (gear.type == GearType.demonShield)
            {
                if (gear.Props.TryGetValue(GearPropType.incMMP, out value))
                {
                    gear.Props.Remove(GearPropType.incMMP);
                    gear.Props.Add(GearPropType.incMDF, value);
                }
            }

            //备份标准属性
            gear.StandardProps = new Dictionary <GearPropType, int>(gear.Props);

            //追加限时属性
            gear.MakeTimeLimitedPropAvailable();

            return(gear);
        }
Beispiel #2
0
        public static SetItem CreateFromNode(Wz_Node setItemNode, Wz_Node optionNode)
        {
            if (setItemNode == null)
            {
                return(null);
            }

            SetItem setItem = new SetItem();
            int     setItemID;

            if (int.TryParse(setItemNode.Text, out setItemID))
            {
                setItem.SetItemID = setItemID;
            }

            Dictionary <string, string> desc = new Dictionary <string, string>();

            foreach (Wz_Node subNode in setItemNode.Nodes)
            {
                switch (subNode.Text)
                {
                case "setItemName":
                    setItem.SetItemName = Convert.ToString(subNode.Value);
                    break;

                case "completeCount":
                    setItem.CompleteCount = Convert.ToInt32(subNode.Value);
                    break;

                case "parts":
                    setItem.Parts = subNode.GetValue <int>() != 0;
                    break;

                case "expandToolTip":
                    setItem.ExpandToolTip = subNode.GetValue <int>() != 0;
                    break;

                case "ItemID":
                    foreach (Wz_Node itemNode in subNode.Nodes)
                    {
                        int idx = Convert.ToInt32(itemNode.Text);
                        if (itemNode.Nodes.Count == 0)
                        {
                            int itemID = Convert.ToInt32(itemNode.Value);
                            setItem.ItemIDs.Add(idx, new SetItemIDPart(itemID));
                        }
                        else
                        {
                            SetItemIDPart part = new SetItemIDPart();
                            int           num;
                            foreach (Wz_Node itemNode2 in itemNode.Nodes)
                            {
                                switch (itemNode2.Text)
                                {
                                case "representName":
                                    part.RepresentName = Convert.ToString(itemNode2.Value);
                                    break;

                                case "typeName":
                                    part.TypeName = Convert.ToString(itemNode2.Value);
                                    break;

                                default:
                                    if (Int32.TryParse(itemNode2.Text, out num) && num > 0)
                                    {
                                        part.ItemIDs[Convert.ToInt32(itemNode2.Value)] = false;
                                    }
                                    break;
                                }
                            }
                            setItem.ItemIDs.Add(idx, part);
                        }
                    }
                    break;

                case "Effect":
                    foreach (Wz_Node effectNode in subNode.Nodes)
                    {
                        int           count  = Convert.ToInt32(effectNode.Text);
                        SetItemEffect effect = new SetItemEffect();
                        foreach (Wz_Node propNode in effectNode.Nodes)
                        {
                            switch (propNode.Text)
                            {
                            case "Option":
                                if (optionNode != null)
                                {
                                    List <Potential> potens = new List <Potential>();
                                    foreach (Wz_Node pNode in propNode.Nodes)
                                    {
                                        string  optText = Convert.ToString(pNode.FindNodeByPath("option").Value).PadLeft(6, '0');
                                        Wz_Node opn     = optionNode.FindNodeByPath(optText);
                                        if (opn == null)
                                        {
                                            continue;
                                        }
                                        Potential p = Potential.CreateFromNode(opn, Convert.ToInt32(pNode.FindNodeByPath("level").Value));
                                        if (p != null)
                                        {
                                            potens.Add(p);
                                        }
                                    }
                                    effect.Props.Add(GearPropType.Option, potens);
                                }
                                break;

                            case "OptionToMob":
                                List <SetItemOptionToMob> opToMobList = new List <SetItemOptionToMob>();
                                for (int i = 1; ; i++)
                                {
                                    Wz_Node optNode = propNode.FindNodeByPath(i.ToString());
                                    if (optNode == null)
                                    {
                                        break;
                                    }

                                    SetItemOptionToMob option = new SetItemOptionToMob();

                                    foreach (Wz_Node pNode in optNode.Nodes)
                                    {
                                        switch (pNode.Text)
                                        {
                                        case "mob":
                                            foreach (Wz_Node mobNode in pNode.Nodes)
                                            {
                                                option.Mobs.Add(mobNode.GetValue <int>());
                                            }
                                            break;

                                        case "mobName":
                                            option.MobName = pNode.GetValue <string>();
                                            break;

                                        default:
                                        {
                                            GearPropType type;
                                            if (Enum.TryParse(pNode.Text, out type))
                                            {
                                                option.Props.Add(type, pNode.GetValue <int>());
                                            }
                                        }
                                        break;
                                        }
                                    }

                                    opToMobList.Add(option);
                                }
                                effect.Props.Add(GearPropType.OptionToMob, opToMobList);
                                break;

                            case "activeSkill":
                                List <SetItemActiveSkill> activeSkillList = new List <SetItemActiveSkill>();
                                for (int i = 0; ; i++)
                                {
                                    Wz_Node optNode = propNode.FindNodeByPath(i.ToString());
                                    if (optNode == null)
                                    {
                                        break;
                                    }

                                    SetItemActiveSkill activeSkill = new SetItemActiveSkill();
                                    foreach (Wz_Node pNode in optNode.Nodes)
                                    {
                                        switch (pNode.Text)
                                        {
                                        case "id":
                                            activeSkill.SkillID = pNode.GetValue <int>();
                                            break;

                                        case "level":
                                            activeSkill.Level = pNode.GetValue <int>();
                                            break;
                                        }
                                    }
                                    activeSkillList.Add(activeSkill);
                                }
                                effect.Props.Add(GearPropType.activeSkill, activeSkillList);
                                break;

                            case "bonusByTime":
                                var bonusByTimeList = new List <SetItemBonusByTime>();
                                for (int i = 0; ; i++)
                                {
                                    Wz_Node optNode = propNode.FindNodeByPath(i.ToString());
                                    if (optNode == null)
                                    {
                                        break;
                                    }

                                    var bonusByTime = new SetItemBonusByTime();
                                    foreach (Wz_Node pNode in optNode.Nodes)
                                    {
                                        switch (pNode.Text)
                                        {
                                        case "termStart":
                                            bonusByTime.TermStart = pNode.GetValue <int>();
                                            break;

                                        default:
                                        {
                                            GearPropType type;
                                            if (Enum.TryParse(pNode.Text, out type))
                                            {
                                                bonusByTime.Props.Add(type, pNode.GetValue <int>());
                                            }
                                        }
                                        break;
                                        }
                                    }
                                    bonusByTimeList.Add(bonusByTime);
                                }
                                effect.Props.Add(GearPropType.bonusByTime, bonusByTimeList);
                                break;

                            default:
                            {
                                GearPropType type;
                                if (Enum.TryParse(propNode.Text, out type))
                                {
                                    effect.Props.Add(type, Convert.ToInt32(propNode.Value));
                                }
                            }
                            break;
                            }
                        }
                        setItem.Effects.Add(count, effect);
                    }
                    break;

                case "Desc":
                    foreach (var descNode in subNode.Nodes)
                    {
                        desc[descNode.Text] = Convert.ToString(descNode.Value);
                    }
                    break;
                }
            }

            //处理额外分组
            if (desc.Count > 0)
            {
                foreach (var kv in desc)
                {
                    SetItemIDPart combinePart     = null;
                    string        combineTypeName = null;
                    switch (kv.Key)
                    {
                    case "weapon":
                        combinePart     = CombinePart(setItem, gearID => Gear.IsWeapon(Gear.GetGearType(gearID)));
                        combineTypeName = ItemStringHelper.GetSetItemGearTypeString(GearType.weapon);
                        break;

                    case "subweapon":
                        combinePart     = CombinePart(setItem, gearID => Gear.IsSubWeapon(Gear.GetGearType(gearID)));
                        combineTypeName = ItemStringHelper.GetSetItemGearTypeString(GearType.subWeapon);
                        break;

                    case "pocket":
                        combinePart     = CombinePart(setItem, gearID => Gear.GetGearType(gearID) == GearType.pocket);
                        combineTypeName = ItemStringHelper.GetSetItemGearTypeString(GearType.pocket);
                        break;
                    }

                    if (combinePart != null)
                    {
                        combinePart.RepresentName = kv.Value;
                        combinePart.TypeName      = combineTypeName; ItemStringHelper.GetSetItemGearTypeString(GearType.weapon);
                    }
                }
            }


            return(setItem);
        }