Beispiel #1
0
        public static int GetAppOpenedCount()
        {
            int    returnValue  = 0;
            string settingValue = string.Empty;

            try
            {
                if (IS.GetSettingStringValue("AppOpenedCount") != string.Empty)
                {
                    settingValue = IS.GetSettingStringValue("AppOpenedCount");
                    returnValue  = Convert.ToInt16(settingValue);
                }
                else   //has not been opened yet
                {
                    returnValue = 0;
                }
            }
            catch (Exception ex)
            {
                ErrorLogConnection cloud = new ErrorLogConnection();
                cloud.UpdateErrorLog("Rate.GetOpenedCount", ex.Message.ToString());
                return(0);
            }
            return(returnValue);
        }
Beispiel #2
0
        //If this is the free version (i.e. only shot available), prompt the user if they would like to purchase the app
        //(this is only done when the 4th play is being entered)
        private void DetermineWhetherToPromptUserToPurchaseApp()
        {
            try
            {
                if (App.DoesUserHaveAbilityToTrackAllStats() == false)
                {
                    if ((App.gAppOpenedCount % 5 == 0) && (App.gHaveWePromptedToPurchase == false))
                    {
                        App.gHaveWePromptedToPurchase = true;
                        CustomMessageBox messageBox = new CustomMessageBox()
                        {
                            Caption            = AppResources.PurchaseApp,
                            Message            = AppResources.PurchaseAppPrompt,
                            LeftButtonContent  = AppResources.PurchaseAppLeftButton,
                            RightButtonContent = AppResources.PurchaseAppRightButton
                        };
                        messageBox.Show();

                        messageBox.Dismissed += (s1, e1) =>
                        {
                            switch (e1.Result)
                            {
                            case CustomMessageBoxResult.LeftButton:
                                (Application.Current.RootVisual as Frame).Navigate(new Uri("/Views/PurchaseApp.xaml", UriKind.Relative));
                                return;

                            case CustomMessageBoxResult.RightButton:
                                _vm.Initialize();
                                break;

                            case CustomMessageBoxResult.None:
                                _vm.Initialize();
                                break;

                            default:
                                break;
                            }
                        };
                    }
                    else
                    {
                        _vm.Initialize();
                    }
                }
                else
                {
                    _vm.Initialize();
                }
            }
            catch (Exception ex)
            {
                ErrorLogConnection cloud = new ErrorLogConnection();
                cloud.UpdateErrorLog("Games.xaml.cs.DetermineWhetherToPromptUserToPurchaseApp", ex.Message.ToString());
                _vm.Initialize();
            }
        }
Beispiel #3
0
        //This is the code to determine whether to prompt user to go to DEMO game
        //We only prompt user to go to demo game if first time opening app AND Free Version
        private void DetermineWhetherToPromptUserToGoToDemoGame()
        {
            try
            {
                if ((demoPrompt == false) && (App.gAppOpenedCount == 1))
                {
                    demoPrompt = true;

                    CustomMessageBox messageBox = new CustomMessageBox()
                    {
                        Caption            = AppResources.DemoGame,
                        Message            = AppResources.GoToDemoGamePrompt,
                        LeftButtonContent  = AppResources.DemoLeftButton,
                        RightButtonContent = AppResources.DemoRightButton
                    };

                    messageBox.Show();

                    messageBox.Dismissed += (s1, e1) =>
                    {
                        switch (e1.Result)
                        {
                        case CustomMessageBoxResult.LeftButton:
                            Demo_Clicked(this, null);
                            break;

                        case CustomMessageBoxResult.RightButton:
                            break;

                        case CustomMessageBoxResult.None:
                            break;

                        default:
                            break;
                        }
                    };
                }
            }
            catch (Exception ex)
            {
                ErrorLogConnection cloud = new ErrorLogConnection();
                cloud.UpdateErrorLog("MainPage.xaml.cs.DetermineWhetherToPromptUserToGoToDemoGame", ex.Message.ToString());
            }
        }
