public void SavePackCoins() { List <InforPack> ListInforPack = new List <InforPack>(); for (int i = 0; i < PackCoin.Count; i++) { InforPack infor = new InforPack(); infor.idPack = i; infor.FirstBuy = PackCoin[i].isFirstBuy; infor.CanBuy = PackCoin[i].Canbuy; ListInforPack.Add(infor); } ListPack Packs = new ListPack(ListInforPack); string json = JsonUtility.ToJson(Packs); PlayerPrefs.SetString(Key_Pack, json); PlayerPrefs.Save(); }
public void Init() { // PlayerPrefs.DeleteKey(Key_Pack_Skins); if (!PlayerPrefs.HasKey(Key_Pack)) { List <InforPack> ListInforPack = new List <InforPack>(); for (int i = 0; i < PackCoin.Count; i++) { InforPack infor = new InforPack(); infor.idPack = i; ListInforPack.Add(infor); } for (int i = 0; i < ListInforPack.Count; i++) { if (i == 0) { ListInforPack[i].FirstBuy = false; ListInforPack[i].CanBuy = true; ListInforPack[i].typePack = TypePack.Coin; } else if (i != 5) { ListInforPack[i].FirstBuy = true; ListInforPack[i].CanBuy = true; ListInforPack[i].typePack = TypePack.Coin; } else { ListInforPack[i].FirstBuy = true; ListInforPack[i].CanBuy = true; ListInforPack[i].typePack = TypePack.Ads; } } ListPack Packs = new ListPack(ListInforPack); string json = JsonUtility.ToJson(Packs); PlayerPrefs.SetString(Key_Pack, json); PlayerPrefs.Save(); } if (!PlayerPrefs.HasKey(Key_Pack_Skins)) { List <PackSkins> ListPackSkins = new List <PackSkins>(); for (int i = 0; i < PackSkin.Count; i++) { PackSkins Skins = new PackSkins(i, false); ListPackSkins.Add(Skins); } ListPackSkins ListPacks = new ListPackSkins(ListPackSkins); string json = JsonUtility.ToJson(ListPacks); PlayerPrefs.SetString(Key_Pack_Skins, json); PlayerPrefs.Save(); } var a = GetPackCoin(); var b = GetPackSkins(); Debug.Log("PACKS Skins: " + b.Count); for (int i = 0; i < PackCoin.Count; i++) { PackCoin[i].LoadPack(a[i].FirstBuy, a[i].CanBuy); } for (int i = 0; i < PackSkin.Count; i++) { PackSkin[i].id = b[i].idPack; PackSkin[i].isBuy = b[i].isBuy; PackSkin[i].LoadStatus(); } }