示例#1
0
        /// <summary>
        /// Gets the current expense alert from the server
        /// </summary>
        /// <returns>Alert from server</returns>
        public async Task <Alert> ExecuteLoadAlert()
        {
            LoadedAlert = true;
            try
            {
                var client = new HttpClient();
                client.Timeout = new TimeSpan(0, 0, 0, 5);

                var response = await client.GetStringAsync("https://gist.github.com/jamesmontemagno/a54af53e027308362415/raw/a828b194254b241281aad79cd362c33295fdb183/gistfile1.txt");

                var alert = await ExpenseService.DeserializeObjectAsync <Alert>(response);

                messageDialog.SendMessage(alert.Details, alert.AlertDateDisplay);
                return(alert);
            }
            catch (Exception exception)
            {
                Debug.WriteLine("Unable to query and gather expenses");
            }
            finally
            {
            }

            return(null);
        }
        public async Task <Expense> SaveExpense(Expense item)
        {
            try
            {
                item.IsDirty = false;
                //if it is new then inser record, else update!
                if (string.IsNullOrWhiteSpace(item.AzureId))
                {
                    await azureService.InsertExpenseAsync(item);
                }
                else
                {
                    await azureService.UpdateExpenseAsync(item);
                }
            }
            catch (Exception ex)
            {
                item.IsDirty = true;
                //unable to sync
                dialog.SendMessage(ex.Message, "Problem!");
            }

            return(await Task.Factory.StartNew(() =>
            {
                var id = db.SaveItem <Expense>(item);
                item.Id = id;
                return item;
            }));
        }
        public void CheckAnswer(int answer)
        {
            if (!place.Question.Answers[answer].IsAnswer)
            {
                messages.SendMessage("Wrong Answer", "Quick Hint: I Love you");
            }

            PlaceComplete = true;
        }
示例#4
0
        private void ExecuteSelectWinnerCommand()
        {
            var potential = members.Where(m => m.CheckedIn).ToList();
            var count     = potential.Count;
            var message   = string.Empty;

            if (count == 0)
            {
                message = "No one has checked in.";
            }
            else if (count == 1)
            {
                message = potential[0].Name + " | " + potential[0].Member.MemberId;
            }
            else
            {
                var member = potential[random.Next(count)];
                message = member.Name + " | " + member.Member.MemberId;
            }

            messageDialog.SendMessage(message, "Winner!!!");
        }
        public async Task ExecuteLoadGameCommand()
#endif
        {
            if (IsBusy)
            {
                return;
            }

            try
            {
                IsBusy = true;
#if TESTER
                var url = string.Format(GameUrl, game);
#else
                var url = string.Format(GameUrl, random.Next(0, 3));
                //var url = string.Format(GameUrl, 0);
#endif
                #if __IOS__
                var client = new HttpClient(new ModernHttpClient.NativeMessageHandler());
                #else
                var client = new HttpClient();
                #endif
                client.Timeout = new TimeSpan(0, 0, 15);
                var result = await client.GetStringAsync(url);

                Game = JsonConvert.DeserializeObject <Game>(result);

                await FileCache.SaveGameDataAsync(result);

                GameLoaded = true;
                #if !__UNIFIED__
                Xamarin.Insights.Track("GameStarted");
                #endif
            }
            catch (Exception ex)
            {
                #if !__UNIFIED__
                Xamarin.Insights.Report(ex);
                #endif
                messages.SendMessage("Not all who wander are lost...", "But you might be. Looks like you were unable to load Evolve Quest because you dropped the connection. Please check if you have reception and try again.");
            }
            finally
            {
                IsBusy = false;
            }
        }
        /// <summary>
        /// Checks the banana.
        /// </summary>
        /// <returns><c>true</c>, if banana was checked, <c>false</c> otherwise.</returns>
        /// <param name="major">Major number of the beacon.</param>
        /// <param name="minor">Minor number of the beacon.</param>
        public void CheckBanana(int major, int minor)
        {
            if (major == 9999 && minor == 1000)
            {
                //Spy monkey found! pop up funny dialog here!
                return;
            }

            if (major == 9999 && major == 9999)
            {
                if (Settings.SecretBeaconFound)
                {
                    return;
                }

                messages.SendMessage("Congratulations!", "You found the top secret hidden beacon and have unlocked a special prize at the end of your adventure!");
                Settings.SecretBeaconFound = true;
                OnPropertyChanged(SecretBananaFoundPropertyName);
                return;
            }

            messages.SendToast("So close! Try another beacon.");
        }
示例#7
0
 private void ExecuteShowInfoCommand()
 {
     dialog.SendMessage("Created by @JamesMontemagno Copyright 2014 Refractored LLC. Open source and created completely in C# with Xamarin!", "About");
 }
示例#8
0
        /// <summary>
        /// Checks the banana.
        /// </summary>
        /// <returns><c>true</c>, if banana was checked, <c>false</c> otherwise.</returns>
        /// <param name="major">Major number of the beacon.</param>
        /// <param name="minor">Minor number of the beacon.</param>
        public void CheckBeacon(int major, int minor)
        {
            if (major == 9999 && minor == 1000)
            {
                //Spy monkey found! pop up funny dialog here!
                return;
            }

            if (major == 9999 && major == 9999)
            {
                if (Settings.SecretBeaconFound)
                {
                    return;
                }

                messages.SendMessage("Congratulations!", "You found the top secret hidden beacon and have unlocked a special prize at the end of your adventure!");
                Settings.SecretBeaconFound = true;
                return;
            }

            bool found = true;

            try
            {
                if (quest == null)
                {
                    return;
                }

                found = false;

                if (major != Quest.Major)
                {
                    return;
                }

                foreach (Beacon beacon in Quest.Beacons)
                {
                    if (beacon.Found)
                    {
                        if (beacon.Minor == minor)
                        {
                            found = true;
                        }

                        continue;
                    }

                    if (beacon.Minor == minor)
                    {
                        beacon.Found = true;
                        OnPropertyChanged(QuestsPropertyName); //refresh bananas!

                        CheckEndQuest();
                        found = true;
                    }
                }
            }
            finally
            {
                if (!found)
                {
                    messages.SendToast("So close! Try another beacon.");
                }
            }
        }