private void HandleModalPopping(object sender, ModalPoppingEventArgs e) { if (e.Modal == _myModalBattleMonsterListPage) { DrawGameBoardAttackerDefender(); StartGameSetting(); RefreshMonsters(); RefreshCharacters(); _myModalBattleMonsterListPage = null; // remember to remove the event handler WDown.App.Current.ModalPopping -= HandleModalPopping; } if (e.Modal == _myModalCharacterSelectPage) { _myModalCharacterSelectPage = null; // remember to remove the event handler WDown.App.Current.ModalPopping -= HandleModalPopping; } if (e.Modal == _myModalUseItemPage) { _myModalUseItemPage = null; WDown.App.Current.ModalPopping -= HandleModalPopping; localMessages = "Character Healed!!"; //refresh curr player stats //cannot attack or rest AttackButton.IsEnabled = false; RestButton.IsEnabled = false; GameNextButton.IsEnabled = true; DrawGameBoardAttackerDefender(); ItemPool.IsEnabled = false; } if (e.Modal == _myModalItemPoolPage) { _myModalUseItemPage = null; WDown.App.Current.ModalPopping -= HandleModalPopping; localMessages = "Items Equipped! "; //refresh currPlayer stats DrawGameBoardAttackerDefender(); //cannot attack or rest AttackButton.IsEnabled = false; RestButton.IsEnabled = false; GameNextButton.IsEnabled = true; //refresh DrawGameBoardAttackerDefender(); } }
public async void ShowUseItemModal(object sender, EventArgs args) { //var player1 = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer(); //string filename1 = "item.mp3"; ////player1.Load(GetStreamFromFile(filename1)); //player1.Load(filename1); //player1.Play(); Debug.WriteLine("Switching to Item Inventory..."); WDown.App.Current.ModalPopping += HandleModalPopping; _myModalUseItemPage = new BattleUseItemPage(_viewModel); await Navigation.PushModalAsync(_myModalUseItemPage); localMessages = "Items equipped! "; //swithcing turn type _viewModel.BattleEngine.TurnType = MoveEnum.UseItem; //button handling is handled in handle modal popping method }