Esempio n. 1
0
        public override void Update(ProjectileObj proj, GameTime gameTime)
        {
            base.Update(proj, gameTime);

            var totalSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (proj.AltY > 0f)
            {
                proj.AltY -= totalSeconds;
                if (proj.AltY <= 0f)
                {
                    //ProceduralLevelScreen currentScreen = Game.ScreenManager.CurrentScreen as ProceduralLevelScreen;
                    //if (currentScreen != null)
                    //{
                    Effects.BlackSmokeEffect.DisplayCrowSmoke(proj.Position);
                    proj.AltY = 0.05f;
                    //}
                }
            }

            if (proj.AltX > 0f)
            {
                proj.AltX       -= totalSeconds;
                proj.Orientation = MathHelper.WrapAngle(proj.Orientation);
            }
            else
            {
                proj.TurnToFace(proj.Target.Position, proj.TurnSpeed, totalSeconds);
            }

            proj.HeadingX      = (float)Math.Cos(proj.Orientation);
            proj.HeadingY      = (float)Math.Sin(proj.Orientation);
            proj.AccelerationX = 0f;
            proj.AccelerationY = 0f;
            proj.Position     += proj.CurrentSpeed * totalSeconds * proj.Heading;

            float rotation = MathHelper.ToDegrees(proj.Orientation);

            if (proj.HeadingX <= 0f)
            {
                proj.Flip = SpriteEffects.FlipHorizontally;
                rotation  = ((rotation >= 0f ? -180f : 180f) + rotation) * 60f * totalSeconds;
            }
            else
            {
                proj.Flip = SpriteEffects.None;
            }

            proj.Rotation = rotation;
            proj.Rotation = MathHelper.Clamp(proj.Rotation, -90f, 90f);

            if (proj.Target == null)
            {
                proj.RunDestroyAnimation(false);
            }
            else
            {
                var enemy = proj.Target as IKillableObj;
                if (enemy != null && enemy.IsKilled)
                {
                    proj.RunDestroyAnimation(false);
                }
            }
        }
Esempio n. 2
0
        public override void Update(ProjectileObj proj, GameTime gameTime)
        {
            base.Update(proj, gameTime);

            var totalSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (proj.AltY > 0f)
            {
                proj.AltY -= totalSeconds;
                if (proj.AltY <= 0f)
                {
                    //ProceduralLevelScreen currentScreen = Game.ScreenManager.CurrentScreen as ProceduralLevelScreen;
                    //if (currentScreen != null)
                    //{
                    Effects.BlackSmokeEffect.DisplayCrowSmoke(proj.Position);
                    proj.AltY = 0.05f;
                    //}
                }
            }

            if (proj.AltX > 0f)
            {
                proj.AltX -= totalSeconds;
                proj.Orientation = MathHelper.WrapAngle(proj.Orientation);
            }
            else
                proj.TurnToFace(proj.Target.Position, proj.TurnSpeed, totalSeconds);

            proj.HeadingX = (float)Math.Cos(proj.Orientation);
            proj.HeadingY = (float)Math.Sin(proj.Orientation);
            proj.AccelerationX = 0f;
            proj.AccelerationY = 0f;
            proj.Position += proj.CurrentSpeed * totalSeconds * proj.Heading;

            float rotation = MathHelper.ToDegrees(proj.Orientation);
            if (proj.HeadingX <= 0f)
            {
                proj.Flip = SpriteEffects.FlipHorizontally;
                rotation = ((rotation >= 0f ? -180f : 180f) + rotation) * 60f * totalSeconds;
            }
            else
                proj.Flip = SpriteEffects.None;

            proj.Rotation = rotation;
            proj.Rotation = MathHelper.Clamp(proj.Rotation, -90f, 90f);

            if (proj.Target == null)
                proj.RunDestroyAnimation(false);
            else
            {
                var enemy = proj.Target as IKillableObj;
                if (enemy != null && enemy.IsKilled)
                    proj.RunDestroyAnimation(false);
            }
        }