private void Equip(int ind) //equpping item { if (slots.ContainsKey(inventory[ind].Slot)) //if slot already has item we ask should we replace it { MainGame.Say("This slot is occupied. Replace?(y/n)", 25); if (StrInput.YNInput()) {//replacin Console.Write("\n"); Item tmp = inventory[ind]; inventory[ind] = slots[inventory[ind].Slot]; slots[inventory[ind].Slot] = tmp; MainGame.Say("You replaced ", 25); MainGame.Say(inventory[ind].Name, MainGame.GetColor(inventory[ind].Rareness), 25);; MainGame.Say(" with ", 25); MainGame.Say(slots[inventory[ind].Slot].Name + ".\n", MainGame.GetColor(slots[inventory[ind].Slot].Rareness), 25); } else//ok den { Console.Write("\n"); return; } } else//or we can just equip it { slots[inventory[ind].Slot] = inventory[ind]; MainGame.Say("You equipped ", 25); MainGame.Say(slots[inventory[ind].Slot].Name + ".\n", MainGame.GetColor(slots[inventory[ind].Slot].Rareness), 25); inventory.RemoveAt(ind); } StatCalc();//recalc stats }
public void TakeDamage(int dmg) { if (dmg < armor) { dmg = 0; } else { dmg -= armor; } Hp -= dmg; MainGame.Say("You recieved ", 25); MainGame.Say(dmg + " damage.\n", ConsoleColor.DarkRed, 25); if (hp == 0) { MainGame.Say("----------YOU DIED----------\n", ConsoleColor.DarkRed, 25); MainGame.Say("Restart?(y/n)\n", 25); if (StrInput.YNInput()) { MainGame.Restart = true; } else { MainGame.Restart = false; } } }
//----------------------------------STATS--------------------------------------- public void GetStats()//askin about stats { int pts = 15; MainGame.Say("-A'right, " + name + ", now I wanna test your skills, wanna se what you're capable of.\n", ConsoleColor.Yellow, 25); MainGame.Say("You have 15 point that you can spend in 3 stats: ", 25); MainGame.Say("strength", ConsoleColor.Red, 25); MainGame.Say(", ", 25); MainGame.Say("agility", ConsoleColor.Green, 25); MainGame.Say(" and ", 25); MainGame.Say("intellect", ConsoleColor.Blue, 25); MainGame.Say(".\n", 25); MainGame.Say("Each stat affects some of your stats and can maximum have 9 points.\n\n", 25); StatField(ref strength, ref pts, ConsoleColor.Red); StatField(ref agility, ref pts, ConsoleColor.Green); StatField(ref intellect, ref pts, ConsoleColor.Blue); StatCalc(); do { MainGame.Say("\nSo you have:\n", 25); StatOut(); if (pts != 0) { MainGame.Say("You have " + pts + " unused points. ", 25); } MainGame.Say("Are you sure you want to continue?(y/n)", 25); if (StrInput.YNInput()) { return; } else { Console.Write("\n"); StatField(ref intellect, ref pts, ConsoleColor.Blue); StatCalc(); } } while (true); }
} //restart flag static void Main(string[] args) { do { ItemInit(); EntityInit(); List <Room> dungeon = new List <Room>(); DungeonFill(dungeon); Player player = new Player(); player.GetName(); player.GetStats(); Say("\n\n-Alright, I have some stuff up here, I think you may need this.\n", ConsoleColor.Yellow, 25); //gives player item based on his stats if (player.MaxStat() == "strength") { player.GetItem(itemListWhite[0]); } else if (player.MaxStat() == "agility") { player.GetItem(itemListWhite[2]); } else if (player.MaxStat() == "intellect") { player.GetItem(itemListWhite[1]); } //some text+askin if player wants to pen inv Say("You come closer to dungeon enteracne. You some mysterious feeling goes through your body.\n", ConsoleColor.White, 25); Say("You can open your inventory before entering the dungeon and see what things overseer gave you.\n", ConsoleColor.White, 25); MainGame.Say("Would you like to open your inventory?(y/n)", 25); if (StrInput.YNInput()) { Console.Write("\n"); player.OpenInventory(); } Say("\nYou enter the dungeon...\n\n\n", 25); Say("You encounter your first room!\n", 25); //proccecing battle+lotting procces for every room foreach (Room room in dungeon) { player.currentRoom = room; Say("You enter " + room.Name + "\n", 25); //Entity interaction Battle(player); //death and restart check if (player.Hp == 0) { break; } //Loot interaction LootRoom(player); //Operations before going to next room Say("You picked everything you could take and you're ready to go.\n", 25); Say("You can open your inventory(I), equipment(E), look back to room(L) or move to the next room(N).\n", 25); do { char ind; ind = Console.ReadKey(true).KeyChar; if (ind == 'i' || ind == 'I')//open inventory { player.OpenInventory(); } else if (ind == 'e' || ind == 'E')//open equipment { player.OpenEquipment(); } else if (ind == 'l' || ind == 'L')//looking back if player forgot smt/threw thing that he needed { LootRoom(player); } else if (ind == 'n' || ind == 'N')//move forward { break; } else//no reaction { continue; } Say("You picked everything you could take and you're ready to go\n", 25); Say("You can open your inventory(I), look back to room(L) or move to the next room(N)\n", 25); } while (true); player.Regen();//hp+mana regen } if (Restart && player.Hp == 0) { continue; } else if (!Restart && player.Hp == 0) { break; } //ending Say("\n\nYou walk through a dungeon. Suddenly you feel wind blowing.\n", 25); Say("Exit should be nearby...\n", 25); Say("You're looking for exit\n", 25); Say("You see the light\n", 25); Say("Dungeon ends...\n", 25); Say("\n\nYou made it!\n", 25); if (StrInput.YNInput()) { Restart = true; } else { Restart = false; } } while (Restart); Console.ReadKey(); }