Example #1
0
 public void SetRewards(LootCrateType crateType, int snoutCoins)
 {
     TextMeshHelper.UpdateTextMeshes(this.coinRewardLabel, snoutCoins.ToString(), false);
     for (int i = 0; i < this.rewardCrateContainer.childCount; i++)
     {
         Transform child = this.rewardCrateContainer.GetChild(i);
         child.gameObject.SetActive(child.name.Equals(crateType.ToString()));
     }
 }
Example #2
0
    public static int GetSnoutCoinPrice(LootCrateType crateType, float timeLeft)
    {
        string valueKey = crateType.ToString();
        int    num      = 0;

        if (Singleton <GameConfigurationManager> .Instance.HasValue("lootcrate_open_hour_rates", valueKey))
        {
            num = Singleton <GameConfigurationManager> .Instance.GetValue <int>("lootcrate_open_hour_rates", valueKey);
        }
        if (num <= 0)
        {
            num = 15;
        }
        return((int)Mathf.Clamp((float)num * (timeLeft / 3600f), 2f, 9999f));
    }
Example #3
0
    public static int GetOpenTimeForCrate(LootCrateType crateType)
    {
        string valueKey = crateType.ToString();

        if (Singleton <GameConfigurationManager> .Instance.HasValue("lootcrate_open_times", valueKey))
        {
            int value = Singleton <GameConfigurationManager> .Instance.GetValue <int>("lootcrate_open_times", valueKey);

            if (value > 0)
            {
                return(value);
            }
        }
        switch (crateType)
        {
        case LootCrateType.Wood:
            return(LootCrateSlots.HoursToSeconds(8f));

        case LootCrateType.Metal:
            return(LootCrateSlots.HoursToSeconds(24f));

        case LootCrateType.Gold:
            return(LootCrateSlots.HoursToSeconds(48f));

        case LootCrateType.Cardboard:
            return(LootCrateSlots.HoursToSeconds(2f));

        case LootCrateType.Glass:
            return(LootCrateSlots.HoursToSeconds(4f));

        case LootCrateType.Bronze:
            return(LootCrateSlots.HoursToSeconds(16f));

        case LootCrateType.Marble:
            return(LootCrateSlots.HoursToSeconds(28f));

        default:
            return(LootCrateSlots.HoursToSeconds(72f));
        }
    }
Example #4
0
    public void SetCrateRankAndReward(LootCrateType crateType, int rank, int reward)
    {
        this.reward = reward;
        Localizer.LocaleParameters localeParameters = Singleton <Localizer> .Instance.Resolve(this.rankLocalizationKey, null);

        TextMeshHelper.UpdateTextMeshes(this.rankLabel, string.Format(localeParameters.translation, rank), false);
        TextMeshHelper.Wrap(this.rankLabel, 15);
        Localizer.LocaleParameters localeParameters2 = Singleton <Localizer> .Instance.Resolve(this.snoutRewardLocalizationKey, null);

        TextMeshHelper.UpdateTextMeshes(this.rewardLabel, string.Format(localeParameters2.translation, reward), false);
        TextMeshSpriteIcons.EnsureSpriteIcon(this.rewardLabel);
        TextMeshHelper.Wrap(this.rewardLabel, 15);
        this.lootCrate.gameObject.SetActive(crateType != LootCrateType.None);
        this.barrelContainer.SetActive(crateType == LootCrateType.None);
        if (crateType != LootCrateType.None)
        {
            this.lootCrate.initialSkinName = crateType.ToString();
            this.lootCrate.Initialize(true);
            this.lootCrate.state.SetAnimation(0, "Idle", true);
            this.lootCrate.Update(Time.deltaTime);
        }
        this.SetLoading(false);
    }
    public void InitPopup(int price, int secondsLeft, GameObject cratePrefab, LootCrateType lootCrate)
    {
        this.currentCrateType = lootCrate;
        this.SnoutCoinPrice   = price;
        if (this.priceLabel)
        {
            TextMesh[] componentsInChildren = this.priceLabel.gameObject.GetComponentsInChildren <TextMesh>();
            for (int i = 0; i < componentsInChildren.Length; i++)
            {
                componentsInChildren[i].text = string.Format("[snout] {0}", this.SnoutCoinPrice);
                TextMeshSpriteIcons.EnsureSpriteIcon(componentsInChildren[i]);
            }
        }
        string formattedTimeFromSeconds = LootCrateSlot.GetFormattedTimeFromSeconds(secondsLeft);

        if (this.timerLabel)
        {
            TextMesh[] componentsInChildren2 = this.timerLabel.gameObject.GetComponentsInChildren <TextMesh>();
            TextMeshHelper.UpdateTextMeshes(componentsInChildren2, formattedTimeFromSeconds, false);
        }
        if (this.unlockNowControls != null)
        {
            Transform transform = this.unlockNowControls.transform.Find("StartUnlockButton/TimeLabel");
            if (transform != null)
            {
                TextMesh[] componentsInChildren3 = transform.gameObject.GetComponentsInChildren <TextMesh>();
                TextMeshHelper.UpdateTextMeshes(componentsInChildren3, formattedTimeFromSeconds, false);
            }
        }
        if (this.skeletonAnimation)
        {
            this.skeletonAnimation.initialSkinName = lootCrate.ToString();
            this.skeletonAnimation.Initialize(true);
            this.skeletonAnimation.state.AddAnimation(0, "Idle", true, 0f);
        }
        this.InitRewardItems(lootCrate);
    }
