コード例 #1
0
    void Update()
    {
        if (!currentCharacter.GetIsBlocked() && !currentCharacter.GetIsAI())
        {
            if (Input.GetKeyDown(GameConstants.A1))
            {  ///Swap for first assist character
                /////Executes only one command, one function checks if the swap is available and performs it if so
                Swap("Assist1", false);
            }

            if (Input.GetKeyDown(GameConstants.A2))
            {  ///Swap for second assist character
                Swap("Assist2", false);
            }
        }
    }
コード例 #2
0
    /*public void falling(){       ///////JUST IN CASE/////////////Loops last frames of falling animation
     *          animator.Play(AnimationStates.JUMPING_DOWN,0,0.5f);
     *  }*/

    /////////////////

    void Update()
    {
        if ((currentCharacter.IsAnimationPlaying() && !currentCharacter.GetIsJumping() && !currentCharacter.GetIsHit()))
        { //In case the animation goes from walking to other animation, prevents from sliding behaviour
            rigidBody.velocity = new Vector2(0, 0);
        }

        if (!currentCharacter.GetIsBlocked())
        {
            ///Moving
            animator.SetFloat("Horizontal", 0);  //Sets the horizontal back to 0 so that the animator can move from walking to standing (if not, loops the walking animation)

            // When character moves right (depending on side of the field)
            if ((Input.GetKey(GameConstants.R)))
            {
                switch (currentCharacter.GetIsFlipped())
                {
                case true: characterActions.Walk(rigidBody, animator, AnimationStates.WALK_BACKWARDS); break;

                case false: characterActions.Walk(rigidBody, animator, AnimationStates.WALK_FORWARDS); break;
                }
            }
            // When character moves left (depending on side of the field)
            else if ((Input.GetKey(GameConstants.L)))
            {
                switch (currentCharacter.GetIsFlipped())
                {
                case true: characterActions.Walk(rigidBody, animator, AnimationStates.WALK_FORWARDS); break;

                case false: characterActions.Walk(rigidBody, animator, AnimationStates.WALK_BACKWARDS); break;
                }
            }

            if (Input.GetKeyUp(GameConstants.L) || Input.GetKeyUp(GameConstants.R))
            {
                characterActions.StopBlocking();
                if (currentCharacter.GetAnimationStatus() == AnimationStates.WALK_BACKWARDS || currentCharacter.GetAnimationStatus() == AnimationStates.WALK_FORWARDS)
                {
                    rigidBody.velocity = new Vector2(0, 0);
                }
            }

            //Blocking
            if ((Input.GetKey(GameConstants.R)) && currentCharacter.GetIsFlipped() || (Input.GetKey(GameConstants.L)) && !currentCharacter.GetIsFlipped())
            {
                characterActions.Block();
            }


            // Crouching
            if (Input.GetKey(GameConstants.D) && !currentCharacter.IsAnimationPlaying() && !currentCharacter.GetIsCrouching() && !currentCharacter.GetIsJumping())
            {
                rigidBody.velocity = new Vector2(0, 0);       //Prevents from sliding
                characterActions.SetCoordinatesWhenLanding(); //Prevents from phasing through the ground if the down button is pressed when the character touches the ground after a jump.
                currentCharacter.PlayAnimation(AnimationStates.CROUCH);
                currentCharacter.SetAnimationStatus(AnimationStates.CROUCH);
                currentCharacter.SetIsCrouching(true);
                currentCharacter.SetAnimationPlaying(false);
            }

            if (Input.GetKeyUp(GameConstants.D) && !currentCharacter.GetIsJumping())
            {
                //SetCoordinatesWhenLanding();
                currentCharacter.SetIsCrouching(false);
                if (!currentCharacter.IsAnimationPlaying())
                {
                    currentCharacter.EndAnimation(AnimationStates.STANDING);
                }
            }

            // Jumping
            if (Input.GetKeyDown(GameConstants.U) && !currentCharacter.IsAnimationPlaying() && !currentCharacter.GetIsCrouching() && !currentCharacter.GetIsJumping())
            {
                if (Input.GetKey(GameConstants.R))
                {
                    characterActions.Jump(rigidBody, "JumpingRight");
                }
                else if (Input.GetKey(GameConstants.L))
                {
                    characterActions.Jump(rigidBody, "JumpingLeft");
                }
                else
                {
                    characterActions.Jump(rigidBody, "JumpingUp");
                }
            }
        }
    }
コード例 #3
0
ファイル: StaticAI.cs プロジェクト: deerter/Scarlet-Flash
    // 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);
                }
            }
        }
    }
コード例 #4
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);
            }
        }
    }