Beispiel #1
0
        public void LoadPlayer(string path)
        {
            if (File.Exists(path))
            {
                StreamReader reader = File.OpenText(path);

                GetInventory().InventoryLength = Convert.ToInt32(reader.ReadLine());

                GetName = reader.ReadLine();

                Item[] newList = new Item[GetInventory().InventoryLength];

                int itemID;

                for (int i = 0; i < GetInventory().InventoryLength; i++)
                {
                    itemID = Convert.ToInt32(reader.ReadLine());

                    //If Attack item
                    if (itemID == 1)
                    {
                        AttackItem attackItem = new AttackItem(reader.ReadLine(),                  //Item Name
                                                               Convert.ToInt32(reader.ReadLine()), //Item damage
                                                               Convert.ToInt32(reader.ReadLine()), //Item value
                                                               itemID,                             //Item ID
                                                               reader.ReadLine());                 //item Description

                        GetInventory().GetItemList[i] = attackItem;
                    }
                    //If Defense item
                    else if (itemID == 2)
                    {
                        DefenseItem defenseItem = new DefenseItem(reader.ReadLine(),                  //Item Name
                                                                  Convert.ToInt32(reader.ReadLine()), //Item defense
                                                                  Convert.ToInt32(reader.ReadLine()), //Item value
                                                                  itemID,                             //Item ID
                                                                  reader.ReadLine());                 //item Description

                        GetInventory().GetItemList[i] = defenseItem;
                    }
                    //If consumable item
                    else if (itemID == 3)
                    {
                        Consumables consumables = new Consumables(reader.ReadLine(),                  //Item Name
                                                                  Convert.ToInt32(reader.ReadLine()), //Item healing
                                                                  Convert.ToInt32(reader.ReadLine()), //Item value
                                                                  itemID,                             //Item ID
                                                                  reader.ReadLine());                 //item Description

                        GetInventory().GetItemList[i] = consumables;
                    }
                }

                GetInventory().Gold = Convert.ToInt32(reader.ReadLine());

                reader.Close();
            }
        }
Beispiel #2
0
 //Constructor for the shop's inventory
 public ShopInventory()
 {
     _itemList[0] = new DefenseItem("Rags", 0, 1, 2, "Used to lcean yourself up.");
     _itemList[1] = new DefenseItem("Leather Armor", 20, 45, 2, "Standard training gear.");
     _itemList[2] = new DefenseItem("Wooden Shield", 5, 10, 2, "Standard trainging gear.");
     _itemList[3] = new AttackItem("Long Sword", 16, 55, 1, "For the more adept warrior.");
     _itemList[4] = new DefenseItem("Gloves", 0, 5, 2, "It's chilly outside.");
     _itemList[5] = new DefenseItem("Leather Boots", 10, 25, 2, "Standard training gear.");
     _itemList[6] = new Consumables("Brownies", 15, 3, 3, "Warm and fluffy. Just like mother used to make them.");
     _itemList[7] = new Consumables("God's Chosen Chicken Sandwich", 777, 10, 3, "This chicken has been embued with the power on high and brings new life to you.");
 }