// Update is called once per frame void Update() { if (ship == null) { return; } if (schedule != null && schedule.tasks.Count > 0) { DateTime currentTime = GameObject.Find("Timer").GetComponent <Timer>().VirtualTime; ShipTask task = schedule.GetNextTask(); if (task.isOverDue(currentTime)) { ForceComplete(task); schedule.CompleteNextTask(); } if (task.isInTaskTime(currentTime)) { ProcessTask(task); } } UpdateStatusPanel(); CheckClick(); CalculateCargoMaintainenceCost(); CalculateCargoOverDueCost(); CalculateCargoOverDueWelfareImpact(); }
// Update is called once per frame void Update() { tortureTime += Time.deltaTime; switch (CurrentStatus) { case Status.Arriving: UpdateArrivingPosition(); break; case Status.Orbiting: UpdateOrbitalPosition(); CheckAndUpdateParams(); CheckAndUpdateTask(); break; case Status.Departing: UpdateDepartingPosition(); CurrentTask = ShipTask.FTL; break; case Status.Dead: //UpdateOrbitalPosition(); break; } /*if (Input.GetKeyUp(KeyCode.F1)) * { * Depart(); * }*/ }
private bool taskHasConflict(ShipTask task) { if (task is ShipMoveTask) { return(ShipMoveTaskHasConflict((ShipMoveTask)task)); } else if (task is UnloadingTask) { return(UnloadingTaskHasConflict((UnloadingTask)task)); } return(false); }
private void ResolveConflictForTask(ShipTask task, ShipSchedule schedule) { if (task is ShipMoveTask) { ResolveConflictForShipMoveTask((ShipMoveTask)task, schedule); return; } else if (task is UnloadingTask) { ResolveConflictForUnloadingTask((UnloadingTask)task, schedule); return; } }
private void ProcessTask(ShipTask task) { if (task is ShipMoveTask) { processShipMoveTask((ShipMoveTask)task); } else if (task is UnloadingTask) { processUnloadingTask((UnloadingTask)task); } else if (task is VanishTask) { processVanishTask((VanishTask)task); } }
private void ForceComplete(ShipTask task) { if (task is ShipMoveTask) { ForceCompleteShipMoveTask((ShipMoveTask)task); } else if (task is UnloadingTask) { ForceCompleteUnloadingTask((UnloadingTask)task); } else if (task is VanishTask) { ForceCompleteVanishTask((VanishTask)task); } ; }
void CheckAndUpdateTask() { wIntel = TaskWeights[ShipTask.Scanning]; wRep = TaskWeights[ShipTask.Repairs]; wFight = TaskWeights[ShipTask.Fighting]; wChill = TaskWeights[ShipTask.Resting]; float nHp = HP / 100f; float nDp = Despair / 100f; if (isBoarded) { TaskWeights[ShipTask.Fighting] = 2; } else { TaskWeights[ShipTask.Fighting] = 0; } TaskWeights[ShipTask.Scanning] = 0.1f; //switchWeightHP = HP < critHP ? 1 : (taskCounter - minDelta) / (maxDelta - minDelta); //switchWeightDesp = HP < critHP ? 0 : (taskCounter - minDelta) / (maxDelta - minDelta); TaskWeights[ShipTask.Repairs] = ((1 - nHp) * ((1 - nHp) / (1 - critHP / 100f)));// * switchWeightHP; if (isFrozen) { TaskWeights[ShipTask.Repairs] = 0; } TaskWeights[ShipTask.Resting] = (nDp);// * switchWeightDesp; if (isStunned) { TaskWeights[ShipTask.Resting] = 1000; } //TaskWeights[ShipTask.Repair] = HP < critHP ? 1 : TaskWeights[ShipTask.Repair]; float maxWeight = -1f; ShipTask nextTask = CurrentTask; foreach (var weight in TaskWeights) { if (weight.Value > maxWeight) { maxWeight = weight.Value; nextTask = weight.Key; } } if (nextTask != CurrentTask) { CurrentTask = nextTask; taskCounter = 0f; } else { taskCounter += Time.deltaTime; } }
public void AppendTask(ShipTask task) { tasks.Add(task); }