예제 #1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            Flipbook.Rotation += rotatingSpeed * elapsedTime;
            Flipbook.Scale    += Vector2.One * scalingFactor * elapsedTime;
            Flipbook.SetTransparency(alpha -= alphaFactor * elapsedTime);

            xMovement.RefreshCurrentPosition(elapsedTime);
            yMovement.RefreshCurrentPosition(elapsedTime);

            Flipbook.Position = initialPosition + new Vector2(xMovement.CurrentPosition, yMovement.CurrentPosition);
        }
예제 #2
0
        private static void LowHealthSmokeParticle(Vector2 position, string smokePath)
        {
            Flipbook fb = new Flipbook(position, new Vector2(16, 16), 32, 32, smokePath,
                                       new AnimationInstance()
            {
                StartingFrame = 0, EndingFrame = 7, TimePerFrame = 1 / 15f
            },
                                       DepthParameter.ProjectileSFX, (float)Parameter.Random.NextDouble() * MathHelper.TwoPi);

            float density = (float)(1 / 3f + 2 * Parameter.Random.NextDouble() / 3);

            fb.SetTransparency(density);
            fb.Scale *= density;

            SpecialEffect se = new SpecialEffect(fb, 1);

            MatchMetadata mm = LevelScene.MatchMetadata;

            Vector2 posFactor =
                -Vector2.UnitY * 2 +
                Vector2.Transform(
                    Vector2.UnitX,
                    Matrix.CreateRotationZ(
                        mm.WindAngleRadians +
                        MathHelper.ToRadians(
                            (0.5f - (float)Parameter.Random.NextDouble()) * 30)) *
                    mm.WindForce / 5);

            if (Math.Abs(posFactor.Y) < 1)
            {
                posFactor = new Vector2(posFactor.X, (posFactor.Y < 0) ? -1 : 1);
            }

            float rotationFactor = (mm.WindForce / 10) * (0.5f - (float)Parameter.Random.NextDouble());
            float scaleFactor    = (float)Parameter.Random.NextDouble();

            se.UpdateAction += (specialEffect, gameTime) =>
            {
                float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

                se.Flipbook.Position += posFactor;
                se.Flipbook.Rotation += rotationFactor;

                se.Flipbook.Scale *= 1 + scaleFactor * elapsedTime * 2;
            };

            SpecialEffectHandler.Add(se);
        }