示例#1
0
    // 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();
    }
示例#2
0
    // 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();
         * }*/
    }
示例#3
0
 private bool taskHasConflict(ShipTask task)
 {
     if (task is ShipMoveTask)
     {
         return(ShipMoveTaskHasConflict((ShipMoveTask)task));
     }
     else if (task is UnloadingTask)
     {
         return(UnloadingTaskHasConflict((UnloadingTask)task));
     }
     return(false);
 }
示例#4
0
 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;
     }
 }
示例#5
0
 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);
     }
 }
示例#6
0
 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);
     }
     ;
 }
示例#7
0
    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;
        }
    }
示例#8
0
 public void AppendTask(ShipTask task)
 {
     tasks.Add(task);
 }