public void DetectCollision_PossibleCollisionDetected_LogWriterIsCalled(int altitude1, int x1, int y1, int altitude2, int x2, int y2) { ITrack testTrack1 = new Track() { Altitude = altitude1, X = x1, Y = y2 }; ITrack testTrack2 = new Track() { Altitude = altitude2, X = x2, Y = y2 }; List <ITrack> tracks = new List <ITrack>() { testTrack1, testTrack2 }; _uut.DetectCollision(tracks); _logWriter.Received().Write(Arg.Any <string>()); }
internal void ReceiverOnTransponderDataReady(object sender, RawTransponderDataEventArgs rawTransponderDataEventArgs) { foreach (var data in rawTransponderDataEventArgs.TransponderData) { HandleData(data); } _detector.VerifyCollisions(); _detector.DetectCollision(_planes); // Used to check planes UpdateScreen(); }
public void CollisionEventArgs_TwoPlanesColliding_PlanesReturnedInEventhandler() { CollisionEventArgs ea = new CollisionEventArgs(null, null); _planes.Add(new Plane() { Altitude = 4000, Tag = "Hello", XCoord = 5000, YCoord = 5000, Speed = 1 }); _planes.Add(new Plane() { Altitude = 4000, Tag = "Wut", XCoord = 5000, YCoord = 5000, Speed = 1 }); _collisionDetector.SeparationEvent += (obj, e) => { ea.CollidingPlane1 = e.CollidingPlane1; ea.CollidingPlane2 = e.CollidingPlane2; }; _collisionDetector.DetectCollision(_planes); Assert.That(_planes.Exists(o => o.Tag == ea.CollidingPlane1.Tag)); Assert.That(_planes.Exists(o => o.Tag == ea.CollidingPlane2.Tag)); }
void CheckIfHit() { projectiles = GameObject.FindGameObjectsWithTag("Projectiles"); foreach (GameObject projectile in projectiles) { if (CollisionDetector.DetectCollision(projectile.GetComponent <Particle2D>(), target.GetComponent <Particle2D>())) { SpawnTarget(); ParticlesManager.instance.DeleteParticle(projectile); score++; return; } } }
void Update() { foreach (Particle2D particle1 in particlesList) { foreach (Particle2D particle2 in particlesList) { if ((CollisionDetector.DetectCollision(particle1, particle2)) && (particle1 != particle2) && (particle1.name == "RndPart") && (particle2.name == "RndPart")) { destroyParticlesList.Add(particle1); destroyParticlesList.Add(particle2); } } } foreach (Particle2D particle in destroyParticlesList) { DeleteParticle(particle.gameObject); } destroyParticlesList.Clear(); }
private void FixedUpdate() { foreach (Particle2D part1 in mParticles) { if (!part1.mIsPlayer) { foreach (Particle2D part2 in mParticles) { if (!part1.Equals(part2) && !part2.mIsPlayer) { if (CollisionDetector.DetectCollision(part1, part2)) { Destroy(part1.gameObject); Destroy(part2.gameObject); } } } } } }
public void DetectCollision_SeparationEvent_WriteToLog(int altitude1, int x1, int y1, int altitude2, int x2, int y2) { ITrack testTrack1 = new Track() { Tag = "XY123456", Altitude = altitude1, X = x1, Y = y2, TimeStamp = DateTime.Now }; ITrack testTrack2 = new Track() { Tag = "II000000", Altitude = altitude2, X = x2, Y = y2, TimeStamp = DateTime.Now }; List <ITrack> tracks = new List <ITrack>() { testTrack1, testTrack2 }; collisionDetector.DetectCollision(tracks); var lastLine = File.ReadLines(@"Track.txt").Last(); Assert.That(lastLine, Is.EqualTo(DateTime.Now.ToShortTimeString() + ": Collision between " + testTrack1.Tag + " and " + testTrack2.Tag)); }
public void ParticleUpdate() { foreach (GameObject par1 in particleList) { foreach (GameObject par2 in particleList) { if (par1 != par2 && par1 != null && par2 != null) { bool colliding = CollisionDetector.DetectCollision(par1, par2); if (colliding == true) { if (!GameManager.destroyList.Contains(par1.GetComponent <Particle2D>().GetID())) { GameManager.destroyList.Add(par1.GetComponent <Particle2D>().GetID()); } if (!GameManager.destroyList.Contains(par2.GetComponent <Particle2D>().GetID())) { GameManager.destroyList.Add(par2.GetComponent <Particle2D>().GetID()); } } } } } foreach (GameObject par in particleList) { if (par != null) { Vector3 viewPos = UnityEngine.Camera.main.WorldToViewportPoint(par.transform.position); if (!(viewPos.x >= 0 && viewPos.x <= 1 && viewPos.y >= 0 && viewPos.y <= 1 && viewPos.z > 0)) { if (!GameManager.destroyList.Contains(par.GetComponent <Particle2D>().GetID())) { GameManager.destroyList.Add(par.GetComponent <Particle2D>().GetID()); } } } } }