示例#1
0
 // Move a gameobject out to a new location and then wait for a period of time, and return back to original position
 public void OutAndReturn(Vector3 end, float speed, float delay)
 {
     duration       = speed;
     endPos         = end;
     returnPosition = transform.position;
     delayReturn    = delay;
     delay          = 0;
     lmethod        = LerpMethod.outandreturn;
     startTime      = Time.time;
     moving         = true;
 }
示例#2
0
        public void Lerp(LerpMethod action, long durationMs = 1000, float calculations = 10, float start = 0, float end = 1)
        {
            long  started    = GetTime();
            float iterations = 0;

            void DoThisLerp()
            {
                float delta = end - start;
                float p     = (delta * iterations) / calculations + start;

                action.Invoke(p);
                long delay = (long)(durationMs / calculations);

                if (iterations < calculations)
                {
                    long nextTime = (long)(durationMs * (iterations + 1) / calculations) + started;
                    Delay(nextTime, DoThisLerp);
                }
                ++iterations;
            }

            DoThisLerp();
        }