Esempio n. 1
0
    public void SavePackSKins()
    {
        List <PackSkins> ListInforPack = new List <PackSkins>();

        for (int i = 0; i < PackSkin.Count; i++)
        {
            PackSkins PackSkins = new PackSkins(PackSkin[i].id, PackSkin[i].isBuy);
            ListInforPack.Add(PackSkins);
        }

        ListPackSkins listpack = new ListPackSkins(ListInforPack);
        string        json     = JsonUtility.ToJson(listpack);

        PlayerPrefs.SetString(Key_Pack_Skins, json);
        PlayerPrefs.Save();
    }
Esempio n. 2
0
    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();
        }
    }