Beispiel #1
0
        /***********************************************
         * Zkontroluje vhodnost letiště pro letadlo.
         * Pokud je letadlo nevhodné, zruší approach.
         * *********************************************/
        private bool CheckLandingAvailability(Airport landingAirport)
        {
            int targetAirport = (int)(landingAirport.Dir / 10);
            string targetAirportSide = landingAirport.Side;
            if (!landReported)
            {
                Main.getInstance().sound.playSequence(CallSign);
                Main.getInstance().sound.play("request");
                Main.getInstance().sound.playSequence("" + targetAirport);
                if (targetAirportSide != "")
                {
                    Main.getInstance().sound.play(targetAirportSide);
                }
                Main.getInstance().sound.playTowerSequence(this.CallSign);
            }
            if (!landingAirport.Working && landingAirport.GetDistanceOnAxis((float)this.X, (float)this.Y) > 4.5)
            {
                //Main.getInstance().sound.playTowerSequence(CallSign);
                Main.getInstance().sound.play("t_cancel");
                ReactionOffset = Main.getInstance().sound.GetFilledTime();
                //Main.getInstance().sound.playSequence(CallSign);
                //Main.getInstance().sound.play("around");
                cancelApproach();
                return false;
            }
            if ((this is Boeing && landingAirport.Length < 2.5) || (this is Airbus && landingAirport.Length < 2.0))
            {
                //Main.getInstance().sound.playTowerSequence(CallSign);
                Main.getInstance().sound.play("t_cancel");
                Main.getInstance().sound.play("t_toobig");
                Main.getInstance().sound.playTowerSequence("" + targetAirport);
                if (targetAirportSide != "")
                {
                    Main.getInstance().sound.play("t_" + targetAirportSide);
                }
                ReactionOffset = Main.getInstance().sound.GetFilledTime();
                //Main.getInstance().sound.playSequence(CallSign);
                //Main.getInstance().sound.play("around");
                cancelApproach();
                return false;
            }

            if (!landReported)
            {
                Main.getInstance().sound.play("t_cleared");
                landReported = true;
            }
            return true;
        }
Beispiel #2
0
        /************************************************************
         * Provádí instrukce autopilota při přiblížení na letiště
         * **********************************************************/
        public void approach(Airport airport)
        {
            float distanceOnAxis = airport.GetDistanceOnAxis((float)this.X, (float)this.Y);
            if (distanceOnAxis < 2.0 && !isLanding)
            {
                cancelApproach();
            }
            else
            {
                Vector2 navigationPoint = distanceOnAxis > 12 ? airport.GetPointOnAxis(10) : airport.GetPointOnAxis(distanceOnAxis - 2);
                navX = navigationPoint.X;
                navY = navigationPoint.Y;
                WantedDir = Main.getCourse((float)this.X, (float)this.Y, navigationPoint.X, navigationPoint.Y);

                // sestupová fáze
                if (distanceOnAxis <= 10.0)
                {
                    if (airport.GetAngleFromAxis((float)this.X, (float)this.Y) <= 2.5)
                    {
                        IsDescendingToRunway = true;
                    }
                    if (IsDescendingToRunway)     // Tento a ten horní IF musí zůstat oddělené, jinak nefunguje správně sestup na výšku 0
                    {
                        int newWantedAlt = (int)MathHelper.Lerp(3000, 0, 1.0f - distanceOnAxis / 10.0f);
                        wantedAlt = newWantedAlt < wantedAlt ? newWantedAlt : wantedAlt;
                        if (wantedAlt < 0)
                        {
                            wantedAlt = 0;
                        }
                    }
                }
                if (distanceOnAxis <= 5.0)
                {
                    if (airport.GetAngleFromAxis((float)this.X, (float)this.Y) <= 2.5 && CheckLandingAvailability(airport))
                    {
                        IsLanding = true;
                    }
                    if (IsLanding)  // Tento a ten horní IF musí zůstat oddělené!
                    {
                        int newWantedSpeed = (int)MathHelper.Lerp(200, 130, 1.0f - distanceOnAxis / 5.0f);
                        wantedSpeed = newWantedSpeed < wantedSpeed ? newWantedSpeed : wantedSpeed;
                        if (wantedSpeed < 130)
                        {
                            wantedSpeed = 130;
                        }
                    }
                }
                // Runway touch
                if (!this.falling && Alt == 0)
                {
                    wantedSpeed = (int)MathHelper.Lerp(130, 100, distanceOnAxis == 0 ? 0 : -distanceOnAxis / (float)airport.Length);
                }
                // Landing finished
                if (-distanceOnAxis > 0.5 * airport.Length)
                {
                    if (isLanding && Alt == 0)
                    {
                        landed = true;
                    }
                    else
                    {
                        cancelApproach();
                    }
                }
            }
        }