// Update is called once per frame
 void Update()
 {
     if (Transforms.Length > 1)
     {
         if (BenjasMath.countdownToZero(ref timeToNext))
         {
             factor     = (float)animationTime * (1 + Mathf.Lerp(-aniTimeVariation, aniTimeVariation, Random.value));
             timeToNext = factor;
             origin     = target;
             target++;
         }
         if (target >= Transforms.Length)
         {
             target = 0;
         }
         float t;
         t = BenjasMath.easeInOut(1f - timeToNext / factor);
         transform.position = Vector3.Lerp(Transforms[origin].position, Transforms[target].position, t);
         t = BenjasMath.easeInOut(1f - rotationSpeedup * timeToNext / factor);
         transform.eulerAngles = BenjasMath.angularLerp(Transforms[origin].eulerAngles, Transforms[target].eulerAngles, t);
     }
     else
     {
         this.enabled = false;
     }
 }
 // Update is called once per frame
 void Update()
 {
     if (testFog)
     {
         doFog();
     }
     if (isFogging)
     {
         if (BenjasMath.countdownToZero(ref fogTime))
         {
             isFogging = false;
         }
         setAlpha(20 * timeFunktion(fogTime / maxFogTime));
     }
 }
예제 #3
0
    void Update()
    {
        if (stopEveryFrame)
        {
            Debug.Break();
        }
        cheatkeys();

        if (state == STATE.PLAYING)
        {
            float normalizedGametime = BenjasMath.timer(ref gameTime, maxGameTime, pausing);
            updateHUD(normalizedGametime);
            if (normalizedGametime == 1)
            {
                onTimeout();
            }

            if (!pausing)
            {
                if (spawnByTime && BenjasMath.countdownToZero(ref timeToSpawn))
                {
                    // switch off spawning by time after first object and switch on spawning when hitting a collider
                    spawnByTime     = false;
                    spawnByCollider = true;
                    //spawn first object
                    onSpawn();
                }
                if (levelControl.isLastLevel())
                {
                    if (Vector3.Distance(glider.transform.position, levelControl.levelInfo().finish.transform.position) < distanceFinishNear)
                    {
                        onFinalFinishNear();
                    }
                }
            }
        }
        else if (state == STATE.ATSTART)
        {
            updateHUD();
        }
    }
예제 #4
0
    void doDocking()
    {
        float t = Mathf.Pow(Mathf.InverseLerp(dockingDuration, 0, dockingTime), 1);

//		float t2 = Mathf.Clamp01(Mathf.InverseLerp(dockingDuration,dockingDuration-1,dockingTime));



        //lerp the position
        transform.position = Vector3.Lerp(transform.position, nextDockingPoint.position, t);
        //lerp the rotation
        transform.eulerAngles = BenjasMath.angularLerp(transform.eulerAngles, nextDockingPoint.eulerAngles, t);
        // lerp the velocity
        //rigi.velocity = Vector3.Lerp(rigi.velocity ,  Vector3.zero,   t2);

        float dist        = Vector3.Distance(transform.position, nextDockingPoint.position);
        float angularDist = Vector3.Distance(transform.eulerAngles, nextDockingPoint.eulerAngles);

        //test if docking time is over or position is close enough (10mm and 1/10°)
        if (BenjasMath.countdownToZero(ref dockingTime) || (dist < 0.01 && angularDist < 0.1))
        {
            finishDocking();
        }
    }
 private bool runDelay()
 {
     return(BenjasMath.countdownToZero(ref delay));
 }