Esempio 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);
        }
    }
Esempio n. 2
0
 public int DoDamage()
 {
     if (Array.IndexOf(AnimationStates.GetAttacks(), animationStatus) >= 0)
     {
         return(character.GetAttackOutput(animationStatus));
     }
     return(0);
 }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if ((currentCharacter.IsAnimationPlaying() && !currentCharacter.GetIsJumping() && !currentCharacter.GetIsHit()) ||
            currentCharacter.GetAnimationStatus() == AnimationStates.STANDING)
        { //In case the animation goes from walking to other animation, prevents from sliding behaviour
            rigidBody.velocity = new Vector2(0, 0);
        }
        rivalCharacter = rivalCharacters.transform.GetChild(0).GetComponent <CharacterFeatures>(); //Has to be done constantly in case it changes

        if (!currentCharacter.GetIsBlocked() && !currentCharacter.GetIsDead())
        {
            AIConditionChecking.CheckTimer(currentTimer.GetTimer());
            AIConditionChecking.CheckCharacterStates(currentCharacter);
            AIConditionChecking.CheckDistance(characterActions);
            AIConditionChecking.CheckCharacterHealth(currentTimer.GetTimer(), characters, rivalCharacters);
            AIConditionChecking.CheckCharacterSwap(characterAssist, currentCharacter, characters);



            if (currentCharacter.GetAnimationStatus() != AnimationStates.WALK_BACKWARDS || characterAction != AnimationStates.BLOCKING_JUMPING ||
                characterAction != AnimationStates.BLOCKING_CROUCHING)
            {
                characterActions.StopBlocking();
            }

            PerformWalkState();
            BugFixStandingIsJumping();



            if (Array.IndexOf(AnimationStates.GetIdleMovements(), currentCharacter.GetAnimationStatus()) >= 0)
            {
                Invoke("PerformNewAction", 2);
                ExecuteRules(rulesEngineSwapCharacter);
                if (Array.IndexOf(AnimationStates.GetAttacks(), rivalCharacter.GetAnimationStatus()) >= 0)
                {
                    ExecuteRules(rulesEngineRivalAttacks);
                }
                if (Array.IndexOf(AnimationStates.GetTakingDamageStates(), rivalCharacter.GetAnimationStatus()) >= 0)
                {
                    ExecuteRules(rulesEngineRivalIsHit);
                }
                if (Array.IndexOf(AnimationStates.GetBlockingStates(), rivalCharacter.GetAnimationStatus()) >= 0)
                {
                    ExecuteRules(rulesEngineRivalBlocks);
                }
                if (rivalCharacter.GetAnimationStatus() == AnimationStates.WALK_BACKWARDS)
                {
                    ExecuteRules(rulesEngineRivalBackwards);
                }
                if (rivalCharacter.GetAnimationStatus() == AnimationStates.WALK_FORWARDS)
                {
                    ExecuteRules(rulesEngineRivalForwards);
                }
                if (rivalCharacter.GetAnimationStatus() == AnimationStates.JUMPING_BACKWARDS)
                {
                    ExecuteRules(rulesEngineRivalJumpingBackwards);
                }
                if (rivalCharacter.GetAnimationStatus() == AnimationStates.JUMPING_FORWARDS)
                {
                    ExecuteRules(rulesEngineRivalJumpingForwards);
                }
                if (rivalCharacter.GetAnimationStatus() == AnimationStates.STANDING || rivalCharacter.GetAnimationStatus() == AnimationStates.CROUCHING ||
                    rivalCharacter.GetAnimationStatus() == AnimationStates.JUMPING_DOWN || rivalCharacter.GetAnimationStatus() == AnimationStates.JUMPING_UP ||
                    rivalCharacter.GetAnimationStatus() == AnimationStates.CROUCH)
                {
                    ExecuteRules(rulesEngineRivalIdle);
                }
            }
        }
    }