Ejemplo n.º 1
0
    private void ExecuteAction()
    {
        if ((Array.IndexOf(AnimationStates.GetAttacks(), characterAction) >= 0))
        {
            characterActions.PerformAttack(characterAction);
        }
        else if (characterAction == AnimationStates.WALK_BACKWARDS)
        {
            characterActions.Block();
            characterActions.Walk(rigidBody, animator, AnimationStates.WALK_BACKWARDS);
        }
        else if (characterAction == AnimationStates.WALK_FORWARDS)
        {
            characterActions.Walk(rigidBody, animator, AnimationStates.WALK_FORWARDS);
        }
        else if (characterAction == AnimationStates.STANDING && !currentCharacter.GetIsJumping())
        {
            animator.SetFloat("Horizontal", 0);
            currentCharacter.EndAnimation(AnimationStates.STANDING);
        }
        else if (characterAction == AnimationStates.JUMPING_BACKWARDS)
        {
            switch (currentCharacter.GetIsFlipped())
            {
            case true: characterActions.Jump(rigidBody, "JumpingRight"); break;

            case false: characterActions.Jump(rigidBody, "JumpingLeft"); break;
            }
        }
        else if (characterAction == AnimationStates.JUMPING_FORWARDS)
        {
            switch (currentCharacter.GetIsFlipped())
            {
            case true: characterActions.Jump(rigidBody, "JumpingLeft"); break;

            case false: characterActions.Jump(rigidBody, "JumpingRight"); break;
            }
        }
        else if (characterAction == AnimationStates.JUMPING_UP)
        {
            characterActions.Jump(rigidBody, "JumpingUp");
        }
        else if (characterAction == AnimationStates.BLOCKING_JUMPING || characterAction == AnimationStates.BLOCKING_CROUCHING)
        {
            characterActions.Block();
            characterActions.Invoke("StopBlocking", 5);   //// Stops blocking after x seconds
        }


        ///// Swap characters
        if (characterAction == "SwapCharacter2")
        {
            characterAssist.Swap("Assist1", false);
        }
        else if (characterAction == "SwapCharacter3")
        {
            characterAssist.Swap("Assist2", false);
        }
    }