예제 #1
0
        private async void updateWind(object sender, EventArgs e)
        {
            WindService service = new WindService();
            WindInfo    x       = await service.getCurrentWindInfo();

            strength.Text  = x.strength.ToString();
            windImg.Source = x.icon;
            await windImg.RotateTo(90 + x.direction);
        }
예제 #2
0
        /**
         * This method is executed when the page is loaded
         * */
        async protected override void OnAppearing()
        {
            base.OnAppearing();
            if (holFini == 0)
            {
                return;
            }

            //if there is still a hole to play
            if (partie.nextHole() && holFini != 2)//holFini == 2 means the user wants to stop the game before the end
            {
                updateScore();
                loadCard();
                Hole nextHole = partie.getNextHole();
                map.setHolePosition(nextHole);
                numcoup.Text = partie.getCurrentHoleNumero() + "";
                parTrou.Text = "PAR " + partie.getNextHole().Par.ToString();
                MyPosition position = new MyPosition(0, 0);
                //make sure that the GPS is avaible
                try
                {
                    position = await localize();

                    map.setUserPosition(position, partie.Shots.Count);
                    partie.CurrentClub = partie.CurrentClub;//just to update the circle
                }
                catch (Exception e)
                {
                    await DisplayAlert("Gps non disponible", "La localisation GPS n'est pas disponible, assurez-vous de l'avoir activé.", "OK");

                    await Navigation.PopToRootAsync();//come back to root to avoid any problems in the game flow
                }

                updateDistance(true);

                //manage the wind icon
                try
                {
                    WindService service = new WindService();
                    await Task.Run(async() =>
                    {
                        WindInfo windInfo = await service.getCurrentWindInfo(map.getUserPosition());
                        Device.BeginInvokeOnMainThread(async() =>
                        {
                            await UpdateWindServiceUI(windInfo);
                        });
                    });
                }
                catch (Exception e)
                {
                    await DisplayAlert("Vent non disponible", "L'information concernant le vent n'est pas disponible", "OK");
                }
            }
            else  //user wants to stop the game
            {
                await Navigation.PushAsync(new GameFinishedPage(partie));

                return;
            }
            holFini = 0;
        }