private static bool UNLOCK_AT_EACH_PS = false; // if true, we unlock something at the end of each PS protected override void Start() { base.Start(); DebugManager.OnSkipCurrentScene += HandleSceneSkip; var jp = AppManager.I.Player.CurrentJourneyPosition; var nEarnedStars = AppManager.I.NavigationManager.CalculateEarnedStarsCount(); if (NavigationManager.TEST_SKIP_GAMES) { nEarnedStars = 3; } // Log various data LogManager.I.LogPlaySessionScore(AppManager.I.JourneyHelper.GetCurrentPlaySessionData().Id, nEarnedStars); AppManager.I.Teacher.logAI.UnlockVocabularyDataForJourneyPosition(AppManager.I.Player.CurrentJourneyPosition); // Advance journey if we earned enough stars if (nEarnedStars > 0) { AppManager.I.Player.AdvanceMaxJourneyPosition(); } if (UNLOCK_AT_EACH_PS) { // Compute numbers we need to unlock var nTotalRewardPacksToUnlock = AppManager.I.NavigationManager.CalculateRewardPacksUnlockCount(); var rewardPacksForJourneyPosition = AppManager.I.RewardSystemManager.GetOrGenerateAllRewardPacksForJourneyPosition(jp); var rewardPacksUnlocked = rewardPacksForJourneyPosition.Where(x => x.IsUnlocked).ToList(); var rewardPacksLocked = rewardPacksForJourneyPosition.Where(x => x.IsLocked).ToList(); int nRewardPacksAlreadyUnlocked = rewardPacksUnlocked.Count(); int nNewRewardPacksToUnlock = nTotalRewardPacksToUnlock - nRewardPacksAlreadyUnlocked; // Unlock the selected set of locked rewards AppManager.I.RewardSystemManager.UnlockPacksSelection(rewardPacksLocked, nNewRewardPacksToUnlock); // Show UI result and unlock transform parent where show unlocked items var uiGameObjects = GameResultUI.ShowEndsessionResult(AppManager.I.NavigationManager.UseEndSessionResults(), nRewardPacksAlreadyUnlocked); // For any rewards mount them model on parent transform object (objs) for (int i = 0; i < rewardPacksUnlocked.Count() && i < uiGameObjects.Length; i++) { var matPair = rewardPacksUnlocked[i].GetMaterialPair(); ModelsManager.MountModel(rewardPacksUnlocked[i].BaseId, uiGameObjects[i].transform, matPair); } } else { GameResultUI.ShowEndsessionResult(AppManager.I.NavigationManager.UseEndSessionResults(), 1); } }
/// <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); }