Exemplo n.º 1
0
 public override void Update(DwarfTime gameTime, Timer.TimerMode mode = Timer.TimerMode.Game)
 {
     base.Update(gameTime, mode);
     CurrentOffset = Composite.PushFrame(CompositeFrames[CurrentFrame]);
     HasValidFrame = true;
     UpdatePrimitive();
 }
Exemplo n.º 2
0
        public virtual void Update(DwarfTime gameTime, Timer.TimerMode mode = Timer.TimerMode.Game)
        {
            if (IsPlaying && CurrentAnimation != null)
            {
                LastFrame = CurrentFrame;
                float dt = mode == Timer.TimerMode.Game ? (float)gameTime.ElapsedGameTime.TotalSeconds : (float)gameTime.ElapsedRealTime.TotalSeconds;
                FrameTimer += dt;

                float time = CurrentAnimation.FrameHZ;

                if (CurrentAnimation.Speeds.Count > 0)
                {
                    time = CurrentAnimation.Speeds[Math.Min(CurrentFrame, CurrentAnimation.Speeds.Count - 1)];
                }

                if (FrameTimer * CurrentAnimation.SpeedMultiplier >= 1.0f / time)
                {
                    NextFrame();
                    FrameTimer = 0.0f;
                }
            }

            // Todo: Track enough state to only do this as needed.
            if (CurrentAnimation != null)
            {
                if (Primitive == null)
                {
                    Primitive = new BillboardPrimitive();
                }
                CurrentAnimation.UpdatePrimitive(Primitive, CurrentFrame);
            }
        }
Exemplo n.º 3
0
        public virtual void Update(DwarfTime gameTime, Timer.TimerMode mode = Timer.TimerMode.Game)
        {
            if (IsPlaying)
            {
                float dt = mode == Timer.TimerMode.Game ? (float)gameTime.ElapsedGameTime.TotalSeconds : (float)gameTime.ElapsedRealTime.TotalSeconds;
                FrameTimer += dt;

                float time = FrameHZ;

                if (Speeds.Count > 0)
                {
                    time = Speeds[Math.Min(CurrentFrame, Speeds.Count - 1)];
                }
                if (FrameTimer * SpeedMultiplier >= 1.0f / time)
                {
                    NextFrame();
                    FrameTimer = 0.0f;
                }
            }
        }
Exemplo n.º 4
0
        public virtual void Update(DwarfTime gameTime, bool WillUseInstancingIfPossible, Timer.TimerMode mode = Timer.TimerMode.Game)
        {
            InstancingPossible = false;

            if (CurrentAnimation == null)
            {
                return;
            }

            if (IsPlaying)
            {
                LastFrame = CurrentFrame;
                float dt = mode == Timer.TimerMode.Game ? (float)gameTime.ElapsedGameTime.TotalSeconds : (float)gameTime.ElapsedRealTime.TotalSeconds;
                FrameTimer += dt;
                float hz   = CurrentAnimation.FrameHZ > 0 ? CurrentAnimation.FrameHZ : 1;
                float time = 1.0f / hz;

                if (CurrentAnimation.Speeds.Count > 0)
                {
                    time = CurrentAnimation.Speeds[Math.Min(CurrentFrame, CurrentAnimation.Speeds.Count - 1)];
                }

                time /= CurrentAnimation.SpeedMultiplier;

                if (FrameTimer >= time)
                {
                    NextFrame();
                    FrameTimer = 0;
                }
            }


            if (!WillUseInstancingIfPossible || !CurrentAnimation.CanUseInstancing)
            {
                // Todo: Only update when actually needed.
                if (Primitive == null)
                {
                    Primitive = new BillboardPrimitive();
                }
                CurrentAnimation.UpdatePrimitive(Primitive, CurrentFrame);
            }
            else
            {
                InstancingPossible = true;
            }
        }