示例#1
0
        public override List<Object> update(GameTime gameTime)
        {
            vel = p.getCenter() - getCenter();
            vel.Normalize();
            if(fire_cooldown < 0) translate(vel * 125 * (float)gameTime.ElapsedGameTime.TotalSeconds);

            rotation = (float)(Math.Atan2(vel.Y, vel.X) + Math.PI / 2);

            List<Object> bullets = new List<Object>();

            if ((p.getCenter() - getCenter()).Length() < 66 && fire_cooldown < 0)
            {
                float b_rot = rotation -(float)Math.PI / 2;

                Vector2 bullet_dir = (new Vector2((float)Math.Cos(b_rot), (float)Math.Sin(b_rot)));

                Bullet b = new Bullet(bullet_dir * 100, getCenter() + bullet_dir * tex.Width, false);
                b.rotation = b_rot;
                bullets.Add(b);
                fire_cooldown = 5;
                playPunch = true;
            }
            fire_cooldown -= gameTime.ElapsedGameTime.TotalSeconds;
            return bullets;
        }
示例#2
0
        public override List<Object> update(GameTime gameTime)
        {
            translate(vel * (float)gameTime.ElapsedGameTime.TotalSeconds * .001F * new Vector2(1,-1) * speed);

            if (energy >= 1) alive = false;

            energy += (float)(gameTime.ElapsedGameTime.TotalSeconds*MathHelper.Min((float)(( gameTime.TotalGameTime.TotalSeconds - Game1.startTime)/200.0), 0.5F));

            energy = MathHelper.Clamp(energy, 0, 1);

            List<Object> bullets = new List<Object>();

            if (firing)
            {
                float b_rot = rotation - (float)Math.PI / 2;

                Vector2 bullet_dir = (new Vector2((float)Math.Cos(b_rot), (float)Math.Sin(b_rot)));

                Bullet b = new Bullet(bullet_dir * 500, getCenter() + bullet_dir * tex.Width / 5, true);
                b.rotation = b_rot;
                bullets.Add(b);
                firing = false;
                energy -= 0.15f;
                playFire = true;

            }

            fire_cooldown -= gameTime.ElapsedGameTime.TotalSeconds;

            return bullets;
        }