void CreateTask(Building building) { UnitTask tempTask = TaskLibrary.Get().CreateTask(UnitTask.TaskType.Build, building.transform.position, building.gameObject); building._BuildTask = tempTask; TaskList.AddTaskToGlobalTaskList(tempTask); }
private void Update() { //check if its fallen through floor if (transform.position.y < -1) { transform.position = new Vector3(transform.position.x, 5, transform.position.z); } if (_timmer > 2 && !_added) { UnitTask tempTask = new UnitTask { _location = transform.position, _taskType = UnitTask.TaskType.Pickup, _taskDescription = "Transporting an Ore", _itemToPickUp = transform.gameObject, _itemType = UnitTask.ItemType.Ore, _requiredTool = Unit.UnitTool.none }; if (SettingScript.instance.UnitPriority == 0) { TaskList.AddTaskToGlobalTaskList(tempTask); } else { TaskList.Tasks.Insert(0, tempTask); } _added = true; } else { _timmer += Time.deltaTime; } }
/// <summary> /// When selecting to pick up a resource, create pick up task depending on resource type and add to task list /// </summary> public void PickUpResource() { if (_ore != null) { TaskList.AddTaskToGlobalTaskList(TaskLibrary.Get().CreateTask(UnitTask.TaskType.Pickup, _ore.transform.position, _ore.gameObject)); //UnitTask tempTask = new UnitTask //{ // _location = _ore.transform.position, // _taskType = UnitTask.TaskType.Pickup, // _taskDescription = "Transporting an Ore", // _itemToPickUp = _ore.transform.gameObject, // _itemType = UnitTask.ItemType.Ore, // _requiredTool = Unit.UnitTool.none //}; //AddTaskToGlobalTaskList(tempTask); } else if (_energyCrystal != null) { TaskList.AddTaskToGlobalTaskList(TaskLibrary.Get().CreateTask(UnitTask.TaskType.Pickup, _energyCrystal.transform.position, _energyCrystal.gameObject)); //UnitTask tempTask = new UnitTask //{ // _location = _energyCrystal.transform.position, // _taskType = UnitTask.TaskType.Pickup, // _taskDescription = "Transporting an Ore", // _itemToPickUp = _energyCrystal.transform.gameObject, // _itemType = UnitTask.ItemType.EnergyCrystal, // _requiredTool = Unit.UnitTool.none //}; //AddTaskToGlobalTaskList(tempTask); } }
// Start is called before the first frame update void Start() { _worldController = WorldController.GetWorldController; _soundManager = _worldController._soundManager; if (_rubble.GetComponentInChildren <MeshRenderer>().material.name.Contains("Dirt")) { _rockType = RockScript.Type.Dirt; } else if (_rubble.GetComponentInChildren <MeshRenderer>().material.name.Contains("LooseRock")) { _rockType = RockScript.Type.LooseRock; } else if (_rubble.GetComponentInChildren <MeshRenderer>().material.name.Contains("SolidRock")) { _rockType = RockScript.Type.HardRock; } UnitTask tempTask = new UnitTask { _location = _rubble.transform.position, _taskType = UnitTask.TaskType.ClearRubble, _targetRubble = this, _requiredTool = Unit.UnitTool.Shovel, _taskDescription = "Clearing rubble" }; TaskList.AddTaskToGlobalTaskList(tempTask); if (_energyCrystal) { if (_rockType == RockScript.Type.Dirt) { _objectAmount = 1; } else if (_rockType == RockScript.Type.LooseRock) { _objectAmount = 2; } else if (_rockType == RockScript.Type.HardRock) { _objectAmount = 3; } _stateSwichWait = _brakeTime / _objectAmount; _stateSwichTime = _brakeTime - _stateSwichWait; } else { if ((_objectAmount = Random.Range(_minDropedObject, _maxDropedObject)) != 0) { _stateSwichWait = _brakeTime / _objectAmount; _stateSwichTime = _brakeTime - _stateSwichWait; } } }
public void SetTask(UnitTask theTask) { _taskSetup = false; _gotItem = false; PlayOrderSound(); switch (_vType) { case VehicleType.smallDrill: if (theTask != null) { if (theTask._taskType == UnitTask.TaskType.Mine || theTask._taskType == UnitTask.TaskType.RechargeVehicle || theTask._taskType == UnitTask.TaskType.Walk) { if (_currentTask != null) { if (_currentTask._taskType != UnitTask.TaskType.RechargeVehicle) { if (_currentTask._taskType == UnitTask.TaskType.Mine) { TaskList.AddTaskToGlobalTaskList(_currentTask); } _currentTask = theTask; } } else { _currentTask = theTask; } } } break; case VehicleType.smallTransport: if (theTask._taskType == UnitTask.TaskType.Pickup || theTask._taskType == UnitTask.TaskType.RechargeVehicle || theTask._taskType == UnitTask.TaskType.Walk) { if (_currentTask != null) { if (_currentTask._taskType != UnitTask.TaskType.RechargeVehicle) { if (_currentTask._taskType == UnitTask.TaskType.Pickup) { TaskList.AddTaskToGlobalTaskList(_currentTask); } _currentTask = theTask; } } else { _currentTask = theTask; } } break; } }
/// <summary> /// When selecting to enter a vehicle, create and set get in vehicle task /// </summary> public void EnterVehicle() { UnitTask tempTask = TaskLibrary.Get().CreateTask(UnitTask.TaskType.GetInVehicle, _vehicle.transform.position, _vehicle.gameObject); if (_worker != null) { _worker.SetTask(tempTask); } else { TaskList.AddTaskToGlobalTaskList(tempTask); } }
/// <summary> /// When selecting to attack, create attack task and add to task list /// </summary> public void AttackEnemy() { TaskList.AddTaskToGlobalTaskList(TaskLibrary.Get().CreateTask(UnitTask.TaskType.Attack, _monster.transform.position, _monster.gameObject)); // UnitTask tempTask = new UnitTask // { // _location = _monster.transform.position, // _taskType = UnitTask.TaskType.Attack, // _requiredTool = Unit.UnitTool.Weapon, // _taskDescription = "Attacking" // }; // AddTaskToGlobalTaskList(tempTask); }
/// <summary> /// When selecting to dig rubble, create digging task and add to task list /// </summary> public void DigRubble() { TaskList.AddTaskToGlobalTaskList(TaskLibrary.Get().CreateTask(UnitTask.TaskType.ClearRubble, _rubble.transform.position, _rubble.gameObject)); //UnitTask tempTask = new UnitTask //{ // _location = _rubble.transform.position, // _taskType = UnitTask.TaskType.ClearRubble, // _targetRubble = _rubble, // _requiredTool = Unit.UnitTool.Shovel, // _taskDescription = "Clearing rubble" //}; //AddTaskToGlobalTaskList(tempTask); }
/// <summary> /// When selecting to reinforce a wall, create a reinforce task and add to task list /// </summary> public void ReinforceRock() { TaskList.AddTaskToGlobalTaskList(TaskLibrary.Get().CreateTask(UnitTask.TaskType.Reinforce, _rock.transform.position, _rock.gameObject)); //UnitTask tempTask = new UnitTask //{ // _location = _rock.transform.position, // _taskType = UnitTask.TaskType.Reinforce, // _targetRock = _rock, // _requiredTool = Unit.UnitTool.Hammer, // _taskDescription = "Reinforcing a wall" //}; //TaskList.AddTaskToGlobalTaskList(tempTask); }
bool TryAddOrder(Tile tile, UnitTask.TaskType type) { if (type == UnitTask.TaskType.none) { tile.CancelTilesTasks(); return(true); } UnitTask task = TaskLibrary.Get().CreateTask(type, tile.transform.position, tile.gameObject); if (task == null || !task.IsValid()) { return(false); } TaskList.AddTaskToGlobalTaskList(task); return(true); }
// Start is called before the first frame update void Start() { UnitTask tempTask = new UnitTask { _location = transform.position, _taskType = UnitTask.TaskType.Build, _targetBuilding = building, _requiredTool = Unit.UnitTool.Hammer, _taskDescription = "Build a building" }; TaskList.AddTaskToGlobalTaskList(tempTask); foreach (VisualEffect smokeVFX in smokeVFXList) { if (smokeVFX) { smokeVFX.Stop(); } } }
/// <summary> /// When selecting to power, power garage /// </summary> public void PowerBuilding() { TaskList.AddTaskToGlobalTaskList(TaskLibrary.Get().CreateTask(UnitTask.TaskType.RefillEnergy, _garage.transform.position, _garage.gameObject)); }
/// <summary> /// When selecting to dig rubble, create digging task and add to task list /// </summary> public void BurnCluster() { TaskList.AddTaskToGlobalTaskList(TaskLibrary.Get().CreateTask(UnitTask.TaskType.flameTarget, _mushroomCluster.transform.position, _mushroomCluster.gameObject)); }