Beispiel #1
0
 public void Update()
 {
     if (SelectedSwarm == null)
     {
         if (Mouse.IsButtonPressed(Mouse.Button.Left))
         {
             // select a swarm
             Vector2 clickPosition = Program.MousePositionToGameCoordinate();
             float distanceToSwarm;
             BoundParticleSwarm nearestSwarm = ParticleManager.GetNearestBoundSwarm(clickPosition, out distanceToSwarm);
             if(nearestSwarm != null && distanceToSwarm < SwarmSelectRadius)
             {
                 SelectedSwarm = nearestSwarm;
                 Balken = new TransitionParticleSwarm(SelectedSwarm);
                 ParticleManager.ParticleSwarms.Add(Balken);
             }
         }
     }
     else
     {
         if (Mouse.IsButtonPressed(Mouse.Button.Left))
         {
             NumSelectedParticles += SelectingSpeed;
             if (NumSelectedParticles > SelectedSwarm.Count)
                 NumSelectedParticles = SelectedSwarm.Count;
             if (NumSelectedParticles >= 1)
             {
                 ParticleManager.TransferParticles(SelectedSwarm, Balken, (int) NumSelectedParticles);
                 NumSelectedParticles %= 1;
             }
         }
         else
         {
             Vector2 releasePosition = Program.MousePositionToGameCoordinate();
             float distanceToSwarm;
             BoundParticleSwarm targetSwarm = ParticleManager.GetNearestBoundSwarm(releasePosition, out distanceToSwarm);
             if (distanceToSwarm > SwarmSelectRadius)
             {
                 targetSwarm = null;
             }
             ParticleManager.ParticleSwarms.Add(Balken.Release(targetSwarm));
             ParticleManager.ParticleSwarms.Remove(Balken);
             SelectedSwarm = null;
             Balken = null;
             NumSelectedParticles = 0F;
         }
     }
 }
Beispiel #2
0
 public void TransferParticles(BoundParticleSwarm from, TransitionParticleSwarm to, int num)
 {
     List<Particle> transferParticles = from.RemoveRandomParticles(num);
     to.AddParticles(transferParticles);
 }