コード例 #1
0
        public GameObject LoadRewardPackOnAntura(RewardPack _rewardPack)
        {
            switch (_rewardPack.Type)
            {
            case RewardTypes.reward:
                return(LoadRewardOnAntura(_rewardPack));

            case RewardTypes.texture:
                Material[] mats = SkinnedMesh.sharedMaterials;
                mats[0] = MaterialManager.LoadTextureMaterial(_rewardPack.ItemID, _rewardPack.ColorId);
                SkinnedMesh.sharedMaterials = mats;
                LoadedTileTexture           = _rewardPack;
                break;

            case RewardTypes.decal:
                Material[] decalMats = SkinnedMesh.sharedMaterials;
                decalMats[1] = MaterialManager.LoadTextureMaterial(_rewardPack.ItemID, _rewardPack.ColorId);
                SkinnedMesh.sharedMaterials = decalMats;
                LoadedDecal = _rewardPack;
                break;

            default:
                Debug.LogWarningFormat("Reward Type {0} not found!", _rewardPack.Type);
                break;
            }
            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Gets the next reward pack. Contains all logic to create new reward.
        /// </summary>
        /// <param name="_rewardType">Type of the reward.</param>
        /// <returns></returns>
        public static RewardPack GetRewardPack(string _playsession, RewardTypes _rewardType, bool _random)
        {
            /// TODOs:
            /// - Filter without already unlocked items
            /// - Automatic select reward type by situation
            RewardPack rp = new RewardPack();

            switch (_rewardType)
            {
            case RewardTypes.reward:
                rp = new RewardPack()
                {
                    // If not random take id from list of already unlocked rewards of this type
                    ItemID = _random ? config.Rewards.GetRandom().ID : AppManager.I.Player.RewardsUnlocked.FindAll(r => r.Type == RewardTypes.reward).GetRandom <RewardPack>().ItemID,
                    // Todo: check if color is not already unlocked!
                    ColorId       = config.RewardsColorPairs.GetRandom().ID,
                    Type          = _rewardType,
                    PlaySessionId = _playsession,
                    IsNew         = true,
                };
                break;

            case RewardTypes.texture:
                rp = new RewardPack()
                {
                    ItemID        = config.RewardsTile.GetRandom().ID,
                    ColorId       = config.RewardsTileColor.GetRandom().ID,
                    Type          = _rewardType,
                    PlaySessionId = _playsession,
                    IsNew         = true,
                };
                break;

            case RewardTypes.decal:
                rp = new RewardPack()
                {
                    ItemID        = config.RewardsDecal.GetRandom().ID,
                    ColorId       = config.RewardsDecalColor.GetRandom().ID,
                    Type          = _rewardType,
                    PlaySessionId = _playsession,
                    IsNew         = true,
                };
                break;

            default:
                break;
            }
            return(rp);
        }
コード例 #3
0
        IEnumerator StartReward()
        {
            // Wait for animation to complete
            //RewardsAnimator animator = this.GetComponent<RewardsAnimator>();
            //while (!animator.IsComplete)
            //    yield return null;
            yield return(new WaitForSeconds(3.5f));

            /* FIRST CONTACT FEATURE */
            if (AppManager.I.Player.IsFirstContact())
            {
                KeeperManager.I.PlayDialog(Db.LocalizationDataId.Reward_Intro);
                // Clean and Charge antura reward.
                AnturaModelManager.Instance.ClearLoadedRewards();
                RewardPack firstUnlockedReward = RewardSystemManager.GetFirstAnturaReward(RewardTypes.reward);
                AppManager.I.Player.AddRewardUnlocked(firstUnlockedReward);
                AnturaModelManager.Instance.LoadRewardPackOnAntura(firstUnlockedReward);
            }
            else
            {
                int rnd = Random.Range(1, 3);
                switch (rnd)
                {
                case 1:
                    KeeperManager.I.PlayDialog(Db.LocalizationDataId.Reward_Big_1);
                    break;

                case 3:
                    KeeperManager.I.PlayDialog(Db.LocalizationDataId.Reward_Big_2);
                    break;

                default:
                    KeeperManager.I.PlayDialog(Db.LocalizationDataId.Reward_Big_3);
                    break;
                }
                AnturaModelManager.Instance.ClearLoadedRewards();
                RewardPack newUnlockedReward = RewardSystemManager.GetNextRewardPack()[0];
                AppManager.I.Player.AddRewardUnlocked(newUnlockedReward);
                AnturaModelManager.Instance.LoadRewardPackOnAntura(newUnlockedReward);
            }
            /* --------------------- */
            ContinueScreen.Show(Continue, ContinueScreenMode.Button);
            yield return(null);
        }
コード例 #4
0
        void Start()
        {
            // Navigation manager
            NavigationManager.I.CurrentScene = AppScene.PlaySessionResult;

            // Calculate items to unlock count
            int itemsToUnlock = NavigationManager.I.CalculateUnlockItemCount();

            List <RewardPack> oldRewards = AppManager.I.Player.RewardsUnlocked.FindAll(ru => ru.PlaySessionId == AppManager.I.Player.CurrentJourneyPosition.ToString());
            int itemAlreadyUnlocked      = oldRewards.Count;

            for (int i = 0; i < itemsToUnlock - oldRewards.Count; i++)
            {
                // if necessary add one new random reward unlocked
                RewardPack newRewardToUnlock = RewardSystemManager.GetNextRewardPack()[0];
                oldRewards.Add(newRewardToUnlock);
                AppManager.I.Player.AddRewardUnlocked(newRewardToUnlock);
            }

            // Show UI result and unlock transform parent where show unlocked items
            GameObject[] objs = new GameObject[] { };
            objs = GameResultUI.ShowEndsessionResult(NavigationManager.I.UseEndSessionResults(), itemAlreadyUnlocked);

            for (int i = 0; i < objs.Length - oldRewards.Count; i++)
            {
                // if necessary add one new random reward not to be unlocked!
                oldRewards.Add(RewardSystemManager.GetNextRewardPack()[0]);
            }

            LogManager.I.LogPlaySessionScore(TeacherAI.I.journeyHelper.GetCurrentPlaySessionData().Id, objs.Length);
            // save max progression (internal check if necessary)
            NavigationManager.I.MaxJourneyPosistionProgress();

            // for any rewards mount them model on parent transform object (objs)
            for (int i = 0; i < oldRewards.Count && i < objs.Length; i++)
            {
                ModelsManager.MountModel(
                    oldRewards[i].ItemID,
                    objs[i].transform,
                    oldRewards[i].GetMaterialPair()
                    );
            }
        }
コード例 #5
0
        /// <summary>
        /// Gets the reward packs for play session ended, already created or create on fly now (and save on player profile).
        /// </summary>
        /// <param name="_playSession">The play session.</param>
        /// <param name="_itemsToUnlock">The items to unlock. Needed to know if must be saved element as unlocked or not.</param>
        /// <param name="_alreadyUnlocked">The already unlocked.</param>
        /// <returns></returns>
        public static List <RewardPack> GetRewardPacksForPlaySession(JourneyPosition _playSession, int _itemsToUnlock, out int _alreadyUnlocked)
        {
            List <RewardPack> rpList = AppManager.I.Player.RewardsUnlocked.FindAll(r => r.PlaySessionId == _playSession.ToString());

            _alreadyUnlocked = rpList.Count;
            int count = _alreadyUnlocked;

            while (rpList.Count < MaxRewardsUnlockableForPlaysession)
            {
                RewardPack newRewardPack = GetNextRewardPack()[0]; //GetRewardPack(RewardTypes.reward);
                count++;
                if (count <= _itemsToUnlock)
                {
                    // Then this new reward is unlocked by gameplay result and after creation must be saved as unlocked to profile.
                    AppManager.I.Player.RewardsUnlocked.Add(newRewardPack);
                    AppManager.I.Player.Save();
                }
                rpList.Add(newRewardPack);
            }
            return(rpList);
        }
コード例 #6
0
        /// <summary>
        /// Gets the first antura reward.
        /// </summary>
        /// <param name="_rewardType">Type of the reward.</param>
        /// <returns></returns>
        public static RewardPack GetFirstAnturaReward(RewardTypes _rewardType)
        {
            RewardPack rp = new RewardPack();

            switch (_rewardType)
            {
            case RewardTypes.reward:
                rp = GetRewardPack("0.0.0", _rewardType, true);
                break;

            case RewardTypes.texture:
                rp = new RewardPack()
                {
                    ItemID        = "Antura_wool_tilemat",
                    ColorId       = "color1",
                    Type          = _rewardType,
                    PlaySessionId = "0.0.0",
                    IsNew         = true,
                };
                break;

            case RewardTypes.decal:
                rp = new RewardPack()
                {
                    ItemID        = "Antura_decalmap01",
                    ColorId       = "color1",
                    Type          = _rewardType,
                    PlaySessionId = "0.0.0",
                    IsNew         = true,
                };
                break;

            default:
                break;
            }
            return(rp);
        }
コード例 #7
0
        /// <summary>
        /// Return PlayerProfile with avatar id in param.
        /// If not exist create new with default settings.
        /// </summary>
        /// <param name="_avatarId"></param>
        /// <returns></returns>
        public PlayerProfile CreateOrLoadPlayerProfile(int _avatarId)
        {
            bool          isNew         = false;
            PlayerProfile returnProfile = LoadPlayerProfileByAvatarId(_avatarId);

            if (returnProfile == null)
            {
                returnProfile = new PlayerProfile();
                isNew         = true;
                // create new
                returnProfile.Id       = AvailablePlayerProfiles.Count + 1;
                returnProfile.AvatarId = _avatarId;
                returnProfile.Key      = returnProfile.Id.ToString();
                returnProfile          = AppManager.I.Modules.PlayerProfile.CreateNewPlayer(returnProfile) as PlayerProfile;
            }
            // Create new antura skin
            RewardPack tileTexture = RewardSystemManager.GetFirstAnturaReward(RewardTypes.texture);

            returnProfile.AddRewardUnlocked(tileTexture);
            returnProfile.CurrentAnturaCustomizations.TileTexture = tileTexture;
            RewardPack decalTexture = RewardSystemManager.GetFirstAnturaReward(RewardTypes.decal);

            returnProfile.AddRewardUnlocked(decalTexture);
            returnProfile.CurrentAnturaCustomizations.DecalTexture = decalTexture;
            // -----
            AppManager.I.PlayerProfileManager.CurrentPlayer = returnProfile as PlayerProfile;
            AppManager.I.PlayerProfileManager.availablePlayerProfiles.Add(AppManager.I.PlayerProfileManager.CurrentPlayer);
            AppManager.I.PlayerProfileManager.CurrentPlayer.Save();
            SaveGameSettings();
            if (isNew && OnNewProfileCreated != null)
            {
                OnNewProfileCreated();
            }

            return(AppManager.I.PlayerProfileManager.CurrentPlayer);
        }
コード例 #8
0
 /// <summary>
 /// Adds the reward unlocked.
 /// </summary>
 /// <param name="_rewardPack">The reward pack.</param>
 public void AddRewardUnlocked(RewardPack _rewardPack)
 {
     RewardsUnlocked.Add(_rewardPack);
     Save();
 }
コード例 #9
0
        /// <summary>
        /// Selects the reward item.
        /// </summary>
        /// <param name="_rewardItemId">The reward item identifier.</param>
        /// <returns></returns>
        public static List <RewardColorItem> SelectRewardItem(string _rewardItemId, RewardTypes _rewardType)
        {
            List <RewardColorItem> returnList = new List <RewardColorItem>();

            /// logic
            /// - Trigger selected reward event.
            /// - Load returnList of color for reward checking unlocked and if exist active one


            switch (_rewardType)
            {
            case RewardTypes.reward:
                foreach (RewardColor color in config.RewardsColorPairs)
                {
                    if (AppManager.I.Player.RewardsUnlocked.Exists(ur => ur.ItemID == _rewardItemId && ur.ColorId == color.ID))
                    {
                        RewardColorItem rci = new RewardColorItem(color);
                        returnList.Add(rci);
                    }
                    else
                    {
                        returnList.Add(null);
                    }
                }
                // set current reward in modification
                CurrentReward = new RewardPack()
                {
                    ItemID = _rewardItemId, Type = RewardTypes.reward
                };
                break;

            case RewardTypes.texture:
                foreach (RewardColor color in config.RewardsTileColor)
                {
                    if (AppManager.I.Player.RewardsUnlocked.Exists(ur => ur.ItemID == _rewardItemId && ur.ColorId == color.ID))
                    {
                        RewardColorItem rci = new RewardColorItem(color);
                        rci.Color2RGB = rci.Color1RGB;     // to avoid exadecimal conversion error on ui rgb code conversion.
                        returnList.Add(rci);
                    }
                    else
                    {
                        returnList.Add(null);
                    }
                }
                // set current reward in modification
                CurrentReward = new RewardPack()
                {
                    ItemID = _rewardItemId, Type = RewardTypes.texture
                };
                break;

            case RewardTypes.decal:
                foreach (RewardColor color in config.RewardsDecalColor)
                {
                    if (AppManager.I.Player.RewardsUnlocked.Exists(ur => ur.ItemID == _rewardItemId && ur.ColorId == color.ID))
                    {
                        RewardColorItem rci = new RewardColorItem(color);
                        rci.Color2RGB = rci.Color1RGB;     // to avoid exadecimal conversion error on ui rgb code conversion.
                        returnList.Add(rci);
                    }
                    else
                    {
                        returnList.Add(null);
                    }
                }
                //foreach (RewardColor color in config.RewardsDecalColor) {
                //    RewardColorItem rci = new RewardColorItem(color);
                //    rci.Color2RGB = rci.Color1RGB; // to avoid exadecimal conversion error on ui rgb code conversion.
                //    returnList.Add(rci);
                //}
                // set current reward in modification
                CurrentReward = new RewardPack()
                {
                    ItemID = _rewardItemId, Type = RewardTypes.decal
                };
                break;

            default:
                Debug.LogWarningFormat("Reward typology requested {0} not found", _rewardType);
                break;
            }
            // check if there is a selected item, if no one select the first.
            if (returnList.Count > 0 && !returnList.Exists(c => c != null && c.IsSelected == true))
            {
                foreach (var firstItem in returnList)
                {
                    if (firstItem != null)
                    {
                        firstItem.IsSelected = true;
                        return(returnList);
                    }
                }
            }
            return(returnList);
        }
コード例 #10
0
 private void RewardSystemManager_OnRewardItemChanged(RewardPack _rewardPack)
 {
     LoadRewardPackOnAntura(_rewardPack);
 }
コード例 #11
0
        /// <summary>
        /// Loads the reward on model.
        /// </summary>
        /// <param name="_id">The identifier.</param>
        /// <returns></returns>
        public GameObject LoadRewardOnAntura(RewardPack _rewardPack)
        {
            Reward reward = RewardSystemManager.GetConfig().Rewards.Find(r => r.ID == _rewardPack.ItemID);

            if (reward == null)
            {
                Debug.LogFormat("Reward {0} not found!", _rewardPack.ItemID);
                return(null);
            }
            // Check if already charged reward of this category
            LoadedModel loadedModel = LoadedModels.Find(lm => lm.Reward.GetRewardCategory() == reward.Category);

            if (loadedModel != null)
            {
                Destroy(loadedModel.GO);
                LoadedModels.Remove(loadedModel);
            }

            // Load Model
            string     boneParent      = reward.BoneAttach;
            Transform  transformParent = transform;
            GameObject rewardModel     = null;

            switch (boneParent)
            {
            case "dog_head":
                transformParent = Dog_head;
                //if (Dog_head_pointer)
                //    Destroy(Dog_head_pointer.gameObject);
                //Dog_head_pointer = ModelsManager.MountModel(reward.ID, transformParent).transform;
                rewardModel = ModelsManager.MountModel(reward.ID, transformParent);
                break;

            case "dog_spine01":
                transformParent = Dog_spine01;
                //if (Dog_spine01_pointer)
                //    Destroy(Dog_spine01_pointer.gameObject);
                //Dog_spine01_pointer = ModelsManager.MountModel(reward.ID, transformParent).transform;
                rewardModel = ModelsManager.MountModel(reward.ID, transformParent);
                break;

            case "dog_jaw":
                transformParent = Dog_jaw;
                //if (Dog_jaw_pointer)
                //    Destroy(Dog_jaw_pointer.gameObject);
                //Dog_jaw_pointer = ModelsManager.MountModel(reward.ID, transformParent).transform;
                rewardModel = ModelsManager.MountModel(reward.ID, transformParent);
                break;

            case "dog_Tail4":
                transformParent = Dog_Tail3;
                //if (Dog_Tail3_pointer)
                //    Destroy(Dog_Tail3_pointer.gameObject);
                //Dog_Tail3_pointer = ModelsManager.MountModel(reward.ID, transformParent).transform;
                rewardModel = ModelsManager.MountModel(reward.ID, transformParent);
                break;

            case "dog_R_ear04":
                transformParent = Dog_R_ear04;
                //if (dog_R_ear04_pointer)
                //    Destroy(dog_R_ear04_pointer.gameObject);
                //dog_R_ear04_pointer = ModelsManager.MountModel(reward.ID, transformParent).transform;
                rewardModel = ModelsManager.MountModel(reward.ID, transformParent);
                break;

            case "dog_L_ear04":
                transformParent = Dog_L_ear04;
                //if (dog_L_ear04_pointer)
                //    Destroy(dog_L_ear04_pointer.gameObject);
                //dog_L_ear04_pointer = ModelsManager.MountModel(reward.ID, transformParent).transform;
                rewardModel = ModelsManager.MountModel(reward.ID, transformParent);
                break;

            default:
                break;
            }

            // Set materials
            ModelsManager.SwitchMaterial(rewardModel, _rewardPack.GetMaterialPair());

            // Save on LoadedModel List
            LoadedModels.Add(new LoadedModel()
            {
                Reward = _rewardPack, GO = rewardModel
            });
            return(rewardModel);
        }
コード例 #12
0
 /// <summary>
 /// Sets the reward material colors.
 /// </summary>
 /// <param name="_gameObject">The game object.</param>
 /// <param name="_rewardPack">The reward pack.</param>
 /// <returns></returns>
 public GameObject SetRewardMaterialColors(GameObject _gameObject, RewardPack _rewardPack)
 {
     ModelsManager.SwitchMaterial(_gameObject, _rewardPack.GetMaterialPair());
     //actualRewardsForCategoryColor.Add()
     return(_gameObject);
 }