public static PlayerAnimation GetAnimation(string key)
        {
            PlayerAnimation returnValue = new PlayerAnimation();

            switch (key)
            {
            case ("Idle"):
                returnValue.animation     = new Animation("Player_Idle");
                returnValue.textureOffset = new Vector2(0, 0);
                returnValue.textureOrigin = new Vector2(32, 128);
                break;

            case ("JumpCharge"):
                returnValue.animation     = new Animation("Player_JumpCharge");
                returnValue.textureOffset = new Vector2(0, 0);
                returnValue.textureOrigin = new Vector2(32, 128);
                break;

            case ("Jump"):
                returnValue.animation       = new Animation("Player_Jump");
                returnValue.animation.speed = .7f;
                returnValue.textureOffset   = new Vector2(0, 0);
                returnValue.textureOrigin   = new Vector2(32, 128);
                break;

            case ("KickFlip"):
                returnValue.animation       = new Animation("Player_Jump");
                returnValue.animation.speed = .7f;
                returnValue.textureOffset   = new Vector2(0, 0);
                returnValue.textureOrigin   = new Vector2(32, 128);
                break;

            case ("Accelerate"):
                returnValue.animation       = new Animation("Player_Accelerate");
                returnValue.animation.speed = .7f;
                returnValue.textureOffset   = new Vector2(0, 10);
                returnValue.textureOrigin   = new Vector2(32, 128);
                break;

            default:
                returnValue.animation     = new Animation("Player_Idle");
                returnValue.textureOffset = new Vector2(0, 0);
                returnValue.textureOrigin = new Vector2(32, 128);
                break;
            }

            return(returnValue);
        }
Exemple #2
0
        public void SetAnimation(string key)
        {
            animationKey = key;
            PlayerAnimation value = PlayerAnimation.GetAnimation(key);

            textureOffset = value.textureOffset;
            textureOrigin = value.textureOrigin;
            animation     = value.animation;

            board.SetAnimation(key);

            if (board.animationFreeze && !animationFreeze)
            {
                animationSpeedPrev = animation.speed;
                animation.speed    = 0;
            }
            else if (!board.animationFreeze && animationFreeze)
            {
                animation.speed = animationSpeedPrev;
            }
        }