Exemplo n.º 1
0
 public override void RegularUpdate()
 {
     if (collection != null && collection.Autocollect)
     {
         Autocollect(true);
     }
     if (State == HomingState.WAITING && time > MinTimeBeforeHome)
     {
         State = HomingState.HOMING;
     }
     if (CollisionMath.CircleOnPoint(loc, target.itemCollectRadius + CollectRadiusBonus, target.location))
     {
         CollectMe();
         return;
     }
     if (State == HomingState.HOMING)
     {
         timeHoming += ETime.FRAME_TIME;
         loc         = Vector2.Lerp(loc, target.location, Mathf.Lerp(homeRate * ETime.FRAME_TIME, peakedHomeRate, timeHoming / maxTimeHoming));
     }
     else
     {
         loc += ETime.FRAME_TIME * (Velocity(time) + summonTarget *
                                    M.DEOutSine(Mathf.Clamp01(time / lerpIntoOffsetTime)) / lerpIntoOffsetTime);
         if (Attractible && CollisionMath.CircleOnPoint(loc, target.itemAttractRadius, target.location))
         {
             SetHome();
         }
         else if (!LocationHelpers.OnScreenInDirection(loc, -screenRange * Direction) ||
                  (time > MinCullTime && !LocationHelpers.OnPlayableScreenBy(CullRadius, loc)))
         {
             PooledDone();
             return;
         }
     }
     tr.localEulerAngles = new Vector3(0, 0, 360 * RotationTurns *
                                       M.EOutSine(Mathf.Clamp01(time / RotationTime)));
     tr.position = loc;
     time       += ETime.FRAME_TIME;
 }