示例#1
0
 public void DoubleCurrentRewards()
 {
     isSubscribed = true;
     PlayerDataManager.AddChestRewards(currentChestRewards);
     MenuController.UpdateTopMenu();
     doubleRewardsActiveContainer.SetActive(value: true);
     doubleRewardsOfferButton.gameObject.SetActive(value: false);
     for (int i = 0; i != shopItems.Count; i++)
     {
         shopItems[i].count *= 2;             //Ë«±¶½±Àø
     }
     doubleRewardRoutine = StartCoroutine(DoubleRewardsRoutine());
     StartCoroutine(CurrencyCountEOFRoutine());
 }
示例#2
0
    private IEnumerator ChestOpenAnimationRoutine(Rarity chestRarity)
    {
        rewardingDone       = false;
        chestExploded       = false;
        currentChestRewards = Variables.instance.GenerateChestRewards(chestRarity);
        PlayerDataManager.AddChestRewards(currentChestRewards);
        contentGridLayoutGroup.enabled = true;
        for (int j = 0; j != currentChestRewards.cards.Count; j++)
        {
            CardElement       component = UnityEngine.Object.Instantiate(cardPrefab).GetComponent <CardElement>();
            Card              card      = currentChestRewards.cards[j];
            ShopMenu.ShopItem item      = new ShopMenu.ShopItem
            {
                rarity = card.rarity,
                count  = card.count,
                id     = card.id,
                type   = ((card.type == CardType.TankCard) ? ShopMenu.ShopItemType.TankCard : ShopMenu.ShopItemType.BoosterCard),
                isNew  = card.isNew
            };
            shopItems.Add(item);
            AddElement(component);
            if (card.type == CardType.TankCard)
            {
                Tank tank = Variables.instance.GetTank(card.id);
                if (card.isNew)
                {
                    newCards.Push(new KeyValuePair <Collectible, CardElement>(tank, component));
                }
            }
        }
        if (currentChestRewards.gems > 0)
        {
            CardElement       component2 = UnityEngine.Object.Instantiate(cardPrefab).GetComponent <CardElement>();
            ShopMenu.ShopItem item2      = new ShopMenu.ShopItem
            {
                rarity = Rarity.Epic,
                count  = currentChestRewards.gems,
                type   = ShopMenu.ShopItemType.Gem
            };
            shopItems.Add(item2);
            AddElement(component2);
        }
        CardElement component3 = UnityEngine.Object.Instantiate(cardPrefab).GetComponent <CardElement>();

        ShopMenu.ShopItem item3 = new ShopMenu.ShopItem
        {
            rarity = chestRarity,
            count  = currentChestRewards.coins,
            type   = ShopMenu.ShopItemType.Coin
        };
        shopItems.Add(item3);
        AddElement(component3);
        LayoutRebuilder.ForceRebuildLayoutImmediate(contentGridLayoutGroup.GetComponent <RectTransform>());
        contentGridLayoutGroup.enabled = false;
        foreach (CardElement element in elements)
        {
            element.gameObject.SetActive(value: false);
        }
        chest.gameObject.SetActive(value: true);
        Image  image = chest;
        object sprite;

        switch (chestRarity)
        {
        default:
            sprite = commonChestSprite;
            break;

        case Rarity.Rare:
            sprite = rareChestSprite;
            break;

        case Rarity.Epic:
            sprite = epicChestSprite;
            break;
        }
        image.sprite = (Sprite)sprite;
        chest.SetNativeSize();
        yield return(new WaitForSeconds(currentOptions.shakeTime));

        AudioMap.PlayClipAt(AudioMap.instance["chestShake"], Vector3.zero, AudioMap.instance.uiMixerGroup);
        LeanTween.delayedCall(currentOptions.windupTime - 0.367f, (Action) delegate
        {
            AudioMap.PlayClipAt(AudioMap.instance["chestWindup"], Vector3.zero, AudioMap.instance.uiMixerGroup);
        });
        for (float time = 0f; time <= currentOptions.windupTime; time += Time.deltaTime)
        {
            chest.transform.rotation = Quaternion.Euler(0f, 0f, 50f * (Mathf.PingPong(time / 0.2f, 0.3f) - 0.2f));
            glowImage.color          = new Color(1f, 1f, 1f, LeanTween.easeInExpo(0f, 1f, time / currentOptions.windupTime));
            yield return(null);
        }
        chest.gameObject.SetActive(value: false);
        chest.transform.rotation = Quaternion.identity;
        currentOptions.explosion.Play();
        AudioMap.PlayClipAt(AudioMap.instance["chestOpen"], Vector3.zero, AudioMap.instance.uiMixerGroup);
        if (chestRarity == Rarity.Epic)
        {
            AudioMap.PlayClipAt(AudioMap.instance["chestOpenChime"], Vector3.zero, AudioMap.instance.uiMixerGroup);
        }
        yield return(new WaitForSeconds(currentOptions.postExplosionWaitTime));

        doubleRewardsOfferButton.gameObject.SetActive(!isSubscribed);
        doubleRewardingDone = !isSubscribed;
        chestExploded       = true;
        MenuController.backButtonOverrideAction = FinishAnimation;
        int num;

        for (int i = 0; i < elements.Count; i = num)
        {
            if (!(elements[i] == null))
            {
                CardElement cardElement = elements[i];
                AudioMap.PlayClipAt(AudioMap.instance["cardReveal"], Vector3.zero, AudioMap.instance.uiMixerGroup);
                cardElement.gameObject.SetActive(value: true);
                cardElement.SetValues(shopItems[i], animateRoll: true, deductCount: true, isSubscribed);
                if (shopItems[i].type == ShopMenu.ShopItemType.TankCard && shopItems[i].isNew)
                {
                    SetNewCard(i);
                }
                if (shopItems[i].type == ShopMenu.ShopItemType.Coin)
                {
                    AnimatedCurrencyController.AnimateCoins(isSubscribed ? (shopItems[i].count / 2) : shopItems[i].count, MenuController.UICamera.WorldToViewportPoint(cardElement.transform.position), MenuController.TotalCoinsPositionViewport, 5, null, delegate(int ts)
                    {
                        MenuController.instance.topTotalCoinsText.Tick(ts);
                    });
                }
                else if (shopItems[i].type == ShopMenu.ShopItemType.Gem)
                {
                    AnimatedCurrencyController.AnimateGems(isSubscribed ? (shopItems[i].count / 2) : shopItems[i].count, MenuController.UICamera.WorldToViewportPoint(cardElement.transform.position), MenuController.TotalGemsPositionViewport, 1, null, delegate(int ts)
                    {
                        MenuController.instance.topTotalGemsText.Tick(ts);
                    });
                }
                yield return(new WaitForSeconds(0.25f));
            }
            num = i + 1;
        }
        if (isSubscribed)
        {
            doubleRewardRoutine = StartCoroutine(DoubleRewardsRoutine());
        }
        FinishAnimation();
    }