Example #1
0
        public override bool GenerateBullet(Vector2 position, float direction, float bonusAccuracy)
        {
            bool bulletGenerated = base.GenerateBullet(position, direction, bonusAccuracy);
            PistolBullet bullet;
            float currentDirection;

            if (bulletGenerated)
            {
                for (int i = 0; i < numberOfBullets; i++)
                {
                    currentDirection = (float)(direction + (accuracy + bonusAccuracy) * (random.NextDouble() - 0.5));

                    bullet = new PistolBullet(position, (float)(bulletSpeed * (1 - 0.1 * random.NextDouble())),
                        currentDirection, (float)(maxDistance * (1 - 0.1 * random.NextDouble())));

                    bullet.CurrentImages.Add(new Image(texture));
                    bullet.CurrentImages[0].OriginX = bullet.CurrentImages[0].Width / 2;
                    bullet.CurrentImages[0].OriginY = bullet.CurrentImages[0].Height / 2;
                    bullet.CurrentImages[0].Angle = currentDirection;
                    bullet.CurrentImages[0].Scale = 0.5f;
                    bullet.AddCollisionMask(baseMask.Clone());

                    OGE.CurrentWorld.AddEntity(bullet);
                }

                PlaySound("pistol");
                OGE.WorldCamera.ShackCamera(2, 0.1f);
            }

            return bulletGenerated;
        }
        public override void DestroyBulletMaxRange()
        {
            PistolBullet bullet;
            Random random = OGE.Random;

            for (int i = 0; i < 360; i += 360 / 15)
            {
                float currentDirection = i;

                bullet = new PistolBullet(Position, bulletSpeed, currentDirection, (float)(maxDistance * (1 - 0.1 * random.NextDouble())));

                bullet.CurrentImages.Add(new Image(texture));
                bullet.CurrentImages[0].OriginX = bullet.CurrentImages[0].Width / 2;
                bullet.CurrentImages[0].OriginY = bullet.CurrentImages[0].Height / 2;
                bullet.CurrentImages[0].Angle = currentDirection;
                bullet.CurrentImages[0].Scale = 0.5f;
                bullet.AddCollisionMask(baseMask.Clone());

                OGE.CurrentWorld.AddEntity(bullet);
            }

            base.DestroyBulletMaxRange();
        }