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(); } } } }
IEnumerator StartTaskRoutine() { yield return(new WaitForSeconds(.2f)); VirtualConsole.Log("Compiling code..."); yield return(new WaitForSeconds(.5f)); Run(code); }
protected void TestPassed() { if (running) { currentIteration++; VirtualConsole.Log($"Test {currentIteration}/{taskIterations} passed"); if (currentIteration == taskIterations) { TaskComplete(); } else { StartNextTestIteration(); } } }
protected virtual void TaskComplete() { VirtualConsole.Log("Task completed"); running = false; }