private void BattleResult(BattleWindow battle) { switch (battle.BattleStatus) { case BattleWindow.Status.Victory: tbLog.Document.Blocks.Add(new Paragraph(new Run($"{gameSession.Hero.Name} kill {gameSession.CurrentEnemy.Name}." + Environment.NewLine))); tbLog.Document.Blocks.Add(new Paragraph(new Run($"{gameSession.Hero.Name} got {gameSession.CurrentEnemy.RewardEXP} exp and {gameSession.CurrentEnemy.RewardGold} gold." + Environment.NewLine))); gameSession.Hero.CurrentEXP += gameSession.CurrentEnemy.RewardEXP; gameSession.Hero.Gold += gameSession.CurrentEnemy.RewardGold; LootEnemy(); gameSession.Hero.LevelUP(); // Check for LevelUP UpdateLocationData(); break; case BattleWindow.Status.Defeat: tbLog.Document.Blocks.Add(new Paragraph(new Run($"{gameSession.CurrentEnemy.Name} kill {gameSession.Hero.Name}." + Environment.NewLine))); gameSession.CurrentLocation = gameSession.Checkpoint; gameSession.Hero.HealingAfterDeath(); break; case BattleWindow.Status.Escape: tbLog.Document.Blocks.Add(new Paragraph(new Run($"You successfully escaped from battle." + Environment.NewLine))); break; default: tbLog.Document.Blocks.Add(new Paragraph(new Run($"You coward! You closed the battle!" + Environment.NewLine))); break; } }
// Timer starts as soon as player encounter aggressive enemy on location private void aggroTimer_Tick(object sender, EventArgs e) { gameSession.CurrentEnemy.HasAdvantage = true; BattleWindow battle = new BattleWindow(gameSession); battle.ShowDialog(); BattleResult(battle); gameSession.CurrentEnemy = null; aggroTimer.Stop(); }
private void AttackEnemy(object sender, MouseButtonEventArgs e) { if (aggroTimer != null) { if (aggroTimer.IsEnabled) { aggroTimer.Stop(); } } if (gameSession.CurrentEnemy == null) { return; } BattleWindow battle = new BattleWindow(gameSession); battle.ShowDialog(); BattleResult(battle); gameSession.CurrentEnemy = null; }