protected virtual void DequeueCrossOrder(SpriteRenderer SR)
        {
            int MoveDir = 0;

            switch (MoveDirection)
            {
            case EDirection.LEFT:
                if (SR.transform.position.x <= LeftBorderX)
                {
                    MoveDir = -1;
                }
                break;

            case EDirection.RIGHT:
                if (SR.transform.position.x >= RightBorderX)
                {
                    MoveDir = 1;
                }
                break;
            }
            float SpriteWidth = SR.sprite.bounds.size.x;

            SpriteWidth *= SR.transform.localScale.x;
            Vector3 PosDelta = new Vector3(1, 0, 0) * SpriteWidth * (ObjectQueue.Count) * (-MoveDir);

            SR.transform.position += PosDelta;
            ObjectQueue.Dequeue();
            ObjectQueue.Enqueue(SR);
        }
Beispiel #2
0
 /// <summary>
 /// 设置到最大容量;
 /// </summary>
 public void SetMaxCapacity(int maxCapacity)
 {
     MaxCapacity = maxCapacity;
     while (IsFull)
     {
         T item = ObjectQueue.Dequeue();
         Destroy(item);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Returns an object from the pipe. If pipe is empty returns null.
        /// This will try the ExternalReader if there are no queued objects.
        /// </summary>
        /// <returns>
        /// object that is retrieved, or AutomationNull.Value if none
        /// </returns>
        internal object Retrieve()
        {
            if (ObjectQueue != null && ObjectQueue.Count != 0)
            {
                return(ObjectQueue.Dequeue());
            }
            else if (_enumeratorToProcess != null)
            {
                if (_enumeratorToProcessIsEmpty)
                {
                    return(AutomationNull.Value);
                }

                if (!ParserOps.MoveNext(_context, null, _enumeratorToProcess))
                {
                    _enumeratorToProcessIsEmpty = true;
                    return(AutomationNull.Value);
                }

                return(ParserOps.Current(null, _enumeratorToProcess));
            }
            else if (ExternalReader != null)
            {
                try
                {
                    object o = ExternalReader.Read();
                    if (AutomationNull.Value == o)
                    {
                        // NOTICE-2004/06/08-JonN 963367
                        // The fix to this bug involves making one last
                        // attempt to read from the pipeline in DoComplete.
                        // We should be sure to not hit the ExternalReader
                        // again if it already reported completion.
                        ExternalReader = null;
                    }

                    return(o);
                }
                catch (PipelineClosedException)
                {
                    return(AutomationNull.Value);
                }
                catch (ObjectDisposedException)
                {
                    return(AutomationNull.Value);
                }
            }
            else
            {
                return(AutomationNull.Value);
            }
        }
Beispiel #4
0
 /// <summary>
 /// 获取到对象实例;
 /// </summary>
 public T Get()
 {
     if (IsEmpty)
     {
         T item = Instantiate();
         return(item);
     }
     else
     {
         T item = ObjectQueue.Dequeue();
         ResetWhenOutPool(item);
         return(item);
     }
 }