Ejemplo n.º 1
0
    /// <summary>
    /// Called from buy StoreItemController OnBuyButton
    /// </summary>
    /// <param name="button"></param>
    public void BuyButtonLogic(StoreItemController storeItemScript)
    {
        Item itemData = storeItemScript.ItemData;

        switch (itemData.CurrencyType)
        {
        case CurrencyTypes.WellaCoin:
            if (DataManager.Instance.GameData.Stats.Stars >= itemData.Cost)
            {
                InventoryManager.Instance.AddItemToInventory(itemData.ID);
                StatsManager.Instance.ChangeStats(coinsDelta: itemData.Cost * -1);
                OnBuyAnimation(storeItemScript);

                // Check for any special cases we need to account for (ie. wallpaper buying)
                storeItemScript.BuyButtonStateCheck();

                // Analytics
                Analytics.Instance.ItemEvent(Analytics.ITEM_STATUS_BOUGHT, itemData.Type, itemData.ID);

                // Play a sound since an item was bought
                AudioManager.Instance.PlayClip("shopBuy");
            }
            else
            {
                HUDUIManager.Instance.PlayNeedCoinAnimation();
                AudioManager.Instance.PlayClip("buttonDontClick");
            }
            break;
        }
    }
Ejemplo n.º 2
0
	public StoreTouchInfo()
	{
		idx = -1;
		type = StoreTouchType.STORE_TOUCH_NONE;
		storeItemController = null;
		touchObject = null;
	}
Ejemplo n.º 3
0
    // Called when item bought, creates a sprite for the item and move it to correct inventory
    public void OnBuyAnimation(StoreItemController storeItemScript)
    {
        Vector3 origin      = storeItemScript.GetSpritePosition();
        Vector3 endPosition = InventoryUIManager.Instance.itemFlyToTransform.position;         // TODO change this

        GameObject animationSprite = GameObjectUtils.AddChild(storeSubPanel, boughtItemTweenPrefab);

        animationSprite.GetComponentInChildren <Image>().sprite = SpriteCacheManager.GetItemSprite(storeItemScript.ItemData.ID);
        animationSprite.transform.position = origin;
        animationSprite.name = storeItemScript.ItemData.ID;

        LeanTween.move(animationSprite, endPosition, 0.666f)
        .setEase(LeanTweenType.easeOutQuad)
        .setOnComplete(OnBuyAnimationDone)
        .setOnCompleteParam(animationSprite);
    }