您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

266 行
7.1 KiB

  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using ArabicSupport;
  5. using CIG;
  6. using CIG.Translation;
  7. using Inno.DLC;
  8. using SUISS.Core;
  9. using SUISS.Promo;
  10. using SUISS.Storage;
  11. using SUISSEngine;
  12. using UnityEngine;
  13. using UnityEngine.SceneManagement;
  14. using UnityEngine.UI;
  15. public class CIGLoadingScreen : MonoBehaviour
  16. {
  17. public static string SparkSocGamesApplicationId
  18. {
  19. get
  20. {
  21. return "com.sparklingsociety.cityisland3";
  22. }
  23. }
  24. public int LoadingScreenShownCount
  25. {
  26. get
  27. {
  28. return this._loadingScreenShownCount;
  29. }
  30. set
  31. {
  32. this._loadingScreenShownCount = value;
  33. this._serializing.Serialize();
  34. }
  35. }
  36. private void Awake()
  37. {
  38. if (!ServiceLocator.WasRegistered<IGameInterface>())
  39. {
  40. }
  41. }
  42. private void Start()
  43. {
  44. bool returning = CIGLoadingScreen._returningToLoadingScreen || CIGLoadingScreen._startNewGame;
  45. if (CIGLoadingScreen._startNewGame)
  46. {
  47. Storage.NewGame();
  48. CIGLoadingScreen._startNewGame = false;
  49. }
  50. CIGLoadingScreen._returningToLoadingScreen = false;
  51. this.InitInfoBox();
  52. if (SingletonMonobehaviour<CIGGameStats>.IsAvailable)
  53. {
  54. SingletonMonobehaviour<CIGGameStats>.Instance.AddScreenViewed();
  55. }
  56. base.StartCoroutine(this.BeginLoading(returning));
  57. FPSCounter.Create();
  58. }
  59. private void OnDestroy()
  60. {
  61. if (SingletonMonobehaviour<CIGGameStats>.IsAvailable)
  62. {
  63. SingletonMonobehaviour<CIGGameStats>.Instance.AddScreenViewed();
  64. }
  65. }
  66. private void Update()
  67. {
  68. if (this._loadOperation != null && this._isLoading)
  69. {
  70. float num = Mathf.Clamp01(this._loadOperation.progress / 0.9f);
  71. this.SetPercentage(num);
  72. if (Mathf.Approximately(num, 1f) && StorageController.Initialized)
  73. {
  74. this.DoneLoading();
  75. }
  76. }
  77. }
  78. private void OnApplicationPause(bool paused)
  79. {
  80. if (!paused)
  81. {
  82. Storage.NewSession();
  83. }
  84. }
  85. public static void MarkNewGame()
  86. {
  87. CIGLoadingScreen._startNewGame = true;
  88. }
  89. public static void MarkReturnToLoadingScreen()
  90. {
  91. CIGLoadingScreen._returningToLoadingScreen = true;
  92. }
  93. private void InitInfoBox()
  94. {
  95. Dictionary<string, object> root = Storage.Get(StorageLifecycle.Player).Root;
  96. if (root.ContainsKey("userKey"))
  97. {
  98. this._userKey = (string)root["userKey"];
  99. this._friendCodeLabel.LocalizedString = Localization.Format("{0} {1}", new ILocalizedString[]
  100. {
  101. Localization.Key("social_your_friendcode"),
  102. Localization.Literal(this._userKey)
  103. });
  104. }
  105. else
  106. {
  107. this._userKey = null;
  108. this._friendCodeLabel.LocalizedString = Localization.EmptyLocalizedString;
  109. }
  110. this._versionLabel.LocalizedString = Localization.Format(Localization.Key("your_game_version"), new ILocalizedString[]
  111. {
  112. Localization.Literal(NativeGameVersion.Version)
  113. });
  114. }
  115. private IEnumerator BeginLoading(bool returning)
  116. {
  117. this._isLoading = true;
  118. this.SetPercentage(0f);
  119. this._playButton.interactable = false;
  120. yield return new WaitForSeconds(0.1f);
  121. if (!returning && !ServiceLocator.WasRegistered<DLCManager>())
  122. {
  123. ServiceLocator.RegistorServiceObject<DLCManager>(new DLCManager("dlc.properties"));
  124. }
  125. this._loadOperation = SceneManager.LoadSceneAsync("Game");
  126. this._loadOperation.allowSceneActivation = false;
  127. yield break;
  128. }
  129. private void DoneLoading()
  130. {
  131. this._isLoading = false;
  132. this._playButtonLabel.LocalizedString = Localization.Key("play");
  133. this._playButton.interactable = true;
  134. }
  135. private IEnumerator Proceed()
  136. {
  137. yield return new WaitForSeconds(0.1f);
  138. if (this._loadOperation != null)
  139. {
  140. this._loadOperation.allowSceneActivation = true;
  141. }
  142. yield break;
  143. }
  144. private void SetPercentage(float percentage)
  145. {
  146. this._playButtonLabel.LocalizedString = Localization.Percentage(percentage, 0);
  147. }
  148. public void OnPlayClicked()
  149. {
  150. if (this._isLoading)
  151. {
  152. return;
  153. }
  154. this._playButton.gameObject.SetActive(false);
  155. this._synchronizingObject.gameObject.SetActive(true);
  156. base.StartCoroutine(this.Proceed());
  157. }
  158. public void OnFacebookClicked()
  159. {
  160. Application.OpenURL(SingletonMonobehaviour<CIGGameConstants>.Instance.FacebookUrl);
  161. }
  162. public void OnTwitterClicked()
  163. {
  164. Application.OpenURL(SingletonMonobehaviour<CIGGameConstants>.Instance.TwitterUrl);
  165. }
  166. public void OnInstagramClicked()
  167. {
  168. Application.OpenURL(SingletonMonobehaviour<CIGGameConstants>.Instance.InstagramUrl);
  169. }
  170. public void OnSSClicked()
  171. {
  172. Application.OpenURL(SingletonMonobehaviour<CIGGameConstants>.Instance.SparklingSocietyUrl);
  173. }
  174. public void OnTermsOfServiceClicked()
  175. {
  176. Application.OpenURL(SingletonMonobehaviour<CIGGameConstants>.Instance.TermsOfServiceUrl);
  177. }
  178. public void OnPrivacyPolicyClicked()
  179. {
  180. Application.OpenURL(SingletonMonobehaviour<CIGGameConstants>.Instance.PrivacyPolicyUrl);
  181. }
  182. protected void OnSerialize(Dictionary<string, object> values)
  183. {
  184. values["LoadingSceenShowCount"] = this._loadingScreenShownCount;
  185. }
  186. protected void OnDeserialize(Dictionary<string, object> values)
  187. {
  188. if (values.ContainsKey("LoadingSceenShowCount"))
  189. {
  190. this._loadingScreenShownCount = (int)values["LoadingSceenShowCount"];
  191. }
  192. else
  193. {
  194. this._loadingScreenShownCount = 0;
  195. }
  196. }
  197. private void OnDeserialized()
  198. {
  199. InstallVersion.Initialise(this.LoadingScreenShownCount == 0);
  200. this.LoadingScreenShownCount++;
  201. }
  202. private const string LoadingScreenShowCountKey = "LoadingSceenShowCount";
  203. [SerializeField]
  204. private LocalizedText _friendCodeLabel;
  205. [SerializeField]
  206. private LocalizedText _versionLabel;
  207. [SerializeField]
  208. private Button _playButton;
  209. [SerializeField]
  210. private LocalizedText _playButtonLabel;
  211. [SerializeField]
  212. private GameObject _synchronizingObject;
  213. [SerializeField]
  214. private Serializing _serializing;
  215. [SerializeField]
  216. private ScriptableObject[] _settingResources;
  217. [SerializeField]
  218. private LoadingScreenController _crossSellPrefab;
  219. private static bool _startNewGame;
  220. private static bool _returningToLoadingScreen;
  221. private string _userKey;
  222. private AsyncOperation _loadOperation;
  223. private bool _isLoading;
  224. private int _loadingScreenShownCount;
  225. }