Example #1
0
 private void HandleConditionIncrement(UnlockCondition c)
 {
     foreach (var achievement in Achievements.Where(a => a.Condition == c))
     {
         CountUp(achievement);
     }
 }
    public bool CheckCondition(UnlockCondition condition)
    {
        List <UnlockCondition> list = new List <UnlockCondition> {
            condition
        };

        return(UnlockManager.Instance.CheckUnlockConditions(list));
    }
Example #3
0
    public void InitUIElements()
    {
        currencyCostIcon.gameObject.SetActive(false);
        if (_foodAndBeverageData.state == ItemState.LOCKED || _foodAndBeverageData.state == ItemState.TO_BE_UNLOCKED)
        {
            lockedBox.SetActive(true);
            idleBox.SetActive(false);
            lockedFillImage.sprite = _foodAndBeverageData.icon;
            lockedNameText.gameObject.GetComponent <LocalizationComponent>().SetTheLocalizedText(_foodAndBeverageData.name);
            tapToUnlockText.gameObject.SetActive(_foodAndBeverageData.state == ItemState.TO_BE_UNLOCKED);
            locketAnim.gameObject.SetActive(_foodAndBeverageData.state == ItemState.LOCKED);
            //lockedInfoText.gameObject.SetActive(_rideData.state == ItemState.LOCKED);
            if (_foodAndBeverageData.state == ItemState.LOCKED)
            {
                lockedInfoText.gameObject.GetComponent <LocalizationComponent>().SetTheLocalizedText();
            }
            else
            {
                AttractionsDataAsset    attractionsDataAsset = GameManager.Instance.GetAttractionsData();
                AttractionDataAssetItem assetDataItem        = attractionsDataAsset.attractionsDataAsset.Find
                                                                   (a => a.gameEventType == attractionsDataAsset.currentEvent);
                BasicAtractionData attrationData     = assetDataItem.GetBasicAttractionForGUID(guid);
                string             costText          = LocalizationManager.Instance.GetTextForKey("UNLOCK_COST");
                UnlockCondition    currencyCondition = attrationData.unlockConditionList.Find(a => a.unlockConditionType == UnlockConditionType.PAY_CURRENCY);
                if (currencyCondition != null)
                {
                    lockedInfoText.text = costText + currencyCondition.unlockConditionValue.currencyAmount.amount.ToString();
                    CurrencyData currencyData = GameManager.Instance.GetGameData().currencies.Find(
                        a => a.type == currencyCondition.unlockConditionValue.currencyAmount.type);
                    currencyCostIcon.gameObject.SetActive(true);
                    currencyCostIcon.sprite = currencyData.icon;
                }
            }
        }

        if (_foodAndBeverageData.state == ItemState.IDLE)
        {
            lockedBox.SetActive(false);
            idleBox.SetActive(true);

            icon.sprite = _foodAndBeverageData.icon;
            nameText.gameObject.GetComponent <LocalizationComponent>().SetTheLocalizedText(_foodAndBeverageData.name);
            descriptionText.gameObject.GetComponent <LocalizationComponent>().SetTheLocalizedText(_foodAndBeverageData.description);
            amountText.text = _userProductData.count.ToString();

            buyBtnText.text = LocalizationManager.Instance.GetTextForKey(buyBtnText.GetComponent <LocalizationComponent>().localizationKey)
                              + " " + _foodAndBeverageData.initialCost.amount.ToString();
            buyBtnCurrencyIcon.sprite = gameAsset.currencies.Find(x => x.type == _foodAndBeverageData.initialCost.type).icon;
            profitDescriptionBox.Init(_foodAndBeverageData.initialProfits);
        }
        //check state
    }
    public void Init(UnlockCondition condition)
    {
        bool isUnlocked = CheckCondition(condition);

        checkIcon.SetActive(isUnlocked);
        uncheckIcon.SetActive(!isUnlocked);

        switch (condition.unlockConditionType)
        {
        case UnlockConditionType.PAY_CURRENCY:
        {
            conditionText.text = "Cost " + condition.unlockConditionValue.currencyAmount.amount.ToString();
            CurrencyData currencyData = GameManager.Instance.GetGameData().currencies.Find(
                a => a.type == condition.unlockConditionValue.currencyAmount.type);
            conditionIcon.sprite = currencyData.icon;
        }
        break;

        case UnlockConditionType.ATTRACTION_COUNT:
        {
            conditionText.text = "Min " + condition.unlockConditionValue.guidCount.ToString();
            BasicAtractionData attractionData = GameManager.Instance.GetAttractionsData().GetCurrentEventAssets().GetBasicAttractionForGUID(
                condition.unlockConditionValue.guidData.guid);
            if (attractionData != null)
            {
                conditionIcon.sprite = attractionData.icon;
            }
        }
        break;

        case UnlockConditionType.FAME_LEVEL:
        {
            conditionText.text = "Min Fame Level: " + condition.unlockConditionValue.fameLevel;
        }
        break;
        }
    }
    bool CheckFameLevel(UnlockCondition condition)
    {
        UnlockConditionValue value = condition.unlockConditionValue;

        return(userInventory.HasMinFameLevel(value.fameLevel));
    }
    bool CheckAttractionCount(UnlockCondition condition)
    {
        UnlockConditionValue value = condition.unlockConditionValue;

        return(userInventory.HasEnoughAttractionOfGUID(value.guidData.guid, value.guidCount));
    }
    bool CheckCurrency(UnlockCondition condition)
    {
        UnlockConditionValue value = condition.unlockConditionValue;

        return(userInventory.HasEnoughCurrency(value.currencyAmount));
    }
