Exemplo n.º 1
0
    void Awake()
    {
        playerTr = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();
        sense    = GetComponent <BokoblinSense>();
        state    = GetComponent <BokoblinState>();
        attack   = GetComponent <BokoblinAttack>();
        agent    = GetComponent <MoveAgent>();
        ani      = GetComponent <BokoblinAnimationCtrl>();
        uiCtrl   = GetComponent <EnemyUICtrl>();
        ragdolls = GetComponentsInChildren <Rigidbody>();
        foreach (Rigidbody bone in ragdolls) // 시작시 래그돌과 콜라이더를 꺼준다
        {
            if (bone.GetComponent <Rigidbody>() != GetComponent <Rigidbody>())
            {
                if (!bone.CompareTag("Weapon"))
                {
                    bone.isKinematic = true;
                    bone.GetComponent <Collider>().enabled = false;
                }
            }
        }

        (root = Selector.Make()).
        AddChild(ActionNode.Make(CheckState)).
        // 전투
        AddChild(Sequence.Make().
                 AddChild(ActionNode.Make(IsAlert)).
                 AddChild(ActionNode.Make(CheckMoveToFoe)).
                 AddChild(ActionNode.Make(AttackFoe)).
                 AddChild(ActionNode.Make(CheckFoeDead))
                 ).
        // 의심
        AddChild(Selector.Make().
                 AddChild(ActionNode.Make(IsAlert)).
                 AddChild(ActionNode.Make(SenseFoe))
                 ).
        // 유휴
        AddChild(Selector.Make().
                 AddChild(ActionNode.Make(IsAlert)).
                 AddChild(ActionNode.Make(Idle))
                 );
    }
 private void Awake()
 {
     state  = GetComponentInParent <BokoblinState>();
     attack = GetComponentInParent <BokoblinAttack>();
     bokoTr = GetComponentInParent <Transform>().parent;
 }