/// <summary> /// Stand up the Page and initiate state /// </summary> public BattleMainPage() { _viewModel = BattleViewModel.Instance; BindingContext = _viewModel; InitializeComponent(); // Show the Next button, hide the Game Over button GameNextButton.IsVisible = true; GameOverButton.IsVisible = false; _viewModel.StartBattle(); Debug.WriteLine("Battle Start" + " Characters :" + _viewModel.BattleEngine.CharacterList.Count); // Load the Characters into the Battle Engine _viewModel.LoadCharacters(); // Start the Round _viewModel.StartRound(); Debug.WriteLine("Round Start" + " Monsters:" + _viewModel.BattleEngine.MonsterList.Count); // Clear the Screen ClearMessages(); ShowModalPageMonsterList(); AllCharactersToScreen(); MessagingCenter.Subscribe <BattlePartyPage>(this, "PartyPageClosed", (PartyPage) => { ShowModalPageMonsterList(); }); }
// think about passing characters or something else instead of game engines public BattleBeginPage() { _instanceC = BattleViewModel.Instance; InitializeComponent(); _instanceC.StartBattle(); // Load the Characters into the Battle Engine _instanceC.LoadCharacters(); Debug.WriteLine("Battle Start" + " Characters :" + _instanceC.BattleEngine.CharacterList.Count); _instanceC.StartRound(); Debug.WriteLine("Round Start" + " Monsters:" + _instanceC.BattleEngine.MonsterList.Count); Debug.WriteLine("########################################"); Debug.WriteLine(Environment.NewLine); BindingContext = _instanceC; //debug for monsters Debug.WriteLine("Monsters are Below :"); for (var i = 0; i < 6; i++) { Debug.WriteLine(_instanceC.BattleEngine.MonsterList[i].FormatOutput()); } Debug.WriteLine("########################################"); Debug.WriteLine(Environment.NewLine); Debug.WriteLine("########################################"); //debug for characters Debug.WriteLine("Charcters are Below :"); //characters below for (var i = 0; i < _instanceC.BattleEngine.CharacterList.Count; i++) { Debug.WriteLine(_instanceC.BattleEngine.CharacterList[i].FormatOutput()); } Debug.WriteLine("########################################"); Debug.WriteLine(Environment.NewLine); Debug.WriteLine("########################################"); }
// When this button is clicked, create Battle page (with no info for now) private async void SelectStartButton_Command(object sender, EventArgs e) { _viewModel.StartRound(); await Navigation.PushAsync(new BattlePage(BattleViewModel.Instance)); }
// Initialize page and populate buttons public BattleMonsterListPage() { InitializeComponent(); _viewModel = BattleViewModel.Instance; //MessagingCenter.Send(this, "StartBattle"); //handle round number 2+ Debug.WriteLine("Current round count in the monsterListPage: " + _viewModel.BattleEngine.BattleScore.RoundCount); if (_viewModel.BattleEngine.BattleScore.RoundCount > 1) { _viewModel.NewRound(); } //handles rounds 1 else { _viewModel.StartBattle(); Debug.WriteLine("Battle Start" + " Characters :" + BattleViewModel.Instance.BattleEngine.CharacterList.Count); // Load the Characters into the Battle Engine //MessagingCenter.Send(this, "LoadCharacters"); _viewModel.LoadCharacters(); // Start the Round //MessagingCenter.Send(this, "StartRound"); _viewModel.StartRound(); Debug.WriteLine("Round Start" + " Monsters:" + BattleViewModel.Instance.BattleEngine.MonsterList.Count); foreach (Models.Monster Monster in BattleViewModel.Instance.BattleEngine.MonsterList) { Debug.WriteLine("Round Start" + " Monster List:" + Monster.Name); } Debug.WriteLine("round start observable collection monster list: "); } Datalist = BattleViewModel.Instance.BattleEngine.MonsterList; BindingContext = Datalist; foreach (var data in Datalist) { var myHP = new Label() { Text = "HP : " + data.GetHealthCurrent(), TextColor = Color.Black, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center }; var myLevel = new Label() { Text = "Level : " + data.Level, TextColor = Color.Black, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center }; var myName = new Label() { Text = data.Name, TextColor = Color.White, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center }; var myURI = "Troll2.png"; if (!string.IsNullOrEmpty(data.ImageURI)) { myURI = data.ImageURI; } var myImage = new Image() { //Source = FileImageSource.FromUri(new Uri(myURI)), Source = myURI, WidthRequest = 50.0, HeightRequest = 50.0 }; StackLayout OuterFrame = new StackLayout { MinimumWidthRequest = 400, WidthRequest = 400, Padding = 10 }; OuterFrame.Children.Add(myImage); OuterFrame.Children.Add(myName); OuterFrame.Children.Add(myLevel); OuterFrame.Children.Add(myHP); MonsterListFrame.Children.Add(OuterFrame); } }