Esempio n. 1
0
        /// <summary>
        /// Move the airplane
        /// </summary>
        /// <param name="aircraft"></param>
        public override void MoveAircraft(Aircraft aircraft)
        {
            //calcul la nouvelle position en x et y
            int destX = aircraft.destinationX;
            int destY = aircraft.destinationY;

            PassengerAircraft passAircraft = (PassengerAircraft)aircraft;
            FlyingState       position     = (FlyingState)passAircraft.CurrentState;
            double            distance     = Math.Sqrt((Math.Pow(destY - position.PosY, 2)) + (Math.Pow(destX - position.PosX, 2)));

            double tickRequired = distance / (passAircraft.Speed * 15);

            // Si le nombre de tick est plus grand que 1, deplacer l'avion
            if (tickRequired > 1)
            {
                double XbyTick = (destX - position.PosX) / tickRequired;
                double YbyTick = (destY - position.PosY) / tickRequired;


                position.PosX += Convert.ToInt32(XbyTick);
                position.PosY += Convert.ToInt32(YbyTick);
            }
            else // sinon, l'avion est a destination
            {
                aircraft.CurrentState.ChangeState(aircraft);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Land the plane, remove from the airport and add to the new one, remove from the flying list and drop the passenger
 /// </summary>
 /// <param name="aircraft"></param>
 public void landPlane(Aircraft aircraft)
 {
     //Parcours les avion
     for (int i = 0; i < Aircrafts.Count; i++)
     {
         if (Aircrafts[i] == aircraft)
         {
             //Parcours les aeroports
             for (int y = 0; y < scenario.Airports.Count; y++)
             {
                 //Si l'avion correspond a la destionation, atterir
                 if (scenario.Airports[y].X == aircraft.destinationX && scenario.Airports[y].Y == aircraft.destinationY)
                 {
                     scenario.Airports[y].Aircrafts.Add(aircraft);
                     aircraft.airport.Aircrafts.Remove(aircraft);
                     scenario.FlyingAicrafts.Remove(aircraft);
                     aircraft.airport = scenario.Airports[y];
                     PassengerAircraft passengerAircraft = (PassengerAircraft)aircraft;
                     passengerAircraft.CurrentCapacity = 0;
                 }
             }
         }
     }
 }