Exemplo n.º 1
0
    private void Awake()
    {
        _agent  = GetComponent <NavMeshAgent>();
        _anim   = GetComponentInChildren <Animator>();
        _stat   = GetComponent <AIStat>();
        _sight  = GetComponentInChildren <Camera>();
        _isInit = false;

        _target         = null;
        _soundResetTime = _soundResetTimer;

        AIState[] stateValues = (AIState[])System.Enum.GetValues(typeof(AIState));
        foreach (AIState s in stateValues)
        {
            System.Type FSMType = System.Type.GetType("AI" + s.ToString());
            AIFSMState  state   = (AIFSMState)GetComponent(FSMType);
            if (null == state)
            {
                state = (AIFSMState)gameObject.AddComponent(FSMType);
            }

            _states.Add(s, state);
            state.enabled = false;
        }
    }
Exemplo n.º 2
0
    private void Awake()
    {
        stat_p = GetComponent <AIStatus>();
        anim_p = GetComponent <Animator>();

        target[0] = gameObject.transform.Find("Monster");
        target[1] = gameObject.transform.Find("BossMonster");

        AIState[] stateValues = (AIState[])System.Enum.GetValues(typeof(AIState));
        foreach (AIState s in stateValues)
        {
            System.Type FSMType = System.Type.GetType("AI" + s.ToString());
            AIFSMState  state   = (AIFSMState)GetComponent(FSMType);

            if (null == state)
            {
                state = (AIFSMState)gameObject.AddComponent(FSMType);
            }

            state_d.Add(s, state);
            state.enabled = false;
        }
    }