示例#1
0
        public void wakeup()
        {
            bool added = FloatUpdate.self.getSubByIdx(floatUpdateHandle) == this;

            if (added)
            {
                float timeleft = FloatUpdate.self.getVal(floatUpdateHandle);
                if (timeleft > 0f)
                {
                    return;
                }
            }

            if (phase == 0 && source != null)
            {
                // just reached the source.
                if (source.attemptToRemove(expectedItemId))
                {
                    FloatUpdate.self.Add(this, cycleDuration);
                    phase = 1;
                    source.wakeup();
                }
            }
            else if (phase == 1 && target != null)
            {
                // just reached the target/destination
                if (target.attemptToInsert(expectedItemId))
                {
                    phase = 0;
                    target.wakeup();
                }
            }
        }
示例#2
0
 public void update(float dt)
 {
     timeLeft -= dt;
     if (timeLeft <= 0.0f)
     {
         if (phase == 0 && source != null)
         {
             // just reached the source.
             if (source.attemptToRemove(expectedItemId))
             {
                 phase    = 1;
                 timeLeft = cycleDuration;
             }
         }
         else if (phase == 1 && target != null)
         {
             // just reached the target/destination
             if (target.attemptToInsert(expectedItemId))
             {
                 phase    = 0;
                 timeLeft = cycleDuration;
             }
         }
     }
 }