I'm developing a 2D game app using unity c#.
I have a list of item(object) and each item contains double Price, double Multiplier and int Level.
I'm trying to load that List to the FireBase Realtime DataBase using json inorder to save the player's peronal shop. to try and make it look like this in the DB:
This is my Item class:
public class Item
{
public double Price {get; set;}
public double Multiplier { get; set; }
public int Level { get; set; }
public Item(double price, double multiplier, int level)
{
this.Price = price;
this.Multiplier = multiplier;
this.Level = level;
}
}
And this is my Shop class:
public class Shop
{
public List<Item> ShopList { get; set; }
public Shop()
{
this.ShopList = new List<Item>();
}
public void InitShop()
{
string[] lines = System.IO.File.ReadAllLines(@"Assets\Scripts\Data\ShopData.txt");
foreach (string line in lines)
{
string[] words = line.Split(',');
double price = Convert.ToDouble(words[0]);
double mul = Convert.ToDouble(words[1]);
int level = Convert.ToInt32(words[2]);
Item i = new Item(price, mul, level);
this.ShopList.Add(i);
}
}
