public void addAirplane(iAirplane airplane) { if (!existIdInMap(airplane.getId())) { airplanes.Add(airplane); } }
public bool checkCrash(iAirplane airplane1) { //CRASH with floor/ground(altitude) if (airplane1.getAltitude() <= this.altitudeCrash) { if (airplane1.getDeployedLandingGear()) { //Landing gear is deployed if (airplane1.getSpeed() <= this.landingMaxSpeed) { //Airplane can land and be removed this.game.addNotification($"Airplane {airplane1.getId()} has landed succesfully.", 6000); } else { Random random = new Random(); int deadPeople = random.Next((int)(airplane1.getCapacity() * 0.2), (int)(airplane1.getCapacity() * 0.8)); this.game.addNotification($"Airplane {airplane1.getId()} has landed with some difficulties killing {deadPeople} people.", 6000); this.stats.addDeadPeople($"{airplane1.getId()} - {airplane1.getVendor()} {airplane1.getModel()} Landed with some difficulties killing {deadPeople} people.", deadPeople); } } else { //Landing gear is not deployed this.game.addNotification($"Airplane {airplane1.getId()} has crashed with the ground. {airplane1.getCapacity()} people have died. Congratulations.", 6000); this.stats.addDeadPeople($"{airplane1.getId()} - {airplane1.getVendor()} {airplane1.getModel()} has crashed with the ground. {airplane1.getCapacity()} people have died.", airplane1.getCapacity()); } return(true); } //CRASH with airplanes foreach (iAirplane airplane2 in this.airplanes) { //Same airplane, stop if (airplane1.getId() == airplane2.getId()) { continue; } //Calculate distance between 2 airplanes double radius = Vector3.Distance(airplane1.get3DPos(), airplane2.get3DPos()); if (radius <= this.distanceCrashRadius) { this.game.addNotification($"Airplane {airplane1.getId()} has crashed with another airplane. {airplane1.getCapacity()} people have died. Congratulations.", 6000); this.stats.addDeadPeople($"{airplane1.getId()} - {airplane1.getVendor()} {airplane1.getModel()} has crashed with another airplane. {airplane1.getCapacity()} people have died.", airplane1.getCapacity()); return(true); } } return(false); }
public void addAirplaneToMap(iAirplane airplane) { if (map.getAirplanes().Count >= this.maxAirplanes) { notificationsManager.addNotification($"Max airplanes reached {map.getAirplanes().Count}/{this.maxAirplanes}"); } else { notificationsManager.addNotification($"Adding airplane {airplane.getId()} to the map. {airplane.getPos().ToString()}"); this.map.addAirplane(airplane); } }
public void checkCollisionDanger(iAirplane airplane1) { //Reset collision danger list airplane1.removeAllCollisionDangerWith(); foreach (iAirplane airplane2 in airplanes) { //Same airplane, stop if (airplane1.getId() == airplane2.getId()) { continue; } //Calculate distance between 2 airplanes double radius = Vector3.Distance(airplane1.get3DPos(), airplane2.get3DPos()); if (radius <= this.distanceCollisionDangerRadius) { //this.game.addNotification($"Airplane {airplane1.getId()} and airplane {airplane2.getId()} are really close!!({(int)Math.Round(distance)})", 6000); airplane1.addCollisionDangerWith(airplane2); airplane2.addCollisionDangerWith(airplane1); } } }
public void removeAirplane(iAirplane airplane) { this.map.removeAirplane(airplane); this.addNotification($"Airplane {airplane.getId()} has been removed from the map."); }