Beispiel #1
0
        public void AddSelectedIcon(Transform icon)
        {
            this.selectedIcon = icon;
            int lastUsedPartIndex = CustomizationManager.GetLastUsedPartIndex(this.type);

            this.UpdateSelectionIcon(WPFMonoBehaviour.gameData.GetCustomPart(this.type, lastUsedPartIndex).name);
        }
Beispiel #2
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);
    }
Beispiel #3
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);
             }
         }
     }
 }
Beispiel #4
0
    private void CreatePartList(bool handleDragIcons)
    {
        this.m_scrollList.Clear();
        foreach (ConstructionUI.PartDesc partDesc in this.m_partDescs)
        {
            BasePart   part       = partDesc.part;
            GameObject gameObject = part.m_constructionIconSprite.gameObject;
            bool       flag       = true;
            int        num        = 0;
            int        num2       = 0;
            int        num3       = GameProgress.GetAllStars() + GameProgress.GetRaceLevelUnlockedStars();
            bool       flag2      = false;
            if (WPFMonoBehaviour.levelManager && WPFMonoBehaviour.levelManager.m_raceLevel && WPFMonoBehaviour.levelManager.CurrentGameMode is BaseGameMode)
            {
                string currentLevelIdentifier = Singleton <GameManager> .Instance.CurrentLevelIdentifier;
                RaceLevels.LevelUnlockablePartsData levelUnlockableData = WPFMonoBehaviour.gameData.m_raceLevels.GetLevelUnlockableData(currentLevelIdentifier);
                if (levelUnlockableData != null)
                {
                    foreach (RaceLevels.UnlockableTier unlockableTier in levelUnlockableData.m_tiers)
                    {
                        if (unlockableTier.m_part == part.m_partType)
                        {
                            if (num3 < unlockableTier.m_starLimit)
                            {
                                flag = false;
                                num  = Mathf.Max(unlockableTier.m_starLimit - num3, 0);
                                num2 = unlockableTier.m_starLimit;
                                if (this.m_unlockPartTierDialog == null)
                                {
                                    this.m_unlockPartTierDialog = UnityEngine.Object.Instantiate <GameObject>(WPFMonoBehaviour.gameData.m_unlockPartTierDialog).GetComponent <UnlockRoadHogsParts>();
                                    this.m_unlockPartTierDialog.transform.position = WPFMonoBehaviour.hudCamera.transform.position + new Vector3(0f, 0f, 10f);
                                    this.m_unlockPartTierDialog.Close();
                                    this.m_unlockPartTierDialog.onOpen += delegate()
                                    {
                                        this.m_constructionUI.DisableFunctionality = true;
                                    };
                                    this.m_unlockPartTierDialog.onClose += delegate()
                                    {
                                        this.m_constructionUI.DisableFunctionality = false;
                                    };
                                }
                            }
                            else if (!GameProgress.GetRaceLevelPartUnlocked(currentLevelIdentifier, part.m_partType.ToString()))
                            {
                                GameProgress.SetRaceLevelPartUnlocked(currentLevelIdentifier, part.m_partType.ToString(), true);
                                flag2 = true;
                            }
                            break;
                        }
                    }
                }
            }
            GameObject original    = (!flag) ? this.m_partUnavailableButtonPrefab : this.m_partButtonPrefab;
            GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(original);
            gameObject2.transform.parent = this.m_scrollList.transform;
            ConstructionUI.SetSortingOrder(gameObject2, 1, string.Empty);
            if (flag)
            {
                gameObject2.GetComponent <DraggableButton>().DragObject = partDesc;
                if (handleDragIcons)
                {
                    gameObject2.GetComponent <DraggableButton>().DragIconPrefab = gameObject;
                }
                gameObject2.GetComponent <DraggableButton>().DragIconScale = 1.75f;
                Transform transform = gameObject2.transform.Find("PartCount");
                transform.GetComponent <TextMesh>().text          = (partDesc.maxCount - partDesc.useCount).ToString();
                transform.GetComponent <PartCounter>().m_partType = partDesc.part.m_partType;
                transform.GetComponent <Renderer>().sortingOrder  = 1;
            }
            else
            {
                Transform transform2 = gameObject2.transform.Find("Starlimit");
                transform2.GetComponent <TextMesh>().text         = num.ToString();
                transform2.GetComponent <Renderer>().sortingOrder = 1;
                int productPrice = Singleton <VirtualCatalogManager> .Instance.GetProductPrice("road_hogs_star_unlock");

                if (productPrice > 0 && !Singleton <BuildCustomizationLoader> .Instance.IsOdyssey)
                {
                    int totalCost = (num2 - num3) * productPrice;
                    this.AddUnlockStarTierPopup(gameObject2.GetComponent <UnavailablePartButton>(), this.m_unlockPartTierDialog, num2, num3, totalCost, () => GameProgress.SnoutCoinCount() >= totalCost);
                }
            }
            GameObject gameObject3 = UnityEngine.Object.Instantiate <GameObject>(gameObject);
            gameObject3.transform.parent        = gameObject2.transform;
            gameObject3.transform.localScale    = new Vector3(1.75f, 1.75f, 1f);
            gameObject3.transform.localPosition = new Vector3(0f, 0f, -0.5f);
            ConstructionUI.SetSortingOrder(gameObject3, 1, string.Empty);
            partDesc.currentPartIcon = gameObject3.transform;
            if (flag)
            {
                gameObject2.GetComponent <DraggableButton>().Icon = gameObject3;
                if (flag2)
                {
                    GameObject gameObject4 = UnityEngine.Object.Instantiate <GameObject>(this.m_partUnlockAnimatedLock);
                    gameObject4.transform.parent        = gameObject2.transform;
                    gameObject4.transform.localPosition = new Vector3(0f, 0.6f, -1f);
                }
            }
            this.m_scrollList.AddButton(gameObject2.GetComponent <Widget>());
        }
        foreach (ConstructionUI.PartDesc partDesc2 in this.m_partDescs)
        {
            if (partDesc2 != null && !(partDesc2.part == null))
            {
                int lastUsedPartIndex = CustomizationManager.GetLastUsedPartIndex(partDesc2.part.m_partType);
                if (lastUsedPartIndex > 0)
                {
                    this.OnPartCustomized(new CustomizePartUI.PartCustomizationEvent(partDesc2.part.m_partType, lastUsedPartIndex));
                }
            }
        }
    }