Ejemplo n.º 1
0
        /// <summary>
        /// Loads a particular enemy sprite sheet and sounds.
        /// </summary>
        public void LoadContent(string spriteSet)
        {
            // Load animations.
            spriteSet = "Sprites/" + spriteSet + "/";
            runAnimation = new Animation(Level.Content.LoadTexture2D(spriteSet + "Run"), 0.1f, true);
            idleAnimation = new Animation(Level.Content.LoadTexture2D(spriteSet + "Idle"), 0.15f, true);
            dieAnimation = new Animation(Level.Content.LoadTexture2D(spriteSet + "Die"), 0.07f, false);
            sprite = new AnimationPlayer();
            sprite.PlayAnimation(idleAnimation);

            //Load textures
            healthBar = Level.Content.LoadTexture2D("Misc/enemyHealthBar");
            healthBarFill = Level.Content.LoadTexture2D("Misc/enemyHealthBarFill");

            //Load sound effects
            killedSound = Level.Content.LoadSoundEffect("Sounds/MonsterKilled");

            // Calculate bounds within texture size.
            int width = (int)(idleAnimation.FrameWidth * 0.35);
            int left = (idleAnimation.FrameWidth - width) / 2;
            int height = idleAnimation.FrameWidth;
            int top = idleAnimation.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the player sprite sheet and sounds.
        /// </summary>
        public void LoadContent()
        {
            //Load textures
            healthBar = Level.Content.LoadTexture2D("Misc/playerHealthBar");
            healthBarFill = Level.Content.LoadTexture2D("Misc/playerHealthBarFill");

            // Load animated textures.
            idleAnimation = new Animation(Level.Content.LoadTexture2D("Sprites/Player/Idle"), 0.1f, true);
            runAnimation = new Animation(Level.Content.LoadTexture2D("Sprites/Player/Run"), 0.1f, true);
            jumpAnimation = new Animation(Level.Content.LoadTexture2D("Sprites/Player/Jump"), 0.1f, false);
            celebrateAnimation = new Animation(Level.Content.LoadTexture2D("Sprites/Player/Celebrate"), 0.1f, false);
            dieAnimation = new Animation(Level.Content.LoadTexture2D("Sprites/Player/Die"), 0.1f, false);
            shieldAnimation = new Animation(Level.Content.LoadTexture2D("Sprites/Player/Shield"), 0.1f, true);
            healAnimation = new Animation(Level.Content.LoadTexture2D("Sprites/Player/Heal"), 0.1f, true);

            sprite = new AnimationPlayer();

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

            // Load sounds.
            killedSound = Level.Content.LoadSoundEffect("Sounds/PlayerKilled");
            jumpSound = Level.Content.LoadSoundEffect("Sounds/PlayerJump");
            fallSound = Level.Content.LoadSoundEffect("Sounds/PlayerFall");
            healSound = Level.Content.LoadSoundEffect("Sounds/Heal");

            int toLoad = 0;
            while (System.IO.File.Exists("Content/Sounds/Hurt/" + toLoad + ".xnb"))
            {
                hurtSound.Add(Level.Content.LoadSoundEffect("Sounds/Hurt/" + toLoad));
                toLoad++;
            }
        }