Exemple #1
0
        private void GameOnGameOver(object sender, EventArgs eventArgs)
        {
            AllGamesOver = (bc.Game.IsGameOver);
            if (!AllGamesOver)
            {
                return;
            }

            ShowAchievement("No more moves", "GAME OVER");

#if GOOGLE_ANALYTICS
            EasyTracker.GetTracker().SendEvent("GameOver" + bc.Game.GameDefinition.UniqueId, "Score", null, TotalScore);
            EasyTracker.GetTracker().SendEvent("GameOver" + bc.Game.GameDefinition.UniqueId, "Moves", null, bc.Game.Moves);
            if (TotalScore == bc.Game.GameData.BestScore)
            {
                EasyTracker.GetTracker().SendEvent("BestScore" + bc.Game.GameDefinition.UniqueId, "BestScore", null, bc.Game.GameData.BestScore);
            }
#endif

            ShowShare = true;
            PlayGrid.IsHitTestVisible = true;
            PlayGrid.AnimateAsync(new FadeInAnimation());
            PlayButton.IsHitTestVisible = true;
            PlayButton.AnimateAsync(new BounceInUpAnimation());

            bc.SaveData();
        }
Exemple #2
0
        private async void PlayButton_Click(object sender, RoutedEventArgs routedEventArgs)
        {
            await PlayGrid.AnimateAsync(new FadeOutAnimation());

            PlayGrid.IsHitTestVisible = false;

#if GOOGLE_ANALYTICS
            EasyTracker.GetTracker().SendEvent("GameStart" + bc.Game.GameDefinition.UniqueId, "Start", null, 0);
#endif

            await bc.Clear();

            bc.Game.Setup();

            TotalScore   = 0;
            AllGamesOver = false;
        }
Exemple #3
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (bc.Game == null)
            {
                var games = await GameDefinitionSource.LoadDataAsync();

                var gameDefinition = games.FirstOrDefault(g => g.UniqueId == (string)e.Parameter);
                if (gameDefinition == null)
                {
                    return;
                }

                bc.Build(gameDefinition);

                bc.Game.TileMoved += GameOnTileMoved;
                bc.NewHighScore   += GameOnNewHighScore;
                bc.NewAchievement += GameOnNewAchievement;
                bc.Game.GameWon   += GameOnGameWon;
                bc.Game.GameOver  += GameOnGameOver;
            }

            if (TotalScore == 0)
            {
                bc.LoadData();
                TotalScore = bc.Game.Score;
                BestScore  = bc.Game.GameData.BestScore;
                Rank       = BinaryGame.GetRank(bc.Game.GameData.BestPiece);
            }
            Rank = BinaryGame.GetRank(bc.Game.GameData.BestPiece);

#if GOOGLE_ANALYTICS
            EasyTracker.GetTracker().SendView("Main" + bc.Game.GameDefinition.UniqueId);
#endif

            if (TotalScore == 0)
            {
                PlayGrid.AnimateAsync(new FadeInAnimation {
                    Delay = 0.3
                });
                PlayButton.AnimateAsync(new BounceInUpAnimation {
                    Delay = 0.4
                });

                PlayGrid.IsHitTestVisible   = true;
                PlayButton.IsHitTestVisible = true;
            }
            else
            {
                PlayGrid.Opacity            = 0;
                PlayGrid.IsHitTestVisible   = false;
                PlayButton.Opacity          = 0;
                PlayButton.IsHitTestVisible = false;
            }

            DataTransferManager.GetForCurrentView().DataRequested += DataTransferManagerOnDataRequested;

            Window.Current.CoreWindow.KeyUp  += CoreWindow_KeyUp;
            Window.Current.VisibilityChanged += OnVisibilityChanged;
        }