public void checkAltitudeDanger(iAirplane airplane) { airplane.setAltitudeDanger(false); if (airplane.getAltitude() <= this.altitudeDanger) { airplane.setAltitudeDanger(true); } }
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); }