private void CreateListItemAsynchronously(PermanentAchievementManager.Achievement itemName, string description, int reward, AssetReference sprite, bool unlocked)
        {
            var achievementItemGameObject          = Instantiate(DisplayItemAddressableAsGameObject, Display).GetComponentInChildren <AchievementListItem>();
            var achievementItemGameObjectTransform = achievementItemGameObject.transform;

            achievementItemGameObjectTransform.SetParent(Display);
            achievementItemGameObjectTransform.localScale = Vector3.one;

            _achievementListItems.Add(itemName, new AchievementItemStruct(achievementItemGameObject.Background, achievementItemGameObject.ReturnNameDisplay, achievementItemGameObject.ReturnDescriptionDisplay, achievementItemGameObject.ReturnRewardDisplay, achievementItemGameObject.ReturnGraphic, unlocked));
            _achievementListItems[itemName].NameDisplay.text        = StringUtilities.AddSpacesBeforeCapitals(itemName.ToString());
            _achievementListItems[itemName].DescriptionDisplay.text = description;
            _achievementListItems[itemName].RewardDisplay.text      = reward.ToString();

            if (unlocked)
            {
                SetUnlockedState(itemName);
            }

            AssetReferenceLoader.LoadAssetReferenceAsynchronously <Sprite>(sprite, (returnSprite) =>
            {
                _achievementListItems[itemName].Graphic.sprite = returnSprite;
                achievementItemGameObject.RemoveClassFromObject();

                if (sprite.Asset)
                {
                    AssetReferenceLoader.UnloadAssetReference(sprite);               //TODO: cant unload sprites in use
                }
            });
        }
Пример #2
0
 private void Validate()
 {
     #if UNITY_EDITOR || DEBUGBUILD
     cheats.SetActive(true);
     Destroy(GetComponent <CheatEnabler>());
     return;
     #endif
     AssetReferenceLoader.DestroyOrUnload(gameObject);
 }
 private static void OpenAddressableMenu <T>(IKeyEvaluator menuReference) where T : IUserInterface
 {
     AssetReferenceLoader.LoadAssetReferenceAsynchronously <GameObject>(menuReference, (returnVariable) =>
     {
         var menu = Instantiate(returnVariable).GetComponent <T>();
         AssetReferenceLoader.DestroyOrUnload(returnVariable);
         menu.Enable();
     });
 }
Пример #4
0
        public static IEnumerator LoadStageWithFade(int stageGroup, int stage, Action fadeCompleteCallBack = null, Action completeCallBack = null)
        {
            yield return(CoRoutineHandler.StartCoroutine(Fade.FadeImageAlphaUp(FadeImage, FadeDuration)));

            fadeCompleteCallBack?.Invoke();

            AssetReferenceLoader.LoadScene(ReturnStageAsAssetReference(stageGroup, stage)); //Should i do a wait here or does the fade disquise it??

            yield return(CoRoutineHandler.StartCoroutine(Fade.FadeImageAlphaDown(FadeImage, FadeDuration)));

            completeCallBack?.Invoke();
        }
Пример #5
0
        protected virtual void OnEnable()
        {
            if (Instance != null)
            {
                Debug.LogWarning("There are 2 " + name + " singletons in the scene. Removing " + gameObject + ".");
                AssetReferenceLoader.DestroyOrUnload(gameObject);
                //Destroy(gameObject);
                return;
            }

            Instance = FindObjectOfType(typeof(T)) as T;
            if (Instance == null)
            {
                Debug.LogError("Can not find singleton: " + name + ".");
            }
        }
        private static void PopAchievement(DynamicAchievementManager.Achievement achievement)
        {
            var assetReference = DynamicAchievementManager.ReturnSpriteAssetReference(achievement);

            _activeAchievements++;
            AssetReferenceLoader.LoadAssetReferenceAsynchronously <Sprite>(assetReference, (returnVariable) =>
            {
                var popUp = PopUps.Dequeue();
                popUp.transform.SetSiblingIndex(_maximumNumberOfActiveAchievements - 1);
                popUp.Show(returnVariable, StringUtilities.AddSpacesBeforeCapitals(achievement.ToString()), DynamicAchievementManager.ReturnDescription(achievement), DynamicAchievementManager.ReturnReward(achievement), () =>
                {
                    _activeAchievements--;
                    PopUps.Enqueue(popUp);
                    popUp.gameObject.SetActive(false);
                });
                AssetReferenceLoader.UnloadAssetReference(assetReference);
                Instance.StartCoroutine(Instance.HandleDelayedAdditions());
            });
        }
    private IEnumerator CreateListAsynchronously(DynamicAchievementManager.Achievement[] achievements)
    {
        var amountOfAchievements = achievements.Length;

        AssetReferenceLoader.LoadAssetReferenceAsynchronously <GameObject>(DisplayItemPrefab, (returnVariable) =>
        {
            DisplayItemAddressableAsGameObject = returnVariable;
            AssetReferenceLoader.DestroyOrUnload(returnVariable);
        });
        yield return(WaitUntilAssetReferenceIsLoadedAsynchronously);

        for (var i = 0; i < amountOfAchievements; i++)
        {
            var achievement = achievements[i];
            CreateListItemAsynchronously(achievement, DynamicAchievementManager.ReturnDescription(achievement), DynamicAchievementManager.ReturnReward(achievement), DynamicAchievementManager.ReturnSpriteAssetReference(achievement), DynamicAchievementManager.ReturnUnlockedState(achievement));
        }

        DisplayItemAddressableAsGameObject = null;
        ListCreated = true;
    }
Пример #8
0
    private IEnumerator ConvertPoolListIntoQueueOfGameObjects(Action callBack)
    {
        var poolsCache = pools;

        foreach (var pool in poolsCache)
        {
            var objectPool = new Queue <GameObject>();
            var maximumAmountOfObjectsInCurrentPool = pool.maximumActiveObjects;
            var assetReference = pool.assetReference;

            AssetReferenceLoader.LoadAssetReferenceAsynchronously <GameObject>(assetReference, (returnVariable) =>
            {
                _currentAddressableAsGameObject = returnVariable;
                AssetReferenceLoader.DestroyOrUnload(returnVariable);
            });

            yield return(WaitUntilAssetReferenceIsLoadedAsynchronously);

            for (var i = 0; i < maximumAmountOfObjectsInCurrentPool; i++)
            {
                var gameObjectCache = Instantiate(_currentAddressableAsGameObject);
                gameObjectCache.SetActive(false);
                objectPool.Enqueue(gameObjectCache);
            }

            _currentAddressableAsGameObject = null;

            if (PoolDictionary.ContainsKey(pool.index))
            {
                DebuggingAid.Debugging.DisplayDebugMessage("Replacing object pool " + pool.index + ". ");
                PoolDictionary.Remove(pool.index);
            }

            PoolDictionary.Add(pool.index, objectPool);
        }

        pools = null;
        callBack();
    }
Пример #9
0
 private void UnloadSelf()
 {
     AssetReferenceLoader.DestroyOrUnload(gameObject);
     Destroy(gameObject);
 }