Example #1
0
        public void RequestsAttackState(GameObject reqEnemy)
        {
            Debug.Log("Request Attack State");

            AIController enemyController = _enemyControllers[reqEnemy];

            bool flagTaken = false;

            foreach (KeyValuePair <GameObject, AIController> item in _enemyControllers)
            {
                //If even one AI Controller has the flag then stop the others from grabbing it
                if (item.Value.HasAttackFlag)
                {
                    flagTaken = true;
                }
            }

            //If any AIController has the flag then don't continue
            if (flagTaken)
            {
                Debug.Log("Flag Was Taken");
                enemyController.EvasiveStateChange(enemyController);
            }
            else
            {
                Debug.Log("Flag Free");
                if (enemyController != null && !enemyController.HasAttackFlag)
                {
                    Debug.Log("Make Attack");
                    enemyController.HasAttackFlag = true;
                    enemyController.AttackStateChange(enemyController);
                }
            }
        }