Exemple #1
0
        /// <summary>
        /// Creates and initalizes the hero.
        /// Sprite textures are loaded in so we can have different animations and textures.
        /// Animations are loaded in and given a AantalBewegingenPerSeconde.
        /// The collisionrectangle is created using the position of the sprite and the texture.
        /// Health has been set so that the player can die when it hits an enemy or jumps in the water.
        /// </summary>
        /// <param name="content"></param>
        /// <param name="_position"></param>
        public Hero(ContentManager content, Vector2 _position) : base(_position)
        {
            relocator = _position;
            //Textures loaden
            SpriteTexture       = content.Load <Texture2D>("Herosprites/Walking_right");
            runningRightTexture = content.Load <Texture2D>("HeroSprites/Walking_right");
            runningLeftTexture  = content.Load <Texture2D>("HeroSprites/Walking_left");
            jumpingTexture      = content.Load <Texture2D>("HeroSprites/Jumping");

            //Animations loaden
            SpriteAnimation = new AnimationMotion();
            SpriteAnimation.AddAnimation(SpriteTexture, 4);
            SpriteAnimation.CurrentAnimation.AantalBewegingenPerSeconde = 1;

            _runningRightAnimation = new AnimationMotion();
            _runningRightAnimation.AddAnimation(runningRightTexture, 4);
            _runningRightAnimation.CurrentAnimation.AantalBewegingenPerSeconde = 2;
            _runningLeftAnimation = new AnimationMotion();
            _runningLeftAnimation.AddAnimation(runningLeftTexture, 4);
            _runningLeftAnimation.CurrentAnimation.AantalBewegingenPerSeconde = 2;
            _jumpingAnimation = new AnimationMotion();
            _jumpingAnimation.AddAnimation(jumpingTexture, 1);
            _jumpingAnimation.CurrentAnimation.AantalBewegingenPerSeconde = 1;

            //CollisionRectangle loaden
            CollisionRectangle = new Rectangle((int)Position.X, (int)Position.Y, SpriteTexture.Width, SpriteTexture.Height / 4);

            //Make Hero fall to its position
            HasJumped = true;

            //Set Health for 100
            Health        = 100;
            TimesDied     = 0;
            TooManyDeaths = false;
        }
        //
        // Methods
        //

        /// <summary>
        ///		Sets the given motion animator to this GameObject
        /// </summary>
        /// <param name="newAnimator"></param>
        public void SetAnimator(AnimationMotion newAnimator)
        {
            this.animator.CancelTimedAnimation();
            AnimationMotionManager.Active.Recycle(this.ObjectName, Id);
            this.animator = newAnimator;
            this.animator.SetTarget(this);
            newAnimator.ScheduleTimedAnimation();
        }
Exemple #3
0
        /// <summary>
        /// Constructor for the Enemies class.
        /// </summary>
        /// <param name="_texture"></param>
        /// <param name="_position"></param>
        /// <param name="_distance"></param>
        public Enemies(Texture2D _texture, Vector2 _position, float _distance) : base(_position)
        {
            SpriteTexture = _texture;
            distance      = 300;

            oldDistance = distance;

            Health    = 10;
            HasJumped = true;

            //Animations loaden
            SpriteAnimation = new AnimationMotion();
            SpriteAnimation.AddAnimation(SpriteTexture, 4);
            SpriteAnimation.CurrentAnimation.AantalBewegingenPerSeconde = 2;


            CollisionRectangle = new Rectangle((int)Position.X, (int)Position.Y, SpriteTexture.Width, SpriteTexture.Height / 4);
        }
 /// <summary>
 ///		Resets animator information
 /// </summary>
 protected override void ResetAnimator()
 {
     this.animator.CancelTimedAnimation();
     AnimationMotionManager.Active.Recycle(this.ObjectName, Id);
     this.animator = AnimationMotionManager.Active.NullAnimation;
 }
        //
        // Constructors
        //

        public GameObjectMotionAnimated() : base()
        {
            this.animator = AnimationMotionManager.Active.NullAnimation;
        }