예제 #1
0
        public static Gif CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode)
        {
            if (node == null)
            {
                return(null);
            }
            Gif gif = new Gif();

            for (int i = 0; ; i++)
            {
                Wz_Node frameNode = node.FindNodeByPath(i.ToString());

                if (frameNode == null || frameNode.Value == null)
                {
                    break;
                }
                GifFrame gifFrame = CreateFrameFromNode(frameNode, findNode);

                if (gifFrame == null)
                {
                    break;
                }
                gif.Frames.Add(gifFrame);
            }
            if (gif.Frames.Count > 0)
            {
                return(gif);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public static Potential LoadFromWz(int optID, int optLevel, GlobalFindNodeFunction findNode)
        {
            Wz_Node itemWz = findNode("Item\\ItemOption.img");

            if (itemWz == null)
            {
                return(null);
            }

            Potential opt = Potential.CreateFromNode(itemWz.FindNodeByPath(optID.ToString("d6")), optLevel);

            return(opt);
        }
예제 #3
0
        public static GifFrame CreateFrameFromNode(Wz_Node frameNode, GlobalFindNodeFunction findNode)
        {
            if (frameNode == null || frameNode.Value == null)
            {
                return(null);
            }

            while (frameNode.Value is Wz_Uol)
            {
                Wz_Uol  uol     = frameNode.Value as Wz_Uol;
                Wz_Node uolNode = uol.HandleUol(frameNode);
                if (uolNode != null)
                {
                    frameNode = uolNode;
                }
            }
            if (frameNode.Value is Wz_Png)
            {
                var    linkNode = frameNode.GetLinkedSourceNode(findNode);
                Wz_Png png      = linkNode?.GetValue <Wz_Png>() ?? (Wz_Png)frameNode.Value;

                var gifFrame = new GifFrame(png.ExtractPng());
                foreach (Wz_Node propNode in frameNode.Nodes)
                {
                    switch (propNode.Text)
                    {
                    case "origin":
                        gifFrame.Origin = (propNode.Value as Wz_Vector);
                        break;

                    case "delay":
                        gifFrame.Delay = propNode.GetValue <int>();
                        break;

                    case "a0":
                        gifFrame.A0 = propNode.GetValue <int>();
                        break;

                    case "a1":
                        gifFrame.A1 = propNode.GetValue <int>();
                        break;
                    }
                }
                if (gifFrame.Delay == 0)
                {
                    gifFrame.Delay = 100;//给予默认delay
                }
                return(gifFrame);
            }
            return(null);
        }
예제 #4
0
        public static Wz_Node GetLinkedSourceNode(this Wz_Node node, GlobalFindNodeFunction findNode)
        {
            string path;

            if (!string.IsNullOrEmpty(path = node.Nodes["source"].GetValueEx <string>(null)))
            {
                return(findNode?.Invoke(path));
            }
            else if (!string.IsNullOrEmpty(path = node.Nodes["_inlink"].GetValueEx <string>(null)))
            {
                var img = node.GetNodeWzImage();
                return(img?.Node.FindNodeByPath(true, path.Split('/')));
            }
            else if (!string.IsNullOrEmpty(path = node.Nodes["_outlink"].GetValueEx <string>(null)))
            {
                return(findNode?.Invoke(path));
            }
            else
            {
                return(node);
            }
        }
예제 #5
0
        public static BitmapOrigin CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode)
        {
            BitmapOrigin bp = new BitmapOrigin();
            Wz_Uol       uol;

            while ((uol = node.GetValue <Wz_Uol>(null)) != null)
            {
                node = uol.HandleUol(node);
            }

            //获取linkNode
            var    linkNode = node.GetLinkedSourceNode(findNode);
            Wz_Png png      = linkNode?.GetValue <Wz_Png>() ?? (Wz_Png)node.Value;

            bp.Bitmap = png?.ExtractPng();
            Wz_Node   originNode = node.FindNodeByPath("origin");
            Wz_Vector vec        = (originNode == null) ? null : originNode.GetValue <Wz_Vector>();

            bp.Origin = (vec == null) ? new Point() : new Point(vec.X, vec.Y);

            return(bp);
        }
예제 #6
0
        public static GearSealedInfo CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode)
        {
            GearSealedInfo info = new GearSealedInfo();

            foreach (Wz_Node child in node.Nodes)
            {
                switch (child.Text)
                {
                case "exp":
                    info.Exp = child.GetValue(0);
                    break;

                case "icon":
                    info.Icon    = BitmapOrigin.CreateFromNode(child, findNode);
                    info.HasIcon = true;
                    break;

                case "iconRaw":
                    info.IconRaw = BitmapOrigin.CreateFromNode(child, findNode);
                    info.HasIcon = true;
                    break;

                default:
                    try
                    {
                        GearPropType propType = (GearPropType)Enum.Parse(typeof(GearPropType), child.Text, true);
                        info.BonusProps[propType] = child.GetValue(0);
                    }
                    finally
                    {
                    }
                    break;
                }
            }
            return(info);
        }
