public void OnDropped(GameObject draggable, FMDropTarget toTarget) { //ToDo: check if the draggable is a worker; if not, ignore //if it is, // check if it is currently assigned to a task; if it is, UNASSIGN (tell both it and the task) // check if what it's dropped into is a task; if it is, ASSIGN (tell both it and the task) FMDraggable draggableComponent = draggable.GetComponent <FMDraggable>(); if (draggableComponent == null) { return; } FMTaskBase task = toTarget == null ? null : toTarget.GetComponent <FMTaskBase>(); // assign to either a null task or a task that can accept a worker bool shouldAssign = (task == null); shouldAssign |= (task != null && task.AcceptsWorkers()); if (shouldAssign) { draggableComponent.Assign(task); } else { draggableComponent.Unassign(); } }
public FMTaskBase currentTask; //a worker can only have one job at a time, or none public void Assign(FMTaskBase task) { //SoundManager.GetOrCreateInstance().play_audio("fish_drop"); Debug.Log("Assign Job " + this.name + " to " + (task != null ? task.name : "<none>") , this); Tutorial.GetOrCreateInstance().HasDraggedWorker = true; Tutorial.GetOrCreateInstance().HasAssignedWorkerToBoat = true; if (currentTask != null) { SoundManager.GetOrCreateInstance().play_audio("fish_remove"); currentTask.RemoveWorker(this); currentTask = null; } currentTask = task; if (currentTask != null) { SoundManager.GetOrCreateInstance().play_audio("fish_assign"); currentTask.AssignWorker(this); } else { SoundManager.GetOrCreateInstance().play_audio("fish_drop"); } }
public void GoToWorkerPool() { var drag_handler = gameObject.GetComponent <FMDraggable>(); if (drag_handler) { drag_handler.enabled = true; } currentTask = null; m_IsSleepingIn = false; // move the sprite to pool for selection... FMBoardReferences.GetOrCreateInstance().m_WorkerPoolStagingArea.AddToStaging(this.transform); }
public void AssignToTask(FMTaskBase task) { if (m_AssignedTask != null) { m_AssignedTask.SetEquipment(null); m_AssignedTask = null; } if (task is FMGeneratorTask) { SetAssignmentCompleted(false); m_CurrentAssignTime = 0f; m_AssignedTask = (FMGeneratorTask)task; m_AssignedTask.SetEquipment(this); m_AssignedTask.fillerImage.color = GetColor(); } }
public void GoHome() { // animate go home m_TimeSleptIn = 0f; m_IsSleepingIn = true; var drag_handler = gameObject.GetComponent <FMDraggable>(); if (drag_handler) { drag_handler.enabled = false; } currentTask = null; FMBoardReferences.GetOrCreateInstance().m_WorkerHomeStagingArea.AddToStaging(this.transform); }
public void GetSomeGrub() { // animate get food int randomSink = Random.Range(0, 3); var sink = FMBoardReferences.GetOrCreateInstance().m_ResourceSinks[randomSink]; m_SicknessLevel = sink.m_CurrentSicknessLevel; m_TimeToReturnToWork = m_SicknessSleepInScalar * m_SicknessLevel; var drag_handler = gameObject.GetComponent <FMDraggable>(); if (drag_handler) { drag_handler.enabled = false; } currentTask = null; sink.m_WorkerStagingArea.AddToStaging(this.transform); //GoHome(); }
public void Assign(FMTaskBase task) { m_OnAssignedTask?.Invoke(task); }