Пример #1
0
        public void DoGameSceneActions()
        {
            if (!Current.IsLoaded)
            {
                Current.Load();
            }

            if (!string.IsNullOrEmpty(Current.Error))
            {
                Debug.LogError(GameLoadErrorMessage + Current.Error);
            }
            else
            {
                PlayerPrefs.SetString(PlayerPrefGameName, Current.Name);
            }

            if (BackgroundImage != null)
            {
                BackgroundImage.sprite = Current.BackgroundImageSprite;
            }
            CardInfoViewer.Instance?.ResetInfo();

            for (int i = OnSceneActions.Count - 1; i >= 0; i--)
            {
                if (OnSceneActions[i] == null)
                {
                    OnSceneActions.RemoveAt(i);
                }
            }
            foreach (UnityAction action in OnSceneActions)
            {
                action();
            }
        }
        private void ResetGameScene()
        {
            if (!Current.HasLoaded)
            {
                Current.Load(UpdateCardGame, LoadCards, LoadSetCards);
                if (Current.IsDownloading)
                {
                    return;
                }
            }

            if (!string.IsNullOrEmpty(Current.Error))
            {
                Debug.LogError(LoadErrorMessage + Current.Error);
                Messenger.Ask(LoadErrorPrompt, IgnoreCurrentErroredGame, Delete);
                return;
            }

#if UNITY_WEBGL
            foreach (UnityCardGame game in AllCardGames.Values)
            {
                game.ReadProperties();
            }
#endif

            // Now is the safest time to set this game as the preferred default game for the player
            PlayerPrefs.SetString(PlayerPrefDefaultGame, Current.Id);

            // Each scene is responsible for adding to OnSceneActions, but they may not remove
            OnSceneActions.RemoveWhere((action) => action == null);
            foreach (UnityAction action in OnSceneActions)
            {
                action();
            }
        }
Пример #3
0
 void OnSceneUnloaded(Scene scene)
 {
     OnSceneActions.Clear();
 }