コード例 #1
0
 private void HandleMovement(float horizontal)
 {
     if (charaRigidbody2D.velocity.y < 0)
     {
         CharaAnimator.SetBool("land", true);
     }
     if (!attack && !guard && !crouch && (onGround || airControl))
     {
         charaRigidbody2D.velocity = new Vector2(horizontal * movementSpeed, charaRigidbody2D.velocity.y);
     }
     if (jump && charaRigidbody2D.velocity.y == 0)
     {
         charaRigidbody2D.AddForce(new Vector2(0, jumpForce));
     }
     CharaAnimator.SetFloat("speed", Mathf.Abs(horizontal));
 }
コード例 #2
0
    public override IEnumerator TakeDamage(float damagePoint)
    {
        if (!immortal)
        {
            health -= (int)damagePoint;
            healthBar.GetComponent <HealthBar> ().UpdateHealthBar(health);
            if (CharaAnimator.GetBool("crouch"))
            {
                CharaAnimator.SetBool("crouch", false);
            }

            if (!IsDead)
            {
                CharaAnimator.SetTrigger("damage");
                if (damageCounter < 2)
                {
                    damageCounter += 1;
                    CharaAnimator.SetInteger("damageCounter", damageCounter);
                }
                else
                {
                    immortal = true;

                    StartCoroutine(IndicateImmortal());
                    yield return(new WaitForSeconds(immortalTime));

                    immortal = false;

                    damageCounter = 0;
                    CharaAnimator.SetInteger("damageCounter", damageCounter);
                }
            }
            else
            {
                CharaAnimator.SetLayerWeight(1, 0);
                CharaAnimator.SetTrigger("die");
                WinLoseManager.Instance.setWinLoseState(WinLoseManager.WinloseState.player2Win);
                BattleSceneManager.Instance.State = BattleSceneManager.BattleSceneState.winLosePose;
            }

            yield return(null);
        }
    }
コード例 #3
0
    private void HandleInput()
    {
        if (Input.GetKeyDown(KeyCode.X) || Input.GetKeyDown("joystick button 0"))
        {
            if (!CharaAnimator.GetBool("crouch"))
            {
                CharaAnimator.SetTrigger("jump");
            }

            //FuzzyStateMachines.Instance.initiateFuSMs();
            //FuzzyStateMachines.Instance.runFuSMs();
        }
        if (Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown("joystick button 3"))
        {
            CharaAnimator.SetTrigger("lightAttack");
            if (!jump)
            {
                PlayerInputManager.instance.getCountMovement(MovementType.playerCounter.lightAttack).addLaunchedMovement(1);
                PlayerInputManager.instance.getCountMovement(MovementType.playerCounter.middleDirection).addLaunchedMovement(1);
            }
            else
            {
                PlayerInputManager.instance.getCountMovement(MovementType.playerCounter.lightAttack).addLaunchedMovement(1);
                PlayerInputManager.instance.getCountMovement(MovementType.playerCounter.upDirection).addLaunchedMovement(1);
            }

            PlayerInputManager.instance.getTotalInput().addLaunchedMovement(1);

            //FuzzyStateMachines.Instance.initiateFuSMs();
            //FuzzyStateMachines.Instance.runFuSMs();
        }
        if (Input.GetKeyDown(KeyCode.C) || Input.GetKeyDown("joystick button 4"))
        {
            CharaAnimator.SetTrigger("rangedAttack");
            if (!jump)
            {
                PlayerInputManager.instance.getCountMovement(MovementType.playerCounter.rangedAttack).addLaunchedMovement(1);
                PlayerInputManager.instance.getCountMovement(MovementType.playerCounter.middleDirection).addLaunchedMovement(1);
            }
            else
            {
                PlayerInputManager.instance.getCountMovement(MovementType.playerCounter.rangedAttack).addLaunchedMovement(1);
                PlayerInputManager.instance.getCountMovement(MovementType.playerCounter.upDirection).addLaunchedMovement(1);
            }

            PlayerInputManager.instance.getTotalInput().addLaunchedMovement(1);

            //FuzzyStateMachines.Instance.initiateFuSMs();
            //FuzzyStateMachines.Instance.runFuSMs();
        }
        if (Input.GetKeyDown(KeyCode.V) || Input.GetKeyDown("joystick button 1"))
        {
            CharaAnimator.SetTrigger("heavyAttack"); //it's become crouch attack, if character is already in crouch position
            if (!crouch)
            {
                PlayerInputManager.instance.getCountMovement(MovementType.playerCounter.heavyAttack).addLaunchedMovement(1);
                PlayerInputManager.instance.getCountMovement(MovementType.playerCounter.middleDirection).addLaunchedMovement(1);
            }
            else
            {
                PlayerInputManager.instance.getCountMovement(MovementType.playerCounter.heavyAttack).addLaunchedMovement(1);
                PlayerInputManager.instance.getCountMovement(MovementType.playerCounter.bottomDirection).addLaunchedMovement(1);
            }

            PlayerInputManager.instance.getTotalInput().addLaunchedMovement(1);

            //FuzzyStateMachines.Instance.initiateFuSMs();
            //FuzzyStateMachines.Instance.runFuSMs();
        }

        //---------------delete this because this fitur is unused-------------------
        if (Input.GetKeyDown(KeyCode.F))
        {
            CharaAnimator.SetBool("guard", true);
        }
        else if (Input.GetKeyUp(KeyCode.F))
        {
            CharaAnimator.SetBool("guard", false);
        }
        //--------------------------------------------------------------------------

        if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetAxis("Vertical") < -0.75f)            //INI MASIH TES!!!!!!!!!!!!!!!!!!!!!!!!!!!
        {
            if (onGround && !jump)
            {
                CharaAnimator.SetBool("crouch", true);
            }

            //FuzzyStateMachines.Instance.initiateFuSMs();
            //FuzzyStateMachines.Instance.runFuSMs();
        }
        else if (Input.GetKeyUp(KeyCode.DownArrow) || Input.GetAxis("Vertical") == 0.0f)
        {
            CharaAnimator.SetBool("crouch", false);
        }
    }
コード例 #4
0
 public void beginingPoseExit()
 {
     CharaAnimator.SetBool("beginingPose", false);
 }