Esempio 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();
                }
            }
        }
    }
Esempio n. 2
0
    IEnumerator StartTaskRoutine()
    {
        yield return(new WaitForSeconds(.2f));

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

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