コード例 #1
0
 public static string Add_to_inventory(string Whatitem, string ID)
 {
     if (Whatitem == "weapon")
     {
         Weapons_Inventory.Add(ID);
     }
     if (Whatitem == "shield")
     {
         Shields_Inventory.Add(ID);
     }
     return("");
 }
コード例 #2
0
        public static string Equip_weapon()
        {
            string userInput = "";

            Console.WriteLine("do you want to equip a 1.weapon or a 2.shield");
            string valik = Console.ReadLine();

            if (valik == "1")
            {
                if (Weapons_Inventory.Count() == 0)
                {
                    Console.WriteLine("You dont have any weapons to equip");
                    Console.ReadKey();
                    return("");
                }


                Draw_inventory(false);
                Console.WriteLine((Weapons_Inventory.Count + 1) + ". Back");
                Console.WriteLine("What item would you like to equip?(number)");

                while (true)
                {
                    userInput = Console.ReadLine();

                    if (int.Parse(userInput) > 0)
                    {
                        if (int.Parse(userInput) < Weapons_Inventory.Count() + 1)
                        {
                            Currently_equipped = Weapons_Inventory[int.Parse(userInput) - 1];
                            Console.WriteLine("You've equipped a/an " + Convertor.exporter_wep(Currently_equipped, "wep_name"));
                            Console.ReadKey();
                            return("");
                        }
                    }

                    if (int.Parse(userInput) == Weapons_Inventory.Count + 1)
                    {
                        return("");
                    }

                    else
                    {
                        Console.WriteLine("Unknown item");
                        return("");
                    }
                }
            }


            if (valik == "2")
            {
                if (Shields_Inventory.Count() == 0)
                {
                    Console.WriteLine("You dont have any shields to equip");
                    Console.ReadKey();
                    return("");
                }
                Draw_inventory(false);
                Console.WriteLine((Shields_Inventory.Count + 1) + ". Back");
                Console.WriteLine("What item would you like to equip?(number)");
                while (true)

                {
                    userInput = Console.ReadLine();

                    if (int.Parse(userInput) > 0)
                    {
                        if (int.Parse(userInput) < Shields_Inventory.Count() + 1)
                        {
                            Currently_equipped_shield = Shields_Inventory[int.Parse(userInput) - 1];
                            Console.WriteLine("You've equipped a/an " + Convertor.exporter_shield(Currently_equipped_shield, "shield_name"));
                            Player_block_chance = int.Parse(Convertor.exporter_shield(Currently_equipped_shield, "shield_block_chance"));
                            Console.ReadKey();
                            return("");
                        }
                    }

                    if (int.Parse(userInput) == Shields_Inventory.Count + 1)
                    {
                        return("");
                    }

                    else
                    {
                        Console.WriteLine("Unknown item");
                    }
                }
            }
            return("");
        }