コード例 #1
0
        private bool SetupAndValidateRewardData()
        {
            _rewardConfigId   = mysteryBoxItem.itemTypeKey;
            _rewardConfigData = rewardConfigModel.GetById(_rewardConfigId);

            if (!mysteryBoxItem.itemType.Equals(ItemType.Reward))
            {
                logger.LogError(Tag, "CollectMysteryBox - input item is not of reward type : " + mysteryBoxItem.id);
                return(false);
            }

            if (_rewardConfigData == null)
            {
                logger.LogError(Tag, "Cannot find reward with id : " + mysteryBoxItem.itemTypeKey);
                return(false);
            }

            if (_rewardConfigData.rewardType != RewardType.MysteryBox)
            {
                logger.LogError(Tag, "Attempted to collect mystery box using a reward of a different type. Reward Id: " + _rewardConfigId);
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public IConfigData Clone()
        {
            RewardConfigData c = new RewardConfigData();

            c.id                    = id;
            c.rewardType            = rewardType;
            c.delayType             = delayType;
            c.delays                = new List <int>(delays);
            c.socialFactor          = socialFactor;
            c.rvFactor              = rvFactor;
            c.doubleFactor          = doubleFactor;
            c.permanentSocialFactor = permanentSocialFactor;
            c.restrictions          = new List <GameElementData>(restrictions);

            return(c);
        }
コード例 #3
0
        List <GameElementData> ClaimItemConfigId(string rewardItemConfigId)
        {
            RewardItemConfigData   rewardItem = rewardItemConfigModel.GetItemById(rewardItemConfigId);
            List <GameElementData> rewards    = rewardItemConfigModel.GetRewardsForItem(rewardItemConfigId);

            bool applyRvFactor = rvFactors.ContainsKey(rewardItem.rewardConfigId) ? rvFactors[rewardItem.rewardConfigId] : false;

            applyRvFactor = applyRvFactor && rewardItem.allowRVFactor;

            RewardConfigData rewardConfig = rewardConfigModel.GetById(rewardItem.rewardConfigId);

            var items = new List <GameElementData>();

            //increase items by factors.
            foreach (var item in rewards)
            {
                if (applyRvFactor)
                {
                    item.value = Mathf.RoundToInt(item.value * rewardConfig.rvFactor);
                }

                if (rewardItem.allowSocialFactor && socialFactor && (!applyRvFactor || (applyRvFactor && rewardConfig.doubleFactor)))
                {
                    item.value = Mathf.RoundToInt(item.value * rewardConfig.socialFactor);
                }

                if (rewardItem.rangeMultiplayer > 1.0f)
                {
                    float randomMultiplayer = UnityEngine.Random.Range(1.0f, rewardItem.rangeMultiplayer);
                    Debug.Log("RewardService - Applying random range multiplier : " + randomMultiplayer);
                }

                items.Add(item);
            }

            collectGameElementsSignal.Dispatch(items);

            //reset rvFactor.
            rvFactors[rewardItem.rewardConfigId] = false;

            return(rewards);
        }