private bool GameTimerCallback()
        {
            Count--;
            if (Count < 0)
            {
                timerIsVisible = false;
                canvasView.InvalidateSurface();
                DisplayAlert("Defeat", "You have lost", "Ok").GetAwaiter().OnCompleted(async() => {
                    if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.iOS)
                    {
                        await Navigation.PushAsync(new AdvPage());
                    }
                    else
                    {
                        BrowserPage browser = new BrowserPage();
                        await Navigation.PushAsync(browser);
                        browser.Navigate(App.Rest.advUrl);
                    }
                });

                return(false);
            }
            else
            {
                canvasView.InvalidateSurface();
                return(true);
            }
        }
示例#2
0
        private async void ShowAd()
        {
            if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.iOS)
            {
                await Navigation.PushAsync(new AdvPage());
            }
            else
            {
                BrowserPage browser = new BrowserPage();
                await Navigation.PushAsync(browser);

                browser.Navigate(App.Rest.advUrl);
            }
        }
        private async void OnWrongConfiguration(object sender, ConfigEventArgs args)
        {
            const float degreeStep       = 15.0f;
            const int   delayMicrosecond = 15;
            int         FRow             = args.FRow;
            int         FCol             = args.FCol;
            int         SRow             = args.SRow;
            int         SCol             = args.SCol;
            int         soundId          = rnd.Next(defeats.Length);
            await       defeats[soundId].PlaySoundAsync();

            tiles[FRow][FCol].IsRotating = true;
            tiles[SRow][SCol].IsRotating = true;
            await Task.Delay(1000);

            while (tiles[FRow][FCol].Deg <= 90 - degreeStep)
            {
                await Task.Delay(delayMicrosecond);

                await Device.InvokeOnMainThreadAsync(() => tiles[FRow][FCol].Deg = tiles[FRow][FCol].Deg + degreeStep);

                await Device.InvokeOnMainThreadAsync(() => tiles[SRow][SCol].Deg = tiles[SRow][SCol].Deg + degreeStep);
            }
            while (tiles[FRow][FCol].Deg >= 0 + degreeStep)
            {
                await Task.Delay(delayMicrosecond);

                await Device.InvokeOnMainThreadAsync(() => tiles[FRow][FCol].Deg = tiles[FRow][FCol].Deg - degreeStep);

                await Device.InvokeOnMainThreadAsync(() => tiles[SRow][SCol].Deg = tiles[SRow][SCol].Deg - degreeStep);
            }
            await Device.InvokeOnMainThreadAsync(() => tiles[FRow][FCol].Deg = 0);

            await Device.InvokeOnMainThreadAsync(() => tiles[SRow][SCol].Deg = 0);

            tiles[FRow][FCol].IsRotating = false;
            tiles[SRow][SCol].IsRotating = false;

            ////
            _Busy.Release();
            bool cond1 = tiles[FRow][FCol].WasTapped;
            bool cond2 = tiles[SRow][SCol].WasTapped;

            if (cond1 || cond2)
            {
                ErrorCounter++;
                if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.iOS)
                {
                    await Navigation.PushAsync(new AdvPage());
                }
                else
                {
                    BrowserPage browser = new BrowserPage();
                    await Navigation.PushAsync(browser);

                    browser.Navigate(App.Rest.advUrl);
                }
            }

            tiles[FRow][FCol].WasTapped = true;
            tiles[SRow][SCol].WasTapped = true;

            tiles[FRow][FCol].Flipped = false;
            tiles[SRow][SCol].Flipped = false;
        }