public void UpdateMultipleAttackTasks(FactionEntity sourceEntity, MultipleAttackManager multipleAttackComp) { if (multipleAttackComp == null) { return; } for (int attackID = 0; attackID < multipleAttackComp.AttackEntities.Length; attackID++) //go through all the attack entities { AttackEntity attackComp = multipleAttackComp.AttackEntities[attackID]; if (!attackComp.IsLocked && !attackComp.IsActive()) //as long as the attack entity is not active and not locked, show a task to activate it: { TaskUI taskUI = Add(new TaskUIAttributes { ID = attackID, type = TaskTypes.attackTypeSelection, icon = attackComp.GetIcon(), source = sourceEntity }, multipleAttackComp.GetTaskPanelCategory()); if (attackComp.CoolDownActive == true) //if the attack type is in cool down mode { Color nextColor = taskUI.GetComponent <Image>().color; nextColor.a = 0.5f; //make it semi-transparent to indicate cooldown to player taskUI.GetComponent <Image>().color = nextColor; } } } }
public void UpdateBuilderTasks(Unit sourceUnit, Builder builderComp) { if (sourceUnit == null || builderComp == null) { return; } int buildingID = -1; foreach (Building building in gameMgr.PlacementMgr.GetBuildings()) //go through all the placeable buildings { buildingID++; if (!builderComp.CanBuild(building)) //if the next building can't be constructed by the selected builders { continue; //move to then next one } TaskUI taskUI = Add(new TaskUIAttributes { ID = buildingID, icon = building.GetIcon(), source = sourceUnit, type = TaskTypes.placeBuilding }, building.GetTaskPanelCategory()); //if the building type has reached its faction limit then show it with the color red taskUI.GetComponent <Image>().color = sourceUnit.FactionMgr.HasReachedLimit(building.GetCode(), building.GetCategory()) ? Color.red : Color.white; } }
public void UpdateTaskLauncherTasks(FactionEntity sourceEntity, TaskLauncher taskLauncher) { if (taskLauncher == null || taskLauncher.Initiated == false || taskLauncher.GetTasksCount() == 0) //if the task launcher is invalid or the source can't manage a task { return; } for (int taskID = 0; taskID < taskLauncher.GetTasksCount(); taskID++) //go through all tasks { FactionEntityTask task = taskLauncher.GetTask(taskID); if (task.IsEnabled() == true) { TaskUI taskUI = Add(new TaskUIAttributes { ID = taskID, type = task.GetTaskType(), icon = task.GetIcon(), source = sourceEntity, taskLauncher = taskLauncher }, task.GetTaskPanelCategory()); if (task.GetTaskType() == TaskTypes.createUnit) //if this is a unit creation task, check if it has reached its limit and change task ui image color accordinly { taskUI.GetComponent <Image>().color = sourceEntity.FactionMgr.HasReachedLimit(task.UnitCode, task.UnitCategory) == true ? Color.red : Color.white; } } } UpdateInProgressTasks(taskLauncher); //show the in progress tasks }