void Awake() { enabled = false; if (instance == null) { Application.targetFrameRate = 300; instance = this; setBounds(); enemyMask = LayerMask.GetMask("Enemy"); #if UNITY_ANDROID activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic <AndroidJavaObject>("currentActivity"); toast = new Toast(); prefs = new SecurePreferences(activity, "resonance.spaceincharge"); #else prefs = new SecurePreferences(); #endif points = prefs.readInt(PREF_POINTS, PREF_POINTS_DEFAULT); setLevels(); setFeatures(); DontDestroyOnLoad(gameObject); } else { instance.mainCamera = Camera.main; instance.cameraShake = instance.mainCamera.GetComponent <CameraShake>(); DestroyImmediate(gameObject); } }
private void setLevels() { GOLDS = 0; CURRENT_LEVEL = prefs.readInt(PREF_CURRENT_LEVEL, PREF_CURRENT_LEVEL_DEFAULT); string[] levels_string = prefs.readString(PREF_LEVELS, PREF_LEVELS_DEFAULT).Split(','); int length = levels_string.Length; for (int i = 0; i < length; i++) { int level_status = int.Parse(levels_string[i]); if (level_status == 0) { break; } LEVELS_STATUS[i] = level_status; GOLDS += level_status - 1; } }
void Awake() { enabled = false; if (instance == null) { Application.targetFrameRate = 300; instance = this; setBounds(); enemyMask = LayerMask.GetMask("Enemy"); #if UNITY_ANDROID activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity"); toast = new Toast(); prefs = new SecurePreferences(activity, "resonance.spaceincharge"); #else prefs = new SecurePreferences(); #endif points = prefs.readInt(PREF_POINTS, PREF_POINTS_DEFAULT); setLevels(); setFeatures(); DontDestroyOnLoad(gameObject); } else { instance.mainCamera = Camera.main; instance.cameraShake = instance.mainCamera.GetComponent<CameraShake>(); DestroyImmediate(gameObject); } }