context: using UnityEngine;
  using System.Collections;
  using Frontiers;
  using System.Collections.Generic;
  using System;
  
  namespace Frontiers.GUI
  {
  		public class GUILoading : MonoBehaviour
  		{
  				public static void Lock(System.Object lockObject)
  				{
  						LockObject = lockObject;
  				}
  
  				public static void Unlock(System.Object lockObject)
  				{
  						if (lockObject == LockObject) {
  								LockObject = null;
  						}
  				}
  
  				public static System.Object LockObject;
  
  				public static bool IsLocked {
  						get {
  								return LockObject != null;
  						}
  				}
  
  				public static bool IsLoading = false;
  				public static GUILoading Get;
  				public static bool SplashScreen = false;
  				public static Mode CurrentMode = Mode.SmallInGame;
  				public static float BackgroundSpriteAlphaMultiplier = 0.5f;
  				public UISprite SplashScreenSprite;
  				public UISprite BackgroundSprite;
  				public UISprite BackgroundOverlaySprite;
  				public float SplashScreenInterval = 0.25f;
  				public Camera LoadingCamera;
  				public GameObject LoadingCompass;
  				public UIRoot Root;
  				public UIPanel LoadingCompassPanel;
  				public UIPanel LoadingCompassArrowPanel;
  				public UILabel DetailsInfoLabel;
  				public UILabel ActivityInfoLabel;
  				public UILabel ErrorMessage;
  				public UILabel QuitMessage;
  				public UIAnchor LoadingAnchor;
  				public GameObject LoadingCompassBig;
  				public UIPanel LoadingCompassPanelBig;
  				public UIPanel LoadingCompassArrowPanelBig;
  				public UILabel DetailsInfoLabelBig;
  				public UILabel ActivityInfoLabelBig;
  				public UILabel ErrorMessageBig;
  				public UILabel QuitMessageBig;
  				public UIAnchor LoadingAnchorBig;
  				public GameObject LoadingCompassLittle;
  				public UIPanel LoadingCompassPanelLittle;
  				public UIPanel LoadingCompassArrowPanelLitte;
  				public UILabel DetailsInfoLabelLittle;
  				public UILabel ActivityInfoLabelLittle;
  				public UILabel ErrorMessageLittle;
  				public UILabel QuitMessageLittle;
  				public UIAnchor LoadingAnchorLittle;
  				public UILabel QuoteText;
  				public GameObject CharacterObject;
  				public Light CharacterLight;
  				public List <CharacterQuote> CharacterQuotes = new List <CharacterQuote>();
  
  				public void SetLittleCompass(bool littleCompass)
  				{
  						if (littleCompass) {
  								LoadingCompass = LoadingCompassLittle;
  								LoadingCompassPanel = LoadingCompassPanelLittle;
  								DetailsInfoLabel = DetailsInfoLabelLittle;
  								ActivityInfoLabel = ActivityInfoLabelLittle;
  								ErrorMessage = ErrorMessageLittle;
  								QuitMessage = QuitMessageLittle;
  								LoadingAnchor = LoadingAnchorLittle;
  								LoadingCompassArrowPanel = LoadingCompassArrowPanelLitte;
  
  								LoadingCompassPanelBig.enabled = false;
  								LoadingCompassPanelLittle.enabled = true;
  						} else {
  								LoadingCompass = LoadingCompassBig;
  								LoadingCompassPanel = LoadingCompassPanelBig;
  								DetailsInfoLabel = DetailsInfoLabelBig;
  								ActivityInfoLabel = ActivityInfoLabelBig;
  								ErrorMessage = ErrorMessageBig;
  								QuitMessage = QuitMessageBig;
  								LoadingAnchor = LoadingAnchorBig;
  								LoadingCompassArrowPanel = LoadingCompassArrowPanelBig;
  
  								LoadingCompassPanelBig.enabled = true;
  								LoadingCompassPanelLittle.enabled = false;
  						}
  						LoadingCompassArrowPanel.enabled = false;
  
  				}
  
  				public static string ActivityInfo {
  						get {
  								return Get.ActivityInfoLabel.text;
  						}
  						set {
  								Get.ActivityInfoLabel.text = value;
  								if (!Get.ActivityInfoLabel.enabled) {
  										Get.ActivityInfoLabel.enabled = true;
  								}
  						}
  				}
  
  				public static string DetailsInfo {
  						get {
  								return Get.DetailsInfoLabel.text;
  						}
  						set {
  								Get.DetailsInfoLabel.text = value;
  								if (!Get.DetailsInfoLabel.enabled) {
  										Get.DetailsInfoLabel.enabled = true;
  								}
  						}
  				}
  
  				public void Awake()
  				{
  						Initialize();
  				}
  
  				public void Initialize()
  				{
  						if (mInitialized)
  								return;
  
  						HideCharacterQuote();
  
  						DontDestroyOnLoad(transform);
  
  						Get = this;
  						Get.LoadingCamera.enabled = true;
  
  						SetLittleCompass(true);
  
  						ActivityInfo = "Loading";
  						DetailsInfo = string.Empty;
  						QuitMessage.enabled = false;
  						ErrorMessage.enabled = false;
  						SplashScreen = false;
  						//SplashScreenSprite.enabled	= false;
  						LoadingCompass.gameObject.SetActive(false);
  
  						SetLittleCompass(false);
  
  						ActivityInfo = "Loading";
  						DetailsInfo = string.Empty;
  						QuitMessage.enabled = false;
  						ErrorMessage.enabled = false;
  						SplashScreen = false;
  						//SplashScreenSprite.enabled	= false;
  						LoadingCompass.gameObject.SetActive(false);
  
  						mInitialized = true;
  				}
  
  				protected static bool mInitialized = false;
  
  				public void Start()
  				{
  						if (GameManager.Get.TestingEnvironment) {
  								SplashScreen = false;
  						} else {
  								StartCoroutine(SplashScreenOverTime());
  						}
  				}
  
  				public IEnumerator SplashScreenOverTime()
  				{
  						yield break;
  						//TEMP - killing this to save memory
  						/*BackgroundSprite.alpha = 1.0f;
  			BackgroundSprite.enabled = true;
  			//fade in...
  			SplashScreen = true;
  			SplashScreenSprite.alpha = 0f;
  			SplashScreenSprite.enabled	= true;
  			SplashScreenSprite.animation.Play ("LogoFadeIn");
  			while (SplashScreenSprite.animation ["LogoFadeIn"].normalizedTime < 1f) {	//Debug.Log ("Fading in..." + SplashScreenSprite.animation ["LogoFadeIn"].normalizedTime);
  				yield return null;
  			}
  			//stay...
  			yield return new WaitForSeconds (SplashScreenInterval);
  			//fade out...
  			SplashScreenSprite.animation.Play ("LogoFadeOut");
  			while (SplashScreenSprite.animation ["LogoFadeOut"].normalizedTime < 1f) {	//Debug.Log ("Fading out..." + SplashScreenSprite.animation ["LogoFadeOut"].normalizedTime);
  				yield return null;
  			}
  			SplashScreenSprite.alpha = 0f;
  			SplashScreenSprite.enabled	= false;
  			SplashScreen = false;*/
  				}
  
  				public static void DisplayError(string errorMessage)
  				{
  						Get.ErrorMessage.enabled = true;
  						Get.ErrorMessage.text = errorMessage;
  						Get.QuitMessage.enabled = true;
  				}
  
  				public static IEnumerator LoadStart(Mode mode, bool startBlack)
  				{
  						CurrentMode = mode;
  
  						if (!mInitialized) {
  								GameObject guiLoading = GameObject.Find("=LOADING=");
  								Get = guiLoading.GetComponent <GUILoading>();
  								Get.Initialize();
  						}
  
  						Get.LoadingCamera.enabled = true;
  						float backgroundAlphaTarget = 0f;
  						//Debug.Log ("GUILOAING: LoadStart");
  						if (IsLoading) {
  								return Get.BreakImmediately();
  						} else {
  								switch (mode) {
  										case Mode.SmallInGame:
  										default:
  												Get.SetLittleCompass(true);
  												Get.BackgroundSprite.enabled = false;
  												Get.BackgroundOverlaySprite.enabled = false;
  												Get.LoadingAnchor.side = UIAnchor.Side.Center;
  												break;
  
  										case Mode.FullScreenBlack:
  												Get.SetLittleCompass(false);
  												backgroundAlphaTarget = 1.0f;
  												Get.DisplayRandomCharacterQuote();
  												if (GameManager.Is(FGameState.Startup) || startBlack) {
  														Get.BackgroundSprite.alpha = 1f;
  														Get.BackgroundOverlaySprite.alpha = BackgroundSpriteAlphaMultiplier;
  												} else {
  														Get.BackgroundSprite.alpha = 0f;
  														Get.BackgroundOverlaySprite.alpha = 0f;
  												}
  												Get.QuoteText.alpha = Get.BackgroundSprite.alpha;
  
  												#if UNITY_EDITOR
  												if (VRManager.VRMode | VRManager.VRTestingMode) {
  												#else
  												if (VRManager.VRMode) {
  												#endif
  														Get.QuoteText.enabled = false;
  														Get.BackgroundSprite.enabled = false;
  														Get.BackgroundOverlaySprite.enabled = false;
  														//we don't use the sprite in VR mode
  														//we just set the background to black
  														Get.LoadingCamera.clearFlags = CameraClearFlags.SolidColor;
  														Get.LoadingCamera.backgroundColor = Color.black;
  														Get.LoadingAnchor.side = UIAnchor.Side.Bottom;
  														Get.LoadingCompass.transform.localPosition = new Vector3 (0f, 350f, 0f);
  												} else {
  														Get.QuoteText.enabled = true;
  														Get.BackgroundSprite.enabled = true;
  														Get.BackgroundOverlaySprite.enabled = true;
  														Get.LoadingCamera.clearFlags = CameraClearFlags.Depth;
  														Get.LoadingAnchor.side = UIAnchor.Side.BottomLeft;
  														Get.LoadingCompass.transform.localPosition = new Vector3 (200f, 350f, 0f);
  												}
  												break;
  								}
  								return Get.LoadStartOverTime(backgroundAlphaTarget);
  						}
  				}
  
  				public static IEnumerator LoadStart(Mode mode)
  				{
  						CurrentMode = mode;
  
  						if (!mInitialized) {
  								GameObject guiLoading = GameObject.Find("=LOADING=");
  								Get = guiLoading.GetComponent <GUILoading>();
  								Get.Initialize();
  						}
  						Get.LoadingCamera.enabled = true;
  						float backgroundAlphaTarget = 0f;
  						//Debug.Log ("GUILOAING: LoadStart");
  						if (IsLoading) {
  								return Get.BreakImmediately();
  						} else {
  								switch (mode) {
  										case Mode.SmallInGame:
  										default:
  												Get.SetLittleCompass(true);
  												Get.BackgroundSprite.enabled = false;
  												Get.BackgroundOverlaySprite.enabled = false;
  												Get.LoadingAnchor.side = UIAnchor.Side.Center;
  												break;
  
  										case Mode.FullScreenBlack:
  												Get.SetLittleCompass(false);
  												backgroundAlphaTarget = 1.0f;
  												Get.DisplayRandomCharacterQuote();
  												if (GameManager.Is(FGameState.Startup)) {
  														Get.BackgroundSprite.alpha = 1f;
  														Get.BackgroundOverlaySprite.alpha = BackgroundSpriteAlphaMultiplier;
  												} else {
  														Get.BackgroundSprite.alpha = 0f;
  														Get.BackgroundOverlaySprite.alpha = 0f;
  												}
  												Get.QuoteText.alpha = Get.BackgroundSprite.alpha;
  
  												#if UNITY_EDITOR
  												if (VRManager.VRMode | VRManager.VRTestingMode) {
  												#else
  
gt: 												if (VRManager.VRMode) {