Esempio n. 1
0
 public override void OnBuyBtnPressed()
 {
     inventory.OnItemBought(_recreationAreaData.guid, AttractionType.RECREATION_AREA, 1);
     inventory.SpendCurrency(_recreationAreaData.initialCost);
     amountText.text = inventory.productDataList.Find(x => x.guid == _recreationAreaData.guid).count.ToString();
 }
Esempio n. 2
0
 public override void OnBuyBtnPressed()
 {
     inventory.OnItemBought(_foodAndBeverageData.guid, AttractionType.FOOD_AND_BEVERAGE, 1);
     inventory.SpendCurrency(_foodAndBeverageData.initialCost);
     amountText.text = inventory.productDataList.Find(x => x.guid == _foodAndBeverageData.guid).count.ToString();
 }
    public void Init()
    {
        userInventory = GameManager.Instance.GetUserInventory();
        foreach (AttractionType type in Enum.GetValues(typeof(AttractionType)))
        {
            List <UserProductData> attractionsList      = userInventory.GetAllAttractionsOfType(type);
            AttractionsDataAsset   attractionsDataAsset = GameManager.Instance.GetAttractionsData();

            BasicAtractionData nextRide = null;
            TabItemState       tabState = TabItemState.IDLE;
            if (type == AttractionType.RIDE)
            {
                tabState = TabItemState.HIGHLIGHT;
            }
            if (attractionsList.Count == 0)
            {
                tabState = TabItemState.LOCKED; //IFATUtodo - this will probably be changed
            }

            List <UserProductData> rideUserItems = attractionsList.FindAll(a => a.type == type);
            if (rideUserItems != null && rideUserItems.Count > 0) // daca ai cel putin un element
            {
                Guid nextElementGuid;
                if (rideUserItems.Count > 0)
                {
                    nextElementGuid = rideUserItems[rideUserItems.Count - 1].guid;
                }
                switch (type)
                {
                case AttractionType.RIDE:
                {
                    List <RideData> assetData        = attractionsDataAsset.GetCurrentEventAssets().rideData;
                    int             lastElementIndex = 0;
                    if (rideUserItems.Count > 0)
                    {
                        lastElementIndex = assetData.FindIndex(a => a.guid == nextElementGuid);
                        if (assetData.Count > lastElementIndex + 1)
                        {
                            nextRide = assetData[lastElementIndex + 1];
                        }
                    }
                    else
                    {
                        nextRide = assetData[0];
                    }
                }
                break;

                case AttractionType.FOOD_AND_BEVERAGE:
                {
                    List <FoodAndBeverageData> assetData = attractionsDataAsset.GetCurrentEventAssets().foodAndBeverageData;
                    int lastElementIndex = 0;
                    if (rideUserItems.Count > 0)
                    {
                        lastElementIndex = assetData.FindIndex(a => a.guid == nextElementGuid);
                        if (assetData.Count > lastElementIndex + 1)
                        {
                            nextRide = assetData[lastElementIndex + 1];
                        }
                    }
                    else
                    {
                        nextRide = assetData[0];
                    }
                }
                break;

                case AttractionType.RECREATION_AREA:
                {
                    List <RecreationAreaData> assetData = attractionsDataAsset.GetCurrentEventAssets().recreationAreaData;
                    int lastElementIndex = 0;
                    if (rideUserItems.Count > 0)
                    {
                        lastElementIndex = assetData.FindIndex(a => a.guid == nextElementGuid);
                        if (assetData.Count > lastElementIndex + 1)
                        {
                            nextRide = assetData[lastElementIndex + 1];
                        }
                    }
                    else
                    {
                        nextRide = assetData[0];
                    }
                }
                break;

                default:
                    break;
                }
                if (nextRide != null)
                {
                    userInventory.OnItemBought(nextRide.guid, type, 0);

                    attractionsList.Add(new UserProductData
                    {
                        count      = 0,
                        guid       = nextRide.guid,
                        guidString = nextRide.guid.ToString(),
                        level      = 0,
                        type       = type
                    });
                }
            }

            if (tabState == TabItemState.LOCKED && nextRide != null)
            {
                bool checkNextRideUnlockConditions = UnlockManager.Instance.CheckUnlockConditions(nextRide.unlockConditionList);
                if (checkNextRideUnlockConditions)
                {
                    tabState = TabItemState.UNLOCKED;
                }
            }

            AttractionItem newItem = new AttractionItem();
            newItem.Init(type, tabState, attractionData, tabParent, listParent,
                         attractionsTabObj, attractionsListObj, attractionsList);
            //  newItem.onClick += OnTabCliked;
            attractionItemList.Add(newItem);
        }
    }