コード例 #1
0
        /// <summary>
        /// Event handler for auto-battle button.
        /// Runs auto-battle, then saves the score in the data source.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public async void AutobattleButton_Clicked(object sender, EventArgs e)
        {
            // Call into Auto Battle from here to do the Battle...

            var Engine = new Game.Engine.AutoBattleEngine();

            // Check whether user has enabled Critical Hits (hackathon rule)
            Engine.CriticalHitsEnabled = BattleEngineViewModel.Instance.Engine.CriticalHitsEnabled;

            // Check whether user has enabled Critical Miss (hackathon rule)
            Engine.CriticalMissEnabled = BattleEngineViewModel.Instance.Engine.CriticalMissEnabled;

            // Check whether user has enabled cloud item drops in battle
            Engine.CloudItemDropEnabled = BattleEngineViewModel.Instance.Engine.CloudItemDropEnabled;

            await Engine.RunAutoBattle();

            var Score = Engine.GetScoreObject();

            string BattleMessage = string.Format("Done {0} Rounds", Score.RoundCount);

            BattleMessageValue.Text = BattleMessage;

            // save new score to data source
            MessagingCenter.Send(this, "Create", Score);
            await Navigation.PushModalAsync(new NavigationPage(new ScorePage(new GenericViewModel <ScoreModel>(), Score)));
        }
コード例 #2
0
        /// <summary>
        /// Auto battle button to call auto battle engine and display the results
        /// </summary>
        public async void AutobattleButton_Clicked(object sender, EventArgs e)
        {
            // Call into Auto Battle from here to do the Battle...

            var Engine = new Game.Engine.AutoBattleEngine();

            var result = await Engine.RunAutoBattle();

            var Score = Engine.GetScoreObject();

            string RoundMessage  = string.Format("No of Rounds: {0}\n", Score.RoundCount);
            string TurnMessage   = string.Format("No of Turns: {0}\n", Score.TurnCount);
            string BattleDetails = "Game Over\n" + RoundMessage + TurnMessage;

            BattleDetails           = BattleDetails.Replace("\n", Environment.NewLine);
            BattleMessageValue.Text = BattleDetails;
        }