예제 #1
0
        public AIAction FindHighestScoreAction(AIManager ai)
        {
            AIAction retVal = null;

            int highest = 0;

            for (int i = 0; i < actionsList.Length; i++)
            {
                if (actionsList[i].scoreCalculation == null)
                {
                    continue;
                }
                int score = actionsList[i].scoreCalculation.Calculate(ai);
                if (score == 0)//if an action has 0 score, its  considered disabled
                {
                    continue;
                }
                if (score > highest)
                {
                    highest = score;
                    retVal  = actionsList[i];
                }
            }
            return(retVal);
        }
예제 #2
0
        public void HandleDecisionsTimer(AIManager ai)
        {
            ai.decisionTimer += ai.delta;
            if (ai.decisionTimer > decisionRate)
            {
                ai.decisionTimer = 0;
                AIAction hightest = FindHighestScoreAction(ai);

                ai.currentAction = hightest;
            }
        }
예제 #3
0
        private void Start()
        {
            states           = GetComponent <StateManager>();
            states.aiManager = this;

            agent = GetComponentInChildren <NavMeshAgent>();

            if (currentActionsHolder != null)
            {
                AIAction hightest = currentActionsHolder.FindHighestScoreAction(this);

                currentAction = hightest;
            }

            weaponHook = GetComponentInChildren <WeaponHook>();
            if (weaponHook != null)
            {
                weaponHook.Init();
            }
        }