Beispiel #1
0
        /// <summary>
        /// Begins or continues playback of an animation.
        /// </summary>
        public void PlayAnimation(Animation animation)
        {
            // If this animation is already running, do not restart it.
            if (Animation == animation)
                return;

            // Start the new animation.
            this.animation = animation;
            this.frameIndex = 0;
            this.time = 0.0f;
        }
Beispiel #2
0
        /// <summary>
        /// Loads a particular enemy sprite sheet and sounds.
        /// </summary>
        public void LoadContent(string spriteSet)
        {
            #region Load animated textures and sounds.

            if (content == null)
                content = new ContentManager(Statics.Game.Services, "Content");

            // Load animations.
            spriteSet = "Sprites/" + spriteSet + "/";
            walkAnimation = new Animation(content.Load<Texture2D>(spriteSet + "Walk"), 0.1f, true);
            dieAnimation = new Animation(content.Load<Texture2D>(spriteSet + "Die"), 0.15f, false);
            finalCombo1Animation = new Animation(content.Load<Texture2D>(spriteSet + "Combo1"), 0.1f, false);
            finalCombo2Animation = new Animation(content.Load<Texture2D>(spriteSet + "Combo2"), 0.1f, false);
            reactionAnimation = new Animation(content.Load<Texture2D>(spriteSet + "Reaction"), 0.1f, false);
            fireReactionAnimation = new Animation(content.Load<Texture2D>(spriteSet + "FireReaction"), 0.1f, false);
            fallAnimation = new Animation(content.Load<Texture2D>(spriteSet + "Fall"), 0.13f, false);
            fireFallAnimation = new Animation(content.Load<Texture2D>(spriteSet + "FireFall"), 0.2f, false);
            idleAnimation = new Animation(content.Load<Texture2D>(spriteSet + "idle"), 0.1f, false);

            killedSound = content.Load<SoundEffect>("Sounds/PlayerKilled");
            hurtSound = content.Load<SoundEffect>("Sounds/EnemyHurt");

            sprite.PlayAnimation(idleAnimation);

            #endregion

            // Calculate bounds within texture size.
            int width = (int)(idleAnimation.FrameWidth * 0.35);
            int left = (idleAnimation.FrameWidth - width) / 2;
            int height = (int)(idleAnimation.FrameWidth * 0.7);
            int top = idleAnimation.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);
            oneFrame = new Rectangle(left, top, FrameWidth, FrameHeight);
            extendedBounds = new Rectangle(BoundingRectangle.Left, BoundingRectangle.Top, BoundingRectangle.Width + 25, BoundingRectangle.Height);
            minimizedBounds = new Rectangle(left, top, width, height);

        }
Beispiel #3
0
        /// <summary>
        /// Loads the player sprite sheet and sounds.
        /// </summary>
        public void LoadContent()
        {
            #region Load animated textures and sounds.

            if (content == null)
                content = new ContentManager(Statics.Game.Services, "Content");

            // Load animated textures.
            idleAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Idle"), 0.1f, true);  
            runAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Run"), 0.1f, true);
            jumpAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Jump"), 0.1f, true);
            dieAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Die"), 0.1f, false);
            kickAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Kick"), 0.02f, false);
            punchAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Punch"), 0.08f, false);
            comboKickAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/ComboKick"), 0.055f, false);
            firePunch1Animation = new Animation(content.Load<Texture2D>("Sprites/Player/FirePunch1"), 0.06f, false);
            firePunch2Animation = new Animation(content.Load<Texture2D>("Sprites/Player/FirePunch2"), 0.06f, false);
            firePunch3Animation = new Animation(content.Load<Texture2D>("Sprites/Player/FirePunch3"), 0.06f, false);
            punchUpAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/PunchUp"), 0.08f, false);
            finalCombo2Animation = new Animation(content.Load<Texture2D>("Sprites/Player/FinalCombo"), 0.08f, false);
            reactionAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Reaction"), 0.04f, false);
            fallAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Fall"), 0.08f, false);
            upgradeAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Upgrade"), 0.2f, false);
            specialAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/SpecialCombo"), 0.05f, false);

            // Load sounds.            
            killedSound = content.Load<SoundEffect>("Sounds/PlayerKilled");
            jumpSound = content.Load<SoundEffect>("Sounds/PlayerJump");
            HitSound = content.Load<SoundEffect>("Sounds/Hit");
            firePunchSound = content.Load<SoundEffect>("Sounds/FirePunch");
            finalComboSound = content.Load<SoundEffect>("Sounds/finalComboSound");

            font = content.Load<SpriteFont>("Fonts/MenuFont");
            #endregion

            // 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);
            oneFrame = new Rectangle(left, top, FrameWidth, FrameHeight);
        }