Пример #1
0
        // Spawns an imprint of this enemy
        public void SpawnImprint(GameTime gameTime)
        {
            ImprintSpawn += gameTime.ElapsedGameTime.Milliseconds;

            if (ImprintSpawn >= 25)
            {
                ImprintSpawn = 0;

                Imprint im;
                if (Type.Equals(level.DashEnemy))
                {
                    im = new Imprint(Position, Type.Texture, Animation.GetRectangle(), 1.0f, rotation, Animation.GetOrigin());
                }
                else
                {
                    im = new Imprint(Position, Type.Texture, new Rectangle(0, 0, (int)Type.Texture.Width, (int)Type.Texture.Height), 1.0f, rotation, Type.GetOrigin());
                }

                level.Imprints.Add(im);
            }
        }
Пример #2
0
        // Updates this bullet
        public void Update(GameTime gameTime)
        {
            // Moves the bullet
            Position += Velocity;

            // Accelerates the bullet
            Velocity += Acceleration;

            // Increases the timer
            Timer += gameTime.ElapsedGameTime.Milliseconds;

            // Determines the rotation
            Rotation = (float)(Math.Atan2(Velocity.Y, Velocity.X));

            if (Type.Properties.Equals(BulletType.BulletProperties.Fire))
            {
                Alpha -= 0.03f;
            }

            if (Type.Equals(level.YellowBullet))
            {
                float newX = (float)Math.Cos((double)Rotation) * 60;
                float newY = (float)Math.Sin((double)Rotation) * 60;
                Texture2D text = level.YellowParticle;
                int r = level.r.Next(3);
                if (r == 0)
                {
                    text = level.RedParticle;
                }

                level.SpawnTrail(5, text, new Vector2(Position.X - newX, Position.Y - newY), Rotation, 0.06f);
            }
            else if (Type.Equals(level.GreenBullet))
            {
                rotTime += MathHelper.Pi / 15.0f;

                /*Imprint im = new Imprint(Position, Type.Texture, new Rectangle(0, 0, Type.Texture.Width, Type.Texture.Height), 1.0f, Rotation, origin);
                level.Imprints.Add(im);*/

                float newX = (float)Math.Cos((double)Rotation) * 20;
                float newY = (float)Math.Sin((double)Rotation) * 20;
                level.SpawnTrail(1, level.GreenParticle, new Vector2(Position.X - newX, Position.Y - newY), Rotation, 0.09f);

                // Helix the bullets
                float xChange = (float)(Math.Cos(Rotation + MathHelper.Pi / 2)) * (float)Math.Sin(rotTime) * 1.5f;
                float yChange = (float)(Math.Sin(Rotation + MathHelper.Pi / 2)) * (float)Math.Sin(rotTime) * 1.5f;

                Position.X += xChange;
                Position.Y += yChange;
            }
            else if (Type.Equals(level.RedBullet))
            {
                float newX = (float)Math.Cos((double)Rotation) * 0;
                float newY = (float)Math.Sin((double)Rotation) * 0;
                level.SpawnTrail(1, level.RedParticle, new Vector2(Position.X - newX, Position.Y - newY), Rotation, 0.06f);
            }
            else if (Type.Equals(level.BlueBullet))
            {
                Imprint im = new Imprint(Position, Type.Texture, new Rectangle(0, 0, Type.Texture.Width, Type.Texture.Height), 1.0f, Rotation, origin);
                level.Imprints.Add(im);
            }

            // Spawn a particle
            ParticleSpawnTime += gameTime.ElapsedGameTime.Milliseconds;
            if(ParticleSpawnTime > MaxSpawnTime && Type.Equals(level.GreenBullet))
            {
                level.SpawnTrailingParticle(this);
                ParticleSpawnTime = 0;
            }
        }