Пример #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();

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

                int itemID;

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

                    //If Attack item
                    if (itemID == 1)
                    {
                        Weapon attackItem = new Weapon(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)
                    {
                        Armor defenseItem = new Armor(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)
                    {
                        Potions consumables = new Potions(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();
            }
        }
Пример #2
0
        public void LoadMerchant(string path)
        {
            if (File.Exists(path))
            {
                StreamReader reader = File.OpenText(path);

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

                GetName = reader.ReadLine();

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

                int itemID;

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

                    if (itemID == 1)
                    {
                        Weapon attackItem = new Weapon(reader.ReadLine(),                  //Name
                                                       Convert.ToInt32(reader.ReadLine()), //Stat
                                                       Convert.ToInt32(reader.ReadLine()), //Value
                                                       itemID,                             //ID
                                                       reader.ReadLine());                 //Description

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

                    else if (itemID == 2)
                    {
                        Armor defenseItem = new Armor(reader.ReadLine(),
                                                      Convert.ToInt32(reader.ReadLine()),
                                                      Convert.ToInt32(reader.ReadLine()),
                                                      itemID,
                                                      reader.ReadLine());

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

                    else if (itemID == 3)
                    {
                        Potions consumables = new Potions(reader.ReadLine(),
                                                          Convert.ToInt32(reader.ReadLine()),
                                                          Convert.ToInt32(reader.ReadLine()),
                                                          itemID,
                                                          reader.ReadLine());

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

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

                reader.Close();
            }
        }
Пример #3
0
 public ShopInventory()
 {
     _itemList    = new Items[7];
     _itemList[0] = new Armor("Jordan's", 200, 80, 2, "Can't be up in the streets with some dirty ass shoes now.");
     _itemList[1] = new Armor("Hello Kitty Watch", 2000, 3, 2, "Some watch my kid gave me, love you baby.");
     _itemList[2] = new Weapon("Glock", 20, 75, 1, "Always stay strapped homie.");
     _itemList[3] = new Armor("Blood Stained Shirt", 0, 5, 2, "Some clothes I picked from a hood rat tryna rob me.");
     _itemList[4] = new Armor("Light Weight BP Vest", 50, 100, 2, "You can't be rolling on them streets without one of these puppies son.");
     _itemList[5] = new Potions("Hashbrown", 15, 3, 3, "Yo fat ass know you want this, straigt form Mickey D's boy.");
     _itemList[6] = new Potions("High Dollar Herbs", 250, 350, 3, "All that needs to be said is, green makes everything go good my man.");
 }