Example #8
0
        private UnlockInfo getUnlockInfo(string infobox)
        {
            UnlockInfo result = null;

            //short circuit infoboxes without supply info
            if (!infobox.Contains("|Unlock "))
            {
                return(result);
            }

            using (var reader = new StringReader(infobox))
            {
                string curLine;
                while ((curLine = reader.ReadLine()) != null)
                {
                    curLine = curLine.Replace(_commons.InfoboxTemplateEnd, string.Empty);

                    if (curLine.StartsWith("|Unlock Condition ", StringComparison.OrdinalIgnoreCase))
                    {
                        var matchAmount = regexUnlockConditionAmount.Match(curLine);
                        if (matchAmount.Success)
                        {
                            var matchedCounter = matchAmount.Groups["counter"].Value;
                            if (!int.TryParse(matchedCounter, out var counter))
                            {
                                throw new Exception("could not find counter");
                            }

                            //handle entry with no value e.g. "|Unlock Condition 1 Amount = "
                            var matchedValue = matchAmount.Groups["value"].Value;
                            if (string.IsNullOrWhiteSpace(matchedValue))
                            {
                                logger.Trace($"skip line with no amount{Environment.NewLine}{nameof(curLine)}: {curLine}{Environment.NewLine}{nameof(matchAmount)}: {matchAmount}");
                                continue;
                            }

                            if (!double.TryParse(matchedValue, NumberStyles.Number, cultureForParsing, out var conditionValue))
                            {
                                throw new Exception("could not find value for input");
                            }

                            if (result == null)
                            {
                                result = new UnlockInfo();
                            }

                            var foundUnlockCondition = result.UnlockConditions.FirstOrDefault(x => x.Order == counter);
                            if (foundUnlockCondition == null)
                            {
                                foundUnlockCondition = new UnlockCondition
                                {
                                    Order = counter
                                };

                                result.UnlockConditions.Add(foundUnlockCondition);
                            }

                            foundUnlockCondition.Amount = conditionValue;

                            continue;
                        }

                        var matchType = regexUnlockConditionType.Match(curLine);
                        if (matchType.Success)
                        {
                            var matchedCounter = matchType.Groups["counter"].Value;
                            if (!int.TryParse(matchedCounter, out var counter))
                            {
                                throw new Exception("could not find counter");
                            }

                            //handle entry with no value e.g. "|Unlock Condition 1 Type = "
                            var matchedTypeName = matchType.Groups["typeName"].Value.Trim();
                            if (string.IsNullOrWhiteSpace(matchedTypeName))
                            {
                                continue;
                            }

                            if (result == null)
                            {
                                result = new UnlockInfo();
                            }

                            var foundUnlockCondition = result.UnlockConditions.FirstOrDefault(x => x.Order == counter);
                            if (foundUnlockCondition == null)
                            {
                                foundUnlockCondition = new UnlockCondition
                                {
                                    Order = counter
                                };

                                result.UnlockConditions.Add(foundUnlockCondition);
                            }

                            foundUnlockCondition.Type = matchedTypeName;

                            continue;
                        }
                    }
                }
            }

            if (result != null)
            {
                //order by number from infobox
                result.UnlockConditions = result.UnlockConditions.OrderBy(x => x.Order).ToList();
            }

            return(result);
        }