示例#1
0
    public static List <BasePart> GetCustomParts(BasePart.PartType type, BasePart.PartTier tier, bool onlyLocked = false)
    {
        List <BasePart>       list        = new List <BasePart>();
        List <CustomPartInfo> customParts = WPFMonoBehaviour.gameData.m_customParts;

        for (int i = 0; i < customParts.Count; i++)
        {
            if (customParts[i].PartType == type)
            {
                for (int j = 0; j < customParts[i].PartList.Count; j++)
                {
                    if (customParts[i].PartList[j].m_partTier == tier)
                    {
                        if (onlyLocked && !CustomizationManager.IsPartUnlocked(customParts[i].PartList[j]))
                        {
                            list.Add(customParts[i].PartList[j]);
                        }
                        else if (!onlyLocked)
                        {
                            list.Add(customParts[i].PartList[j]);
                        }
                    }
                }
                break;
            }
        }
        return(list);
    }
示例#2
0
    public static BasePart GetRandomCraftablePartFromTier(BasePart.PartTier tier, bool onlyLocked = false)
    {
        BasePart result;

        if (!Singleton <PredefinedRewards> .Instance.AllRewardsGiven && Singleton <PredefinedRewards> .Instance.GetReward(tier, out result))
        {
            return(result);
        }
        List <BasePart> allTierParts = CustomizationManager.GetAllTierParts(tier, (!onlyLocked) ? CustomizationManager.PartFlags.None : CustomizationManager.PartFlags.Locked);

        if (allTierParts.Count == 0)
        {
            return(null);
        }
        int num  = UnityEngine.Random.Range(0, allTierParts.Count);
        int num2 = num;

        while (!allTierParts[num].craftable)
        {
            num++;
            if (num >= allTierParts.Count)
            {
                num = 0;
            }
            if (num2 == num)
            {
                return(null);
            }
        }
        return(allTierParts[num]);
    }
示例#3
0
    public static List <BasePart> GetAllTierParts(BasePart.PartTier tier, PartFlags flags = CustomizationManager.PartFlags.None)
    {
        List <BasePart> list = new List <BasePart>();

        if (tier == BasePart.PartTier.Regular)
        {
            for (int i = 0; i < WPFMonoBehaviour.gameData.m_parts.Count; i++)
            {
                if (flags == CustomizationManager.PartFlags.None)
                {
                    list.Add(WPFMonoBehaviour.gameData.m_parts[i].GetComponent <BasePart>());
                }
            }
        }
        else
        {
            List <CustomPartInfo> customParts = WPFMonoBehaviour.gameData.m_customParts;
            for (int j = 0; j < customParts.Count; j++)
            {
                if (customParts[j] != null && customParts[j].PartList != null && customParts[j].PartList.Count != 0)
                {
                    for (int k = 0; k < customParts[j].PartList.Count; k++)
                    {
                        if (customParts[j].PartList[k].m_partTier == tier && CustomizationManager.HasPartFlags(customParts[j].PartList[k], flags))
                        {
                            list.Add(customParts[j].PartList[k]);
                        }
                    }
                }
            }
        }
        return(list);
    }
示例#4
0
    public static int GetUnlockedPartCount(bool useTier = false, BasePart.PartTier tier = BasePart.PartTier.Common)
    {
        int num = 0;

        if (!useTier)
        {
            num = CustomizationManager.cachedUnlockedPartCount;
        }
        if (num < 0 || useTier)
        {
            num = 0;
            List <CustomPartInfo> customParts = WPFMonoBehaviour.gameData.m_customParts;
            for (int i = 0; i < customParts.Count; i++)
            {
                if (customParts[i] != null && customParts[i].PartList != null && customParts[i].PartList.Count != 0)
                {
                    for (int j = 0; j < customParts[i].PartList.Count; j++)
                    {
                        if (CustomizationManager.IsPartUnlocked(customParts[i].PartList[j]) && (!useTier || (useTier && customParts[i].PartList[j].m_partTier == tier)))
                        {
                            num++;
                        }
                    }
                }
            }
        }
        if (!useTier)
        {
            CustomizationManager.cachedUnlockedPartCount = num;
        }
        return(num);
    }
