void OnItemPurchased(int index) { Character character = characterDB.GetCharacter(index); CharacterItemUI uiItem = GetItemUI(index); if (GameDataManager.CanSpendCoins(character.price)) { //Proceed with the purchase operation GameDataManager.SpendCoins(character.price); //Play purchase FX purchaseFx.Play(); //Update Coins UI text GameSharedUI.Instance.UpdateCoinsUIText(); //Update DB's Data characterDB.PurchaseCharacter(index); uiItem.SetCharacterAsPurchased(); uiItem.OnItemSelect(index, OnItemSelected); //Add purchased item to Shop Data GameDataManager.AddPurchasedCharacter(index); } else { //No enough coins.. AnimateNoMoreCoinsText(); uiItem.AnimateShakeItem(); } }
private void OnItemPurchased(int index) { Character character = characterDB.GetPurchased(index); CharacterItemUI uiItem = GetItemUI(index); if (GameDataManager.CanSpendCoins(character.price)) { GameDataManager.SpendCoins(character.price); purchaseFx.Play(); GameSharedUI.Instance.UpdateCoinsUIText(); characterDB.PurchasedCharacter(index); uiItem.SetCharacterAsPurchased(); uiItem.OnItemSelect(index, OnItemSelect); GameDataManager.AddPurchasedCharacter(index); } else { AnimateNoMoreCoins(); uiItem.AnimateShakeItem(); } }