Beispiel #1
0
        //public List<CustomShopItemController> m_customShopItemControllers;
        //public List<ShopItemController> m_shopItemControllers;

        public int CustomPriceMethod(CustomShopController shop, CustomShopItemController shopItem, PickupObject item)
        {
            if (customPrice != null)
            {
                return(customPrice(shop, shopItem, item));
            }
            return(0);
        }
Beispiel #2
0
 private void AssignItemFacing(Transform spawnTransform, CustomShopItemController itemController)
 {
     if (spawnTransform.name.Contains("SIDE") || spawnTransform.name.Contains("EAST"))
     {
         itemController.itemFacing = DungeonData.Direction.EAST;
     }
     else if (spawnTransform.name.Contains("WEST"))
     {
         itemController.itemFacing = DungeonData.Direction.WEST;
     }
     else if (spawnTransform.name.Contains("NORTH"))
     {
         itemController.itemFacing = DungeonData.Direction.NORTH;
     }
 }
Beispiel #3
0
        protected override void DoSetup()
        {
            base.m_shopItems = new List <GameObject>();
            List <int> list = new List <int>();
            Func <GameObject, float, float> weightModifier = null;

            if (SecretHandshakeItem.NumActive > 0)
            {
                weightModifier = delegate(GameObject prefabObject, float sourceWeight)
                {
                    PickupObject component10 = prefabObject.GetComponent <PickupObject>();
                    float        num7        = sourceWeight;
                    if (component10 != null)
                    {
                        int quality = (int)component10.quality;
                        num7 *= 1f + (float)quality / 10f;
                    }
                    return(num7);
                };
            }
            bool flag = GameStatsManager.Instance.IsRainbowRun;

            for (int i = 0; i < base.spawnPositions.Length; i++)
            {
                if (flag)
                {
                    base.m_shopItems.Add(null);
                }
                else
                {
                    GameObject gameObject5 = this.shopItems.SubshopSelectByWeightWithoutDuplicatesFullPrereqs(this.m_shopItems, weightModifier, 1, GameManager.Instance.IsSeeded);
                    this.m_shopItems.Add(gameObject5);
                }
            }
            m_itemControllers = new List <ShopItemController>();
            for (int m = 0; m < base.spawnPositions.Length; m++)
            {
                Transform transform = base.spawnPositions[m];
                if (!flag && !(base.m_shopItems[m] == null))
                {
                    PickupObject component4 = base.m_shopItems[m].GetComponent <PickupObject>();
                    if (!(component4 == null))
                    {
                        GameObject gameObject6 = new GameObject("Shop item " + m.ToString());
                        Transform  transform2  = gameObject6.transform;
                        transform2.parent        = transform;
                        transform2.localPosition = Vector3.zero;
                        EncounterTrackable component5 = component4.GetComponent <EncounterTrackable>();
                        if (component5 != null)
                        {
                            GameManager.Instance.ExtantShopTrackableGuids.Add(component5.EncounterGuid);
                        }
                        CustomShopItemController shopItemController = gameObject6.AddComponent <CustomShopItemController>();


                        this.AssignItemFacing(transform, shopItemController);
                        if (!base.m_room.IsRegistered(shopItemController))
                        {
                            base.m_room.RegisterInteractable(shopItemController);
                        }

                        shopItemController.CurrencyType = currencyType;


                        shopItemController.customCanBuy   += CustomCanBuyMethod;
                        shopItemController.customPrice    += CustomPriceMethod;
                        shopItemController.removeCurrency += RemoveCurrencyMethod;

                        shopItemController.OnPurchase += OnPurchaseMethod;
                        shopItemController.OnSteal    += OnStealMethod;

                        shopItemController.customPriceSprite = this.customPriceSprite;

                        shopItemController.Initialize(component4, this);
                        m_itemControllers.Add(shopItemController);
                    }
                }
            }
            bool flag3 = false;

            if (base.shopItemsGroup2 != null && base.spawnPositionsGroup2.Length > 0)
            {
                int count = base.m_shopItems.Count;
                for (int num2 = 0; num2 < base.spawnPositionsGroup2.Length; num2++)
                {
                    if (flag)
                    {
                        base.m_shopItems.Add(null);
                    }
                    else
                    {
                        float num3 = base.spawnGroupTwoItem1Chance;
                        if (num2 == 1)
                        {
                            num3 = base.spawnGroupTwoItem2Chance;
                        }
                        else if (num2 == 2)
                        {
                            num3 = base.spawnGroupTwoItem3Chance;
                        }
                        bool isSeeded = GameManager.Instance.IsSeeded;
                        if (((!isSeeded) ? UnityEngine.Random.value : BraveRandom.GenerationRandomValue()) < num3)
                        {
                            float replaceFirstRewardWithPickup = GameManager.Instance.RewardManager.CurrentRewardData.ReplaceFirstRewardWithPickup;
                            if (!flag3 && ((!isSeeded) ? UnityEngine.Random.value : BraveRandom.GenerationRandomValue()) < replaceFirstRewardWithPickup)
                            {
                                flag3 = true;
                                GameObject item2 = base.shopItems.SelectByWeightWithoutDuplicatesFullPrereqs(base.m_shopItems, weightModifier, GameManager.Instance.IsSeeded);
                                base.m_shopItems.Add(item2);
                            }
                            else if (!GameStatsManager.Instance.IsRainbowRun)
                            {
                                GameObject rewardObjectShopStyle2 = GameManager.Instance.RewardManager.GetRewardObjectShopStyle(GameManager.Instance.PrimaryPlayer, false, false, base.m_shopItems);
                                base.m_shopItems.Add(rewardObjectShopStyle2);
                            }
                            else
                            {
                                base.m_shopItems.Add(null);
                            }
                        }
                        else
                        {
                            base.m_shopItems.Add(null);
                        }
                    }
                }
                for (int num4 = 0; num4 < base.spawnPositionsGroup2.Length; num4++)
                {
                    Transform transform3 = base.spawnPositionsGroup2[num4];
                    if (!flag && !(base.m_shopItems[count + num4] == null))
                    {
                        PickupObject component8 = base.m_shopItems[count + num4].GetComponent <PickupObject>();
                        if (!(component8 == null))
                        {
                            GameObject gameObject8 = new GameObject("Shop 2 item " + num4.ToString());
                            Transform  transform4  = gameObject8.transform;
                            transform4.parent        = transform3;
                            transform4.localPosition = Vector3.zero;
                            EncounterTrackable component9 = component8.GetComponent <EncounterTrackable>();
                            if (component9 != null)
                            {
                                GameManager.Instance.ExtantShopTrackableGuids.Add(component9.EncounterGuid);
                            }
                            CustomShopItemController shopItemController2 = gameObject8.AddComponent <CustomShopItemController>();
                            this.AssignItemFacing(transform3, shopItemController2);
                            if (!base.m_room.IsRegistered(shopItemController2))
                            {
                                base.m_room.RegisterInteractable(shopItemController2);
                            }
                            shopItemController2.Initialize(component8, this);
                            m_itemControllers.Add(shopItemController2);
                        }
                    }
                }
            }

            /*for (int num6 = 0; num6 < m_customShopItemControllers.Count; num6++)
             * {
             *
             *      m_customShopItemControllers[num6].CurrencyType = currencyType;
             *
             *      m_customShopItemControllers[num6].CustomCanBuy += Balls.CustomCanBuy;
             *      m_customShopItemControllers[num6].CustomPrice += Balls.CustomPrice;
             *      m_customShopItemControllers[num6].RemoveCurrency += Balls.RemoveCurrency;
             *      m_customShopItemControllers[num6].customPriceSprite = this.customPriceSprite;
             * }*/
        }