Beispiel #1
0
        public void StartLanding()
        {
            Helpers.AudioHelper.ToggleEngine();

            Device.StartTimer(TimeSpan.FromMilliseconds(Common.CoreConstants.PollingIncrement), () =>
            {
                UpdateFlightParameters();

                if (this.ActiveLandingParameters.Altitude > 0.0)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        this.Altitude      = this.ActiveLandingParameters.Altitude;
                        this.DescentRate   = this.ActiveLandingParameters.Velocity;
                        this.FuelRemaining = this.ActiveLandingParameters.Fuel / 1000;
                        this.Thrust        = this.ActiveLandingParameters.Thrust;
                    });

                    if (this.FuelRemaining == 0.0)
                    {
                        Helpers.AudioHelper.KillEngine();
                    }
                    if (this.IsAuthenticated)
                    {
                        Helpers.ActivityHelper.SendTelemetryAsync(this.UserId, this.Altitude, this.DescentRate, this.FuelRemaining, this.Thrust);
                    }

                    return(this.IsActive);
                }
                else
                {
                    this.ActiveLandingParameters.Altitude = 0.0;
                    this.IsActive = false;

                    Device.BeginInvokeOnMainThread(() =>
                    {
                        this.Altitude      = this.ActiveLandingParameters.Altitude;
                        this.DescentRate   = this.ActiveLandingParameters.Velocity;
                        this.FuelRemaining = this.ActiveLandingParameters.Fuel / 1000;
                        this.Thrust        = this.ActiveLandingParameters.Thrust;
                    });

                    LandingResultType landingResult = (this.ActiveLandingParameters.Velocity > -5.0) ? LandingResultType.Landed : LandingResultType.Kaboom;

                    if (this.IsAuthenticated)
                    {
                        Helpers.ActivityHelper.SendTelemetryAsync(this.UserId, this.Altitude, this.DescentRate, this.FuelRemaining, this.Thrust);
                        Helpers.ActivityHelper.AddActivityAsync(landingResult);
                    }

                    MessagingCenter.Send(this.ActivityPage, "ActivityUpdate", landingResult);
                    return(false);
                }
            });
        }
Beispiel #2
0
 public static async void AddActivityAsync(LandingResultType landingResult)
 {
     try {
         await TelemetryManager.DefaultManager.AddActivityAsync(new ActivityItem()
         {
             ActivityDate = DateTime.Now.ToUniversalTime(),
             Status       = landingResult.ToString(),
             Description  = (landingResult == LandingResultType.Landed) ? "The Eagle has landed!" : "That's going to leave a mark!"
         });
     }
     catch { }
 }