예제 #7
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 (!int.TryParse(subNode.Text, out _) && 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);
            }

            //自动填充Grade
            if (gear.Options.Any(opt => opt != null) && gear.Grade == GearGrade.C)
            {
                gear.Grade = GearGrade.B;
            }

            //添加默认装备要求
            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);
        }
예제 #8
0
        public static Frame CreateFromNode(Wz_Node frameNode, GraphicsDevice graphicsDevice, GlobalFindNodeFunction findNode)
        {
            if (frameNode == null || frameNode.Value == null)
            {
                return(null);
            }

            while (frameNode.Value is Wz_Uol)
            {
                Wz_Uol  uol     = frameNode.Value as Wz_Uol;
                Wz_Node uolNode = uol.HandleUol(frameNode);
                if (uolNode != null)
                {
                    frameNode = uolNode;
                }
            }
            if (frameNode.Value is Wz_Png)
            {
                var    linkNode = frameNode.GetLinkedSourceNode(findNode);
                Wz_Png png      = linkNode?.GetValue <Wz_Png>() ?? (Wz_Png)frameNode.Value;

                var frame = new Frame(png.ToTexture(graphicsDevice))
                {
                    Png = png,
                };

                foreach (Wz_Node propNode in frameNode.Nodes)
                {
                    switch (propNode.Text)
                    {
                    case "origin":
                        frame.Origin = (propNode.Value as Wz_Vector).ToPoint();
                        break;

                    case "delay":
                        frame.Delay = propNode.GetValue <int>();
                        break;

                    case "z":
                        frame.Z = propNode.GetValue <int>();
                        break;

                    case "a0":
                        frame.A0 = propNode.GetValue <int>();
                        break;

                    case "a1":
                        frame.A1 = propNode.GetValue <int>();
                        break;
                    }
                }

                if (frame.Delay == 0)
                {
                    frame.Delay = 100;//给予默认delay
                }
                return(frame);
            }
            return(null);
        }
        public static SpineAnimationData CreateFromNode(Wz_Node atlasNode, bool?useJson, GraphicsDevice graphicsDevice, GlobalFindNodeFunction findNode)
        {
            var textureLoader = new WzSpineTextureLoader(atlasNode.ParentNode, graphicsDevice, findNode);

            return(CreateFromNode(atlasNode, useJson, textureLoader));
        }
