コード例 #1
0
        private async void ShowProtection(VoiceCommandServiceConnection voiceCommandServiceConnection)
        {
            // Show we've recognized the command.
            await this.ReportProgress("Checking your protection status...", voiceCommandServiceConnection);

            // Read data.
            var serializer = new FantasyKingdomSerializer();
            var protection = await serializer.Load<Protection>();

            // Return answer.
            string message;

            if (protection != null)
            {
                if (protection.ExpirationTime < DateTime.Now)
                {
                    message = string.Format(
                        "Unfortunately, your protection has expired at {0}.",
                        protection.ExpirationTime);
                }
                else
                {
                    message = string.Format("Yes, you are still protected until {0}.", protection.ExpirationTime);
                }
            }
            else
            {
                message = "Sorry, I couldn't find any protection status data.";
            }

            await this.ReportSuccess(message, voiceCommandServiceConnection);
        }
コード例 #2
0
        private async void ShowConstruction(VoiceCommandServiceConnection voiceCommandServiceConnection)
        {
            // Show we've recognized the command.
            await this.ReportProgress("Checking your construction progress...", voiceCommandServiceConnection);

            // Read data.
            var serializer = new FantasyKingdomSerializer();
            var construction = await serializer.Load<Construction>();

            // Return answer.
            string message;

            if (construction != null)
            {
                if (construction.FinishedTime < DateTime.Now)
                {
                    message = string.Format(
                        "Your {0} has been finished at {1}.",
                        construction.ConstructionName,
                        construction.FinishedTime);
                }
                else
                {
                    message = string.Format(
                        "Your {0} will be finished at {1}.",
                        construction.ConstructionName,
                        construction.FinishedTime);
                }
            }
            else
            {
                message = "Sorry, I couldn't find any constructions.";
            }

            await this.ReportSuccess(message, voiceCommandServiceConnection);
        }
コード例 #3
0
        private async void ShowTreasury(VoiceCommandServiceConnection voiceCommandServiceConnection)
        {
            // Show we've recognized the command.
            await this.ReportProgress("Checking your treasury...", voiceCommandServiceConnection);

            // Read data.
            var serializer = new FantasyKingdomSerializer();
            var treasury = await serializer.Load<Treasury>();

            // Return answer.
            var message = treasury != null
                ? string.Format(
                    "You have {0} gold.", treasury.Gold)
                : "Sorry, I couldn't find your treasury.";

            await this.ReportSuccess(message, voiceCommandServiceConnection);            
        }
コード例 #4
0
        private async void ShowAttack(VoiceCommandServiceConnection voiceCommandServiceConnection)
        {
            // Show we've recognized the command.
            await this.ReportProgress("Checking for recent attacks...", voiceCommandServiceConnection);

            // Read data.
            var serializer = new FantasyKingdomSerializer();
            var attackReport = await serializer.Load<AttackReport>();

            // Return answer.
            var message = attackReport != null
                ? string.Format(
                    "You have been attacked at {0} by {1}.",
                    attackReport.AttackTime,
                    attackReport.AttackerName)
                : "There haven't been any attacked recently.";

            await this.ReportSuccess(message, voiceCommandServiceConnection);
        }