Exemplo n.º 1
0
        /// <summary>
        /// Plays one of the available animations that matches the specified name.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="resetAnim"></param>
        /// <param name="loopMode"></param>
        public void PlayAnimation(string name, bool resetAnim = false, LoopMode loopMode = LoopMode.Default)
        {
            ActorAnimation anim = this.GetAnimation(name);

            // When specifying default, let the animation decide which loop mode to use.
            if (anim != null && loopMode == LoopMode.Default)
            {
                loopMode = anim.PreferredLoopMode;
            }

            // Still set to default? Use a regular loop then.
            if (loopMode == LoopMode.Default)
            {
                loopMode = LoopMode.Loop;
            }

            // If we're already playing that animation, just continue doing it.
            if (this.activeAnim == anim && !resetAnim)
            {
                return;
            }

            this.activeAnim     = anim;
            this.activeLoopMode = loopMode;

            if (this.activeAnim != null && loopMode == LoopMode.RandomSingle)
            {
                this.animTime = MathF.Rnd.NextFloat(0.0f, this.activeAnim.Duration);
            }
            else
            {
                this.animTime = 0.0f;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Plays one of the available animations that matches the specified name.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="resetAnim"></param>
        /// <param name="loopMode"></param>
        public void PlayAnimation(string name, bool resetAnim = false, LoopMode loopMode = LoopMode.Default)
        {
            ActorAnimation anim = this.GetAnimation(name);

            // When specifying default, let the animation decide which loop mode to use.
            if (anim != null && loopMode == LoopMode.Default)
                loopMode = anim.PreferredLoopMode;

            // Still set to default? Use a regular loop then.
            if (loopMode == LoopMode.Default)
                loopMode = LoopMode.Loop;

            // If we're already playing that animation, just continue doing it.
            if (this.activeAnim == anim && !resetAnim)
                return;

            this.activeAnim = anim;
            this.activeLoopMode = loopMode;

            if (this.activeAnim != null && loopMode == LoopMode.RandomSingle)
                this.animTime = MathF.Rnd.NextFloat(0.0f, this.activeAnim.Duration);
            else
                this.animTime = 0.0f;
        }