Exemplo n.º 1
0
    void Update()
    {
        if (running)
        {
            float drainRate   = baseDrainRate + Mathf.Pow(roverSpeed, drainPow) / motorEfficiency;
            float deltaCharge = drainRate * Time.deltaTime;
            float movePercent = Mathf.Min(batteryRemaining, deltaCharge) / deltaCharge;
            batteryRemaining = Mathf.Max(0, batteryRemaining - deltaCharge);

            rover.transform.position += Vector3.right * roverSpeed * Time.deltaTime * movePercent;

            if (batteryRemaining <= 0)
            {
                float dst = rover.transform.position.x - initialPos.x;

                if (dst > targetDst - bufferDst)
                {
                    TestPassed();
                }
                else
                {
                    float remainingDst = targetDst - dst;
                    VirtualConsole.Log("Dst remaining: " + VirtualConsole.RoundValueForDisplay(remainingDst));
                    TestFailed();
                }
            }
        }
    }
Exemplo n.º 2
0
    IEnumerator StartTaskRoutine()
    {
        yield return(new WaitForSeconds(.2f));

        VirtualConsole.Log("Compiling code...");
        yield return(new WaitForSeconds(.5f));

        Run(code);
    }
Exemplo n.º 3
0
 protected void TestPassed()
 {
     if (running)
     {
         currentIteration++;
         VirtualConsole.Log($"Test {currentIteration}/{taskIterations} passed");
         if (currentIteration == taskIterations)
         {
             TaskComplete();
         }
         else
         {
             StartNextTestIteration();
         }
     }
 }
Exemplo n.º 4
0
 protected virtual void TaskComplete()
 {
     VirtualConsole.Log("Task completed");
     running = false;
 }