Beispiel #4
0
        public static void UpdateOpenedCount()
        {
            int    newOpenedCount = 0;
            string settingValue   = string.Empty;

            try
            {
                if (IS.GetSettingStringValue("AppOpenedCount") != string.Empty)
                {
                    settingValue   = IS.GetSettingStringValue("AppOpenedCount");
                    newOpenedCount = Convert.ToInt16(settingValue) + 1;
                    IS.SaveSetting("AppOpenedCount", newOpenedCount.ToString());
                }
                else   //has not been opened yet so intitialize as first time being opened
                {
                    IS.SaveSetting("AppOpenedCount", "1");
                }
            }
            catch (Exception ex)
            {
                ErrorLogConnection cloud = new ErrorLogConnection();
                cloud.UpdateErrorLog("Rate.UpdateOpenedCount", ex.Message.ToString());
            }
        }
        public static int CalculateTimeElapsedInGameInSeconds(Game game, int currentPeriod, string currentClock)
        {
            int elapsedTimeInSeconds;

            try
            {
                if (game.ClockUpOrDown.ToUpper() == "DOWN")
                {
                    elapsedTimeInSeconds = CalculateTimeElapsedInGameInSecondsForCLOCKDOWN(game, currentPeriod, currentClock);
                }
                else
                {
                    elapsedTimeInSeconds = CalculateTimeElapsedInGameInSecondsForCLOCKUP(game, currentPeriod, currentClock);
                }

                return(elapsedTimeInSeconds);
            }
            catch (Exception ex)
            {
                ErrorLogConnection cloud = new ErrorLogConnection();
                cloud.UpdateErrorLog("StatCalculationModule.CalculateTimeElapsedInGameInSeconds", ex.Message.ToString());
                return(0);
            }
        }
Beispiel #6
0
        //Prompt to rate every 10th time. 25th time ok only to rate, never prompt them again after they rate.
        public static void RateTheApp()
        {
            try
            {
                //Could have called procs to get if app has been rated or the opened count, but since we do this in app intialize, using global variables instead
                //hasAppBeenRated = HasAppBeenRated();
                //appOpenedCount = GetAppOpenedCount();

                //10/25/14 TJY Change from prompting to rate every 10 times to every 2 times
                if ((App.gAppOpenedCount % 2 == 0) && App.gHasAppBeenRated.ToUpper() == "NO")
                {
                    CustomMessageBox messageBox = new CustomMessageBox()
                    {
                        Caption            = AppResources.RateApp,
                        Message            = AppResources.RateAppQuestion,
                        LeftButtonContent  = AppResources.RateLeftButton,
                        RightButtonContent = AppResources.RateRightButton
                    };

                    messageBox.Show();

                    messageBox.Dismissed += (s1, e1) =>
                    {
                        switch (e1.Result)
                        {
                        case CustomMessageBoxResult.LeftButton:
                            MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
                            marketplaceReviewTask.Show();
                            IS.SaveSetting("AppRated", "YES");
                            App.gHasAppBeenRated = "YES";
                            DAL.Instance().SetUpStatsForApp();     //10/25/14 TJY If Rate app give all stats functionality
                            break;

                        case CustomMessageBoxResult.RightButton:
                            IS.SaveSetting("AppRated", "NO");
                            App.gHasAppBeenRated = "NO";
                            break;

                        case CustomMessageBoxResult.None:
                            break;

                        default:
                            break;
                        }
                    };
                }
                else
                {
                    if (App.gAppOpenedCount >= 12 && App.gHasAppBeenRated.ToUpper() == "NO")
                    {
                        CustomMessageBox messageBox = new CustomMessageBox()
                        {
                            Caption           = AppResources.RateApp,
                            Message           = AppResources.RateAppPrompt,
                            LeftButtonContent = AppResources.Ok
                        };
                        messageBox.Show();

                        messageBox.Dismissed += (s1, e1) =>
                        {
                            switch (e1.Result)
                            {
                            case CustomMessageBoxResult.LeftButton:
                                MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
                                marketplaceReviewTask.Show();
                                IS.SaveSetting("AppRated", "YES");
                                App.gHasAppBeenRated = "YES";
                                DAL.Instance().SetUpStatsForApp();     //10/25/14 TJY If Rate app give all stats functionality
                                break;

                            case CustomMessageBoxResult.RightButton:
                                break;

                            case CustomMessageBoxResult.None:
                                break;

                            default:
                                break;
                            }
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLogConnection cloud = new ErrorLogConnection();
                cloud.UpdateErrorLog("RATE.RateTheApp", ex.Message.ToString());
            }
        }