예제 #10
0
        public static Item CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode)
        {
            Item item = new Item();
            int  value;

            if (node == null ||
                !Int32.TryParse(node.Text, out value) &&
                !((value = node.Text.IndexOf(".img")) > -1 && Int32.TryParse(node.Text.Substring(0, value), out value)))
            {
                return(null);
            }
            item.ItemID = value;

            Wz_Node infoNode = node.FindNodeByPath("info");

            if (infoNode != null)
            {
                Wz_Node pngNode;
                foreach (Wz_Node subNode in infoNode.Nodes)
                {
                    switch (subNode.Text)
                    {
                    case "icon":
                        pngNode = subNode;
                        while (pngNode.Value is Wz_Uol)
                        {
                            Wz_Uol  uol     = pngNode.Value as Wz_Uol;
                            Wz_Node uolNode = uol.HandleUol(subNode);
                            if (uolNode != null)
                            {
                                pngNode = uolNode;
                            }
                        }
                        if (pngNode.Value is Wz_Png)
                        {
                            item.Icon = BitmapOrigin.CreateFromNode(pngNode, findNode);
                        }
                        break;

                    case "iconRaw":
                        pngNode = subNode;
                        while (pngNode.Value is Wz_Uol)
                        {
                            Wz_Uol  uol     = pngNode.Value as Wz_Uol;
                            Wz_Node uolNode = uol.HandleUol(subNode);
                            if (uolNode != null)
                            {
                                pngNode = uolNode;
                            }
                        }
                        if (pngNode.Value is Wz_Png)
                        {
                            item.IconRaw = BitmapOrigin.CreateFromNode(pngNode, findNode);
                        }
                        break;

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

                    case "lv":
                        item.Level = Convert.ToInt32(subNode.Value);
                        break;

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

            Wz_Node specNode = node.FindNodeByPath("spec");

            if (specNode != null)
            {
                foreach (Wz_Node subNode in specNode.Nodes)
                {
                    ItemSpecType type;
                    if (Enum.TryParse(subNode.Text, out type))
                    {
                        try
                        {
                            item.Specs.Add(type, Convert.ToInt32(subNode.Value));
                        }
                        finally
                        {
                        }
                    }
                }
            }
            return(item);
        }
 public WzSpineTextureLoader(Wz_Node topNode, GraphicsDevice graphicsDevice, GlobalFindNodeFunction findNodeFunc)
 {
     this.TopNode          = topNode;
     this.GraphicsDevice   = graphicsDevice;
     this.FindNodeFunction = findNodeFunc;
 }
예제 #12
0
        public static Skill CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode)
        {
            Skill skill = new Skill();
            int   skillID;

            if (!Int32.TryParse(node.Text, out skillID))
            {
                return(null);
            }
            skill.SkillID = skillID;

            foreach (Wz_Node childNode in node.Nodes)
            {
                switch (childNode.Text)
                {
                case "icon":
                    skill.Icon = BitmapOrigin.CreateFromNode(childNode, findNode);
                    break;

                case "iconMouseOver":
                    skill.IconMouseOver = BitmapOrigin.CreateFromNode(childNode, findNode);
                    break;

                case "iconDisabled":
                    skill.IconDisabled = BitmapOrigin.CreateFromNode(childNode, findNode);
                    break;

                case "common":
                    foreach (Wz_Node commonNode in childNode.Nodes)
                    {
                        if (commonNode.Value != null && !(commonNode.Value is Wz_Vector))
                        {
                            skill.common[commonNode.Text] = commonNode.Value.ToString();
                        }
                    }
                    break;

                case "PVPcommon":
                    foreach (Wz_Node commonNode in childNode.Nodes)
                    {
                        if (commonNode.Value != null && !(commonNode.Value is Wz_Vector))
                        {
                            skill.PVPcommon[commonNode.Text] = commonNode.Value.ToString();
                        }
                    }
                    break;

                case "level":
                    for (int i = 1; ; i++)
                    {
                        Wz_Node levelNode = childNode.FindNodeByPath(i.ToString());
                        if (levelNode == null)
                        {
                            break;
                        }
                        Dictionary <string, string> levelInfo = new Dictionary <string, string>();

                        foreach (Wz_Node commonNode in levelNode.Nodes)
                        {
                            if (commonNode.Value != null && !(commonNode.Value is Wz_Vector))
                            {
                                levelInfo[commonNode.Text] = commonNode.Value.ToString();
                            }
                        }

                        skill.levelCommon.Add(levelInfo);
                    }
                    break;

                case "hyper":
                    skill.Hyper = (HyperSkillType)childNode.GetValue <int>();
                    break;

                case "invisible":
                    skill.Invisible = childNode.GetValue <int>() != 0;
                    break;

                case "combatOrders":
                    skill.CombatOrders = childNode.GetValue <int>() != 0;
                    break;

                case "notRemoved":
                    skill.NotRemoved = childNode.GetValue <int>() != 0;
                    break;

                case "masterLevel":
                    skill.MasterLevel = childNode.GetValue <int>();
                    break;

                case "reqLev":
                    skill.ReqLevel = childNode.GetValue <int>();
                    break;

                case "req":
                    foreach (Wz_Node reqNode in childNode.Nodes)
                    {
                        if (reqNode.Text == "level")
                        {
                            skill.ReqLevel = reqNode.GetValue <int>();
                        }
                        else if (reqNode.Text == "reqAmount")
                        {
                            skill.ReqAmount = reqNode.GetValue <int>();
                        }
                        else
                        {
                            int reqSkill;
                            if (Int32.TryParse(reqNode.Text, out reqSkill))
                            {
                                skill.ReqSkill[reqSkill] = reqNode.GetValue <int>();
                            }
                        }
                    }
                    break;

                case "action":
                    for (int i = 0; ; i++)
                    {
                        Wz_Node idxNode = childNode.FindNodeByPath(i.ToString());
                        if (idxNode == null)
                        {
                            break;
                        }
                        skill.Action.Add(idxNode.GetValue <string>());
                    }
                    break;
                }
            }

            //判定技能声明版本
            skill.PreBBSkill = false;
            if (skill.levelCommon.Count > 0)
            {
                if (skill.common.Count <= 0 ||
                    (skill.common.Count == 1 && skill.common.ContainsKey("maxLevel")))
                {
                    skill.PreBBSkill = true;
                }
            }

            return(skill);
        }
예제 #13
0
        public static FrameAnimationData CreateFromNode(Wz_Node node, GraphicsDevice graphicsDevice, GlobalFindNodeFunction findNode)
        {
            if (node == null)
            {
                return(null);
            }
            var anime = new FrameAnimationData();

            for (int i = 0; ; i++)
            {
                Wz_Node frameNode = node.FindNodeByPath(i.ToString());

                if (frameNode == null || frameNode.Value == null)
                {
                    break;
                }
                Frame frame = Frame.CreateFromNode(frameNode, graphicsDevice, findNode);

                if (frame == null)
                {
                    break;
                }
                anime.Frames.Add(frame);
            }
            if (anime.Frames.Count > 0)
            {
                return(anime);
            }
            else
            {
                return(null);
            }
        }
예제 #14
0
        //public LifeAnimateCollection Animates { get; private set; }


        public static Mob CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode)
        {
            int   mobID;
            Match m = Regex.Match(node.Text, @"^(\d{7})\.img$");

            if (!(m.Success && Int32.TryParse(m.Result("$1"), out mobID)))
            {
                return(null);
            }

            Mob mobInfo = new Mob();

            mobInfo.ID = mobID;
            Wz_Node infoNode = node.FindNodeByPath("info");

            //加载基础属性
            if (infoNode != null)
            {
                foreach (var propNode in infoNode.Nodes)
                {
                    switch (propNode.Text)
                    {
                    case "level": mobInfo.Level = propNode.GetValueEx <int>(0); break;

                    case "defaultHP": mobInfo.DefaultHP = propNode.GetValueEx <string>(null); break;

                    case "defaultMP": mobInfo.DefaultMP = propNode.GetValueEx <string>(null); break;

                    case "finalmaxHP": mobInfo.FinalMaxHP = propNode.GetValueEx <string>(null); break;

                    case "finalmaxMP": mobInfo.FinalMaxMP = propNode.GetValueEx <string>(null); break;

                    case "maxHP": mobInfo.MaxHP = propNode.GetValueEx <long>(0); break;

                    case "maxMP": mobInfo.MaxMP = propNode.GetValueEx <long>(0); break;

                    case "hpRecovery": mobInfo.HPRecovery = propNode.GetValueEx <int>(0); break;

                    case "mpRecovery": mobInfo.MPRecovery = propNode.GetValueEx <int>(0); break;

                    case "speed": mobInfo.Speed = propNode.GetValueEx <int>(0); break;

                    case "flySpeed": mobInfo.FlySpeed = propNode.GetValueEx <int>(0); break;

                    case "PADamage": mobInfo.PADamage = propNode.GetValueEx <int>(0); break;

                    case "MADamage": mobInfo.MADamage = propNode.GetValueEx <int>(0); break;

                    case "PDRate": mobInfo.PDRate = propNode.GetValueEx <int>(0); break;

                    case "MDRate": mobInfo.MDRate = propNode.GetValueEx <int>(0); break;

                    case "acc": mobInfo.Acc = propNode.GetValueEx <int>(0); break;

                    case "eva": mobInfo.Eva = propNode.GetValueEx <int>(0); break;

                    case "pushed": mobInfo.Pushed = propNode.GetValueEx <int>(0); break;

                    case "exp": mobInfo.Exp = propNode.GetValueEx <int>(0); break;

                    case "boss": mobInfo.Boss = propNode.GetValueEx <int>(0) != 0; break;

                    case "undead": mobInfo.Undead = propNode.GetValueEx <int>(0) != 0; break;

                    case "firstAttack": mobInfo.FirstAttack = propNode.GetValueEx <int>(0) != 0; break;

                    case "bodyAttack": mobInfo.BodyAttack = propNode.GetValueEx <int>(0) != 0; break;

                    case "category": mobInfo.Category = propNode.GetValueEx <int>(0); break;

                    case "removeAfter": mobInfo.RemoveAfter = propNode.GetValueEx <int>(0); break;

                    case "damagedByMob": mobInfo.DamagedByMob = propNode.GetValueEx <int>(0) != 0; break;

                    case "invincible": mobInfo.Invincible = propNode.GetValueEx <int>(0) != 0; break;

                    case "notAttack": mobInfo.NotAttack = propNode.GetValueEx <int>(0) != 0; break;

                    case "fixedDamage": mobInfo.FixedDamage = propNode.GetValueEx <int>(0); break;

                    case "elemAttr": mobInfo.ElemAttr = new MobElemAttr(propNode.GetValueEx <string>(null)); break;

                    case "link": mobInfo.Link = propNode.GetValueEx <int>(0); break;

                    case "skeleton": mobInfo.Skeleton = propNode.GetValueEx <int>(0) != 0; break;

                    case "jsonLoad": mobInfo.JsonLoad = propNode.GetValueEx <int>(0) != 0; break;

                    //case "skill": LoadSkill(mobInfo, propNode); break;
                    //case "attack": LoadAttack(mobInfo, propNode); break;
                    //case "buff": LoadBuff(mobInfo, propNode); break;
                    case "revive":
                        for (int i = 0; ; i++)
                        {
                            var reviveNode = propNode.FindNodeByPath(i.ToString());
                            if (reviveNode == null)
                            {
                                break;
                            }
                            mobInfo.Revive.Add(reviveNode.GetValue <int>());
                        }
                        break;
                    }
                }
            }

            //读取怪物默认动作
            {
                Wz_Node linkNode = null;
                if (mobInfo.Link != null && findNode != null)
                {
                    linkNode = findNode(string.Format("Mob\\{0:d7}.img", mobInfo.Link));
                }
                if (linkNode == null)
                {
                    linkNode = node;
                }

                var imageFrame = new BitmapOrigin();

                foreach (var action in new[] { "stand", "move", "fly" })
                {
                    var actNode = linkNode.FindNodeByPath(action + @"\0");
                    if (actNode != null)
                    {
                        imageFrame = BitmapOrigin.CreateFromNode(actNode, findNode);
                        if (imageFrame.Bitmap != null)
                        {
                            break;
                        }
                    }
                }

                mobInfo.Default = imageFrame;
            }

            return(mobInfo);
        }
예제 #15
0
        //public LifeAnimateCollection Animates { get; private set; }

        public static Npc CreateFromNode(Wz_Node node, GlobalFindNodeFunction findNode)
        {
            int   npcID;
            Match m = Regex.Match(node.Text, @"^(\d{7})\.img$");

            if (!(m.Success && Int32.TryParse(m.Result("$1"), out npcID)))
            {
                return(null);
            }

            Npc npcInfo = new Npc();

            npcInfo.ID = npcID;
            Wz_Node infoNode = node.FindNodeByPath("info");

            //加载基础属性
            if (infoNode != null)
            {
                foreach (var propNode in infoNode.Nodes)
                {
                    switch (propNode.Text)
                    {
                    case "shop": npcInfo.Shop = propNode.GetValueEx <int>(0) != 0; break;

                    case "link": npcInfo.Link = propNode.GetValueEx <int>(0); break;

                    case "default": npcInfo.Default = BitmapOrigin.CreateFromNode(propNode, null); break;
                    }
                }
            }

            //读取默认图片
            if (npcInfo.Default.Bitmap == null)
            {
                Wz_Node linkNode = null;
                if (npcInfo.Link != null && findNode != null)
                {
                    linkNode = findNode(string.Format("Npc\\{0:d7}.img", npcInfo.Link));
                }
                if (linkNode == null)
                {
                    linkNode = node;
                }

                var imageFrame = new BitmapOrigin();

                foreach (var action in new[] { "stand", "move", "fly" })
                {
                    var actNode = linkNode.FindNodeByPath(action + @"\0");
                    if (actNode != null)
                    {
                        imageFrame = BitmapOrigin.CreateFromNode(actNode, findNode);
                        if (imageFrame.Bitmap != null)
                        {
                            break;
                        }
                    }
                }

                npcInfo.Default = imageFrame;
            }

            return(npcInfo);
        }