public MovingParticleSwarm(int particleCount, Vector2 startPosition, BoundParticleSwarm target)
     : base(particleCount, startPosition)
 {
     startPos = startPosition;
     if (target != null)
         SetTarget(target);
 }
 public MovingParticleSwarm Release(BoundParticleSwarm target = null)
 {
     if (target == null)
         target = from;
     var movingSwarm = new MovingParticleSwarm(0, from.Position, target);
     movingSwarm.AddParticles(RemoveRandomParticles(Particles.Count));
     return movingSwarm;
 }
Beispiel #3
0
        public ParticleController(ParticleManager particleManager, Map map)
        {
            this.ParticleManager = particleManager;
            this.Map = map;

            this.SelectedSwarm = null;

            this.NumSelectedParticles = 0F;
            this.SelectingSpeed = 1.3F;
            this.SwarmSelectRadius = 5F;
        }
Beispiel #4
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;
         }
     }
 }
 public TransitionParticleSwarm(BoundParticleSwarm startSwarm) : base(0, startSwarm.Position)
 {
     from = startSwarm;
     ParticleSpeed = 0.1F;
 }
 public void SetTarget(BoundParticleSwarm target)
 {
     this.TargetSwarm = target;
     t = (TargetSwarm.Position - startPos).length / 2;
 }
Beispiel #7
0
 public void TransferParticles(BoundParticleSwarm from, TransitionParticleSwarm to, int num)
 {
     List<Particle> transferParticles = from.RemoveRandomParticles(num);
     to.AddParticles(transferParticles);
 }