コード例 #1
0
        // O(1) complexity, since there is no big loop to go through
        public void Create(double x, double y, double velocityX, double velocityY, int lifetime)
        {
            // Make sure the pool isn't full
            Debug.Assert(_firstAvilable != null);

            // remove if from the avilable list
            ParticleWithFreeList newParticle = _firstAvilable;
            _firstAvilable = newParticle.GetNext();

            newParticle.Initialize(x,y,velocityX,velocityY, lifetime);
        }
コード例 #2
0
 public void Animate()
 {
     for (int i = 0; i < POOL_SIZE; i++)
     {
         if (_particlesFreeList[i].Animate())
         {
             // add this particle to the front of the list
             _particlesFreeList[i].SetNext(_firstAvilable);
             _firstAvilable = _particlesFreeList[i];
         }
     }
 }
コード例 #3
0
 public void Animate()
 {
     for (int i = 0; i < POOL_SIZE; i++)
     {
         if (_particlesFreeList[i].Animate())
         {
             // add this particle to the front of the list
             _particlesFreeList[i].SetNext(_firstAvilable);
             _firstAvilable = _particlesFreeList[i];
         }
     }
 }
コード例 #4
0
        // O(1) complexity, since there is no big loop to go through
        public void Create(double x, double y, double velocityX, double velocityY, int lifetime)
        {
            // Make sure the pool isn't full
            Debug.Assert(_firstAvilable != null);

            // remove if from the avilable list
            ParticleWithFreeList newParticle = _firstAvilable;

            _firstAvilable = newParticle.GetNext();

            newParticle.Initialize(x, y, velocityX, velocityY, lifetime);
        }
コード例 #5
0
        public ParticlePoolWithFreeList()
        {
            // these initialization loops are not totally correct (according to the book)
            // since I cannot use pointers in C#

            _particlesFreeList = new ParticleWithFreeList[POOL_SIZE];

            for (int i = 0; i < POOL_SIZE; i++)
            {
                _particlesFreeList[i] = new ParticleWithFreeList(i.ToString());
            }

            for (int i = 0; i < POOL_SIZE; i++)
            {
                _particlesFreeList[i].SetNext(_particlesFreeList[i + 1]);
            }

            _firstAvilable = _particlesFreeList[0];
            _particlesFreeList[POOL_SIZE - 1].SetNext(null);
        }
コード例 #6
0
        public ParticlePoolWithFreeList()
        {
            // these initialization loops are not totally correct (according to the book)
            // since I cannot use pointers in C#

            _particlesFreeList = new ParticleWithFreeList[POOL_SIZE];

            for (int i = 0; i < POOL_SIZE; i++)
            {
                _particlesFreeList[i] = new ParticleWithFreeList(i.ToString());
            }

            for (int i = 0; i < POOL_SIZE; i++)
            {
                _particlesFreeList[i].SetNext(_particlesFreeList[i + 1]);
            }

            _firstAvilable = _particlesFreeList[0];
            _particlesFreeList[POOL_SIZE - 1].SetNext(null);
        }
コード例 #7
0
 // some kind of linked list
 public void SetNext(ParticleWithFreeList next)
 {
     _next = next;
 }
コード例 #8
0
 public ParticleWithFreeList(string name)
 {
     _framesLeft = 0;
     _name       = name;
     _next       = null;
 }
コード例 #9
0
 // some kind of linked list
 public void SetNext(ParticleWithFreeList next)
 {
     _next = next;
 }
コード例 #10
0
 public ParticleWithFreeList(string name)
 {
     _framesLeft = 0;
     _name = name;
     _next = null;
 }