Пример #1
0
        /// <summary>
        /// Initializes the Character.
        /// </summary>
        /// <param name="map">The Map to place the Character on.</param>
        /// <param name="skelManager">The SkeletonManager to use for the Character's skeletons.</param>
        public virtual void Initialize(Map map, SkeletonManager skelManager)
        {
            // HACK: This is quite a dirty way to do this
            _map = map;
            _interpolator.Teleport(Position);

            _characterSprite = CreateCharacterSprite(this, this, skelManager);

            CharacterSprite.SetSet(BodyInfo.Stand, BodyInfo.Size);
            CharacterSprite.SetBody(BodyInfo.Body);
        }
Пример #2
0
        /// <summary>
        /// Updates the character's sprites.
        /// Only used in sidescroller builds.
        /// </summary>
        protected virtual void UpdateAnimation()
        {
#if !TOPDOWN
            // Only update if the state has changed
            if (_lastState == State)
            {
                return;
            }

            _lastState = State;

            switch (State)
            {
            case CharacterState.Idle:
                CharacterSprite.SetSet(BodyInfo.Stand, BodyInfo.Size);
                break;

            case CharacterState.Falling:
            case CharacterState.FallingLeft:
            case CharacterState.FallingRight:
                CharacterSprite.SetSet(BodyInfo.Fall, BodyInfo.Size);
                break;

            case CharacterState.Jumping:
            case CharacterState.JumpingLeft:
            case CharacterState.JumpingRight:
                CharacterSprite.SetSet(BodyInfo.Jump, BodyInfo.Size);
                break;

            case CharacterState.WalkingLeft:
            case CharacterState.WalkingRight:
                CharacterSprite.SetSet(BodyInfo.Walk, BodyInfo.Size);
                break;
            }
#endif
        }