Beispiel #1
0
 public override void DrawBlast(SpriteBatch _spriteBatch, Vector2 position, float rot)
 {
     if (m_FireAnimation.CanDraw() && Firing)
     {
         m_FireAnimation.DrawAnimationFrame(_spriteBatch);
         foreach (Line line in m_BulletLines)
         {
             line.Draw(_spriteBatch);
         }
         //if frame is at 12
         if (m_FireAnimation.FrameCounter == 12)
         {
             CanDamage = false;
         }
     }
     else if (Firing)
     {
         Firing          = false;
         m_ElapsedFrames = FireRate;
         if (m_ReloadSound != null)
         {
             m_ReloadSound.Stop();
             m_ReloadSound.Dispose();
         }
         m_ReloadSound = SoundBank.GetSoundInstance("SoundShotgunReload");
         m_ReloadSound.Play();
     }
 }
Beispiel #2
0
        //foreach line of the shotgun i need to update the lines based on the player center,
        //and rotate it and give it length, then update the graphical lines
        public override void Update(Vector2 playerCenter, Vector2 playerVelocity, float rotationAngle, int accuracy, bool shotFired, TimeSpan elapsedTime)
        {
            base.Update(playerCenter, playerVelocity, rotationAngle, accuracy, shotFired, elapsedTime);
            if (!Firing)
            {
                //float accuracyInRadians = WEAPON_RANDOM.Next(0, accuracy) * ((float)Math.PI / 180);
                //TODO: add a random so its either plus or minus accuracy
                float centerVector = rotationAngle;
                if (NumberOfBullets > 1)
                {
                    float leftAngle = centerVector - (Spread / (NumberOfBullets - 1));
                    LeftAngle = leftAngle;
                }
                else
                {
                    LeftAngle = centerVector;
                }

                foreach (Line line in m_BulletLines)
                {
                    line.Update(playerCenter, LeftAngle, SightRange);
                }
                m_CurrentShotInfo = new SpriteInfo(playerCenter, playerVelocity, rotationAngle, NumberOfBullets, LeftAngle);
            }
            //firing a shot, save the state
            if (!Firing && shotFired && CanFire())
            {
                Firing = true;
                m_FireAnimation.SpriteInfo = m_CurrentShotInfo;
                CanDamage = false;
                if (m_FireAnimation.CanStartAnimating())
                {
                    m_FireAnimation.Finished = false;
                }
                if (m_ChargeSound != null)
                {
                    m_ChargeSound.Stop();
                    m_ChargeSound.Dispose();
                }
                m_ChargeSound = SoundBank.GetSoundInstance("SoundRifleCharge");
                m_ChargeSound.Play();
            }
            if (m_FireAnimation.Animating && m_FireAnimation.FrameCounter == CHARGE_TIME)
            {
                if (m_ShotSound != null)
                {
                    m_ShotSound.Stop();
                    m_ShotSound.Dispose();
                }
                if (m_ChargeSound != null)
                {
                    m_ChargeSound.Stop();
                    m_ChargeSound.Dispose();
                }
                m_ShotSound = SoundBank.GetSoundInstance("SoundRifleShot");
                m_ShotSound.Play();
            }
        }
