public void ProcessAttackScreen(Humanoid Enemy) { stats.UpdateWorld(this); while (Enemy.IsAlive() && MainCharacter.IsAlive()) { Humanoid FirstAttacker = MainCharacter.GetWearablePower().Defence <= Enemy.GetWearablePower().Defence ? MainCharacter : Enemy; Humanoid SecondAttacker = FirstAttacker == MainCharacter ? Enemy : MainCharacter; int damage = 0; if (FirstAttacker == MainCharacter) { if (GetMainCharacterAttackAnswer(out damage)) { return; } else { MainCharacter.AttackOther(Enemy, damage); } if (Enemy.IsAlive()) { AttackMainPlayWithEnemy(Enemy); } } else { AttackMainPlayWithEnemy(Enemy); if (MainCharacter.IsAlive()) { if (GetMainCharacterAttackAnswer(out damage)) { return; } else { MainCharacter.AttackOther(Enemy, damage); } } } } double distance = (new System.Windows.Point(CurrentX, CurrentY) - new System.Windows.Point(HomeTown.X, HomeTown.Y)).LengthSquared; if (distance < 0) { distance = -distance; } int Income = (int)(distance * 0.25d); if (Enemy.IsAlive()) { if (Income > 0) { MainCharacter.Orens -= Income; WriteLineColor($"You have been defeated in battle.", ConsoleColor.DarkMagenta, ConsoleColor.Black); WriteLineColor($"You woke in your bed.", ConsoleColor.DarkMagenta, ConsoleColor.Black); WriteLineColor($"{GetOrenLabel(Income)} have been deducted from your bag...", ConsoleColor.DarkMagenta, ConsoleColor.Black); WriteLineColor($"You now have {GetOrenLabel(MainCharacter.Orens)}", ConsoleColor.Yellow, ConsoleColor.Black); } CurrentLocation = Location.LocationSpot; CurrentX = HomeTown.X; CurrentY = HomeTown.Y; ActiveLocation = HomeTown; ActiveWorld.IncrementTime(12, false); } else { WriteLineColor($"You have defeated your enemy in battle!", ConsoleColor.DarkMagenta, ConsoleColor.Black); switch (Enemy.Race) { case Race.Orc: TotalOrcsDefeated += 1; break; case Race.Human: TotalHumansDefeated += 1; break; case Race.Elf: TotalElfsDefeated += 1; break; default: break; } if (Income > 0) { MainCharacter.Orens += Income; WriteLineColor($"You found {GetOrenLabel(Income)} while searching the enemies body!!!", ConsoleColor.Yellow, ConsoleColor.Black); if (Enemy.Hands != null && Percent(50)) { WriteLineColor($"You have found {Enemy.Hands.Name}.", ConsoleColor.Yellow, ConsoleColor.Black); MainCharacter.Inventory.Items.Add(WeaponItem.Clone(Enemy.Hands)); } WriteLineColor($"You now have {GetOrenLabel(MainCharacter.Orens)}", ConsoleColor.Yellow, ConsoleColor.Black); } ActiveWorld.IncrementTime(1, false); } }
public void ProcessRandomEvent() { if (Percent(50)) // 100 / 2 = 50% { if (Percent(25)) // 100 / 4 = 25% { CurrentForestEvent = ForestEvent.Battle; var Enemies = new Humanoid(); Enemies.Gender = (Gender)random.Next(2); Enemies.Race = (Race)random.Next(3); Enemies.SetLevel(MainCharacter.CombatLevel.Value); if (Percent(50)) { Enemies.Hands = WeaponItem.Clone(Database.Weapons[random.Next(Database.Weapons.Count)]); } WriteLineColor($"You are under attack by a {Enemies.Gender} {Enemies.Race} level {Enemies.CombatLevel.Value}!!!!", ConsoleColor.Red, ConsoleColor.Black); var power = Enemies.GetWearablePower(); WriteLineColor($"this enemy has {power.Strength} strength {power.Defence} defence and {power.Inteligence} inteligence", ConsoleColor.DarkCyan, ConsoleColor.Black); ProcessAttackScreen(Enemies); if (CurrentLocation == Location.Forest) { WriteLine($"Your current location is now {CurrentX}, {CurrentY}."); } CurrentForestEvent = ForestEvent.None; stats.UpdateWorld(this); } else if (Percent(10)) { var orens = random.Next(30, 101); MainCharacter.Orens += orens; WriteLineColor($"You found {GetOrenLabel(orens)} on the ground!!!", ConsoleColor.Yellow, ConsoleColor.Black); WriteLineColor($"You now have {GetOrenLabel(MainCharacter.Orens)}", ConsoleColor.Yellow, ConsoleColor.Black); } else if (Percent(10)) { CurrentForestEvent = ForestEvent.Stranger; var person = new Humanoid(); person.Gender = (Gender)random.Next(2); person.Race = (Race)random.Next(3); person.SetRandomNewName(); person.SetLevel(random.Next(MainCharacter.CombatLevel.Value + 5)); stats.UpdateWorld(this); WriteLineColor($"Stranger approachers...\r\n i'm looking for somewhere to live", ConsoleColor.Red, ConsoleColor.Black); string input = Question("Do you want to help this stranger?", "no", "yes"); if (input == "yes") { TotalStrangersCollected += 1; WriteLine($"Sure you can come to my town {HomeTown.Name}."); WriteLine($"The Coordinates are {HomeTown.X}, {HomeTown.Y}."); int xp = 100; if (Percent(15)) { person.Smithing.AddXP(person.Smithing.GetXPToLevelUp(RandomNumber(30))); if (person.Smithing.Value > 15) { HomeTown.Buildings.Add(new Buildings() { Owner = person, Type = BuildingType.Blacksmith }); WriteLineColor($"{person.Name}, Just opened a new Blacksmith at your home town.", ConsoleColor.Yellow, ConsoleColor.Black); xp += 100; } } else if (Percent(15)) { person.Barter.AddXP(person.Barter.GetXPToLevelUp(RandomNumber(30))); if (person.Barter.Value > 10) { HomeTown.Buildings.Add(new Buildings() { Owner = person, Type = BuildingType.Store }); WriteLineColor($"{person.Name}, Just opened a new store at your home town.", ConsoleColor.Yellow, ConsoleColor.Black); xp += 100; } } WriteLineColor($"{person.Name}: Well i better get going then, Thank you so much, Catch you soon.", ConsoleColor.Yellow, ConsoleColor.Black); int orens = RandomNumber(50); if (orens > 0) { MainCharacter.Orens += orens; WriteLineColor($"Hope this helps you, {person.Name} gave you {GetOrenLabel(orens)}", ConsoleColor.Yellow, ConsoleColor.Black); WriteLineColor($"You now have {GetOrenLabel(MainCharacter.Orens)}", ConsoleColor.Yellow, ConsoleColor.Black); UpdateStats(MainCharacter); xp += 10; } MainCharacter.Barter.AddXP(xp); WriteLineColor($"You received {xp} xp for Barter Skill.", ConsoleColor.DarkCyan, ConsoleColor.Black); HomeTown.PeopleWhoLiveHere.Add(person); } else { int orens = 100; MainCharacter.Orens += orens; WriteLine("I'm a bandit, give me all your orens and you wont get hurt!"); WriteLineColor($"You stole {GetOrenLabel(orens)}!!!", ConsoleColor.Yellow, ConsoleColor.Black); WriteLineColor($"You now have {GetOrenLabel(MainCharacter.Orens)}", ConsoleColor.Yellow, ConsoleColor.Black); UpdateStats(MainCharacter); } CurrentForestEvent = ForestEvent.None; stats.UpdateWorld(this); WriteLine($"Your current location is now {CurrentX}, {CurrentY}."); } } UpdateStats(MainCharacter); }