Exemplo n.º 1
0
 public purchasData purchaseDataAdress()
 {
     pPath           = Path.Combine(Application.persistentDataPath, "purchaseData.json");
     purchaseString  = File.ReadAllText(pPath);
     purchaseManager = JsonUtility.FromJson <purchasData>(purchaseString);
     return(purchaseManager);
 }
Exemplo n.º 2
0
    public bool setItem(int planeNum)
    {
        purchaseManager = purchaseDataAdress();
        print(purchaseManager.firstPlane);
        if (planeNum == 1)
        {
            if (purchaseManager.firstPlane == 1)
            {
                planeNumberData.planeNumber = planeNum;
                applyLastPlane();
                print(planeNumberData.planeNumber);
                return(true);
            }
        }

        if (planeNum == 2)
        {
            if (purchaseManager.secondPlane == 1)
            {
                planeNumberData.planeNumber = planeNum;
                applyLastPlane();
                return(true);
            }
        }

        planeNumberData.planeNumber = 0;
        applyLastPlane();
        return(false);
    }
Exemplo n.º 3
0
    public void purchase(int itemNum, int itemPrice)
    {
        dataManager = playerDataAdress();

        if (dataManager.gold >= itemPrice)
        {
            purchaseState = true;
            // saving gold amount
            dataManager.gold -= itemPrice;
            string writeJson = JsonUtility.ToJson(dataManager);
            File.WriteAllText(path, writeJson);


            // reading purchase data


            purchaseManager = purchaseDataAdress();

            if (itemNum == 1)
            {
                purchaseManager.firstPlane = 1;
                writeJson = JsonUtility.ToJson(purchaseManager);
                File.WriteAllText(pPath, writeJson);
            }
        }
        else
        {
            notEnoughGold = true;
        }
    }
Exemplo n.º 4
0
 public void purchaseItem(int ItemNum)
 {
     ItemPrice = ItemPriceList[ItemNum];
     data.purchase(ItemNum, ItemPrice);
     purchaseManager = data.purchaseDataAdress();
 }
Exemplo n.º 5
0
 void Start()
 {
     data            = MenuManager.GetComponent <DataLoader>();
     menuLoader      = GetComponent <MenuDataLoader>();
     purchaseManager = data.purchaseDataAdress();
 }