//update task when it's upgraded: public void Update(string upgradedUnitCode, Unit targetUnitPrefab, Upgrade.NewTaskInfo newTaskInfo) { //does the current task create the unit that is getting upgraded if (type == TaskTypes.createUnit && unitCreationAttributes.prefabs[0].GetCode() == upgradedUnitCode) { //update task info: unitCreationAttributes.prefabs.Clear(); unitCreationAttributes.prefabs.Add(targetUnitPrefab); description = newTaskInfo.description; icon = newTaskInfo.icon; reloadTime = newTaskInfo.reloadTime; requiredResources = newTaskInfo.newResources.Clone() as ResourceInput[]; } }
//update an upgraded unit creation task's info: private void UpdateUnitCreationTask(TaskLauncher taskLauncher, string upgradedUnitCode, Unit targetUnitPrefab, Upgrade.NewTaskInfo newTaskInfo) { //go through the tasks: for (int i = 0; i < taskLauncher.GetTasksCount(); i++) { taskLauncher.GetTask(i).Update(upgradedUnitCode, targetUnitPrefab, newTaskInfo); } }