Beispiel #1
0
 public IEnumerable <RewardBase> GetRewardBasesOfType(RewardBaseType baseType)
 {
     return(partsConfig.GetBasesForType(baseType));
 }
Beispiel #2
0
        /// <summary>
        /// Generate a new list of reward packs to be unlocked.
        /// </summary>
        /// <param name="baseType">Type of the reward.</param>
        private List <RewardPack> GenerateNewRewardPacks(RewardBaseType baseType, RewardUnlockMethod unlockMethod, string[] allowedCategories = null)
        {
            List <RewardPack> newRewardPacks = new List <RewardPack>();

            switch (unlockMethod)
            {
            case RewardUnlockMethod.NewBase: {
                // We force a NEW base
                var lockedBases = GetLockedRewardBasesOfBaseType(baseType);

                if (allowedCategories != null)
                {
                    lockedBases = lockedBases.Where(x => allowedCategories.Contains((x as RewardProp).Category)).ToList();
                }

                if (lockedBases.Count == 0)
                {
                    throw new NullReferenceException(
                              "We do not have enough rewards to get a new base of type " + baseType);
                }

                var newBase              = lockedBases.RandomSelectOne();
                var lockedPacks          = GetLockedRewardPacksOfBaseType(baseType);
                var lockedPacksOfNewBase = lockedPacks.Where(x => x.BaseId == newBase.ID).ToList();

                // We add one random pack of the new base
                newRewardPacks.Add(lockedPacksOfNewBase.RandomSelectOne());
            }
            break;

            case RewardUnlockMethod.NewBaseAndAllColors: {
                // We force a NEW base
                //Debug.Log("Tot locked rewards count: " + GetAllLockedRewardPacks().Count());

                var lockedBases = GetLockedRewardBasesOfBaseType(baseType);

                //Debug.Log("locked bases count: " + lockedBases.Count);

                /*
                 * if (allowedCategories != null) {
                 *  //Debug.Log("Allowed categories: " + allowedCategories.ToDebugString());
                 *  lockedBases = lockedBases.Where(x => allowedCategories.Contains((x as RewardProp).Category)).ToList();
                 * }
                 */

                if (lockedBases.Count == 0)
                {
                    throw new NullReferenceException(
                              "We do not have enough rewards to get a new base of type " + baseType);
                }

                var newBase              = lockedBases[0];// lockedBases.RandomSelectOne();
                var lockedPacks          = GetLockedRewardPacksOfBaseType(baseType);
                var lockedPacksOfNewBase = lockedPacks.Where(x => x.BaseId == newBase.ID).ToList();

                // We add all locked packs of that base
                newRewardPacks.AddRange(lockedPacksOfNewBase);
            }
            break;

            case RewardUnlockMethod.NewColor: {
                // We force an OLD base
                var unlockedBases = GetUnlockedRewardBasesOfBaseType(baseType);
                var unlockedBasesWithColorsLeft = unlockedBases.Where(b => GetLockedRewardPacksOfBaseType(baseType).Count(p => p.BaseId == b.ID) > 0).ToList();

                if (unlockedBasesWithColorsLeft.Count == 0)
                {
                    throw new NullReferenceException(
                              "We do not have unlocked bases that still have colors to be unlocked for base type " + baseType);
                }

                var oldBase              = unlockedBasesWithColorsLeft.RandomSelectOne();
                var lockedPacks          = GetLockedRewardPacksOfBaseType(baseType);
                var lockedPacksOfOldBase = lockedPacks.Where(x => x.BaseId == oldBase.ID).ToList();
                if (lockedPacksOfOldBase.Count == 0)
                {
                    throw new NullReferenceException(
                              "We do not have enough rewards to get a new color for an old base of type " + baseType);
                }

                newRewardPacks.Add(lockedPacksOfOldBase.RandomSelectOne());
            }
            break;

            case RewardUnlockMethod.BaseColorCombo: {
                // We get any reward pack
                var lockedPacks = GetLockedRewardPacksOfBaseType(baseType);

                if (lockedPacks.Count == 0)
                {
                    throw new NullReferenceException(
                              "We do not have enough rewards left of type " + baseType);
                }

                newRewardPacks.Add(lockedPacks.RandomSelectOne());
            }
            break;
            }
            return(newRewardPacks);
        }
Beispiel #3
0
        /// <summary>
        /// Gets the reward base items (null if a base is not unlocked)
        /// </summary>
        /// <param name="baseType">Base type of the reward.</param>
        /// <param name="_parentsTransForModels">The parents transform for models.</param>
        /// <param name="_category">The category reward identifier.</param>
        public List <RewardBaseItem> GetRewardBaseItems(RewardBaseType baseType, List <Transform> _parentsTransForModels, string _category = "")
        {
            List <RewardBaseItem> returnList = new List <RewardBaseItem>();

            // Load the return list with an item for each base, or a NULL if no base has been unlocked
            var currentAnturaCustomizations = AppManager.I.Player.CurrentAnturaCustomizations;
            var rewardBases = GetRewardBasesOfType(baseType);

            if (baseType == RewardBaseType.Prop && _category != "")
            {
                rewardBases = rewardBases.Where(rewardBase => (rewardBase as RewardProp).Category == _category).ToList();
            }

            foreach (var rewardBase in rewardBases)
            {
                bool isToBeShown = IsRewardBaseUnlocked(rewardBase);
                // Debug.Log("Reward prop base "  + rewardBase.ID + " to be shown? " + isToBeShown);

                if (isToBeShown)
                {
                    returnList.Add(new RewardBaseItem()
                    {
                        data       = rewardBase,
                        IsNew      = IsRewardBaseNew(rewardBase),
                        IsSelected = currentAnturaCustomizations.HasBaseEquipped(rewardBase.ID)
                    });
                }
                else
                {
                    returnList.Add(null);
                }
            }


            // Load models and textures for the buttons
            switch (baseType)
            {
            case RewardBaseType.Prop:
                for (int i = 0; i < returnList.Count; i++)
                {
                    if (returnList[i] != null)
                    {
                        ModelsManager.MountModel(returnList[i].data.ID, _parentsTransForModels[i]);
                    }
                }
                break;

            case RewardBaseType.Texture:
                for (int i = 0; i < returnList.Count; i++)
                {
                    if (returnList[i] != null)
                    {
                        string    texturePath  = "AnturaStuff/Textures_and_Materials/";
                        Texture2D inputTexture = Resources.Load <Texture2D>(texturePath + returnList[i].data.ID);
                        _parentsTransForModels[i].GetComponent <RawImage>().texture = inputTexture;
                    }
                }
                break;

            case RewardBaseType.Decal:
                for (int i = 0; i < returnList.Count; i++)
                {
                    if (returnList[i] != null)
                    {
                        string    texturePath  = "AnturaStuff/Textures_and_Materials/";
                        Texture2D inputTexture = Resources.Load <Texture2D>(texturePath + returnList[i].data.ID);
                        _parentsTransForModels[i].GetComponent <RawImage>().texture = inputTexture;
                        //Debug.Log("Returned texture " + inputTexture.name + " for reward " + returnList[i].data.ID);
                    }
                }
                break;

            default:
                Debug.LogWarningFormat("Reward base type requested {0} not found", baseType);
                break;
            }

            return(returnList);
        }
Beispiel #4
0
 public bool DoesRewardCategoryContainUnlockedElements(RewardBaseType baseType, string _rewardCategory = "")
 {
     return(GetUnlockedRewardPacks().Any(r => r.BaseType == baseType && r.Category == _rewardCategory));
 }