Esempio n. 1
0
 /// <summary>
 /// Loads the antura customization elements on Antura model.
 /// </summary>
 /// <param name="_anturaCustomization">The antura customization.</param>
 public void LoadAnturaCustomization(AnturaCustomization _anturaCustomization)
 {
     ClearLoadedRewardPacks();
     foreach (var propPack in _anturaCustomization.PropPacks)
     {
         LoadRewardPackOnAntura(propPack);
         ModelsManager.SwitchMaterial(LoadRewardPackOnAntura(propPack), propPack.GetMaterialPair());
     }
     LoadRewardPackOnAntura(_anturaCustomization.TexturePack);
     LoadRewardPackOnAntura(_anturaCustomization.DecalPack);
 }
        /// <summary>
        /// Saves the antura customization using the current model customization.
        /// </summary>
        /// <returns></returns>
        public AnturaCustomization SaveAnturaCustomization()
        {
            AnturaCustomization returnCustomization = new AnturaCustomization();

            foreach (LoadedModel loadedModel in LoadedModels)
            {
                returnCustomization.PropPacks.Add(loadedModel.RewardPack);
                returnCustomization.PropPacksIds.Add(loadedModel.RewardPack.UniqueId);
            }
            returnCustomization.TexturePack   = LoadedTexturePack;
            returnCustomization.TexturePackId = LoadedTexturePack.UniqueId;
            returnCustomization.DecalPack     = LoadedDecalPack;
            returnCustomization.DecalPackId   = LoadedDecalPack.UniqueId;
            AppManager.I.Player.SaveAnturaCustomization(returnCustomization);
            return(returnCustomization);
        }
Esempio n. 3
0
        /// <summary>
        /// Loads all rewards in "this" object instance from list of reward ids.
        /// </summary>
        /// <param name="_listOfIdsAsJsonString">The list of ids as json string.</param>
        public void LoadFromListOfIds(string _listOfIdsAsJsonString)
        {
            if (AppManager.I.Player == null)
            {
                Debug.Log("No default reward already created. Unable to load customization now");
                return;
            }

            AnturaCustomization tmp = JsonUtility.FromJson <AnturaCustomization>(_listOfIdsAsJsonString);

            if (tmp != null)
            {
                PropPacksIds  = tmp.PropPacksIds;
                TexturePackId = tmp.TexturePackId;
                DecalPackId   = tmp.DecalPackId;
            }

            var rewardSystem = AppManager.I.RewardSystemManager;

            if (string.IsNullOrEmpty(TexturePackId))
            {
                RewardPack defaultTileTexturePack = rewardSystem.GetAllRewardPacksOfBaseType(RewardBaseType.Texture)[0];
                Debug.LogWarning("AnturaCustomization: Using default texture: " + defaultTileTexturePack);
                TexturePackId = defaultTileTexturePack.UniqueId;
            }
            if (string.IsNullOrEmpty(DecalPackId))
            {
                RewardPack defaultDecalTexturePack = rewardSystem.GetAllRewardPacksOfBaseType(RewardBaseType.Decal)[0];
                Debug.LogWarning("AnturaCustomization: Using default decal: " + defaultDecalTexturePack);
                DecalPackId = defaultDecalTexturePack.UniqueId;
            }

            // Load correct packs from IDs
            PropPacks = new List <RewardPack>();
            foreach (string propPackId in PropPacksIds)
            {
                var pack = rewardSystem.GetRewardPackByUniqueId(propPackId);
                if (pack != null)
                {
                    PropPacks.Add(pack);
                }
            }

            TexturePack = rewardSystem.GetRewardPackByUniqueId(TexturePackId);
            DecalPack   = rewardSystem.GetRewardPackByUniqueId(DecalPackId);
        }