示例#5
0
 public void AddPartRoot(BasePart.PartTier partTier, GameObject partRoot)
 {
     if (this.partInstances.ContainsKey(partTier) && this.parts.ContainsKey(partTier))
     {
         partRoot.name = this.parts[partTier][this.partInstances[partTier].Count].name;
         this.partInstances[partTier].Add(partRoot);
     }
 }
示例#6
0
 public List <GameObject> GetPartTierInstances(BasePart.PartType partType, BasePart.PartTier partTier)
 {
     if (this.parts != null && this.parts.ContainsKey(partType) && this.parts[partType].partInstances != null && this.parts[partType].partInstances.ContainsKey(partTier))
     {
         return(this.parts[partType].partInstances[partTier]);
     }
     return(null);
 }
示例#7
0
    private BasePart GetRandomPart(BasePart.PartTier tier)
    {
        BasePart randomCraftablePartFromTier = CustomizationManager.GetRandomCraftablePartFromTier(tier, true);

        if (randomCraftablePartFromTier == null)
        {
            randomCraftablePartFromTier = CustomizationManager.GetRandomCraftablePartFromTier(tier, false);
        }
        return(randomCraftablePartFromTier);
    }
示例#8
0
    public static int GetTotalPartCountForTier(BasePart.PartTier tier)
    {
        int num = CustomizationManager.cachedPartTierCount[(int)tier];

        if (num < 0)
        {
            num = CustomizationManager.GetAllTierParts(tier, CustomizationManager.PartFlags.None).Count;
        }
        return(num);
    }
示例#9
0
    public static BasePart GetRandomPartFromTier(BasePart.PartTier tier, bool onlyLocked = false)
    {
        List <BasePart> allTierParts = CustomizationManager.GetAllTierParts(tier, (!onlyLocked) ? CustomizationManager.PartFlags.None : CustomizationManager.PartFlags.Locked);

        if (allTierParts.Count == 0)
        {
            return(null);
        }
        int index = UnityEngine.Random.Range(0, allTierParts.Count);

        return(allTierParts[index]);
    }
示例#10
0
    private void UnlockParts(BasePart.PartTier tier, CustomizationManager.PartFlags flags)
    {
        List <BasePart> allTierParts = CustomizationManager.GetAllTierParts(tier, flags);

        if (allTierParts == null || allTierParts.Count == 0)
        {
            return;
        }
        for (int i = 0; i < allTierParts.Count; i++)
        {
            CustomizationManager.UnlockPart(allTierParts[i], "Cheat");
        }
    }
示例#11
0
        private int PartChance(BasePart.PartTier tier)
        {
            int result = 0;

            for (int i = 0; i < this.partChances.Count; i++)
            {
                if (this.partChances[i].Item1 == tier)
                {
                    result = this.partChances[i].Item2;
                    break;
                }
            }
            return(result);
        }
