Пример #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;
        }
    }
Пример #2
0
 private void Awake()
 {
     anim   = GetComponent <Animator>();
     status = GetComponent <AIStatus>().stat;
 }
Пример #3
0
        public void ChooseAction(ulong id, AIStat aiStat, CombatInstance instance)
        {
            ulong[] actions = aInventorySystem.GetHand(id);
            if (actions == null) return;

            int count = 4;
            List<ulong> canUse = new List<ulong>();
            for (int i = 0; i < count; i++)
            {
                if (actions[i] != 0)
                    if (CanPerform(id, actions[i])) canUse.Add(actions[i]);
            }

            count = canUse.Count;
            if (count == 0) return;
            ShuffleBag<ulong> actionBag = new ShuffleBag<ulong>();

            for (int i = 0; i < count; i++)
            {
                string s = actionSystem.GetActionKey(canUse[i]);
                switch (aiStat)
                {
                    case AIStat.AGGRESSION:
                        actionBag.Add(canUse[i], (int)actionSystem.GetAggression(s));
                        break;
                    case AIStat.BALANCE:
                        actionBag.Add(canUse[i], (int)actionSystem.GetBalance(s));
                        break;
                    case AIStat.DEFENSE:
                        actionBag.Add(canUse[i], (int)actionSystem.GetDefense(s));
                        break;
                }
            }

            PerformAction(id, actionBag.Next(), instance);
        }