Beispiel #3
0
        //foreach line of the shotgun i need to update the lines based on the player center,
        //and rotate it and give it length, then update the graphical lines
        public override void Update(Vector2 playerCenter, Vector2 playerVelocity, float rotationAngle, int accuracy, bool shotFired, TimeSpan elapsedTime)
        {
            base.Update(playerCenter, playerVelocity, rotationAngle, accuracy, shotFired, elapsedTime);
            //float accuracyInRadians = WEAPON_RANDOM.Next(0, accuracy) * ((float)Math.PI / 180);
            //TODO: add a random so its either plus or minus accuracy
            float centerVector = rotationAngle;

            m_CurrentShotInfo = new SpriteInfo(playerCenter, playerVelocity, rotationAngle, NumberOfBullets, LeftAngle);

            m_Bullets.RemoveAll(x => x.CanDelete);
            foreach (Bullet b in m_Bullets)
            {
                b.Update(elapsedTime);
            }
            //firing a shot, save the state
            if (shotFired && CanFire())
            {
                Bullet temp = new Bullet(m_CurrentShotInfo, 10);
                temp.LoadContent();
                m_Bullets.Add(temp);
                m_ElapsedFrames = FireRate;

                if (m_ShotSound != null)
                {
                    m_ShotSound.Stop();
                    m_ShotSound.Dispose();
                }
                m_ShotSound = SoundBank.GetSoundInstance("SoundPlasmaShot");
                m_ShotSound.Play();
            }
            if (m_Bullets.Count > 0)
            {
                BulletsExist = true;
            }
            else
            {
                BulletsExist = false;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public DeathMenu()
            : base("You Died!")
        {
            // Create our menu entries.
            MenuEntry NewGameEntry      = new MenuEntry("Try Again");
            MenuEntry UpgradeMenuEntry  = new MenuEntry("Upgrade");
            MenuEntry optionsMenuEntry  = new MenuEntry("Options");
            MenuEntry ExitGameMenuEntry = new MenuEntry("Exit Game");

            // Hook up menu event handlers.
            NewGameEntry.Selected      += NewGameMenuEntrySelected;
            UpgradeMenuEntry.Selected  += UpgradeMenuEntrySelected;
            ExitGameMenuEntry.Selected += ExitGameMenuEntrySelected;
            optionsMenuEntry.Selected  += OptionsMenuEntrySelected;

            // Add entries to the menu.
            MenuEntries.Add(NewGameEntry);
            MenuEntries.Add(UpgradeMenuEntry);
            MenuEntries.Add(optionsMenuEntry);
            MenuEntries.Add(ExitGameMenuEntry);
            IsPopup = true;
            song    = SoundBank.GetSoundInstance("menuMusic");
            StartbackgroundMusic();
        }
Beispiel #5
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
            {
                content = ScreenManager.Game.Content;
            }

            //gameFont = content.Load<SpriteFont>("GSMgamefont");

            m_World = new World(new Vector2(0, 0));
            ConvertUnits.SetDisplayUnitToSimUnitRatio(5);

            Player p = Player.Load(content);

            if (p == null)
            {
                Vector2 playerPosition = new Vector2(Game1.GameWidth / 2, Game1.GameHeight / 2);
                m_Player.Init(content, playerPosition);
            }
            else
            {
                m_Player = p;
            }
            //init object manager and set objects for it
            GlobalObjectManager.Init(m_Player, content, m_World);
            TextureBank.SetContentManager(content);
            SoundBank.SetContentManager(content);
            m_Player.LoadContent(m_World);
            UserInterface.LoadContent(content, Game1.GameWidth, Game1.GameHeight);
            GlobalObjectManager.LoadContent();

            m_song = SoundBank.GetSong("PUNCHING-Edit");
            UserInterface.SetTimeToDeath(m_Player.TimeToDeath);

            Zombie.LoadTextures();
            Slime.LoadTextures();
            Anubis.LoadTextures();


            Viewport viewport = ScreenManager.GraphicsDevice.Viewport;

            backgroundTexture = new RenderTarget2D(ScreenManager.GraphicsDevice, viewport.Width, viewport.Height, false,
                                                   SurfaceFormat.Color, DepthFormat.None, ScreenManager.GraphicsDevice.PresentationParameters.MultiSampleCount, RenderTargetUsage.PreserveContents);


            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            GraphicsDevice device = ScreenManager.GraphicsDevice;

            device.SetRenderTarget(backgroundTexture);
            spriteBatch.Begin();
            UserInterface.DrawBackground(spriteBatch);
            spriteBatch.End();

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();

            m_World.Step(0f);

            isLoaded = true;
        }
Beispiel #6
0
 public override SoundEffectInstance GetPickupSound()
 {
     m_PickupSound = SoundBank.GetSoundInstance("SoundCheatPickup");
     return(m_PickupSound);
 }
Beispiel #7
0
 public virtual SoundEffectInstance GetPickupSound()
 {
     return(SoundBank.GetSoundInstance("SoundWeaponPickup"));
 }