Exemplo n.º 1
0
        public static object GetImgPropVal(this WzProperty prop, Type type, string attributeName)
        {
            var tc = Type.GetTypeCode(type);

            switch (tc)
            {
            case TypeCode.Boolean:
                return(prop.GetInt32(attributeName) != 0);

            case TypeCode.Byte:
                return(prop.GetInt8(attributeName));

            case TypeCode.Int16:
                return(prop.GetInt16(attributeName));

            case TypeCode.Int32:
                if (prop.GetAllChildren().Count > 0)
                {
                    return(0);
                }

                return(prop.GetInt32(attributeName));

            case TypeCode.Int64:
                return(prop.GetInt64(attributeName));

            case TypeCode.String:
                return(prop.GetString(attributeName));

            case TypeCode.Object:
                switch (type.Name)
                {
                case "Point":
                {
                    if (prop[attributeName] is WzVector2D vector)
                    {
                        return(new Point(vector.X, vector.Y));
                    }
                    else
                    {
                        return(new Point());
                    }
                }
                }
                break;

            case TypeCode.Double:
                return(Convert.ToDouble(prop.Get(attributeName)));
            }

            throw new InvalidOperationException();
        }
Exemplo n.º 2
0
        private static QuestDemand RegisterQuestDemand(WzProperty baseNode)
        {
            if (baseNode.GetAllChildren().Count <= 0)
            {
                return(null);
            }

            var demands = new QuestDemand
            {
                LevelMax          = baseNode.GetInt32("lvmax"),
                LevelMin          = baseNode.GetInt32("lvmin"),
                TamingMobLevelMax = baseNode.GetInt32("pettamenessmax"),
                TamingMobLevelMin = baseNode.GetInt32("pettamenessmin"),
                PetTamenessMax    = baseNode.GetInt32("tamingmoblevelmin"),
                PetTamenessMin    = baseNode.GetInt32("tamingmoblevelmax"),
                Pop             = baseNode.GetInt32("pop"),
                RepeatByDay     = baseNode.GetInt32("dayByDay") != 0,
                SubJobFlags     = baseNode.GetInt32("subJobFlags"),
                NormalAutoStart = baseNode.GetInt32("normalAutoStart") > 0,
            };

            if (baseNode["mob"] is WzProperty mobNode)
            {
                demands.DemandMob = mobNode.GetAllChildren()
                                    .Values
                                    .Cast <WzProperty>()
                                    .Select(item =>
                                            new MobInfo
                {
                    MobID = item.GetInt32("id"),
                    Count = item.GetInt32("count")
                })
                                    .ToArray();
            }

            if (baseNode["quest"] is WzProperty questNode)
            {
                demands.DemandQuest = questNode.GetAllChildren()
                                      .Values
                                      .Cast <WzProperty>()
                                      .Select(item =>
                                              new QuestDemand.QuestRecord
                {
                    QuestID = item.GetInt16("id"),
                    State   = item.GetInt32("state")
                })
                                      .ToArray();
            }

            if (baseNode["item"] is WzProperty itemNode)
            {
                demands.DemandItem = itemNode.GetAllChildren()
                                     .Values
                                     .Cast <WzProperty>()
                                     .Select(item =>
                                             new ItemInfo
                {
                    ItemID = item.GetInt32("id"),
                    Count  = item.GetInt32("count")
                })
                                     .ToArray();
            }

            if (baseNode["skill"] is WzProperty skillNode)
            {
                demands.DemandSkill = skillNode.GetAllChildren()
                                      .Values
                                      .Cast <WzProperty>()
                                      .Select(item =>
                                              new SkillInfo
                {
                    SkillID = item.GetInt32("id"),
                    Acquire = item.GetInt32("acquire")
                })
                                      .ToArray();
            }

            if (baseNode["equipSelectNeed"] is WzProperty equipSelectNode)
            {
                demands.EquipSelectNeed = equipSelectNode.GetAllChildren().Values.Cast <int>().ToArray();
            }

            if (baseNode["equipAllNeed"] is WzProperty equipNode)
            {
                demands.EquipAllNeed = equipNode.GetAllChildren().Values.Cast <int>().ToArray();
            }

            if (baseNode["job"] is WzProperty jobNode)
            {
                demands.Job = jobNode.GetAllChildren().Values.Cast <int>().ToArray();
            }

            if (baseNode["fieldEnter"] is WzProperty fieldNode)
            {
                demands.FieldEnter = fieldNode.GetAllChildren().Values.Cast <int>().ToArray();
            }

            return(demands);
        }
Exemplo n.º 3
0
        private static QuestAct RegisterQuestAct(WzProperty baseNode)
        {
            if (baseNode.GetAllChildren().Count <= 0)
            {
                return(null);
            }

            var rewards = new QuestAct
            {
                IncExp         = baseNode.GetInt32("exp"),
                IncMoney       = baseNode.GetInt32("money"),
                IncPop         = baseNode.GetInt32("pop"),
                IncPetTameness = baseNode.GetInt32("pettameness"),
                IncPetSpeed    = baseNode.GetInt32("petspeed"),
                PetSkill       = baseNode.GetInt32("petskill"),
                NextQuest      = baseNode.GetInt32("nextQuest"),
                BuffItemID     = baseNode.GetInt32("buffItemID"),
                LevelMin       = baseNode.GetInt32("lvmin"),
                LevelMax       = baseNode.GetInt32("lvmax"),
                Info           = baseNode.GetString("info")
            };

            if (baseNode["item"] is WzProperty itemRewards)
            {
                rewards.Items = itemRewards.GetAllChildren()
                                .Values
                                .Cast <WzProperty>()
                                .Select(item =>
                                        new QuestAct.ActItem
                {
                    Item = new ItemInfo
                    {
                        ItemID = item.GetInt32("id"),
                        Count  = item.GetInt32("count"),
                    },
                    Period        = item.GetInt32("period"),
                    JobFlag       = item.GetInt32("job"),
                    Gender        = item.GetInt32("gender"),
                    ProbRate      = item.GetInt32("prop"),
                    ItemVariation = item.GetInt32("var"),
                })
                                .ToArray();
            }

            if (baseNode["skill"] is WzProperty skillRewards)
            {
                rewards.Skills = skillRewards.GetAllChildren()
                                 .Values
                                 .Cast <WzProperty>()
                                 .Select(item =>
                                         new QuestAct.ActSkill
                {
                    SkillID     = item.GetInt32("id"),
                    MasterLevel = item.GetInt32("masterLevel"),
                    SkillLevel  = item.GetInt32("skillLevel") != 0
                                                                ? item.GetInt32("skillLevel")
                                                                : item.GetInt32("acquire"),
                    Job = (item["job"] as WzProperty)?.GetAllChildren().Values.Cast <int>()
                          .ToArray() ?? new int[0]
                })
                                 .ToArray();
            }

            return(rewards);
        }