Example #6
0
    public void AddLootCrate(LootCrateType lootCrateType, int amount, LootCrate.AnalyticData data, bool fromQueue = false, int xp = 0)
    {
        if (this.lootcrateRewardQueue == null)
        {
            this.lootcrateRewardQueue = new Queue <LootCrateRewardQueueElement>();
        }
        if (this.lootCrateAnimation != null)
        {
            if (this.lootCrateAnimationInstance == null)
            {
                this.lootCrateAnimationInstance = UnityEngine.Object.Instantiate <GameObject>(this.lootCrateAnimation, Vector3.up * 1000f, Quaternion.identity);
            }
            else
            {
                this.lootCrateAnimationInstance.SetActive(true);
            }
            this.lootCrateAnimationInstance.transform.parent = base.transform;
            LootCrateRewardQueueElement lootCrateRewardQueueElement = null;
            if (!fromQueue)
            {
                bool flag = this.lootcrateRewardQueue.Count == 0;
                for (int i = 0; i < amount; i++)
                {
                    lootCrateRewardQueueElement = new LootCrateRewardQueueElement(lootCrateType, data, xp);
                    this.lootcrateRewardQueue.Enqueue(lootCrateRewardQueueElement);
                }
                if (!flag)
                {
                    return;
                }
            }
            else
            {
                lootCrateRewardQueueElement = this.lootcrateRewardQueue.Peek();
            }
            this.closeButton.SetActive(false);
            this.closeButtonGfx.SetActive(false);
            this.crateOpened = false;
            LootCrateRewards.SlotRewards[] randomRewards = LootCrateRewards.GetRandomRewards(lootCrateType);
            if (randomRewards == null)
            {
                return;
            }
            int             num = 0;
            LootCrateButton componentInChildren = this.lootCrateAnimationInstance.GetComponentInChildren <LootCrateButton>();
            componentInChildren.GainedXP = lootCrateRewardQueueElement.xp;
            componentInChildren.Init(lootCrateType);
            LootCrateButton lootCrateButton = componentInChildren;
            lootCrateButton.onOpeningDone = (Action)Delegate.Combine(lootCrateButton.onOpeningDone, new Action(delegate()
            {
                base.StartCoroutine(this.CrateOpened());
            }));
            base.StartCoroutine(this.DelayIntro(componentInChildren, Vector3.forward * -1f));
            List <BasePart> list  = new List <BasePart>();
            int             num2  = 0;
            int             num3  = 0;
            int             num4  = 0;
            int             num5  = 0;
            int             num6  = 0;
            int             num7  = 0;
            List <int>      list2 = new List <int>();
            for (int j = 0; j < randomRewards.Length; j++)
            {
                int num8 = UnityEngine.Random.Range(0, randomRewards.Length);
                int num9 = randomRewards.Length;
                while (list2.Contains(num8) && num9 >= 0)
                {
                    if (++num8 >= randomRewards.Length)
                    {
                        num8 = 0;
                    }
                    num9--;
                }
                if (num9 >= 0)
                {
                    list2.Add(num8);
                    LootCrateRewards.SlotRewards reward = randomRewards[num8];
                    LootCrateRewards.Reward      type   = reward.Type;
                    switch (type)
                    {
                    case LootCrateRewards.Reward.Part:
                    {
                        bool     isDuplicatePart = false;
                        int      num10           = 0;
                        int      num11           = 10;
                        BasePart randomLootCrateRewardPartFromTier;
                        do
                        {
                            randomLootCrateRewardPartFromTier = CustomizationManager.GetRandomLootCrateRewardPartFromTier(reward.PartTier, false);
                            num11--;
                        }while (list.Contains(randomLootCrateRewardPartFromTier) && num11 > 0);
                        list.Add(randomLootCrateRewardPartFromTier);
                        if (CustomizationManager.IsPartUnlocked(randomLootCrateRewardPartFromTier))
                        {
                            num10 = Singleton <GameConfigurationManager> .Instance.GetValue <int>("part_salvage_rewards", randomLootCrateRewardPartFromTier.m_partTier.ToString());

                            GameProgress.AddScrap(num10);
                            num2 += num10;
                            num7++;
                            isDuplicatePart = true;
                        }
                        else
                        {
                            CustomizationManager.UnlockPart(randomLootCrateRewardPartFromTier, lootCrateType.ToString() + "_crate");
                        }
                        componentInChildren.SetIcon(num, randomLootCrateRewardPartFromTier.m_constructionIconSprite.gameObject, string.Empty, (int)reward.PartTier, isDuplicatePart, true);
                        componentInChildren.SetScrapIcon(num, this.scrapIcons[0], num10.ToString());
                        BasePart.PartTier partTier = reward.PartTier;
                        if (partTier != BasePart.PartTier.Common)
                        {
                            if (partTier != BasePart.PartTier.Rare)
                            {
                                if (partTier == BasePart.PartTier.Epic)
                                {
                                    num6++;
                                }
                            }
                            else
                            {
                                num5++;
                            }
                        }
                        else
                        {
                            num4++;
                        }
                        break;
                    }

                    case LootCrateRewards.Reward.Powerup:
                    {
                        GameObject iconPrefab       = this.powerUpIcons[reward.Powerup - LootCrateRewards.Powerup.Magnet];
                        string     customTypeOfGain = lootCrateType.ToString() + " crate";
                        switch (reward.Powerup)
                        {
                        case LootCrateRewards.Powerup.Magnet:
                            GameProgress.AddSuperMagnet(1);
                            if (Singleton <IapManager> .Instance != null)
                            {
                                Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.SuperMagnetSingle, 1, customTypeOfGain);
                            }
                            break;

                        case LootCrateRewards.Powerup.Superglue:
                            GameProgress.AddSuperGlue(1);
                            if (Singleton <IapManager> .Instance != null)
                            {
                                Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.SuperGlueSingle, 1, customTypeOfGain);
                            }
                            break;

                        case LootCrateRewards.Powerup.Turbo:
                            GameProgress.AddTurboCharge(1);
                            if (Singleton <IapManager> .Instance != null)
                            {
                                Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.TurboChargeSingle, 1, customTypeOfGain);
                            }
                            break;

                        case LootCrateRewards.Powerup.Supermechanic:
                            GameProgress.AddBluePrints(1);
                            if (Singleton <IapManager> .Instance != null)
                            {
                                Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.BlueprintSingle, 1, customTypeOfGain);
                            }
                            break;

                        case LootCrateRewards.Powerup.NightVision:
                            GameProgress.AddNightVision(1);
                            if (Singleton <IapManager> .Instance != null)
                            {
                                Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.NightVisionSingle, 1, customTypeOfGain);
                            }
                            break;
                        }
                        componentInChildren.SetIcon(num, iconPrefab, string.Empty, 0, false, true);
                        break;
                    }

                    case LootCrateRewards.Reward.Dessert:
                        if (reward.GoldenCupcake)
                        {
                            GameObject gameObject = WPFMonoBehaviour.gameData.m_desserts[WPFMonoBehaviour.gameData.m_desserts.Count - 1];
                            Dessert    component  = gameObject.GetComponent <Dessert>();
                            GameProgress.AddDesserts(component.saveId, 1);
                            componentInChildren.SetIcon(num, this.dessertIcons[1], string.Empty, 0, false, true);
                        }
                        else
                        {
                            GameObject gameObject2 = WPFMonoBehaviour.gameData.m_desserts[UnityEngine.Random.Range(0, WPFMonoBehaviour.gameData.m_desserts.Count - 1)];
                            Dessert    component2  = gameObject2.GetComponent <Dessert>();
                            GameProgress.AddDesserts(component2.saveId, reward.Desserts);
                            componentInChildren.SetIcon(num, this.dessertIcons[0], reward.Desserts.ToString(), 0, false, true);
                        }
                        num3 += reward.Desserts;
                        break;

                    case LootCrateRewards.Reward.Scrap:
                    {
                        GameProgress.AddScrap(reward.Scrap);
                        num2 += reward.Scrap;
                        GameObject        scrapRewardContainer = componentInChildren.SetIcon(num, this.scrapIcons[0], reward.Scrap.ToString(), 0, false, true);
                        LootRewardElement component3           = scrapRewardContainer.GetComponent <LootRewardElement>();
                        if (component3 != null)
                        {
                            LootRewardElement lootRewardElement = component3;
                            lootRewardElement.onRewardOpened = (Action)Delegate.Combine(lootRewardElement.onRewardOpened, new Action(delegate()
                                {
                                    ScrapButton.Instance.AddParticles(scrapRewardContainer, reward.Scrap, 0f, (float)reward.Scrap);
                                }));
                        }
                        break;
                    }

                    case LootCrateRewards.Reward.Coin:
                    {
                        GameProgress.AddSnoutCoins(reward.Coins);
                        GameObject        coinRewardContainer = componentInChildren.SetIcon(num, this.coinIcons[0], reward.Coins.ToString(), 0, false, true);
                        LootRewardElement component4          = coinRewardContainer.GetComponent <LootRewardElement>();
                        if (component4 != null)
                        {
                            LootRewardElement lootRewardElement2 = component4;
                            lootRewardElement2.onRewardOpened = (Action)Delegate.Combine(lootRewardElement2.onRewardOpened, new Action(delegate()
                                {
                                    SnoutButton.Instance.AddParticles(coinRewardContainer, reward.Scrap, 0f, (float)reward.Scrap);
                                }));
                        }
                        break;
                    }
                    }
                    num++;
                }
            }
            if (lootCrateRewardQueueElement != null && num > 0)
            {
                lootCrateRewardQueueElement.SetRewarded();
                int @int = GameProgress.GetInt(lootCrateType.ToString() + "_crates_collected", 0, GameProgress.Location.Local, null);
                GameProgress.SetInt(lootCrateType.ToString() + "_crates_collected", @int + 1, GameProgress.Location.Local);
            }
            EventManager.Send(new LootCrateDelivered(lootCrateType));
            int value = GameProgress.GetInt("Total_parts_scrapped", 0, GameProgress.Location.Local, null) + num7;
            GameProgress.SetInt("Total_parts_scrapped", value, GameProgress.Location.Local);
            int value2 = GameProgress.GetInt("Total_parts_received", 0, GameProgress.Location.Local, null) + num4 + num5 + num6;
            GameProgress.SetInt("Total_parts_received", value2, GameProgress.Location.Local);
        }
    }