示例#12
0
    private void RepositionIcons(PartData data, float xPos)
    {
        for (int i = 0; i < this.PartTierCount - 1; i++)
        {
            for (int j = 0; j < data.RowWidth(); j++)
            {
                int index = j;
                BasePart.PartTier tier          = (BasePart.PartTier)i;
                Vector3           localPosition = new Vector3(xPos + (float)index * this.horizontalPadding, (float)(this.PartTierCount / 2) - (float)i * this.verticalPadding + this.verticalPadding);
                localPosition.y += ((i != 0) ? 0f : this.firstRowPadding);
                if (!this.columns.Contains(localPosition.x))
                {
                    this.columns.Add(localPosition.x);
                }
                if (tier == BasePart.PartTier.Epic && index >= data.PartCount(tier))
                {
                    index -= data.PartCount(tier);
                    tier   = BasePart.PartTier.Legendary;
                }
                if (data.partInstances.ContainsKey(tier) && index < data.partInstances[tier].Count)
                {
                    data.partInstances[tier][index].transform.localPosition = localPosition;
                    if (CustomizationManager.IsPartNew(data.parts[tier][index]))
                    {
                        PartData   data_ = data;
                        GameObject gameObject;
                        if (this.AddNewContentTag(data.partInstances[tier][index], out gameObject))
                        {
                            GameObjectEvents gameObjectEvents  = gameObject.AddComponent <GameObjectEvents>();
                            GameObjectEvents gameObjectEvents2 = gameObjectEvents;
                            gameObjectEvents2.OnVisible = (Action <bool>) Delegate.Combine(gameObjectEvents2.OnVisible, new Action <bool>(delegate(bool visible)
                            {
                                if (visible)
                                {
                                    CustomizationManager.SetPartNew(data_.parts[tier][index], false);
                                }
                            }));
                            this.newButtons.Add(gameObject);
                        }
                    }
                }
            }
        }
        int lastUsedPartIndex = CustomizationManager.GetLastUsedPartIndex(data.PartType);

        data.UpdateSelectionIcon(this.gameData.GetCustomPart(data.PartType, lastUsedPartIndex).name);
    }
示例#13
0
 public bool GetReward(BasePart.PartTier tier, out BasePart part)
 {
     part = null;
     if (this.rewards != null && this.rewards.Count > 0)
     {
         int num  = UnityEngine.Random.Range(0, this.rewards.Count);
         int num2 = num;
         do
         {
             num++;
             if (num >= this.rewards.Count)
             {
                 num = 0;
             }
             BasePart.PartType type        = (!this.FirstRewardGiven) ? this.firstReward : this.rewards[num];
             List <BasePart>   customParts = CustomizationManager.GetCustomParts(type, tier, true);
             if (customParts.Count > 0)
             {
                 int num3 = UnityEngine.Random.Range(0, customParts.Count);
                 int num4 = num3;
                 do
                 {
                     num3++;
                     if (num3 >= customParts.Count)
                     {
                         num3 = 0;
                     }
                     if (customParts[num3].craftable)
                     {
                         part = customParts[num3];
                         if (this.FirstRewardGiven)
                         {
                             this.SetRewardGiven(type, true);
                         }
                         else
                         {
                             this.FirstRewardGiven = true;
                         }
                         num  = num2;
                         num3 = num4;
                     }
                 }while (num3 != num4);
             }
         }while (num != num2);
     }
     return(part != null);
 }
示例#14
0
 private void EnablePartIcons(PartData data, bool enable)
 {
     if (data.SelectedIcon != null)
     {
         data.SelectedIcon.gameObject.SetActive(enable);
     }
     for (int i = 0; i < this.PartTierCount; i++)
     {
         BasePart.PartTier key = (BasePart.PartTier)i;
         if (data.partInstances != null && data.partInstances.ContainsKey(key))
         {
             for (int j = 0; j < data.partInstances[key].Count; j++)
             {
                 data.partInstances[key][j].SetActive(enable);
             }
         }
     }
 }
示例#15
0
 private BasePart.PartTier GetPartTierFromAmount(int amount)
 {
     for (int i = 3; i > 0; i--)
     {
         if (amount == AlienCustomizationManager.GetPrice())
         {
             return(BasePart.PartTier.Legendary);
         }
         GameConfigurationManager instance        = Singleton <GameConfigurationManager> .Instance;
         string            craft_PRICE_CONFIG_KEY = WorkshopMenu.CRAFT_PRICE_CONFIG_KEY;
         BasePart.PartTier partTier = (BasePart.PartTier)i;
         if (amount >= instance.GetValue <int>(craft_PRICE_CONFIG_KEY, partTier.ToString()))
         {
             return((BasePart.PartTier)i);
         }
     }
     return(BasePart.PartTier.Regular);
 }
