Exemplo n.º 1
0
        private void PreloadResource(ResourceLoader resLoader, PortalItem portal)
        {
            string path;

            var view = new PortalItem.ItemView();

            //加载editor
            {
                var typeName = PortalItem.PortalTypes[portal.Type];
                path = $@"Map\MapHelper.img\portal\editor\{typeName}";
                var aniData = resLoader.LoadAnimationData(path);
                if (aniData != null)
                {
                    view.EditorAnimator = CreateAnimator(aniData);
                }
            }
            //加载动画
            {
                string typeName, imgName;
                switch (portal.Type)
                {
                case 7:
                    typeName = PortalItem.PortalTypes[2]; break;

                default:
                    typeName = PortalItem.PortalTypes[portal.Type]; break;
                }

                switch (portal.Image)
                {
                case 0:
                    imgName = "default"; break;

                default:
                    imgName = portal.Image.ToString(); break;
                }
                path = $@"Map\MapHelper.img\portal\game\{typeName}\{imgName}";

                var aniNode = PluginManager.FindWz(path);
                if (aniNode != null)
                {
                    bool useParts = new[] { "portalStart", "portalContinue", "portalExit" }
                    .Any(aniName => aniNode.Nodes[aniName] != null);

                    if (useParts) //加载动作动画
                    {
                        var animator = CreateSMAnimator(aniNode, resLoader);
                        view.Animator   = animator;
                        view.Controller = new PortalItem.Controller(view);
                    }
                    else //加载普通动画
                    {
                        var aniData = resLoader.LoadAnimationData(aniNode);
                        if (aniData != null)
                        {
                            view.Animator = CreateAnimator(aniData);
                        }
                    }
                }
            }

            portal.View = view;
        }
Exemplo n.º 2
0
        public void Load(Wz_Node mapImgNode, ResourceLoader resLoader)
        {
            var infoNode = mapImgNode.Nodes["info"];

            if (infoNode == null)
            {
                throw new Exception("Cannot find map info node.");
            }

            //试图读取ID
            LoadIDOrName(mapImgNode);
            //加载基本信息
            LoadInfo(infoNode);
            //读取link
            if (this.Link != null && !FindMapByID(this.Link.Value, out mapImgNode))
            {
                throw new Exception("Cannot find or extract map link node.");
            }

            //加载小地图
            Wz_Node node;

            if (!string.IsNullOrEmpty(this.MapMark))
            {
                node = PluginManager.FindWz("Map\\MapHelper.img\\mark\\" + this.MapMark);
                if (node != null)
                {
                    node = node.GetLinkedSourceNode(PluginManager.FindWz);
                    this.MiniMap.MapMark = resLoader.Load <Texture2D>(node);
                }
            }
            if ((node = mapImgNode.Nodes["miniMap"]) != null)
            {
                LoadMinimap(node, resLoader);
            }

            //加载地图元件
            if ((node = mapImgNode.Nodes["back"]) != null)
            {
                LoadBack(node);
            }
            for (int i = 0; i <= 7; i++)
            {
                if ((node = mapImgNode.Nodes[i.ToString()]) != null)
                {
                    LoadLayer(node, i);
                }
            }
            if ((node = mapImgNode.Nodes["foothold"]) != null)
            {
                for (int i = 0; i <= 7; i++)
                {
                    var fhLevel = node.Nodes[i.ToString()];
                    if (fhLevel != null)
                    {
                        LoadFoothold(fhLevel, i);
                    }
                }
            }
            if ((node = mapImgNode.Nodes["life"]) != null)
            {
                LoadLife(node);
            }
            if ((node = mapImgNode.Nodes["reactor"]) != null)
            {
                LoadReactor(node);
            }
            if ((node = mapImgNode.Nodes["portal"]) != null)
            {
                LoadPortal(node);
            }
            if ((node = mapImgNode.Nodes["ladderRope"]) != null)
            {
                LoadLadderRope(node);
            }
            if ((node = mapImgNode.Nodes["skyWhale"]) != null)
            {
                LoadSkyWhale(node);
            }
            if ((node = mapImgNode.Nodes["ToolTip"]) != null)
            {
                LoadTooltip(node);
            }
            if ((node = mapImgNode.Nodes["particle"]) != null)
            {
                LoadParticle(node);
            }

            //计算地图大小
            CalcMapSize();
        }
Exemplo n.º 3
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();
            }
        }