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();
                }
            }
        }
    }