示例#16
0
    private void ShowGetMoreScrapDialog(int missingScrapAmount, BasePart.PartTier nextTier)
    {
        GameData gameData = Singleton <GameManager> .Instance.gameData;
        int      value    = Singleton <GameConfigurationManager> .Instance.GetValue <int>("scrap_to_coin_value", "value");

        if (value > 0)
        {
            int price = missingScrapAmount * value;
            if (this.getMoreScrapDialog == null && gameData.m_getMoreScrapDialog != null)
            {
                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(gameData.m_getMoreScrapDialog);
                gameObject.transform.position = new Vector3(0f, 0f, -15f);
                this.getMoreScrapDialog       = gameObject.GetComponent <GetMoreScrapDialog>();
            }
            if (this.getMoreScrapDialog != null)
            {
                this.getMoreScrapDialog.SetScrapAmount(missingScrapAmount, nextTier);
                this.getMoreScrapDialog.ConfirmButtonText  = string.Format("[snout] {0}", price);
                this.getMoreScrapDialog.ShowConfirmEnabled = (() => true);
                this.getMoreScrapDialog.Close();
                this.getMoreScrapDialog.SetOnConfirm(delegate
                {
                    if (GameProgress.UseSnoutCoins(price))
                    {
                        Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(WPFMonoBehaviour.gameData.commonAudioCollection.snoutCoinUse);
                        GameProgress.AddScrap(missingScrapAmount);
                        SnoutButton.Instance.UpdateAmount(false);
                        this.AddScrap(0);
                        this.getMoreScrapDialog.Close();
                    }
                    else if (Singleton <IapManager> .IsInstantiated())
                    {
                        this.getMoreScrapDialog.Close();
                        Singleton <IapManager> .Instance.OpenShopPage(new Action(this.getMoreScrapDialog.Open), "SnoutCoinShop");
                    }
                    else
                    {
                        this.getMoreScrapDialog.Close();
                    }
                });
                this.getMoreScrapDialog.Open();
            }
        }
    }
示例#17
0
    private void UpdateRandomPart(int newSeed)
    {
        UnityEngine.Random.State state = UnityEngine.Random.state;
        this.randomSeed = newSeed;
        UnityEngine.Random.InitState(this.randomSeed);
        BasePart.PartTier partTier     = (BasePart.PartTier)UnityEngine.Random.Range(0, 4);
        List <BasePart>   allTierParts = CustomizationManager.GetAllTierParts(partTier, (partTier != BasePart.PartTier.Regular) ? CustomizationManager.PartFlags.Craftable : CustomizationManager.PartFlags.None);

        if (allTierParts.Count > 0)
        {
            int index = UnityEngine.Random.Range(0, allTierParts.Count);
            this.CurrentFavorite = allTierParts[index];
        }
        if (this.OnPartAcquired != null)
        {
            this.OnPartAcquired();
        }
        UnityEngine.Random.state = state;
    }
示例#18
0
    private GameObject GetIconBackground(BasePart.PartTier tier)
    {
        switch (tier)
        {
        default:
            return(this.regularIcon);

        case BasePart.PartTier.Common:
            return(this.commonIcon);

        case BasePart.PartTier.Rare:
            return(this.rareIcon);

        case BasePart.PartTier.Epic:
            return(this.epicIcon);

        case BasePart.PartTier.Legendary:
            return(this.legendaryIcon);
        }
    }
示例#19
0
    public static int CustomizationCount(BasePart.PartTier tier, PartFlags flags = CustomizationManager.PartFlags.None)
    {
        int num = 0;
        List <CustomPartInfo> customParts = WPFMonoBehaviour.gameData.m_customParts;

        for (int i = 0; i < customParts.Count; i++)
        {
            if (customParts[i] != null && customParts[i].PartList != null && customParts[i].PartList.Count != 0)
            {
                for (int j = 0; j < customParts[i].PartList.Count; j++)
                {
                    if (customParts[i].PartList[j].m_partTier == tier && CustomizationManager.HasPartFlags(customParts[i].PartList[j], flags))
                    {
                        num++;
                    }
                }
            }
        }
        return(num);
    }
