// Handles when user chooses an option and hits submit
        public async void SubmitClicked(object sender, EventArgs args)
        {
            //send the selected monster info into target
            if (_viewModel.BattleEngine.PlayerCurrent.PlayerType == PlayerTypeEnum.Character)
            {
                _viewModel.BattleEngine.ManualTarget = SelectedMonster;
            }

            //update xaml front end local message section
            if (_viewModel.BattleEngine.TurnType == MoveEnum.Rest)
            {
                LocalMessageText.Text = localMessages;
            }

            else if (_viewModel.BattleEngine.TurnType == MoveEnum.UseItem)
            {
                LocalMessageText.Text = localMessages;
            }

            else
            {
                LocalMessageText.Text = null;
            }
            //do the turn
            _viewModel.RoundNextTurn();


            //update front end options after turn taken


            if (_viewModel.BattleEngine.PlayerCurrent.PlayerType == PlayerTypeEnum.Character)
            {
                ItemPool.IsEnabled       = true;
                GameNextButton.IsEnabled = false;
                AttackButton.IsEnabled   = true;
                RestButton.IsEnabled     = true;
                UseItemButton.IsEnabled  = true;
            }
            else
            {
                ItemPool.IsEnabled       = false;
                GameNextButton.IsEnabled = true;
                AttackButton.IsEnabled   = false;
                RestButton.IsEnabled     = false;
                UseItemButton.IsEnabled  = false;
            }
            // Hold the current state
            var CurrentRoundState = _viewModel.BattleEngine.RoundStateEnum;

            Debug.WriteLine("Current round state after this turn: " + CurrentRoundState.ToString());

            // Draw the Game Board
            DrawGameBoardAttackerDefender();
            RefreshMonsters();
            RefreshCharacters();

            //used if im using an observable collection
            //_viewModel.SyncMonsterAndCharacterLists();


            //updates current player up in frontend
            OnPropertyChanged();

            //reset all these for next turn
            ableToSelectMonster = false;

            SelectedMonster = null;


            // If the round is over start a new one...
            if (CurrentRoundState == RoundEnum.NewRound)
            {
                Debug.WriteLine("NEW ROUND TRIGGERED");
                _viewModel.NewRound();

                // Show new round and Round count
                Debug.WriteLine("New Round :" + _viewModel.BattleEngine.BattleScore.RoundCount);

                //push up modal monster list page to show new monsters youre fighting
                ShowModalPageMonsterList();
                //StartGameSetting();

                // Show name of current player

                Debug.WriteLine("current player: " + _viewModel.BattleEngine.PlayerCurrent.Name);



                if (_viewModel.BattleEngine.PlayerCurrent.PlayerType == PlayerTypeEnum.Character)
                {
                    GameNextButton.IsEnabled = false;
                    AttackButton.IsEnabled   = true;
                    RestButton.IsEnabled     = true;
                    UseItemButton.IsEnabled  = true;
                    ItemPool.IsEnabled       = true;
                }
                else
                {
                    GameNextButton.IsEnabled = true;
                    AttackButton.IsEnabled   = false;
                    RestButton.IsEnabled     = false;
                    UseItemButton.IsEnabled  = false;
                    ItemPool.IsEnabled       = false;
                }
                OnPropertyChanged();
            }


            // Check for Game Over
            if (CurrentRoundState == RoundEnum.GameOver)
            {
                //MessagingCenter.Send(this, "EndBattle");
                _viewModel.EndBattle();
                Debug.WriteLine("End Battle");

                // Output Formatted Results
                var myResult = _viewModel.BattleEngine.GetResultsOutput();
                Debug.Write(myResult);
                OnPropertyChanged();

                // Let the user know the game is over
                GameMessage("Game Over\n");

                // Change to the Game Over Button
                GameNextButton.IsVisible = false;
                GameOverButton.IsVisible = true;

                return;
            }

            // Output The Message that happened.
            GameMessage(_viewModel.BattleEngine.BattleMessages.TurnMessage);


            Debug.WriteLine("List of characters and HP remaining: ");
            foreach (Models.Character character in _viewModel.BattleEngine.CharacterList)
            {
                Debug.WriteLine("Name : " + character.Name);
                Debug.WriteLine("HP : " + character.CharacterAttribute.getCurrentHealth() + "/" + character.CharacterAttribute.getMaxHealth());
            }
            Debug.WriteLine("\n");
            Debug.WriteLine("List of monsters and HP remaining: ");
            foreach (Models.Monster monster in _viewModel.BattleEngine.MonsterList)
            {
                Debug.WriteLine("Name : " + monster.Name);
                Debug.WriteLine("HP : " + monster.MonsterAttribute.getCurrentHealth() + "/" + monster.MonsterAttribute.getMaxHealth());
            }
        }
        /// <summary>
        /// Next Turn Button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public async void OnNextClicked(object sender, EventArgs args)
        {
            // Hold the current state
            var CurrentRoundState = _viewModel.BattleEngine.RoundStateEnum;

            // If the round is over start a new one...
            if (CurrentRoundState == RoundEnum.NewRound)
            {
                //ItemDropPage
                //Send the user to the party page to reorganize their items
                ShowModalPageBattleParty();

                _viewModel.NewRound();
                MessagingCenter.Send(this, "NewRound");
                Debug.WriteLine("New Round :" + _viewModel.BattleEngine.BattleScore.RoundCount);
            }

            // Check for Game Over
            if (CurrentRoundState == RoundEnum.GameOver)
            {
                _viewModel.EndBattle();
                MessagingCenter.Send(this, "EndBattle");
                Debug.WriteLine("End Battle");

                // Output Formatted Results
                var myResult = _viewModel.BattleEngine.GetResultsOutput();
                Debug.Write(myResult);

                // Let the user know the game is over
                ClearMessages();              // Clear message
                AppendMessage("Game Over\n"); // Show Game Over

                // Clear the players from the center of the board
                DrawGameBoardClear();

                // Change to the Game Over Button
                GameNextButton.IsVisible = false;
                GameOverButton.IsVisible = true;


                // Save the Score to the Score View Model, by sending a message to it.
                var myScore = _viewModel.BattleEngine.BattleScore;
                MessagingCenter.Send(this, "AddData", myScore);
                return;
            }

            // Do the turn...
            _viewModel.RoundNextTurn();
            MessagingCenter.Send(this, "RoundNextTurn");

            // Output the Game Board
            DrawGameBoardAttackerDefender();

            // Output The Message that happened.
            GameMessage();

            // Output TimeWarp If it Happens
            if (GameGlobals.TimeWarpEnabled)
            {
                AppendMessage("Time Warp Happened\n");
            }
        }
