Exemplo n.º 1
0
 public override void RegularUpdate()
 {
     if (cT.Cancelled)
     {
         Finish();
     }
     else
     {
         var target = source.GlobalPosition();
         if (containerActive != LocationHelpers.OnPlayableScreenBy(5f, target))
         {
             container.SetActive(containerActive = !containerActive);
         }
         if (containerActive)
         {
             var p = tr.localPosition;
             p.x = Mathf.Clamp(source.GlobalPosition().x,
                               GameManagement.References.bounds.left + yield,
                               GameManagement.References.bounds.right - yield);
             tr.localPosition = p;
             text.color       = new Color(1, 1, 1,
                                          Mathf.Clamp01(Mathf.Lerp(0.1f, 1.5f, enemy == null ? 1 : enemy.DisplayBarRatio)));
         }
     }
 }
Exemplo n.º 2
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;
 }