示例#20
0
 private void SetCheckMark(BasePart.PartTier tier, bool enabled)
 {
     if (tier != BasePart.PartTier.Epic)
     {
         if (tier != BasePart.PartTier.Rare)
         {
             if (tier == BasePart.PartTier.Common)
             {
                 this.SetCheckMark(this.commonPartStarsRoot.parent, enabled);
             }
         }
         else
         {
             this.SetCheckMark(this.rarePartStarsRoot.parent, enabled);
         }
     }
     else
     {
         this.SetCheckMark(this.epicPartStarsRoot.parent, enabled);
     }
 }
示例#21
0
 private void SetStarsEnabled(BasePart.PartTier tier, bool enabled, Action OnAnimationEnd)
 {
     if (tier != BasePart.PartTier.Epic)
     {
         if (tier != BasePart.PartTier.Rare)
         {
             if (tier == BasePart.PartTier.Common)
             {
                 this.SetStarEnabled(this.commonPartStarsRoot, enabled, OnAnimationEnd);
             }
         }
         else
         {
             this.SetStarEnabled(this.rarePartStarsRoot, enabled, OnAnimationEnd);
         }
     }
     else
     {
         this.SetStarEnabled(this.epicPartStarsRoot, enabled, OnAnimationEnd);
     }
 }
示例#22
0
    public void CraftSelectedPart()
    {
        if (this.IsMachineLocked)
        {
            return;
        }
        this.queuedAddScrapActions = 0;
        BasePart.PartTier partTierFromAmount = this.GetPartTierFromAmount(GameProgress.GetInt("Machine_scrap_amount", 0, GameProgress.Location.Local, null));
        Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(this.gameData.commonAudioCollection.craftLeverCrank);

        if (partTierFromAmount == BasePart.PartTier.Regular)
        {
            this.SetMachineAnimation(this.insufficientScrapAnimationName, false, false, true);
            Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(this.gameData.commonAudioCollection.craftEmpty);

            MaterialAnimation component = this.MachineLabel.GetComponent <MaterialAnimation>();
            if (component != null)
            {
                component.PlayAnimation(true, 5);
            }
            return;
        }
        SnoutButton.Instance.EnableButton(false);
        int      num      = 0;
        BasePart basePart = null;

        if (partTierFromAmount == BasePart.PartTier.Legendary && AlienCustomizationManager.GetNextUnlockable(out basePart))
        {
            num = AlienCustomizationManager.GetPrice();
        }
        else if (partTierFromAmount != BasePart.PartTier.Legendary)
        {
            num = Singleton <GameConfigurationManager> .Instance.GetValue <int>(WorkshopMenu.CRAFT_PRICE_CONFIG_KEY, partTierFromAmount.ToString());

            basePart = CustomizationManager.GetRandomCraftablePartFromTier(partTierFromAmount, true);
        }
        if (basePart && num > 0 && GameProgress.UseScrap(num))
        {
            this.SetMachineAnimation((!this.IsAlienMachine) ? this.craftAnimationName : this.slimeCraftAnimationName, false, false, false);
            Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(this.gameData.commonAudioCollection.craftPart);

            CustomizationManager.UnlockPart(basePart, "crafted");
            this.RemoveScrap(num);
            this.SetMachineIdleSound(0);
            PlayerProgress.ExperienceType experienceType = PlayerProgress.ExperienceType.CommonPartCrafted;
            if (partTierFromAmount == BasePart.PartTier.Rare)
            {
                experienceType = PlayerProgress.ExperienceType.RarePartCrafted;
            }
            if (partTierFromAmount == BasePart.PartTier.Epic)
            {
                experienceType = PlayerProgress.ExperienceType.EpicPartCrafted;
            }
            if (partTierFromAmount == BasePart.PartTier.Legendary)
            {
                experienceType = PlayerProgress.ExperienceType.LegendaryPartCrafted;
            }
            PlayerProgressBar.Instance.DelayUpdate();
            int exp = Singleton <PlayerProgress> .Instance.AddExperience(experienceType);

            this.ShowReward(basePart, exp);
            string key  = "CraftCount" + basePart.m_partTier.ToString();
            int    @int = GameProgress.GetInt(key, 0, GameProgress.Location.Local, null);
            GameProgress.SetInt(key, @int + 1, GameProgress.Location.Local);
            if (Singleton <SocialGameManager> .IsInstantiated() && basePart.m_partTier == BasePart.PartTier.Epic)
            {
                Singleton <SocialGameManager> .Instance.ReportAchievementProgress("grp.CRAFT_PARTS", 100.0);
            }
            this.partsCraftedWhileInScreen++;
            EventManager.Send(new CraftingMachineEvent(WorkshopMenu.CraftingMachineAction.CraftPart, 0));
        }
        else if (basePart)
        {
        }
    }
