コード例 #1
0
ファイル: StaticAI.cs プロジェクト: deerter/Scarlet-Flash
    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);
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (!currentCharacter.GetIsBlocked())
        {
            ///Standing Attacks
            if (Input.GetKeyDown(GameConstants.LP) && !currentCharacter.IsAnimationPlaying() && !currentCharacter.GetIsCrouching() && !currentCharacter.GetIsJumping())
            {
                characterActions.PerformAttack(AnimationStates.LIGHT_PUNCH);
            }

            if (Input.GetKeyDown(GameConstants.LK) && !currentCharacter.IsAnimationPlaying() && !currentCharacter.GetIsCrouching() && !currentCharacter.GetIsJumping())
            {
                characterActions.PerformAttack(AnimationStates.LIGHT_KICK);
            }

            if (Input.GetKeyDown(GameConstants.HP) && !currentCharacter.IsAnimationPlaying() && !currentCharacter.GetIsCrouching() && !currentCharacter.GetIsJumping())
            {
                characterActions.PerformAttack(AnimationStates.HEAVY_PUNCH);
            }

            if (Input.GetKeyDown(GameConstants.HK) && !currentCharacter.IsAnimationPlaying() && !currentCharacter.GetIsCrouching() && !currentCharacter.GetIsJumping())
            {
                characterActions.PerformAttack(AnimationStates.HEAVY_KICK);
            }

            /////Crouching Attacks
            if (Input.GetKeyDown(GameConstants.LP) && currentCharacter.GetIsCrouching() && !currentCharacter.IsAnimationPlaying())
            {
                characterActions.PerformAttack(AnimationStates.CROUCHING_LIGHT_PUNCH);
            }

            if (Input.GetKeyDown(GameConstants.LK) && currentCharacter.GetIsCrouching() && !currentCharacter.IsAnimationPlaying())
            {
                characterActions.PerformAttack(AnimationStates.CROUCHING_LIGHT_KICK);
            }

            if (Input.GetKeyDown(GameConstants.HP) && currentCharacter.GetIsCrouching() && !currentCharacter.IsAnimationPlaying())
            {
                characterActions.PerformAttack(AnimationStates.CROUCHING_HEAVY_PUNCH);
            }

            if (Input.GetKeyDown(GameConstants.HK) && currentCharacter.GetIsCrouching() && !currentCharacter.IsAnimationPlaying())
            {
                characterActions.PerformAttack(AnimationStates.CROUCHING_HEAVY_KICK);
            }

            //////Jumping Attacks
            if (Input.GetKeyDown(GameConstants.LP) && currentCharacter.GetIsJumping() && !currentCharacter.IsAnimationPlaying())
            {
                characterActions.PerformAttack(AnimationStates.JUMPING_LIGHT_PUNCH);
            }

            if (Input.GetKeyDown(GameConstants.LK) && currentCharacter.GetIsJumping() && !currentCharacter.IsAnimationPlaying())
            {
                characterActions.PerformAttack(AnimationStates.JUMPING_LIGHT_KICK);
            }

            if (Input.GetKeyDown(GameConstants.HP) && currentCharacter.GetIsJumping() && !currentCharacter.IsAnimationPlaying())
            {
                characterActions.PerformAttack(AnimationStates.JUMPING_HEAVY_PUNCH);
            }

            if (Input.GetKeyDown(GameConstants.HK) && currentCharacter.GetIsJumping() && !currentCharacter.IsAnimationPlaying())
            {
                characterActions.PerformAttack(AnimationStates.JUMPING_HEAVY_KICK);
            }
        }
    }