//gives the player items public void Get_Items() { //generates a random amount of gold for the player to find in the room * [(the number of visited rooms/5), rounded up] int grand = (int)(new Random().Next(1, 11)) * (roomsVisited / 5); gold += grand; Gold.Content = "Gold: " + gold; textCRWL.Text = $"Searching around the room you find {grand} gold coins."; //variable to hold the item found string name = ""; //adds new item to the player's inventory using (DungeonContext context = new DungeonContext()) { context.Inventories.Add(new Inventory() { InventoryName = "Health Potion" }); context.SaveChanges(); var query = context.Inventories.Select(b => b.InventoryName).ToList(); inventoryList.ItemsSource = query; foreach (var item in query) { name = item; } textCRWL.Text += $" Additionally you've found {name}."; } }
private void RightB_Click(object sender, RoutedEventArgs e) { if (exploreMode == true) { Explore_Click(sender, e); } //buy mode else { if (rightBougth == false) { //checks if player has enough gold to buy the item if (gold >= 10) { rightItem.Source = null; //the bought potion gets added to the inventory using (DungeonContext context = new DungeonContext()) { context.Inventories.Add(new Inventory() { InventoryName = "Health Potion" }); context.SaveChanges(); var query = context.Inventories.Select(b => b.InventoryName).ToList(); inventoryList.ItemsSource = query; } textCRWL.Text = "You bought a Health Potion."; //bought gets set to true stopping from buying a non exsistant item rightBougth = true; //the display for gold changes and then the gold gets subtracted Gold.Content = "Gold: " + (gold - 10); gold -= 10; } else { textCRWL.Text = "You don't have enough gold to buy this item."; } } //excutes if the item has been bought else { textCRWL.Text = "You've already bought this item."; } } }
//the function executes per enemy attack public void Enemy_Attack() { //first checks if the enemy is alive if (Beastiary.MonsterHealth > 0) { //then the enemy attacks the player healthBar.Value -= Beastiary.MonsterAttack; textCRWL.Text += $" The enemy strikes you, dealing {Beastiary.MonsterAttack} damage to you!"; //then it checks if the player has died. if they did the game is closed if (healthBar.Value == 0) { Close(); } } else //when the enemy dies, the player can progress again and is given an item { textCRWL.Text = "Victory!"; enemyScreen.Source = null; //the enemy is declared dead allowing the player to explore once again isEnemyAlive = false; //variable to hold the item found string name = ""; using (DungeonContext context = new DungeonContext()) { context.Inventories.Add(new Inventory() { InventoryName = "Sludge" }); context.SaveChanges(); var query = context.Inventories.Select(b => b.InventoryName).ToList(); inventoryList.ItemsSource = query; foreach (var item in query) { name = item; } textCRWL.Text += $" You got {name}! It smells awful..."; } } }
//room naming convention: XYZ. Example: 1NE //X: number of corridors (after 3, evens: two corridors, odds: one or three corridors) //Y: type of room. N ormal (nothing in it), E nemy, M erchant //Z: type of type. There are different types of shops and enemies. //Example 1: 1NE (one corridoe, normal room, empty) //Example 2: 1EN (one corridor, enemy, normal type) //current number of screens: 4 //current number of enemies: 1 //current number of merchants: 0 //string lore = ""; public MainWindow() { InitializeComponent(); using (DungeonContext context = new DungeonContext()) { context.Inventories.RemoveRange(context.Inventories); context.SaveChanges(); } textCRWL.Text = "You venture into the dark depths of these decrepit catacombs. You search for treasure, but you may find more than you might have bargained for. For even though these Catacombs are Rampant With Loot, they also hold death."; //uncomment only when you add new rooms //using (DungeonContext context = new DungeonContext()) //{ // context.Rooms.Add(new Room() { RoomName = "1EN" }); // context.Rooms.Add(new Room() { RoomName = "1NE" }); // context.Rooms.Add(new Room() { RoomName = "2NE" }); // context.Rooms.Add(new Room() { RoomName = "3M3" }); // context.Rooms.Add(new Room() { RoomName = "3NE" }); // context.Monsters.Add(new Monster() { MonsterName = "Putrid Sludge", MonsterAttack = 5, MonsterHealth = 10 }); // context.SaveChanges(); //} //var path = Path.Combine(Directory.GetCurrentDirectory(), "\\images\\lorem.txt"); //lore = System.IO.File.ReadAllText(path); //for(int i = 0; i < lore.Length; i++) //{ // textCRWL.Text = textCRWL.Text + lore[i]; //} //using (DungeonContext context = new DungeonContext()) //{ // context.Inventories.Remove(b); //} }