示例#23
0
 public void SetScrapAmount(int scrapAmount, BasePart.PartTier tier)
 {
     this.buyScrapAmount = scrapAmount;
     this.partTier       = tier;
 }
示例#24
0
    public void AddScrap(int addScrapAmount = 0)
    {
        this.queuedAddScrapActions++;
        if (this.IsMachineLocked)
        {
            return;
        }
        this.queuedAddScrapActions--;
        int num   = GameProgress.ScrapCount();
        int num2  = GameProgress.GetInt("Machine_scrap_amount", 0, GameProgress.Location.Local, null);
        int num3  = num - num2;
        int value = Singleton <GameConfigurationManager> .Instance.GetValue <int>(WorkshopMenu.CRAFT_PRICE_CONFIG_KEY, BasePart.PartTier.Common.ToString());

        int value2 = Singleton <GameConfigurationManager> .Instance.GetValue <int>(WorkshopMenu.CRAFT_PRICE_CONFIG_KEY, BasePart.PartTier.Rare.ToString());

        int value3 = Singleton <GameConfigurationManager> .Instance.GetValue <int>(WorkshopMenu.CRAFT_PRICE_CONFIG_KEY, BasePart.PartTier.Epic.ToString());

        int  price = AlienCustomizationManager.GetPrice();
        bool flag  = CustomizationManager.CustomizationCount(BasePart.PartTier.Common, CustomizationManager.PartFlags.Locked | CustomizationManager.PartFlags.Craftable) <= 0;
        bool flag2 = CustomizationManager.CustomizationCount(BasePart.PartTier.Rare, CustomizationManager.PartFlags.Locked | CustomizationManager.PartFlags.Craftable) <= 0;
        bool flag3 = CustomizationManager.CustomizationCount(BasePart.PartTier.Epic, CustomizationManager.PartFlags.Locked | CustomizationManager.PartFlags.Craftable) <= 0;
        bool flag4 = CustomizationManager.CustomizationCount(BasePart.PartTier.Legendary, CustomizationManager.PartFlags.Locked | CustomizationManager.PartFlags.Craftable) <= 0;

        BasePart.PartTier nextTier = BasePart.PartTier.Regular;
        int num4 = 0;
        int num5;

        if (addScrapAmount > 0)
        {
            num4 = addScrapAmount;
            if (num4 + num2 < value)
            {
                num5 = 0;
            }
            else if (num4 + num2 < value2)
            {
                num5 = 1;
            }
            else if (num4 + num2 < value3)
            {
                num5 = 2;
            }
            else if (this.IsAlienMachine && num4 + num2 < price)
            {
                num5 = 2;
            }
            else
            {
                num5 = 3;
            }
            if (!this.IsAlienMachine && num4 + num2 > value3)
            {
                num4 = value3 - num2;
            }
            else if (this.IsAlienMachine && num4 + num2 > price)
            {
                num4 = price - num2;
            }
        }
        else if (!flag && num2 < value)
        {
            nextTier = BasePart.PartTier.Common;
            num4     = value - num2;
            num5     = 0;
        }
        else if (!flag2 && num2 < value2)
        {
            nextTier = BasePart.PartTier.Rare;
            num4     = value2 - num2;
            num5     = 1;
        }
        else if (!flag3 && num2 < value3)
        {
            nextTier = BasePart.PartTier.Epic;
            num4     = value3 - num2;
            num5     = 2;
        }
        else if (this.IsAlienMachine && !flag4 && num2 < price)
        {
            nextTier = BasePart.PartTier.Legendary;
            num4     = price - num2;
            num5     = 0;
        }
        else
        {
            num5 = 3;
        }
        if (num4 > 0 && num3 > 0)
        {
            if (num4 > num3)
            {
                this.ShowGetMoreScrapDialog(num4 - num3, nextTier);
                num4 = num3;
            }
            int partTierFromAmount = (int)this.GetPartTierFromAmount(num2);
            num2 += num4;
            GameProgress.SetInt("Machine_scrap_amount", num2, GameProgress.Location.Local);
            EventManager.Send(new CraftingMachineEvent(WorkshopMenu.CraftingMachineAction.AddScrap, GameProgress.GetInt("Machine_scrap_amount", 0, GameProgress.Location.Local, null)));
            num5 = (int)this.GetPartTierFromAmount(num2);
            if (num5 >= 0)
            {
                this.SetMachineAnimation(this.chainPullAnimationName, false, true, false);
                this.SetMachineAnimation(this.feedAnimationNames[num5], false, false, true);
                this.SetMachineAnimation(this.idleAnimationNames[num5], true, true, true);
                if (num5 != partTierFromAmount)
                {
                    this.SetMachineIdleSound(num5);
                }
            }
            base.StartCoroutine(this.MoveNuts(this.nutRootUpper, this.nutRootLower, num4, 0.2f));
            Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(this.gameData.commonAudioCollection.insertScrap);
        }
        else
        {
            this.queuedAddScrapActions = 0;
            this.SetMachineAnimation(this.idleAnimationNames[num5], true, true, true);
            this.SetMachineIdleSound(num5);
            if (num4 > 0 && num3 <= 0)
            {
                this.ShowGetMoreScrapDialog(num4, nextTier);
            }
        }
    }
