|
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using ArabicSupport;
- using CIG;
- using CIG.Translation;
- using Inno.DLC;
- using SUISS.Core;
- using SUISS.Promo;
- using SUISS.Storage;
- using SUISSEngine;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
-
- public class CIGLoadingScreen : MonoBehaviour
- {
- public static string SparkSocGamesApplicationId
- {
- get
- {
- return "com.sparklingsociety.cityisland3";
- }
- }
-
- public int LoadingScreenShownCount
- {
- get
- {
- return this._loadingScreenShownCount;
- }
- set
- {
- this._loadingScreenShownCount = value;
- this._serializing.Serialize();
- }
- }
-
- private void Awake()
- {
- if (!ServiceLocator.WasRegistered<IGameInterface>())
- {
- }
- }
-
- private void Start()
- {
- bool returning = CIGLoadingScreen._returningToLoadingScreen || CIGLoadingScreen._startNewGame;
- if (CIGLoadingScreen._startNewGame)
- {
- Storage.NewGame();
- CIGLoadingScreen._startNewGame = false;
- }
- CIGLoadingScreen._returningToLoadingScreen = false;
- this.InitInfoBox();
- if (SingletonMonobehaviour<CIGGameStats>.IsAvailable)
- {
- SingletonMonobehaviour<CIGGameStats>.Instance.AddScreenViewed();
- }
- base.StartCoroutine(this.BeginLoading(returning));
- FPSCounter.Create();
- }
-
- private void OnDestroy()
- {
- if (SingletonMonobehaviour<CIGGameStats>.IsAvailable)
- {
- SingletonMonobehaviour<CIGGameStats>.Instance.AddScreenViewed();
- }
- }
-
- private void Update()
- {
- if (this._loadOperation != null && this._isLoading)
- {
- float num = Mathf.Clamp01(this._loadOperation.progress / 0.9f);
- this.SetPercentage(num);
- if (Mathf.Approximately(num, 1f) && StorageController.Initialized)
- {
- this.DoneLoading();
- }
- }
- }
-
- private void OnApplicationPause(bool paused)
- {
- if (!paused)
- {
- Storage.NewSession();
- }
- }
-
- public static void MarkNewGame()
- {
- CIGLoadingScreen._startNewGame = true;
- }
-
- public static void MarkReturnToLoadingScreen()
- {
- CIGLoadingScreen._returningToLoadingScreen = true;
- }
-
- private void InitInfoBox()
- {
- Dictionary<string, object> root = Storage.Get(StorageLifecycle.Player).Root;
- if (root.ContainsKey("userKey"))
- {
- this._userKey = (string)root["userKey"];
- this._friendCodeLabel.LocalizedString = Localization.Format("{0} {1}", new ILocalizedString[]
- {
- Localization.Key("social_your_friendcode"),
- Localization.Literal(this._userKey)
- });
- }
- else
- {
- this._userKey = null;
- this._friendCodeLabel.LocalizedString = Localization.EmptyLocalizedString;
- }
- this._versionLabel.LocalizedString = Localization.Format(Localization.Key("your_game_version"), new ILocalizedString[]
- {
- Localization.Literal(NativeGameVersion.Version)
- });
- }
-
-
- private IEnumerator BeginLoading(bool returning)
- {
- this._isLoading = true;
- this.SetPercentage(0f);
- this._playButton.interactable = false;
- yield return new WaitForSeconds(0.1f);
- if (!returning && !ServiceLocator.WasRegistered<DLCManager>())
- {
- ServiceLocator.RegistorServiceObject<DLCManager>(new DLCManager("dlc.properties"));
- }
- this._loadOperation = SceneManager.LoadSceneAsync("Game");
- this._loadOperation.allowSceneActivation = false;
- yield break;
- }
-
- private void DoneLoading()
- {
- this._isLoading = false;
- this._playButtonLabel.LocalizedString = Localization.Key("play");
- this._playButton.interactable = true;
- }
-
- private IEnumerator Proceed()
- {
- yield return new WaitForSeconds(0.1f);
- if (this._loadOperation != null)
- {
- this._loadOperation.allowSceneActivation = true;
- }
- yield break;
- }
-
- private void SetPercentage(float percentage)
- {
- this._playButtonLabel.LocalizedString = Localization.Percentage(percentage, 0);
- }
-
- public void OnPlayClicked()
- {
- if (this._isLoading)
- {
- return;
- }
- this._playButton.gameObject.SetActive(false);
- this._synchronizingObject.gameObject.SetActive(true);
- base.StartCoroutine(this.Proceed());
- }
-
- public void OnFacebookClicked()
- {
- Application.OpenURL(SingletonMonobehaviour<CIGGameConstants>.Instance.FacebookUrl);
- }
-
- public void OnTwitterClicked()
- {
- Application.OpenURL(SingletonMonobehaviour<CIGGameConstants>.Instance.TwitterUrl);
- }
-
- public void OnInstagramClicked()
- {
- Application.OpenURL(SingletonMonobehaviour<CIGGameConstants>.Instance.InstagramUrl);
- }
-
- public void OnSSClicked()
- {
- Application.OpenURL(SingletonMonobehaviour<CIGGameConstants>.Instance.SparklingSocietyUrl);
- }
-
- public void OnTermsOfServiceClicked()
- {
- Application.OpenURL(SingletonMonobehaviour<CIGGameConstants>.Instance.TermsOfServiceUrl);
- }
-
- public void OnPrivacyPolicyClicked()
- {
- Application.OpenURL(SingletonMonobehaviour<CIGGameConstants>.Instance.PrivacyPolicyUrl);
- }
-
- protected void OnSerialize(Dictionary<string, object> values)
- {
- values["LoadingSceenShowCount"] = this._loadingScreenShownCount;
- }
-
- protected void OnDeserialize(Dictionary<string, object> values)
- {
- if (values.ContainsKey("LoadingSceenShowCount"))
- {
- this._loadingScreenShownCount = (int)values["LoadingSceenShowCount"];
- }
- else
- {
- this._loadingScreenShownCount = 0;
- }
- }
-
- private void OnDeserialized()
- {
- InstallVersion.Initialise(this.LoadingScreenShownCount == 0);
- this.LoadingScreenShownCount++;
- }
-
- private const string LoadingScreenShowCountKey = "LoadingSceenShowCount";
-
- [SerializeField]
- private LocalizedText _friendCodeLabel;
-
- [SerializeField]
- private LocalizedText _versionLabel;
-
- [SerializeField]
- private Button _playButton;
-
- [SerializeField]
- private LocalizedText _playButtonLabel;
-
- [SerializeField]
- private GameObject _synchronizingObject;
-
- [SerializeField]
- private Serializing _serializing;
-
- [SerializeField]
- private ScriptableObject[] _settingResources;
-
- [SerializeField]
- private LoadingScreenController _crossSellPrefab;
-
- private static bool _startNewGame;
-
- private static bool _returningToLoadingScreen;
-
- private string _userKey;
-
- private AsyncOperation _loadOperation;
-
- private bool _isLoading;
-
- private int _loadingScreenShownCount;
- }
|