Example #3
0
        //do this to display next turn button
        public async void Turn_Command(object sender, EventArgs e)
        {
            // go to the next turn
            _instanceC.RoundNextTurn();
            //MessagingCenter.Send(this, "RoundNextTurn");

            // Hold the current state
            var CurrentRoundState = _instanceC.BattleEngine.RoundStateEnum;

            // If the round is over start a new one...
            if (CurrentRoundState == RoundEnum.NewRound)
            {
                ClearMessages();
                _instanceC.NewRound();
                // MessagingCenter.Send(this, "NewRound");

                Debug.WriteLine("!!!!!!!!!!!!!!New Round :" + _instanceC.BattleEngine.BattleScore.RoundCount);

                //ShowModalPageMonsterList();
            }

            // Check for Game Over
            if (CurrentRoundState == RoundEnum.GameOver)
            {
                _instanceC.EndBattle();
                //MessagingCenter.Send(this, "EndBattle");
                Debug.WriteLine("End Battle!!!!!!!!!!!!!!!!!!!");


                // output results of the game after battle is over
                var myResult = _instanceC.BattleEngine.GetResultsOutput();
                var myScore  = _instanceC.BattleEngine.GetScoreValue();
                Debug.Write(myResult);

                // Let the user know the game is over
                ClearMessages();              // Clear message
                AppendMessage("Game Over\n"); // Show Game Over

                var outputString = "Mellow Fox Battle Over!";

                // the pop up for either cancel or see the score details
                var action = await DisplayActionSheet(outputString,
                                                      "Cancel",
                                                      null,
                                                      "View Score Results");

                // Show the results
                if (action == "View Score Results")
                {
                    var myScoreObject = _instanceC.BattleEngine.GetScoreObject();
                    await Navigation.PushAsync(new GameOver(new ScoreDetailViewModel(myScoreObject)));

                    //await Navigation.PushAsync(new ScoreDetailPage(new ScoreDetailViewModel(myScoreObject)));
                }


                return;
            }


            //updates the data
            _instanceC.LoadDataCommand.Execute(null);
            // game message
            GameMessage();
        }