示例#1
0
        public void OutputAllCandleTextures()
        {
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "candle");

            Directory.CreateDirectory(path);

            int candleBodyID = 505;

            try
            {
                for (int action = 0; action < 30; action++)
                {
                    for (int direction = 0; direction < 8; direction++)
                    {
                        // get the resource provider
                        IResourceProvider provider = ServiceRegistry.GetService <IResourceProvider>();
                        IAnimationFrame[] frames   = provider.GetAnimation(candleBodyID, action, direction, 0);
                        if (frames != null)
                        {
                            for (int i = 0; i < frames.Length; i++)
                            {
                                if (frames[i] != null)
                                {
                                    Utility.SaveTexture(frames[i].Texture, Path.Combine(path, string.Format("{0}-{1}-{2}.png",
                                                                                                            action, direction, i)));
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }
示例#2
0
        // ======================================================================
        // Code to get frames for drawing
        // ======================================================================

        private IAnimationFrame getFrame(int body, ref int hue, int facing, int action, float frame, out int frameCount)
        {
            // patch light source animations: candles and torches.
            if (body >= 500 && body <= 505)
            {
                patchLightSourceAction(ref action);
            }

            frameCount = 0;

            IResourceProvider provider = ServiceRegistry.GetService <IResourceProvider>();

            IAnimationFrame[] frames = provider.GetAnimation(body, ref hue, action, facing);
            if (frames == null)
            {
                return(null);
            }
            frameCount = frames.Length;
            int iFrame = (int)frame; // frameFromSequence(frame, iFrames.Length);

            if (iFrame >= frameCount)
            {
                iFrame = 0;
            }

            if (frames[iFrame].Texture == null)
            {
                return(null);
            }
            return(frames[iFrame]);
        }
示例#3
0
        // ======================================================================
        // Code to get frames for drawing
        // ======================================================================

        private IAnimationFrame getFrame(int bodyID, int hue, int facing, int action, float frame, out int frameCount)
        {
            if (bodyID >= 500 && bodyID <= 505)
            {
                patchLightSourceAction(ref action, ref frame);
            }

            frameCount = 0;

            // get the resource provider
            IResourceProvider provider = ServiceRegistry.GetService <IResourceProvider>();

            IAnimationFrame[] frames = provider.GetAnimation(bodyID, action, facing, hue);
            if (frames == null)
            {
                return(null);
            }
            frameCount = frames.Length;
            int iFrame = (int)frame; // frameFromSequence(frame, iFrames.Length);

            if (frames[iFrame].Texture == null)
            {
                return(null);
            }
            return(frames[iFrame]);
        }
示例#4
0
        private void animate(MobileAction action, int actionIndex, int repeatCount, bool reverse, bool repeat, int delay, bool isRequestedAction)
        {
            if (m_action == action)
            {
                if (m_IsAnimatationPaused)
                {
                    UnPauseAnimation();
                }
            }

            if (isRequestedAction)
            {
                m_actionCanBeInteruptedByStand = true;
            }

            if ((m_action != action) || (m_actionIndex != actionIndex))
            {
                // If we are switching from any action to a stand action, then hold the last frame of the
                // current animation for a moment. Only Stand actions are held; thus when any hold ends,
                // then we know we were holding for a Stand action.
                if (!(m_action == MobileAction.None) && (action == MobileAction.Stand && m_action != MobileAction.Stand))
                {
                    if (m_action != MobileAction.None)
                    {
                        PauseAnimation();
                    }
                }
                else
                {
                    m_action = action;
                    UnPauseAnimation();
                    m_actionIndex    = actionIndex;
                    m_animationFrame = 0f;

                    // get the resource provider
                    IResourceProvider provider = ServiceRegistry.GetService <IResourceProvider>();
                    IAnimationFrame[] frames   = provider.GetAnimation(
                        Parent.Body, actionIndex, (int)Parent.Facing, Parent.Hue);
                    if (frames != null)
                    {
                        m_FrameCount = frames.Length;
                        m_FrameDelay = delay;
                        if (repeat == false)
                        {
                            m_repeatCount = 0;
                        }
                        else
                        {
                            m_repeatCount = repeatCount;
                        }
                    }
                }
            }
        }
示例#5
0
        private IAnimationFrame getFrame(Body body, int facing, int frameIndex, int hue)
        {
            // get the resource provider
            IResourceProvider provider = ServiceRegistry.GetService <IResourceProvider>();

            IAnimationFrame[] frames = provider.GetAnimation(body, BodyConverter.DeathAnimationIndex(body), facing, hue);
            if (frames == null)
            {
                return(null);
            }
            if (frames[frameIndex].Texture == null)
            {
                return(null);
            }
            return(frames[frameIndex]);
        }