/// Called whenever the inventory is updated to refresh the UI /// public void OnInventoryUpdated() { //Debug.Log( string.Format("Coins: {0}", InventorySystem.Get().GetAmount(InventorySystem.k_coinsId)) ); //Retrieve player items playerDets.softCurrency = InventorySystem.Get().GetAmount(InventorySystem.k_coinsId); //Grab coins playerDets.hardCurrency = InventorySystem.Get().GetAmount(InventorySystem.k_gemsId); //Grab gems playerDets.score = InventorySystem.Get().GetAmount(InventorySystem.k_scoreId); //Grab gems playerDets.tutorial = InventorySystem.Get().GetAmount(InventorySystem.k_tutorial); //Grab gems for (int i = 0; i < maxCats; i++) { playerInv.catsUnlocked[i] = InventorySystem.Get().GetAmount(InventorySystem.k_CatNum[i]); } for (int i = 0; i < maxSkin; i++) { playerInv.catSkins[i] = InventorySystem.Get().GetAmount(InventorySystem.k_CatSkins[i]); } for (int i = 0; i < maxHead; i++) { playerInv.catHeadItems[i] = InventorySystem.Get().GetAmount(InventorySystem.k_HeadNum[i]); } for (int i = 0; i < maxCollar; i++) { playerInv.catCollarItems[i] = InventorySystem.Get().GetAmount(InventorySystem.k_CollarNum[i]); } for (int i = 0; i < maxRoom; i++) { playerInv.catRoomItems[i] = InventorySystem.Get().GetAmount(InventorySystem.k_RoomNum[i]); } //---------------------------- //After retrieving all of the players current items, we grab their saved cat setups playerStab.currentCat = InventorySystem.Get().GetAmount(InventorySystem.k_currentCat); playerStab.currentRoom = InventorySystem.Get().GetAmount(InventorySystem.k_currentRoom); for (int i = 0; i < maxCats; i++) { playerStab.catSkinCurrent[i] = InventorySystem.Get().GetAmount(InventorySystem.k_CatSkinCurr[i]); } for (int i = 0; i < maxCats; i++) { playerStab.catHeadCurrent[i] = InventorySystem.Get().GetAmount(InventorySystem.k_CatHeadCurr[i]); } for (int i = 0; i < maxCats; i++) { playerStab.catCollarCurrent[i] = InventorySystem.Get().GetAmount(InventorySystem.k_CatCollarCurr[i]); } //playerInv.catsUnlocked = InventorySystem.Get().GetAmount(InventorySystem.k_CatNum); //Grab gems }
/// private void Start() { m_coinText = transform.FindChild("CoinText").GetComponent <Text>(); m_coinText.text = "Coins: Fetching"; m_gemText = transform.FindChild("GemText").GetComponent <Text>(); m_gemText.text = "Gems: Fetching"; InventorySystem.Get().OnInventoryUpdated += OnInventoryUpdated; }
/// Called by ChilliConnect when a purchase has been redeemed on the server. /// We close of the transaction, award the items and notify the listener that the purchase has finished. /// /// NOTE: We have to handle duplicate purchases here /// /// @param product /// Purchased product /// @param status /// Status of the product /// @param rewards /// Items to award for the given product as specified on the ChilliConnect dashboard /// public void OnPurchaseRedeemed(Product product, string status, PurchaseExchange rewards) { Debug.Log(string.Format("Product redeemed: {0}. Status: {1}", product.definition.storeSpecificId, status)); // NOTE: If the status is "InvalidRedeemed" then the user has already been awarded the IAP and this is // a duplicate purchase. In this case you might want to explain that to the user rather than just closing // the transaction silently. // If it is "InvalidVerificationFailed" then probably a fraudulent purchase if (status != "InvalidRedeemed" && status != "InvalidVerificationFailed") { foreach (var reward in rewards.Items) { InventorySystem.Get().AddItem(reward.Key, reward.Amount); } } m_unityStoreController.ConfirmPendingPurchase(product); OnPurchaseCompleteEvent(); }
/// private void Start() { /* * m_coinText = transform.FindChild("CoinText").GetComponent<Text>(); * m_coinText.text = "Coins: Fetching"; * m_gemText = transform.FindChild("GemText").GetComponent<Text>(); * m_gemText.text = "Gems: Fetching"; */ maxCats = playerInv.numberOfCats; maxSkin = playerInv.numberOfSkins; maxHead = playerInv.numberOfHead; maxCollar = playerInv.numberOfCollar; maxRoom = playerInv.numberOfRooms; InventorySystem.Get().OnInventoryUpdated += OnInventoryUpdated; StartCoroutine(InitialRun()); }
/// Called whenever the inventory is updated to refresh the UI /// public void OnInventoryUpdated() { m_coinText.text = string.Format("Coins: {0}", InventorySystem.Get().GetAmount(InventorySystem.k_coinsId)); m_gemText.text = string.Format("Gems: {0}", InventorySystem.Get().GetAmount(InventorySystem.k_gemsId)); }