Exemplo n.º 1
0
        public void FireShot(
            Vector2 location,
            Vector2 velocity,
            bool playerFired)
        {
            Sprite thisShot = new Sprite(
                location,
                Texture,
                InitialFrame,
                velocity);

            thisShot.Velocity *= shotSpeed;

            for (int x = 1; x < FrameCount; x++)
            {
                thisShot.AddFrame(new Rectangle(
                                      InitialFrame.X + (InitialFrame.Width * x),
                                      InitialFrame.Y,
                                      InitialFrame.Width,
                                      InitialFrame.Height));
            }
            thisShot.CollisionRadius = CollisionRadius;
            Shots.Add(thisShot);

            if (playerFired)
            {
                SoundManager.PlayPlayerShot();
            }
            else
            {
                SoundManager.PlayEnemyShot();
            }
        }
Exemplo n.º 2
0
        public void FireShot(
            Vector2 location,
            Vector2 velocity,
            GunManager.CurrentGun gun)
        {
            InitialFrame = InitialFrameOG;
            int extraCollide = 0;

            if (gun == GunManager.CurrentGun.Rocket)
            {
                InitialFrame = new Rectangle(0, 367, 47, 23);
                extraCollide = 30;
            }

            /*if (gun == GunManager.CurrentGun.Donut)
             * {
             *  InitialFrame = new Rectangle(0, 311, 25, 46);
             *  extraCollide = 30;
             * }*/
            Sprite thisShot = new Sprite(
                location,
                Texture,
                InitialFrame,
                velocity);

            thisShot.Velocity *= shotSpeed + 10;
            if (gun == GunManager.CurrentGun.Rocket)
            {
                thisShot.isRocket = true;
                thisShot.Rotation = (float)Math.Atan2(velocity.Y, velocity.X);
                MouseState ms        = Mouse.GetState();
                Vector2    msCollide = new Vector2(ms.X, ms.Y);
                for (int i = 0; i < EnemyManager.Enemies.Count - 1; i++)
                {
                    if (EnemyManager.Enemies[i].EnemySprite.IsCircleColliding(msCollide, 20))
                    {
                        thisShot.tracking = i;
                    }
                }
            }
            for (int x = 1; x < 3; x++)
            {
                thisShot.AddFrame(new Rectangle(
                                      InitialFrame.X + (InitialFrame.Width * x),
                                      InitialFrame.Y,
                                      InitialFrame.Width,
                                      InitialFrame.Height));
            }
            thisShot.CollisionRadius = CollisionRadius + extraCollide;
            Shots.Add(thisShot);

            SoundManager.PlayPlayerShot();
        }