Example #7
0
    public static int TryToActivateLootCrateAtSlot(int index, LootCrateType crateType, OnTimedOut onCrateUnlocked)
    {
        if (LootCrateSlots.IsUnlockingInProgress())
        {
            return(-1);
        }
        string slotIdentifier = LootCrateSlot.GetSlotIdentifier(index);

        GameProgress.SetString(slotIdentifier, string.Format("{0},{1}", LootCrateSlot.State.Locked.ToString(), crateType.ToString()), GameProgress.Location.Local);
        if (!Singleton <TimeManager> .Instance.HasTimer(slotIdentifier))
        {
            DateTime time = Singleton <TimeManager> .Instance.CurrentTime.AddSeconds((double)LootCrateSlots.GetOpenTimeForCrate(crateType));

            Singleton <TimeManager> .Instance.CreateTimer(slotIdentifier, time, onCrateUnlocked);

            GameProgress.SetString("LootCrateSlotOpening", slotIdentifier, GameProgress.Location.Local);
            if (LootCrateSlots.instance != null)
            {
                LootCrateSlots.instance.ShowFullBubble(LootCrateSlots.AreSlotsFull());
            }
            return(0);
        }
        return(1);
    }
Example #8
0
    public static void AddLootCrateToSlot(int index, LootCrateType crateType)
    {
        string slotIdentifier = LootCrateSlot.GetSlotIdentifier(index);

        GameProgress.SetString(slotIdentifier, string.Format("{0},{1},{2}", LootCrateSlot.State.Inactive.ToString(), crateType.ToString(), "new"), GameProgress.Location.Local);
    }
Example #9
0
 public static void RemoveLootcrate(LootCrateType crateType)
 {
     GameProgress.m_data.AddToInt(string.Format("Crate_amount_{0}", crateType.ToString()), -1, 0, int.MaxValue);
 }
Example #10
0
 public static void AddLootcrate(LootCrateType crateType, int amount = 1)
 {
     GameProgress.m_data.AddToInt(string.Format("Crate_amount_{0}", crateType.ToString()), amount, int.MinValue, int.MaxValue);
 }
Example #11
0
 public static int GetLootcrateAmount(LootCrateType crateType)
 {
     return(GameProgress.m_data.GetInt(string.Format("Crate_amount_{0}", crateType.ToString()), 0));
 }