private void BtnAttack_Click(object sender, RoutedEventArgs e) { bool added = (Game.Map.Adventurer + Game.Map.CurrentLocation.Monster); pbHeroHealth.Value -= (double)(Game.Map.Adventurer.CurrentHitPoints / Game.Map.Adventurer.MaximumHitPoints) * 100.0; pbMonsterHealth.Value -= (double)(Game.Map.CurrentLocation.Monster.CurrentHitPoints / Game.Map.CurrentLocation.Monster.MaximumHitPoints) * 100.0; Window wnd = null; if (Game.Map.Adventurer.IsAlive == false) { Game.GameStates = Game.GameState.Lost; wnd = new frmGameOver(); wnd.Show(); this.Close(); } else if (Game.Map.CurrentLocation.Monster.IsAlive == false) { Game.Map.Cells[Game.Map.Adventurer.PositionY, Game.Map.Adventurer.PositionX].Monster = null; this.Close(); } else { ChangingData(); } }
/// <summary> /// Gets frmItem or frmMonster when hero moves down /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnDown_Click(object sender, RoutedEventArgs e) { if (Game.Map.MoveHero(Actor.Direction.Down)) { Window wind = null; if (Game.Map.CurrentLocation.HasItem) { if (Game.Map.CurrentLocation.Item.GetType() == typeof(Door)) { wind = new frmGameOver(); } else { wind = new frmItem(); } } else if (Game.Map.CurrentLocation.HasMonster) { wind = new frmMonster(); } if (wind != null) { wind.ShowDialog(); } } ShowContent(); AssignGameState(); }
/// <summary> /// Assigns the game state if lost /// </summary> public void AssignGameState() { if (Game.GameStates == Game.GameState.Lost) { frmGameOver frm = new frmGameOver(); frm.ShowDialog(); } }
/// <summary> /// Creating a method tocall the subform when game is lost. /// </summary> private void HandleGameState() { if (Game.State == Game.GameState.Lost) { Window wd = new frmGameOver(); wd.ShowDialog(); //DrawMap(); } }
/// <summary> /// making the move button which make hero to enable in map /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnMove_Click(object sender, RoutedEventArgs e) { Button btn = (Button)sender; Actor.Direction dir = (Actor.Direction)btn.Tag; bool needToAct = Game.Map.MoveAdventurer(dir); if (needToAct) { Window wnd = null; if (Game.Map.CurrentLocation.HasItem) { wnd = new frmItem(); } // checking wether the hero current location has door if (Game.Map.CurrentLocation.Item is Door) { Game.State = Game.GameState.Won; wnd = new frmGameOver(); } else if (Game.Map.CurrentLocation.HasMonster) { wnd = new frmMonster(); } else { // do nothing } if (wnd != null) { wnd.ShowDialog(); } } DrawMap(); updateDetail(); }
/// <summary> /// attacking the hero /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAttack_Click(object sender, RoutedEventArgs e) { bool action = (Game.Map.Adventurer + Game.Map.CurrentLocation.Monster); Window wnd = null; if (Game.Map.Adventurer.isAlive() == false) { Game.State = Game.GameState.Lost; wnd = new frmGameOver(); wnd.Show(); this.Close(); } else if (Game.Map.CurrentLocation.Monster.isAlive() == false) { Game.Map.Cells[Game.Map.Adventurer.PositionY, Game.Map.Adventurer.PositionX].Monster = null; this.Close(); } else { displayInfo(); } }