コード例 #1
0
        void UpdateEnter(GameTime gt)
        {
            fadeInLerp += gt.Delta() / FadeInTime;
            fadeInValue = MathHelper.Lerp(1f, 0f, fadeInLerp);

            lbLife -= gt.Delta();

            if (fadeInValue < 0)
            {
                State = GameStateType.Running;
            }
        }
コード例 #2
0
        void UpdateExit(GameTime gt)
        {
            fadeOutLerp += gt.Delta() / FadeOutTime;
            fadeOutValue = MathHelper.Lerp(0f, 1f, fadeOutLerp);

            if (fadeOutValue >= 1f)
            {
                ExitState();
            }
        }
コード例 #3
0
 protected override void UpdateParticles(GameTime gameTime)
 {
     foreach (var particle in Particles)
     {
         if (!particle.Direction.HasValue)
         {
             particle.Rotation  = (float)Math.PI * new Random().Next(0, 360) / 180.0f;
             particle.Direction = new Vector2(0, 1.0f);
         }
         else
         {
             particle.Rotation += 1.0f * gameTime.Delta();
         }
     }
 }
コード例 #4
0
ファイル: ParticleEffect.cs プロジェクト: aldrikboy/TruckerX
        public void Update(GameTime gameTime)
        {
            timer += gameTime.ElapsedGameTime;

            if (timer >= Interval)
            {
                for (int i = 0; i < particlesPerSpawn; i++)
                {
                    SpawnParticle();
                }
                if (StopAfterNextEmit)
                {
                    this.Stop();
                }
                timer = TimeSpan.Zero;
            }

            UpdateParticles(gameTime);

            float delta = gameTime.Delta();

            for (int i = 0; i < Particles.Count; i++)
            {
                var particle = Particles[i];

                if (particle.AliveTime >= this.particleLifespan)
                {
                    Particles.RemoveAt(i);
                    i--;
                }

                if (particle.Direction.HasValue)
                {
                    particle.AliveTime += gameTime.ElapsedGameTime;
                    particle.Position  += new Vector2(particle.Direction.Value.X * delta * particle.Speed,
                                                      particle.Direction.Value.Y * delta * particle.Speed);
                }
            }
        }
コード例 #5
0
 protected override void UpdateParticles(GameTime gameTime)
 {
     foreach (var particle in Particles)
     {
         if (!particle.Direction.HasValue)
         {
             var rand = new Random();
             if (rand.Next(0, 4) != 0)
             {
                 continue;                        // Make sure the confetti doesn't come out all at once.
             }
             particle.Rotation  = (float)Math.PI * new Random().Next(0, 360) / 180.0f;
             particle.Color     = Color.FromNonPremultiplied(rand.Next(100, 255), rand.Next(100, 255), rand.Next(100, 255), 255);
             particle.Direction = new Vector2().RandomNormalized() * 2;
         }
         else
         {
             particle.Rotation += 4.0f * gameTime.Delta();
             particle.Direction = new Vector2(particle.Direction.Value.X, particle.Direction.Value.Y + (2.5f * gameTime.Delta()));
         }
     }
 }
コード例 #6
0
        public void Update(GameTime gt)
        {
            Size     = Gui.PrevSize;
            Position = Gui.PrevPos;

            var delta = gt.Delta();

            var list = FramesGui.Instance.frames;

            if (list != null && list.Count > 0)
            {
                if (currentFrame == null)
                {
                    currentFrame = list[0];
                }

                timer += delta;

                if (timer >= currentFrame.FrameSpeed)
                {
                    frame = (frame + 1) % list.Count;
                    timer = 0;
                }

                if (frame >= list.Count)
                {
                    frame = 0;
                }

                currentFrame = list[frame];
            }
            else
            {
                currentFrame = null;
            }
        }
コード例 #7
0
 public override void Update(GameTime gt)
 {
     base.Update(gt);
     LifeTime -= gt.Delta();
 }