private void DecideWhatToSpawn(List <AITaskCommand> aiTaskCommands, AISpawnStrategy strategySpawn) { int currentBlood = _bloodController.GetCurrentAIBlood(); List <EntityBloodCost> costs = strategySpawn.entitiesBloodCost; for (int i = 0; i < costs.Count; i++) { if (costs[i].bloodCost <= currentBlood) { SpawnAITaskCommand spawnCommand = new SpawnAITaskCommand(costs[i].entity, _highLevelAi.SpawnableCells); aiTaskCommands.Insert(0, spawnCommand); currentBlood -= costs[i].bloodCost; } else { break; } } }
public void AnalyzeGameTerrain(StrategicObjective chosenStrategicObjective, AISpawnStrategy aiSpawnStrategy) { //declaramos la lisa de pequeños comandos que realizara la ia List <AITaskCommand> aiTaskCommands = new List <AITaskCommand>(); LevelController levelController = Object.FindObjectOfType <LevelController>(); Entity[] IAcontrolledEntities = levelController.AIEntities.ToArray(); Entity[] playerControlledEntites = levelController.PlayerEntities.ToArray(); //check your controlled entities and see the influences they have in their surroundings //en funcion del objetivo estrategico se fijaran las tareas que podran ser de un tipo o de otro. for (int i = 0; i < IAcontrolledEntities.Length; i++) { AnalyzeSurroundingInfluences(aiTaskCommands, chosenStrategicObjective, IAcontrolledEntities[i], playerControlledEntites, levelController); } Debug.Log(aiTaskCommands.Count); _tasksAllocator.OnTaskCommandsReceived(aiTaskCommands, IAcontrolledEntities, aiSpawnStrategy); }
public void OnTaskCommandsReceived(List <AITaskCommand> aiTaskCommands, Entity[] controlledEntities, AISpawnStrategy aISpawnStrategy) { LevelController _levelController = Object.FindObjectOfType <LevelController>(); //analiar los recursos de sangre que tenemos //en funcion de esos recursos y las tareas que tenemos decidir //antes de llamar a todos lo comandos hay que ver si hay una desproporcion entre tareas //y tropas controladas por nosotros //todo cambiar el magic number por un parametro desde el high level if (IsSpawnNeeded(aiTaskCommands, _levelController.AIEntities.ToArray(), _levelController.PlayerEntities.ToArray(), 2)) { DecideWhatToSpawn(aiTaskCommands, aISpawnStrategy); } _highLevelAi.StartCoroutine(PerformDifferentTasks(aiTaskCommands)); //añadirlo a una cola en algun monobehaviour para que una corutina lo vaya sacando poco a poco. Debug.Log("AI Done"); //_turnHandler.AIDone = true; }