コード例 #1
0
        void Shoot(GameTime gameTime)
        {
            if (bulletCooldownTime < 0.0f)
            {
                Vector2 shootPosition;
                //find pos.x
                if (direction.X > 0)
                {
                    shootPosition.X = position.X + base.rectangle.Width - simplePlatformer.bulletTexture.Width / 2;
                }
                else
                {
                    shootPosition.X = position.X - simplePlatformer.bulletTexture.Width / 2;
                }

                shootPosition.Y = position.Y + (base.rectangle.Height / 2) - (simplePlatformer.bulletTexture.Height / 2);

                Vector2 shootDirection = (movement + direction * bulletSpeed) * Vector2.UnitX;

                simplePlatformer.Shoot(shootPosition, shootDirection, bulletSpeed, bulletStrength);
                bulletGroup++;

                if (bulletGroup >= bulletGroupMax)
                {
                    bulletCooldownTime = bulletTime;
                    bulletGroup        = 0;
                }
            }
        }