/// <summary> /// Asks the user how many of the item they wish to buy /// </summary> /// <param name="universe"></param> /// <param name="item"></param> /// <returns></returns> public static int HowMany(Universe universe, Item.Items item) { TextBoxViews.ReWriteToMessageBox(universe, "How many " + item + "s would you like?", true); return(Validators.ValidInt()); }
public static int ValidInt() { bool validIntResponse = false; int validInt = 16; string invalidInt; while (!validIntResponse) { TextBoxViews.ClearInput(); Console.SetCursorPosition(7, 56); invalidInt = Console.ReadLine(); if (int.TryParse(invalidInt, out validInt)) { validIntResponse = true; } else { TextBoxViews.ErrorTextBox("Error: you need to enter a valid real Interger"); } } TextBoxViews.ClearInputBox(); TextBoxViews.ClearErrorTextBox(); return(validInt); }
//make a loop to hold player movement and other values public static bool GameLoop(Adventurer adventurer, Universe universe) { Random random = new Random(); int encounter = 0; bool playing = true; bool win = false; TextBoxViews.DisplayPlayerInfo(adventurer); TextBoxViews.DisplayHeader(); Console.CursorVisible = false; while (playing) { TextBoxViews.DisplayPosition(adventurer); playing = Map.movement(adventurer, universe); Map.CheckPosition(adventurer, universe); encounter = random.Next(1, 30); if (encounter < 2 && adventurer.MapLocation == Humanoid.Location.MainWorld) { Slime slime = new Slime(); Slime.InitializeNewSlime(slime); playing = Battle.BattleLoop(adventurer, universe, slime); } if (universe.TripleTrouble[0].Defeated && universe.TripleTrouble[1].Defeated && universe.TripleTrouble[2].Defeated) { adventurer.playerWin = true; playing = false; } if (adventurer.diedOnFinal) { playing = false; } } return(win); }
public static bool ValidYesNo() { bool validIntResponse = false; bool yesno = true; string response; while (!validIntResponse) { TextBoxViews.ClearInput(); Console.SetCursorPosition(7, 56); response = Console.ReadLine(); if ((response.ToLower() == "yes") || (response.ToLower() == "y")) { yesno = true; validIntResponse = true; } else if ((response.ToLower() == "no") || (response.ToLower() == "n")) { yesno = false; validIntResponse = true; } else { TextBoxViews.ErrorTextBox("Error: you need to enter either yes or no"); } } TextBoxViews.ClearInputBox(); TextBoxViews.ClearErrorTextBox(); return(yesno); }
public static bool BattleLoop(Adventurer adventurer, Universe universe, Slime slime) { TextBoxViews.ClearMapBox(); TextBoxViews.RedrawBox(universe, 6); bool blocked; bool stillAlive = true; TextBoxViews.ReWriteToMessageBox(universe, "A slime attacks!"); Random random = new Random(); do { TextDrawings.DisplaySlime(slime); TextBoxViews.WriteToEvent("Slime : " + slime.Health); TextBoxViews.DisplayPlayerInfo(adventurer); blocked = Attack(adventurer, universe, slime); TextBoxViews.WriteToEvent("Slime : " + slime.Health); if (slime.Health > 0) { SlimeATK(adventurer, universe, slime, blocked); } } while ((adventurer.Health > 0) && (slime.Health > 0)); if (adventurer.Health > 0) { int coinDrop; int gelDrop; int expGain; coinDrop = random.Next(10, 30); gelDrop = random.Next(5, 15); expGain = random.Next(10, slime.ExpGiv); TextBoxViews.WriteToMessageBox(universe, $"You have succeeded in battle and have recieved {coinDrop} coins and {gelDrop} gel."); adventurer.Coins += coinDrop; adventurer.ItemsDictionary[Item.Items.SlimeGel] += gelDrop; adventurer.Experinece += expGain; if (adventurer.Experinece >= adventurer.MaxExperience) { Adventurer.PlayerLevelUp(adventurer, universe); } } else { stillAlive = false; } TextBoxViews.ClearMapBox(); TextBoxViews.RemoveContent(universe, 3); TextBoxViews.DisplayMenu(universe); TextBoxViews.DisplayPlayerInfo(adventurer); return(stillAlive); }
public static void CheckAndPickupItem(Universe universe, Adventurer adventurer) { int checkx = adventurer.Xpos; int checky = adventurer.Ypos; switch (adventurer.LookDirection) { case Humanoid.Direction.LEFT: checkx--; break; case Humanoid.Direction.RIGHT: checkx++; break; case Humanoid.Direction.UP: checky--; break; case Humanoid.Direction.DOWN: checky++; break; default: break; } foreach (var item in universe.ItemList) { if ((item.houseLoc != House.houseName.None) && (item.houseLoc == adventurer.InHouseName)) { if (!item.itemTaken) { if ((item.XPos == checkx) && (item.YPos == checky)) { item.itemTaken = true; adventurer.ItemsDictionary[item.ItemType] += 1; DisplayMap.DisplayItemToPickup(item.XPos, item.YPos, item.itemTaken); TextBoxViews.WriteToMessageBox(universe, "You picked up a " + item.ItemType.ToString()); } } } else if (item.worldLoc == adventurer.MapLocation) { if (!item.itemTaken) { //matches locations if ((item.XPos == checkx) && (item.YPos == checky)) { item.itemTaken = true; adventurer.ItemsDictionary[item.ItemType] += 1; DisplayMap.DisplayItemToPickup(item.XPos, item.YPos, item.itemTaken); TextBoxViews.WriteToMessageBox(universe, "You picked up a " + item.ItemType.ToString()); } } } } }//End of last Method
public static void PlayerPotionHeal(Adventurer adventurer, Universe universe) { TextBoxViews.WriteToMessageBox(universe, "You drank the health potion and healed for 20 health"); adventurer.Health += 20; if (adventurer.Health > adventurer.MaxHealth) { adventurer.Health = adventurer.MaxHealth; } TextBoxViews.DisplayPlayerInfo(adventurer); }
/// <summary> /// Prints where you have been in order /// </summary> /// <param name="adventurer"></param> /// <param name="universe"></param> public static void PlayerLocationss(Adventurer adventurer, Universe universe) { string message = "Where you have been. In order :"; foreach (var location in adventurer.PreviousLocations) { message += location.ToString(); message += ", "; } TextBoxViews.WriteToMessageBox(universe, message); }
public static Adventurer.Weapon WeaponValidation() { Adventurer.Weapon weapon = Adventurer.Weapon.Sword; bool loop = true; string response; while (loop) { TextBoxViews.ClearInput(); Console.SetCursorPosition(4, 56); response = Console.ReadLine(); switch (response.ToUpper()) { case "BOW": weapon = Adventurer.Weapon.Bow; loop = false; break; case "SWORD": weapon = Adventurer.Weapon.Sword; loop = false; break; case "STAFF": weapon = Adventurer.Weapon.Staff; loop = false; break; case "BROADSWORD": weapon = Adventurer.Weapon.BroadSword; loop = false; break; case "DAGGER": weapon = Adventurer.Weapon.Dagger; loop = false; break; case "MACE": weapon = Adventurer.Weapon.Mace; loop = false; break; default: TextBoxViews.ErrorTextBox("Invalid Weapon Please type in a valid weapon from the provided above"); break; } } TextBoxViews.ClearInputBox(); TextBoxViews.ClearErrorTextBox(); return(weapon); }
public static void PlayerLevelUp(Adventurer adventurer, Universe universe) { adventurer.Experinece = 0; adventurer.MaxExperience += 30; adventurer.MaxHealth += 10; adventurer.Damage += 3; adventurer.PlayerLevel++; adventurer.Health = adventurer.MaxHealth; TextBoxViews.WriteToMessageBox(universe, $"You Leveled up! /n Max Health : {adventurer.MaxHealth} /n Damage : {adventurer.Damage}"); TextBoxViews.DisplayPlayerInfo(adventurer); }
public static Humanoid.Race RaceValidation() { Humanoid.Race race = Humanoid.Race.Orc; bool loop = true; string response; while (loop) { TextBoxViews.ClearInput(); Console.SetCursorPosition(4, 56); response = Console.ReadLine(); switch (response.ToUpper()) { case "HUMAN": race = Adventurer.Race.Human; loop = false; break; case "SLIME": race = Adventurer.Race.Slime; loop = false; break; case "ORC": race = Adventurer.Race.Orc; loop = false; break; case "ELVE": race = Adventurer.Race.Elve; loop = false; break; default: TextBoxViews.ErrorTextBox("Invalid Race Please type in a valid race from the provided above"); break; } } TextBoxViews.ClearInputBox(); TextBoxViews.ClearErrorTextBox(); return(race); }
public static void StartGame() { bool didjaWin; Console.CursorVisible = false; Windows[] windows = new Windows[6]; Console.BackgroundColor = ConsoleColor.Gray; Console.ForegroundColor = ConsoleColor.Black; Console.SetWindowSize(150, 60); //WindowConfig.NumbersOnScreen(); TextBoxViews.SplashScreen(40, 25); Console.ReadLine(); Console.Clear(); windows = InitializeWindowScreens(); Universe universe = new Universe(); universe = universe.InitializeUniverse(windows); TextBoxViews.WriteToMessageBox(universe, "After defeating the slime king peace was returned to the land. But not all peace lasts forever, and a group of bandits have set up camp in a nearby cave and it is your job to take them out..."); Adventurer adventurer = new Adventurer(); adventurer = TextBoxViews.GetPlayerInfo(universe); TextBoxViews.DisplayMenu(universe); didjaWin = GameLoop(adventurer, universe); TextBoxViews.RedrawBox(universe, 5); if (adventurer.playerWin) { TextBoxViews.WriteToMessageBox(universe, "YOU WIN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } else if (adventurer.diedOnFinal) { TextBoxViews.WriteToMessageBox(universe, "So close..."); } TextBoxViews.WriteToMessageBox(universe, "Game Over"); }
/// <summary> /// lets you talk to NPC's /// Cycles through set text each npc has /// </summary> /// <param name="adventurer"></param> /// <param name="universe"></param> public static void NPCTalk(Adventurer adventurer, Universe universe) { int xPos = adventurer.Xpos; int yPos = adventurer.Ypos; if (adventurer.InaHouse && adventurer.InHouseName == House.houseName.Market) { switch (adventurer.LookDirection) { case Humanoid.Direction.LEFT: xPos -= 2; break; case Humanoid.Direction.RIGHT: xPos++; break; case Humanoid.Direction.UP: yPos--; break; case Humanoid.Direction.DOWN: yPos++; break; default: break; } } else { switch (adventurer.LookDirection) { case Humanoid.Direction.LEFT: xPos--; break; case Humanoid.Direction.RIGHT: xPos++; break; case Humanoid.Direction.UP: yPos--; break; case Humanoid.Direction.DOWN: yPos++; break; default: break; } } bool trig = true; string text = "There is no-one to talk with in front of you, Are you going insane?"; foreach (NPC npc in universe.NPCList) { if (npc.Xpos == xPos && npc.Ypos == yPos) { TextBoxViews.RedrawBox(universe, 7); TextBoxViews.WriteToNpcNameBox(npc.Name); text = npc.messages[npc.listCurrent]; npc.listCurrent++; if (npc.MapLocation == adventurer.MapLocation) { if (npc.Name == "Merchant") { TextBoxViews.MerchantMessage(universe, adventurer); trig = false; QuestTrigger(adventurer, universe, Adventurer.Quest.GoShopping); } else if (npc.Name == "OLD MAN") { QuestTrigger(adventurer, universe, Adventurer.Quest.MeetTheOldMan); } else if (npc.Name == "Cerri") { if (adventurer.ItemsDictionary[Item.Items.Parcel] >= 1) { TextBoxViews.WriteToMessageBox(universe, "Oh? You found my parcel! Thank you!"); adventurer.ItemsDictionary[Item.Items.Parcel]--; TextBoxViews.WriteToMessageBox(universe, "Here is a few Health potions for your troubles."); adventurer.ItemsDictionary[Item.Items.HealthPotion] += 2; trig = false; QuestTrigger(adventurer, universe, Adventurer.Quest.DeliverTheParcel); } } else if (npc.Name == "Arista") { adventurer.Health = adventurer.MaxHealth; } } else if (adventurer.InHouseName == npc.InHouseName) { if (npc.Name == "Merchant") { TextBoxViews.MerchantMessage(universe, adventurer); trig = false; QuestTrigger(adventurer, universe, Adventurer.Quest.GoShopping); } else if (npc.Name == "OLD MAN") { QuestTrigger(adventurer, universe, Adventurer.Quest.MeetTheOldMan); } else if (npc.Name == "Cerri") { if (adventurer.ItemsDictionary[Item.Items.Parcel] >= 1) { TextBoxViews.WriteToMessageBox(universe, "Oh? You found my parcel! Thank you!"); adventurer.ItemsDictionary[Item.Items.Parcel]--; TextBoxViews.WriteToMessageBox(universe, "Here is a few Health potions for your troubles."); adventurer.ItemsDictionary[Item.Items.HealthPotion] += 2; trig = false; QuestTrigger(adventurer, universe, Adventurer.Quest.DeliverTheParcel); } } else if (npc.Name == "Arista") { adventurer.Health = adventurer.MaxHealth; } } if (npc.listCurrent >= npc.listMax) { npc.listCurrent = 0; } TextBoxViews.RemoveBox(universe, 7); TextBoxViews.RemoveContent(universe, 7); } } if (adventurer.MapLocation == Humanoid.Location.Cave) { foreach (var enemy in universe.TripleTrouble) { if (!enemy.Defeated && (enemy.Ypos == yPos) && (enemy.Xpos == xPos)) { TextBoxViews.WriteToMessageBox(universe, "I will Beat you!!!"); enemy.Defeated = true; Slime slime = new Slime(); Slime.InitializeNewSlime(slime, true); adventurer.diedOnFinal = !Battle.BattleLoop(adventurer, universe, slime); } } } if (trig) { TextBoxViews.WriteToMessageBox(universe, text); } }
/// <summary> /// Checks what quest the player is on. /// </summary> /// <param name="universe"></param> /// <param name="adventurer"></param> public static void CheckPlayerQuest(Universe universe, Adventurer adventurer) { foreach (var quest in adventurer.QuestCompletion) { if (quest.Key == adventurer.CurrentQuest) { switch (adventurer.CurrentQuest) { case Adventurer.Quest.MeetTheOldMan: TextBoxViews.DisplayQuest("Go talk to the old man"); if (quest.Value && !adventurer.QuestDone[0]) { Console.SetCursorPosition(110, 24); Console.Write("Completed Quest"); Thread.Sleep(1000); Console.SetCursorPosition(110, 24); Console.Write(" "); adventurer.CurrentQuest = Adventurer.Quest.GoHome; adventurer.QuestDone[0] = true; } break; case Adventurer.Quest.GoHome: TextBoxViews.DisplayQuest("Go back to your house"); if (quest.Value && !adventurer.QuestDone[1]) { Console.SetCursorPosition(110, 24); Console.Write("Completed Quest"); Thread.Sleep(1000); Console.SetCursorPosition(110, 24); Console.Write(" "); adventurer.CurrentQuest = Adventurer.Quest.GoShopping; adventurer.QuestDone[1] = true; } break; case Adventurer.Quest.GoShopping: TextBoxViews.DisplayQuest("Go buy some supplies"); if (quest.Value && !adventurer.QuestDone[2]) { Console.SetCursorPosition(110, 24); Console.Write("Completed Quest"); Thread.Sleep(1000); Console.SetCursorPosition(110, 24); Console.Write(" "); adventurer.CurrentQuest = Adventurer.Quest.LeaveHome; adventurer.QuestDone[2] = true; } break; case Adventurer.Quest.LeaveHome: TextBoxViews.DisplayQuest("Leave town"); if (quest.Value && !adventurer.QuestDone[3]) { Console.SetCursorPosition(110, 24); Console.Write("Completed Quest"); Thread.Sleep(1000); Console.SetCursorPosition(110, 24); Console.Write(" "); adventurer.CurrentQuest = Adventurer.Quest.TheNewGuyInTown; adventurer.QuestDone[3] = true; } break; case Adventurer.Quest.TheNewGuyInTown: TextBoxViews.DisplayQuest("Go to town 2"); if (quest.Value && !adventurer.QuestDone[4]) { Console.SetCursorPosition(110, 24); Console.Write("Completed Quest"); Thread.Sleep(1000); Console.SetCursorPosition(110, 24); Console.Write(" "); adventurer.CurrentQuest = Adventurer.Quest.DeliverTheParcel; adventurer.QuestDone[4] = true; } break; case Adventurer.Quest.DeliverTheParcel: TextBoxViews.DisplayQuest("Find the parcel in Town"); if (quest.Value && !adventurer.QuestDone[5]) { Console.SetCursorPosition(110, 24); Console.Write("Completed Quest"); Thread.Sleep(1000); Console.SetCursorPosition(110, 24); Console.Write(" "); adventurer.CurrentQuest = Adventurer.Quest.FightTheCaveTrio; adventurer.QuestDone[5] = true; } break; case Adventurer.Quest.FightTheCaveTrio: TextBoxViews.DisplayQuest("Go fight the trio!"); if (quest.Value && !adventurer.QuestDone[6]) { Console.SetCursorPosition(110, 24); Console.Write("Completed Quest"); Thread.Sleep(1000); Console.SetCursorPosition(110, 24); Console.Write(" "); adventurer.CurrentQuest = Adventurer.Quest.None; adventurer.QuestDone[6] = true; adventurer.playerWin = true; } break; default: break; } } } }
/// <summary> /// Checks the player's position Handles BOTH mainworld and House Locations /// </summary> /// <param name="universe"></param> /// <param name="adventurer"></param> public static void CheckPlayerPosition(Universe universe, Adventurer adventurer) { if (!adventurer.InaHouse) { switch (adventurer.MapLocation) { case Humanoid.Location.MainWorld: foreach (Towns town in universe.TownList) { if (adventurer.Ypos == town.Ypos && adventurer.Xpos == town.Xpos) { TextBoxViews.RedrawBox(universe, 6); TextBoxViews.WriteToEvent(adventurer.MapLocation.ToString()); TextBoxViews.ClearMapBox(); adventurer.MapLocation = town.TownLocName; adventurer.PreviousLocations.Add(adventurer.MapLocation); adventurer.Xpos = 40; adventurer.Ypos = 48; } } TextBoxViews.RedrawBox(universe, 6); TextBoxViews.WriteToEvent(adventurer.MapLocation.ToString()); break; case Humanoid.Location.TutTown: if (adventurer.Ypos >= 50) { TextBoxViews.ClearMapBox(); adventurer.MapLocation = Humanoid.Location.MainWorld; adventurer.Xpos = universe.TownList[0].Xpos; adventurer.Ypos = universe.TownList[0].Ypos; adventurer.PreviousLocations.Add(adventurer.MapLocation); Map.QuestTrigger(adventurer, universe, Adventurer.Quest.LeaveHome); TextBoxViews.RedrawBox(universe, 6); TextBoxViews.WriteToEvent(adventurer.MapLocation.ToString()); } foreach (var house in universe.HouseList) { if ((adventurer.Xpos == house.EnterPosition[0]) && (adventurer.Ypos == house.EnterPosition[1]) && (house.HouseLoc == Humanoid.Location.TutTown)) { adventurer.InaHouse = true; house.PlayerInside = true; adventurer.Xpos = 56; adventurer.Ypos = 32; adventurer.InHouseName = house.HouseName; TextBoxViews.RedrawBox(universe, 6); TextBoxViews.WriteToEvent(adventurer.InHouseName.ToString()); TextBoxViews.ClearMapBox(); } } TextBoxViews.RedrawBox(universe, 6); TextBoxViews.WriteToEvent(adventurer.MapLocation.ToString()); break; case Humanoid.Location.CherryGrove: Map.QuestTrigger(adventurer, universe, Adventurer.Quest.TheNewGuyInTown); if (adventurer.Ypos >= 50) { TextBoxViews.ClearMapBox(); adventurer.MapLocation = Humanoid.Location.MainWorld; adventurer.Xpos = universe.TownList[1].Xpos; adventurer.Ypos = universe.TownList[1].Ypos; adventurer.PreviousLocations.Add(adventurer.MapLocation); } foreach (var house in universe.HouseList) { if ((adventurer.Xpos == house.EnterPosition[0]) && (adventurer.Ypos == house.EnterPosition[1]) && (house.HouseLoc == Humanoid.Location.CherryGrove)) { adventurer.InaHouse = true; house.PlayerInside = true; adventurer.Xpos = 56; adventurer.Ypos = 32; adventurer.InHouseName = house.HouseName; TextBoxViews.RedrawBox(universe, 6); TextBoxViews.WriteToEvent(adventurer.InHouseName.ToString()); TextBoxViews.ClearMapBox(); } } TextBoxViews.RedrawBox(universe, 6); TextBoxViews.WriteToEvent(adventurer.MapLocation.ToString()); break; case Humanoid.Location.Cave: if (adventurer.Ypos >= 50) { TextBoxViews.ClearMapBox(); adventurer.MapLocation = Humanoid.Location.MainWorld; adventurer.Xpos = universe.TownList[3].Xpos; adventurer.Ypos = universe.TownList[3].Ypos; adventurer.PreviousLocations.Add(adventurer.MapLocation); } break; default: break; } } else if (adventurer.InaHouse) { switch (adventurer.InHouseName) { case House.houseName.None: break; case House.houseName.PlayerHome: Map.QuestTrigger(adventurer, universe, Adventurer.Quest.GoHome); if (adventurer.Xpos == 56 && adventurer.Ypos == 33) { adventurer.InaHouse = false; foreach (var house in universe.HouseList) { if (adventurer.InHouseName == house.HouseName) { house.PlayerInside = false; adventurer.InHouseName = House.houseName.None; adventurer.Xpos = house.EnterPosition[0]; adventurer.Ypos = house.EnterPosition[1] + 1; } } TextBoxViews.ClearMapBox(); } break; case House.houseName.HealHouse: if (adventurer.Xpos == 56 && adventurer.Ypos == 33) { adventurer.InaHouse = false; foreach (var house in universe.HouseList) { if (adventurer.InHouseName == house.HouseName) { house.PlayerInside = false; adventurer.InHouseName = House.houseName.None; adventurer.Xpos = house.EnterPosition[0]; adventurer.Ypos = house.EnterPosition[1] + 1; } } TextBoxViews.ClearMapBox(); } break; case House.houseName.Market: if (adventurer.Xpos == 56 && adventurer.Ypos == 33) { adventurer.InaHouse = false; foreach (var house in universe.HouseList) { if (adventurer.InHouseName == house.HouseName) { house.PlayerInside = false; adventurer.InHouseName = House.houseName.None; adventurer.Xpos = house.EnterPosition[0]; adventurer.Ypos = house.EnterPosition[1] + 1; } } TextBoxViews.ClearMapBox(); } break; case House.houseName.CerriHouse: if (adventurer.Xpos == 56 && adventurer.Ypos == 33) { adventurer.InaHouse = false; foreach (var house in universe.HouseList) { if (adventurer.InHouseName == house.HouseName) { house.PlayerInside = false; adventurer.InHouseName = House.houseName.None; adventurer.Xpos = house.EnterPosition[0]; adventurer.Ypos = house.EnterPosition[1] + 1; } } TextBoxViews.ClearMapBox(); } break; case House.houseName.AmastaHouse: if (adventurer.Xpos == 56 && adventurer.Ypos == 33) { adventurer.InaHouse = false; foreach (var house in universe.HouseList) { if (adventurer.InHouseName == house.HouseName) { house.PlayerInside = false; adventurer.InHouseName = House.houseName.None; adventurer.Xpos = house.EnterPosition[0]; adventurer.Ypos = house.EnterPosition[1] + 1; } } TextBoxViews.ClearMapBox(); } break; case House.houseName.AristaHouse: if (adventurer.Xpos == 56 && adventurer.Ypos == 33) { adventurer.InaHouse = false; foreach (var house in universe.HouseList) { if (adventurer.InHouseName == house.HouseName) { house.PlayerInside = false; adventurer.InHouseName = House.houseName.None; adventurer.Xpos = house.EnterPosition[0]; adventurer.Ypos = house.EnterPosition[1] + 1; } } TextBoxViews.ClearMapBox(); } break; default: break; } } }
/// <summary> /// Sets up an inventory to display in the Menu /// </summary> /// <param name="adventurer"></param> public static void InventoryManagment(Adventurer adventurer, Universe universe) { bool usingInventory = true; ConsoleKeyInfo key; Dictionary <Item.Items, int> itemList = new Dictionary <Item.Items, int>(); Item.Items[] itemarray = new Item.Items[10]; int i = 0; foreach (var item in adventurer.ItemsDictionary) { itemList.Add(item.Key, item.Value); itemarray[i] = item.Key; i++; } Item.Items itemToUse = Item.Items.Nothing; while (usingInventory) { TextBoxViews.RemoveContent(universe, 3); TextBoxViews.DisplayInventory(itemList); bool error = false; key = Console.ReadKey(); try { //remove use item from temp inventory switch (key.Key) { case ConsoleKey.D1: itemList[itemarray[0]] -= 1; itemToUse = itemarray[0]; break; case ConsoleKey.D2: itemList[itemarray[1]] -= 1; itemToUse = itemarray[1]; break; case ConsoleKey.D3: itemList[itemarray[2]] -= 1; itemToUse = itemarray[2]; break; case ConsoleKey.D4: itemList[itemarray[3]] -= 1; itemToUse = itemarray[3]; break; case ConsoleKey.D5: itemList[itemarray[4]] -= 1; itemToUse = itemarray[4]; break; case ConsoleKey.D6: itemList[itemarray[5]] -= 1; itemToUse = itemarray[5]; break; case ConsoleKey.D7: itemList[itemarray[6]] -= 1; itemToUse = itemarray[6]; break; case ConsoleKey.D8: itemList[itemarray[7]] -= 1; itemToUse = itemarray[7]; break; case ConsoleKey.D9: usingInventory = false; break; case ConsoleKey.NumPad1: itemList[itemarray[0]] -= 1; itemToUse = itemarray[0]; break; case ConsoleKey.NumPad2: itemList[itemarray[1]] -= 1; itemToUse = itemarray[1]; break; case ConsoleKey.NumPad3: itemList[itemarray[2]] -= 1; itemToUse = itemarray[2]; break; case ConsoleKey.NumPad4: itemList[itemarray[3]] -= 1; itemToUse = itemarray[3]; break; case ConsoleKey.NumPad5: itemList[itemarray[4]] -= 1; itemToUse = itemarray[4]; break; case ConsoleKey.NumPad6: itemList[itemarray[5]] -= 1; itemToUse = itemarray[5]; break; case ConsoleKey.NumPad7: itemList[itemarray[6]] -= 1; itemToUse = itemarray[6]; break; case ConsoleKey.NumPad8: itemList[itemarray[7]] -= 1; itemToUse = itemarray[7]; break; case ConsoleKey.NumPad9: usingInventory = false; break; case ConsoleKey.LeftArrow: usingInventory = false; break; case ConsoleKey.RightArrow: usingInventory = false; break; case ConsoleKey.UpArrow: usingInventory = false; break; case ConsoleKey.DownArrow: usingInventory = false; break; default: break; } } catch (Exception) { error = true; //No throwing in here } finally { //I decided im not dealing with the program deciding to add to nothing. tOb can keep trying though try { if (!error && !(key.Key == ConsoleKey.D9 || key.Key == ConsoleKey.NumPad9) && !(adventurer.ItemsDictionary[itemToUse] <= 0)) { switch (itemToUse) { case Item.Items.HealthPotion: Adventurer.PlayerPotionHeal(adventurer, universe); adventurer.ItemsDictionary[itemToUse] = itemList[itemToUse]; break; case Item.Items.ManaPotion: TextBoxViews.WriteToMessageBox(universe, "You feel all tingly inside"); adventurer.ItemsDictionary[itemToUse] = itemList[itemToUse]; break; case Item.Items.Stone: TextBoxViews.WriteToMessageBox(universe, "You throw the stone and it vanishes into the distance..."); adventurer.ItemsDictionary[itemToUse] = itemList[itemToUse]; break; case Item.Items.SlimeGel: TextBoxViews.WriteToMessageBox(universe, "You cannot use slime..."); itemList[itemToUse]++; break; case Item.Items.Parcel: TextBoxViews.WriteToMessageBox(universe, "You cannot use the parcel you are delivering!"); itemList[itemToUse]++; break; case Item.Items.Nothing: TextBoxViews.WriteToMessageBox(universe, "There is nothing there"); break; default: break; } } else if (!(key.Key == ConsoleKey.D9 || key.Key == ConsoleKey.NumPad9) && (itemList[itemToUse] < 0)) { TextBoxViews.WriteToMessageBox(universe, "You dont have that item"); itemList[itemToUse]++; } else if (!(key.Key == ConsoleKey.D9 || key.Key == ConsoleKey.NumPad9)) { TextBoxViews.WriteToMessageBox(universe, "You dont have that item"); } } catch (Exception) { } //End try catch inventory navigation } //end finally } //end using inventory while TextBoxViews.DisplayMenu(universe); }
/// <summary> /// Lets you purchase from a merchant /// </summary> /// <param name="universe"></param> /// <param name="adventurer"></param> public static void MerchantBuy(Universe universe, Adventurer adventurer) { ConsoleKeyInfo consoleKey; bool keepShopping = true; Dictionary <Item.Items, int> itemToPurchase = new Dictionary <Item.Items, int>(); TextBoxViews.MerchMenu(universe); Item.Items item = Item.Items.SlimeGel; while (keepShopping) { bool purchase = false; bool chooseSomething = true; int cost = 0; while (chooseSomething) { consoleKey = Console.ReadKey(); switch (consoleKey.Key) { case ConsoleKey.NumPad1: item = Item.Items.HealthPotion; itemToPurchase[item] = HowMany(universe, Item.Items.HealthPotion); cost = 20 * itemToPurchase[item]; chooseSomething = false; break; case ConsoleKey.D1: item = Item.Items.HealthPotion; itemToPurchase[item] = HowMany(universe, Item.Items.HealthPotion); cost = 20 * itemToPurchase[item]; chooseSomething = false; break; case ConsoleKey.NumPad2: item = Item.Items.ManaPotion; itemToPurchase[item] = HowMany(universe, Item.Items.ManaPotion); cost = 20 * itemToPurchase[item]; chooseSomething = false; break; case ConsoleKey.D2: item = Item.Items.ManaPotion; itemToPurchase[item] = HowMany(universe, Item.Items.ManaPotion); cost = 20 * itemToPurchase[item]; chooseSomething = false; break; case ConsoleKey.NumPad3: item = Item.Items.Stone; itemToPurchase[item] = HowMany(universe, Item.Items.Stone); cost = 2 * itemToPurchase[item]; chooseSomething = false; break; case ConsoleKey.D3: item = Item.Items.Stone; itemToPurchase[item] = HowMany(universe, Item.Items.Stone); cost = 2 * itemToPurchase[item]; chooseSomething = false; break; case ConsoleKey.NumPad9: keepShopping = false; chooseSomething = false; break; case ConsoleKey.D9: keepShopping = false; chooseSomething = false; break; case ConsoleKey.LeftArrow: keepShopping = false; chooseSomething = false; break; case ConsoleKey.RightArrow: keepShopping = false; chooseSomething = false; break; case ConsoleKey.UpArrow: keepShopping = false; chooseSomething = false; break; case ConsoleKey.DownArrow: keepShopping = false; chooseSomething = false; break; default: TextBoxViews.ReWriteToMessageBox(universe, "Please choose something I have and not the air please.", true); break; } } //Prints question if (keepShopping == true) { TextBoxViews.ReWriteToMessageBox(universe, "So you want to buy " + itemToPurchase[item] + " " + item + "(s) for " + cost + " gold? Yes/No", true); //Gets user input purchase = Validators.ValidYesNo(); } if (keepShopping) { //checks if the player has enough coins if (purchase && (adventurer.Coins >= cost)) { adventurer.ItemsDictionary[item] += itemToPurchase[item]; adventurer.Coins -= cost; TextBoxViews.ReWriteToMessageBox(universe, "Thanks for buyin", true); } else if (purchase && !(adventurer.Coins >= cost)) { TextBoxViews.ReWriteToMessageBox(universe, "Hey! You dont have enough to buy that!!!", true); } } TextBoxViews.DisplayPlayerInfo(adventurer); } }
public static bool movement(Adventurer adventurer, Universe universe) { ConsoleKeyInfo keyPress; keyPress = Console.ReadKey(); bool playing = true; int[] lastPosition = new int[2]; lastPosition[0] = adventurer.Xpos; lastPosition[1] = adventurer.Ypos; Console.SetCursorPosition(lastPosition[0], lastPosition[1]); Console.Write(" "); switch (keyPress.Key) { case ConsoleKey.LeftArrow: adventurer.LookDirection = Humanoid.Direction.LEFT; if (adventurer.LastDirection == adventurer.LookDirection) { MovementRestriction(adventurer, universe, adventurer.LookDirection); } adventurer.LastDirection = adventurer.LookDirection; Console.SetCursorPosition(adventurer.Xpos, adventurer.Ypos); Console.Write("☺"); break; case ConsoleKey.UpArrow: adventurer.LookDirection = Humanoid.Direction.UP; if (adventurer.LastDirection == adventurer.LookDirection) { MovementRestriction(adventurer, universe, adventurer.LookDirection); } adventurer.LastDirection = adventurer.LookDirection; Console.SetCursorPosition(adventurer.Xpos, adventurer.Ypos); Console.Write("☺"); break; case ConsoleKey.RightArrow: adventurer.LookDirection = Humanoid.Direction.RIGHT; if (adventurer.LastDirection == adventurer.LookDirection) { MovementRestriction(adventurer, universe, adventurer.LookDirection); } adventurer.LastDirection = adventurer.LookDirection; Console.SetCursorPosition(adventurer.Xpos, adventurer.Ypos); Console.Write("☺"); break; case ConsoleKey.DownArrow: adventurer.LookDirection = Humanoid.Direction.DOWN; if (adventurer.LastDirection == adventurer.LookDirection) { MovementRestriction(adventurer, universe, adventurer.LookDirection); } adventurer.LastDirection = adventurer.LookDirection; Console.SetCursorPosition(adventurer.Xpos, adventurer.Ypos); Console.Write("☺"); break; case ConsoleKey.NumPad0: break; case ConsoleKey.NumPad1: NPCTalk(adventurer, universe); break; case ConsoleKey.NumPad2: TextBoxViews.DisplayTownDesc(universe); break; case ConsoleKey.NumPad3: PlayerLocationss(adventurer, universe); break; case ConsoleKey.NumPad4: InventoryManagment(adventurer, universe); break; case ConsoleKey.NumPad5: Check.CheckAndPickupItem(universe, adventurer); break; case ConsoleKey.NumPad6: break; case ConsoleKey.NumPad7: break; case ConsoleKey.NumPad8: break; case ConsoleKey.NumPad9: playing = false; break; case ConsoleKey.D1: NPCTalk(adventurer, universe); break; case ConsoleKey.D2: TextBoxViews.DisplayTownDesc(universe); break; case ConsoleKey.D3: PlayerLocationss(adventurer, universe); break; case ConsoleKey.D4: InventoryManagment(adventurer, universe); break; case ConsoleKey.D5: Check.CheckAndPickupItem(universe, adventurer); break; case ConsoleKey.D9: playing = false; break; default: break; } return(playing); }
private static void SlimeATK(Adventurer adventurer, Universe universe, Slime slime, bool blocked) { //Setup Random random = new Random(); int attack = random.Next(1, 4); int damage = 0; bool tOb = true;//tOb is here to help //If else statement to handle what happens next if (!slime.PowerAttack) { if (attack == 1) { TextBoxViews.ReWriteToMessageBox(universe, "The slime jumps at you and lands on your foot..."); damage = random.Next(5, slime.Damage); } else if (attack == 2) { TextBoxViews.ReWriteToMessageBox(universe, "The slime jumps at you and hits you in the chest..."); damage = random.Next(5, slime.Damage); } else if (attack == 3) { TextBoxViews.ReWriteToMessageBox(universe, "The slime readies to do a very powerful attack..."); slime.PowerAttack = true; tOb = false; } else { TextBoxViews.WriteToMessageBox(universe, "Error: No attack defined..."); } } else if (slime.PowerAttack) { damage = random.Next(20, slime.Damage * 3); TextBoxViews.ReWriteToMessageBox(universe, "The slime slams into you with a lot of force."); } else { TextBoxViews.ReWriteToMessageBox(universe, "Not supposed to HAPPEN"); } if (tOb) { if (blocked) { TextBoxViews.ReWriteToMessageBox(universe, "You blocked the slime's attack"); slime.PowerAttack = false; } else if (slime.PowerAttack) { if (damage > 29) { TextBoxViews.ReWriteToMessageBox(universe, "The slime hits you for a whopping " + damage + " damage! Thats a lot of damage."); } else { TextBoxViews.ReWriteToMessageBox(universe, "The slime hits you for a whopping " + damage + " damage!"); } slime.PowerAttack = false; adventurer.Health -= damage; } else { TextBoxViews.ReWriteToMessageBox(universe, $"The slime deals {damage} damage."); adventurer.Health = adventurer.Health - damage; } } }
private static bool Attack(Adventurer adventurer, Universe universe, Slime slime) { Random random = new Random(); int damage = adventurer.Damage; bool blocking = false; bool tOb = true; string attackMsg = "You slap the slime, YEAH F*** THAT GUY. WOOOOOOOOOOOOOOOOOO"; if ((adventurer.PlayerWeapon == Adventurer.Weapon.BroadSword) || (adventurer.PlayerWeapon == Adventurer.Weapon.Sword)) { attackMsg = "You swing your " + adventurer.PlayerWeapon + " at the slime"; } else if ((adventurer.PlayerWeapon == Adventurer.Weapon.Dagger)) { attackMsg = "You stabb the slime with your " + adventurer.PlayerWeapon; } else if ((adventurer.PlayerWeapon == Adventurer.Weapon.Bow)) { attackMsg = "You shoot the slime with an arrow"; } else if ((adventurer.PlayerWeapon == Adventurer.Weapon.Mace)) { attackMsg = "You hit the slime with your " + adventurer.PlayerWeapon; } else if ((adventurer.PlayerWeapon == Adventurer.Weapon.Staff)) { attackMsg = "You cast a fire spell on the slime."; } // // PLAYER MENU // //New method for handling TextBoxViews.DisplayCustom(universe, new string[4] { " Attack", " Throw a Rock : " + adventurer.ItemsDictionary[Item.Items.Stone], " Block", "Use a potion : " + adventurer.ItemsDictionary[Item.Items.HealthPotion] }); TextBoxViews.ReWriteToMessageBox(universe, "Please choose an action...", true); while (tOb) { ConsoleKeyInfo key = Console.ReadKey(); switch (key.Key) { case ConsoleKey.D1: TextBoxViews.ReWriteToMessageBox(universe, attackMsg + " You dealt " + damage + " damage."); slime.Health -= damage; tOb = false; break; case ConsoleKey.D2: if (adventurer.ItemsDictionary[Item.Items.Stone] >= 1) { adventurer.ItemsDictionary[Item.Items.Stone]--; damage = 2; TextBoxViews.ReWriteToMessageBox(universe, "You throw a stone at the slime and deal " + damage.ToString() + " damage."); slime.Health -= damage; tOb = false; } else { TextBoxViews.ReWriteToMessageBox(universe, "You dont have any rocks to throw", true); } break; case ConsoleKey.D3: TextBoxViews.ReWriteToMessageBox(universe, "You get ready to block the slime's next attack."); blocking = true; tOb = false; break; case ConsoleKey.D4: if (adventurer.ItemsDictionary[Item.Items.HealthPotion] > 0) { adventurer.ItemsDictionary[Item.Items.HealthPotion]--; Adventurer.PlayerPotionHeal(adventurer, universe); tOb = false; } else { TextBoxViews.WriteToMessageBox(universe, "You don't have any health potions left"); } break; case ConsoleKey.NumPad1: TextBoxViews.ReWriteToMessageBox(universe, attackMsg + " You dealt " + damage + " damage."); tOb = false; break; case ConsoleKey.NumPad2: if (adventurer.ItemsDictionary[Item.Items.Stone] > 0) { adventurer.ItemsDictionary[Item.Items.Stone]--; damage = 2; TextBoxViews.ReWriteToMessageBox(universe, "You throw a stone at the slime and deal " + damage.ToString() + " damage."); slime.Health -= damage; tOb = false; } else { TextBoxViews.ReWriteToMessageBox(universe, "You dont have any stones to throw!"); } break; case ConsoleKey.NumPad3: TextBoxViews.ReWriteToMessageBox(universe, "You get ready to block the slime's next attack."); blocking = true; tOb = false; break; case ConsoleKey.NumPad4: if (adventurer.ItemsDictionary[Item.Items.HealthPotion] > 0) { adventurer.ItemsDictionary[Item.Items.HealthPotion]--; Adventurer.PlayerPotionHeal(adventurer, universe); tOb = false; } else { TextBoxViews.WriteToMessageBox(universe, "You don't have any health potions left"); } break; default: TextBoxViews.ReWriteToMessageBox(universe, "Please Choose an attack using the numbers on your keyboard.", true); break; } } return(blocking); }