Esempio n. 1
0
        public static LifeInfo CreateFromNode(Wz_Node mobNode)
        {
            if (mobNode == null)
            {
                return(null);
            }

            var lifeInfo = new LifeInfo();
            var infoNode = mobNode.Nodes["info"];

            if (infoNode != null)
            {
                foreach (Wz_Node node in infoNode.Nodes)
                {
                    switch (node.Text)
                    {
                    case "level": lifeInfo.level = node.GetValueEx <int>(0); break;

                    case "maxHP": lifeInfo.maxHP = node.GetValueEx <long>(0); break;

                    case "maxMP": lifeInfo.maxMP = node.GetValueEx <long>(0); break;

                    case "speed": lifeInfo.speed = node.GetValueEx <int>(0); break;

                    case "PADamage": lifeInfo.PADamage = node.GetValueEx <int>(0); break;

                    case "PDDamage": lifeInfo.PDDamage = node.GetValueEx <int>(0); break;

                    case "PDRate": lifeInfo.PDRate = node.GetValueEx <int>(0); break;

                    case "MADamage": lifeInfo.MADamage = node.GetValueEx <int>(0); break;

                    case "MDDamage": lifeInfo.MDDamage = node.GetValueEx <int>(0); break;

                    case "MDRate": lifeInfo.MDRate = node.GetValueEx <int>(0); break;

                    case "exp": lifeInfo.exp = node.GetValueEx <int>(0); break;

                    case "undead": lifeInfo.undead = node.GetValueEx <int>(0) != 0; break;

                    case "boss": lifeInfo.boss = node.GetValueEx <int>(0) != 0; break;

                    case "elemAttr":
                        string elem = node.GetValueEx <string>(string.Empty);
                        for (int i = 0; i < elem.Length; i += 2)
                        {
                            LifeInfo.ElemResistance resist = (LifeInfo.ElemResistance)(elem[i + 1] - 48);
                            switch (elem[i])
                            {
                            case 'I': lifeInfo.elemAttr.I = resist; break;

                            case 'L': lifeInfo.elemAttr.L = resist; break;

                            case 'F': lifeInfo.elemAttr.F = resist; break;

                            case 'S': lifeInfo.elemAttr.S = resist; break;

                            case 'H': lifeInfo.elemAttr.H = resist; break;

                            case 'D': lifeInfo.elemAttr.D = resist; break;

                            case 'P': lifeInfo.elemAttr.P = resist; break;
                            }
                        }
                        break;
                    }
                }
            }
            return(lifeInfo);
        }
Esempio n. 2
0
        private void PreloadResource(ResourceLoader resLoader, LifeItem life)
        {
            string path;

            switch (life.Type)
            {
            case LifeItem.LifeType.Mob:
                path = $@"Mob\{life.ID:D7}.img";
                var mobNode = PluginManager.FindWz(path);

                //加载mob数据
                if (mobNode != null)
                {
                    life.LifeInfo = LifeInfo.CreateFromNode(mobNode);
                }

                //获取link
                int?mobLink = mobNode?.FindNodeByPath(@"info\link").GetValueEx <int>();
                if (mobLink != null)
                {
                    path    = $@"Mob\{mobLink.Value:D7}.img";
                    mobNode = PluginManager.FindWz(path);
                }

                //加载动画
                if (mobNode != null)
                {
                    var aniItem = this.CreateSMAnimator(mobNode, resLoader);
                    if (aniItem != null)
                    {
                        AddMobAI(aniItem);
                        life.View = new LifeItem.ItemView()
                        {
                            Animator = aniItem
                        };
                    }
                }
                break;

            case LifeItem.LifeType.Npc:
                path = $@"Npc\{life.ID:D7}.img";
                var npcNode = PluginManager.FindWz(path);

                //TODO: 加载npc数据
                int?npcLink = npcNode?.FindNodeByPath(@"info\link").GetValueEx <int>();
                if (npcLink != null)
                {
                    path    = $@"Npc\{npcLink.Value:D7}.img";
                    npcNode = PluginManager.FindWz(path);
                }

                //加载动画
                if (npcNode != null)
                {
                    var aniItem = this.CreateSMAnimator(npcNode, resLoader);
                    if (aniItem != null)
                    {
                        AddNpcAI(aniItem);
                        life.View = new LifeItem.ItemView()
                        {
                            Animator = aniItem
                        };
                    }
                }
                break;
            }

            if (life.View == null) //空动画
            {
                life.View = new LifeItem.ItemView();
            }
        }