Beispiel #1
0
    private void ChangeState(States newState)
    {
        switch (currentState)
        {
        case States.INITIAL:
            break;

        case States.ENEMY_PASSIVE:
            enemyPassiveFsm.enabled = false;
            break;

        case States.NOTICE:
            break;

        case States.CHASE:
            blackboard.animator.SetBool("isCharging", false);
            enemyCol.height = 2.0f;
            enemyCol.center = Vector3.zero;
            blackboard.attackCollider.enabled = false;
            seek.enabled = false;
            blackboard.rb.constraints = RigidbodyConstraints.FreezeRotation;
            break;
        }

        switch (newState)
        {
        case States.INITIAL:
            break;

        case States.ENEMY_PASSIVE:
            enemyPassiveFsm.enabled = true;
            break;

        case States.NOTICE:
            blackboard.animator.SetTrigger("hasNoticed");
            blackboard.NoticeSound();
            break;

        case States.CHASE:
            blackboard.animator.SetBool("isCharging", true);
            enemyCol.height = blackboard.enemyColliderChaseHeight;
            enemyCol.center = enemyCol.center - new Vector3(0, (2.0f - blackboard.enemyColliderChaseHeight) / 2, 0);
            blackboard.attackCollider.enabled = true;
            blackboard.ownKS.maxSpeed         = blackboard.chasingSpeed;
            seek.enabled = true;
            seek.target  = blackboard.player.gameObject;
            break;
        }
        currentState = newState;
        blackboard.statesText.text = currentState.ToString();
    }