Ejemplo n.º 1
0
 /// <summary>
 /// 更新粒子物理属性,如果粒子超过边界,将其回收
 /// </summary>
 /// <param name="elapsedTime"></param>
 /// <param name="size"></param>
 public void Update(float elapsedTime, Vector2 size)
 {
     {
         if (surfaceLoaded)
         {
             for (int i = ActiveParticles.Count - 1; i >= 0; i--)
             {
                 var p = ActiveParticles[i];
                 if (p == null)
                 {
                     ActiveParticles.RemoveAt(i);
                     return;
                 }
                 if (p.Position.X > 0 - size.Y * (float)Math.Tan(1.5708 - (minRotationAngle + maxRotationAngle) / 2) && p.Position.X <= size.X && p.Position.Y <= size.Y)
                 {
                     p.Update(elapsedTime);
                 }
                 else
                 {
                     ActiveParticles.RemoveAt(i);
                     FreeParticles.Push(p);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 internal void ImmersiveOut()
 {
     inited = false;
     for (int i = ActiveParticles.Count - 1; i >= 0; i--)
     {
         var p = ActiveParticles[i];
         ActiveParticles.RemoveAt(i);
         FreeParticles.Push(p);
     }
     isImmersive = false;
 }
Ejemplo n.º 3
0
 // 刷新所有的激活粒子
 public virtual void Update(float elapsedTime)
 {
     if (surfaceLoaded)
     {
         // 从队列的末尾向前遍历,这样执行 Remove 的时候不会出错
         for (int i = activeParticles.Count - 1; i >= 0; i--)
         {
             Particle particle = activeParticles[i];
             if (particle == null)
             {
                 ActiveParticles.RemoveAt(i);
                 return;
             }
             if (!particle.Update(elapsedTime))
             {
                 // 如果粒子不再存活,将它去掉
                 activeParticles.RemoveAt(i);
                 freeParticles.Push(particle);
             }
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 更新粒子物理属性,如果粒子超过边界,将其回收
 /// </summary>
 /// <param name="elapsedTime"></param>
 /// <param name="size"></param>
 public void Update(float elapsedTime, Vector2 size)
 {
     if (surfaceLoaded)
     {
         for (int i = ActiveParticles.Count - 1; i >= 0; i--)
         {
             var p = ActiveParticles[i];
             if (p == null)
             {
                 ActiveParticles.RemoveAt(i);
                 return;
             }
             if (p.Position.X < (size.X + (surfacesBounds[p.Key].Width) / 2))
             {
                 p.Update(elapsedTime);
             }
             else
             {
                 ActiveParticles.RemoveAt(i);
                 FreeParticles.Push(p);
             }
         }
     }
 }