Ejemplo n.º 1
0
        /// <summary>
        /// Loads a particular knife sprite sheet and sounds.
        /// </summary>
        public void LoadContent()
        {
            this.Reset();

            explosion = new GrenadeExplosion(game, position, _player);

            idleAnimation = new Animation(game.Content.Load <Texture2D>("Sprites/Weapons/bomb"), 0.1f, true);
            sprite.PlayAnimation(idleAnimation);

            explosionSound = game.Content.Load <SoundEffect>("Sounds/explosionSound");

            throwSound                 = game.Content.Load <SoundEffect>("Sounds/throwSound");
            bombSound                  = game.Content.Load <SoundEffect>("Sounds/bombSound");
            bombSoundInstance          = bombSound.CreateInstance();
            bombSoundInstance.IsLooped = true;
            bombSoundInstance.Volume   = 0.55f;


            // Calculate bounds within texture size.
            int width  = (int)(idleAnimation.FrameWidth * 0.4);
            int left   = (idleAnimation.FrameWidth - width) / 2;
            int height = 10;
            int top    = idleAnimation.FrameHeight - height;

            localBounds = new Rectangle(left, top, width, height);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads a particular knife sprite sheet and sounds.
        /// </summary>
        public void LoadContent()
        {
            this.Reset();

            explosion = new GrenadeExplosion(game, position, _player);

            idleAnimation = new Animation(game.Content.Load<Texture2D>("Sprites/Weapons/bomb"), 0.1f, true);
            sprite.PlayAnimation(idleAnimation);

            explosionSound = game.Content.Load<SoundEffect>("Sounds/explosionSound");

            throwSound = game.Content.Load<SoundEffect>("Sounds/throwSound");
            bombSound = game.Content.Load<SoundEffect>("Sounds/bombSound");
            bombSoundInstance = bombSound.CreateInstance();
            bombSoundInstance.IsLooped = true;
            bombSoundInstance.Volume = 0.55f;

            // Calculate bounds within texture size.
            int width = (int)(idleAnimation.FrameWidth * 0.4);
            int left = (idleAnimation.FrameWidth - width) / 2;
            int height = 10;
            int top = idleAnimation.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);
        }