Exemplo n.º 1
0
        private void PreloadResource(ResourceLoader resLoader, ReactorItem reactor)
        {
            string path        = $@"Reactor\{reactor.ID:D7}.img";
            var    reactorNode = PluginManager.FindWz(path);

            int?reactorLink = reactorNode?.FindNodeByPath(@"info\link").GetValueEx <int>();

            if (reactorLink != null)
            {
                path        = $@"Reactor\{reactorLink.Value:D7}.img";
                reactorNode = PluginManager.FindWz(path);
            }

            //加载动画
            var aniData = new Dictionary <string, RepeatableFrameAnimationData>();

            Wz_Node frameNode;

            for (int i = 0; (frameNode = reactorNode.Nodes[i.ToString()]) != null; i++)
            {
                //加载循环动画
                var ani = resLoader.LoadAnimationData(frameNode) as RepeatableFrameAnimationData;
                if (ani != null)
                {
                    var ani2 = new RepeatableFrameAnimationData(ani.Frames);
                    ani2.Repeat = ani.Repeat ?? true; //默认循环
                    aniData.Add(i.ToString(), ani2);
                }

                //加载跳转动画
                var    hitNode = frameNode.Nodes["hit"];
                Wz_Uol uol;
                if ((uol = hitNode?.GetValue <Wz_Uol>()) != null)
                {
                    hitNode = uol.HandleUol(hitNode);
                }
                if (hitNode != null)
                {
                    var aniHit = resLoader.LoadAnimationData(hitNode) as RepeatableFrameAnimationData;
                    aniData.Add($@"{i}/hit", aniHit);
                }
            }

            var view = new ReactorItem.ItemView();

            view.Animator   = new StateMachineAnimator(aniData);
            view.Controller = new ReactorItem.Controller(view);

            reactor.View = view;
        }
Exemplo n.º 2
0
        private StateMachineAnimator CreateSMAnimator(Wz_Node node, ResourceLoader resLoader)
        {
            var aniData = new Dictionary <string, RepeatableFrameAnimationData>();

            foreach (var actionNode in node.Nodes)
            {
                var actName = actionNode.Text;
                if (actName != "info" && !actName.StartsWith("condition"))
                {
                    var ani = resLoader.LoadAnimationData(actionNode) as RepeatableFrameAnimationData;
                    if (ani != null)
                    {
                        aniData.Add(actName, ani);
                    }
                }
            }
            if (aniData.Count > 0)
            {
                return(new StateMachineAnimator(aniData));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        private void PreloadResource(ResourceLoader resLoader, TileItem tile)
        {
            string path    = $@"Map\Tile\{tile.TS}.img\{tile.U}\{tile.No}";
            var    aniItem = resLoader.LoadAnimationData(path);

            tile.View = new TileItem.ItemView()
            {
                Animator = CreateAnimator(aniItem)
            };
        }
Exemplo n.º 4
0
        private void PreloadResource(ResourceLoader resLoader, ObjItem obj)
        {
            string path    = $@"Map\Obj\{obj.OS}.img\{obj.L0}\{obj.L1}\{obj.L2}";
            var    aniItem = resLoader.LoadAnimationData(path);

            obj.View = new ObjItem.ItemView()
            {
                Animator = CreateAnimator(aniItem)
            };
        }
Exemplo n.º 5
0
        private void PreloadResource(ResourceLoader resLoader, BackItem back)
        {
            string aniDir;

            switch (back.Ani)
            {
            case 0: aniDir = "back"; break;

            case 1: aniDir = "ani"; break;

            case 2: aniDir = "spine"; break;

            default: throw new Exception($"Unknown back ani value: {back.Ani}.");
            }
            string path    = $@"Map\Back\{back.BS}.img\{aniDir}\{back.No}";
            var    aniItem = resLoader.LoadAnimationData(path);

            back.View = new BackItem.ItemView()
            {
                Animator = CreateAnimator(aniItem, back.SpineAni)
            };
        }
Exemplo n.º 6
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;
        }