示例#25
0
 public int PartCount(BasePart.PartTier tier)
 {
     return((!this.parts.ContainsKey(tier)) ? 0 : this.parts[tier].Count);
 }
示例#26
0
        public Sprite GetIcon(BasePart.PartTier tier, int index)
        {
            BasePart basePart = (index >= this.PartCount(tier)) ? null : this.parts[tier][index];

            return(basePart.m_constructionIconSprite);
        }
示例#27
0
 private void CreatePartIcons(PartData data, float xPos, Transform parent, List <GameObject> newButtons)
 {
     for (int i = 0; i < this.PartTierCount - 1; i++)
     {
         for (int j = 0; j < data.RowWidth(); j++)
         {
             int     index         = j;
             Vector3 localPosition = new Vector3(xPos + (float)index * this.horizontalPadding, (float)(this.PartTierCount / 2) - (float)i * this.verticalPadding + this.verticalPadding);
             localPosition.y += ((i != 0) ? 0f : this.firstRowPadding);
             BasePart.PartTier tier = (BasePart.PartTier)i;
             bool flag;
             if (tier == BasePart.PartTier.Epic)
             {
                 flag = (index < data.PartCount(tier) || data.PartCount(BasePart.PartTier.Legendary) > 0);
                 if (index >= data.PartCount(tier))
                 {
                     index -= data.PartCount(tier);
                     tier   = BasePart.PartTier.Legendary;
                 }
             }
             else
             {
                 flag = (index < data.PartCount(tier));
             }
             if (!this.columns.Contains(localPosition.x))
             {
                 this.columns.Add(localPosition.x);
             }
             if (flag)
             {
                 GameObject bg = UnityEngine.Object.Instantiate <GameObject>(this.GetIconBackground(tier));
                 bg.transform.parent        = parent;
                 bg.transform.localPosition = localPosition;
                 Sprite     icon2 = data.GetIcon(tier, index);
                 GameObject icon  = null;
                 if (icon2 != null)
                 {
                     icon = UnityEngine.Object.Instantiate <GameObject>(icon2.gameObject);
                     icon.transform.parent        = bg.transform;
                     icon.transform.localPosition = new Vector3(0f, 0f, -0.1f);
                     icon.transform.localScale    = Vector3.one * this.iconScale;
                 }
                 if (tier != BasePart.PartTier.Regular)
                 {
                     this.ToGray(bg, !CustomizationManager.IsPartUnlocked(data.parts[tier][index]));
                 }
                 if (this.IsKingsFavorite(data.parts[tier][index]))
                 {
                     GameObject gameObject;
                     this.AddKingsFavoriteTag(bg, out gameObject);
                 }
                 GameObject item;
                 if (CustomizationManager.IsPartNew(data.parts[tier][index]) && this.AddNewContentTag(bg, out item))
                 {
                     newButtons.Add(item);
                 }
                 data.AddPartRoot(tier, bg);
                 Button           button            = bg.GetComponentInChildren <Button>();
                 GameObjectEvents gameObjectEvents  = bg.AddComponent <GameObjectEvents>();
                 GameObjectEvents gameObjectEvents2 = gameObjectEvents;
                 gameObjectEvents2.OnEnabled = (Action <bool>) Delegate.Combine(gameObjectEvents2.OnEnabled, new Action <bool>(delegate(bool enabled)
                 {
                     if (enabled)
                     {
                         if (this.IsKingsFavorite(data.parts[tier][index]))
                         {
                             GameObject gameObject2;
                             this.AddKingsFavoriteTag(bg, out gameObject2);
                         }
                         else
                         {
                             this.ClearKingsFavoriteTag(bg);
                         }
                         if (tier != BasePart.PartTier.Regular)
                         {
                             bool flag2 = CustomizationManager.IsPartUnlocked(data.parts[tier][index]);
                             this.ToGray(bg, !flag2);
                             Collider component = bg.GetComponent <Collider>();
                             component.enabled  = flag2;
                             button.enabled     = flag2;
                             if (tier == BasePart.PartTier.Legendary)
                             {
                                 if (icon)
                                 {
                                     icon.SetActive(flag2);
                                 }
                                 bg.transform.Find("QuestionMark").gameObject.SetActive(!flag2);
                             }
                             int lastUsedPartIndex = CustomizationManager.GetLastUsedPartIndex(data.PartType);
                             data.UpdateSelectionIcon(this.gameData.GetCustomPart(data.PartType, lastUsedPartIndex).name);
                             if (CustomizationManager.IsPartNew(data.parts[tier][index]))
                             {
                                 GameObject item2;
                                 if (this.AddNewContentTag(bg, out item2))
                                 {
                                     newButtons.Add(item2);
                                 }
                             }
                             else
                             {
                                 this.ClearNewTags(bg);
                             }
                         }
                     }
                 }));
                 GameObjectEvents gameObjectEvents3 = gameObjectEvents;
                 gameObjectEvents3.OnVisible = (Action <bool>) Delegate.Combine(gameObjectEvents3.OnVisible, new Action <bool>(delegate(bool visible)
                 {
                     button.enabled = visible;
                 }));
                 this.SetSortingLayer(bg, this.sortingLayer);
             }
         }
     }
 }
示例#28
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);
        }
    }
示例#29
0
 public PartPlacedEvent(BasePart.PartType partType, BasePart.PartTier partTier, Vector3 position)
 {
     this.partType = partType;
     this.partTier = partTier;
     this.position = position;
 }