public void OnLevelLoaded() { switchDifficultyView.OnLevelLoaded(); CytoidApplication.CurrentLevel = LoadedLevel; UpdateBestText(); var useLocalOptions = ZPlayerPrefs.GetBool(PreferenceKeys.WillOverrideOptions(CytoidApplication.CurrentLevel), false); overrideOptionsToggle.isOn = useLocalOptions; if (useLocalOptions) { localIsInversedToggle.isOn = ZPlayerPrefs.GetBool(PreferenceKeys.WillInverse(CytoidApplication.CurrentLevel), false); localUserOffsetInput.text = ZPlayerPrefs.GetFloat(PreferenceKeys.NoteDelay(CytoidApplication.CurrentLevel), PlayerPrefs.GetFloat("user_offset")).ToString(); } else { localIsInversedToggle.isOn = isInversedToggle.isOn; localUserOffsetInput.text = userOffsetInput.text; } // confirmText.text = "Are you sure you want to delete\n" + LoadedLevel.id + "?"; deleteButton.SetActive(!LoadedLevel.is_internal); PlayerPrefs.SetString("last_level", LoadedLevel.id); }
private IEnumerator OnAndroidPlayerLoaded() { if (Math.Abs(startAt) > 0.00001) { ANAMusic.seekTo(anaId, (int)(startAt * 1000)); } yield return(new WaitForSeconds(1)); ANAMusic.play(anaId); var userOffset = PlayerPrefs.GetFloat("user_offset", 0.12f); // Override options? if (ZPlayerPrefs.GetBool(PreferenceKeys.WillOverrideOptions(CytoidApplication.CurrentLevel))) { userOffset = ZPlayerPrefs.GetFloat(PreferenceKeys.NoteDelay(CytoidApplication.CurrentLevel)); } StartTime = Time.time + Chart.offset + userOffset; }
public void OnLevelLoaded() { switchDifficultyView.OnLevelLoaded(); CytoidApplication.CurrentLevel = LoadedLevel; UpdateBestText(); var useLocalOptions = ZPlayerPrefs.GetBool(PreferenceKeys.WillOverrideOptions(CytoidApplication.CurrentLevel), false); overrideOptionsToggle.isOn = useLocalOptions; localIsInversedToggle.isOn = isInversedToggle.isOn; localUserOffsetInput.text = userOffsetInput.text; if (useLocalOptions) { localIsInversedToggle.isOn = ZPlayerPrefs.GetBool(PreferenceKeys.WillInverse(CytoidApplication.CurrentLevel), false); localUserOffsetInput.text = ZPlayerPrefs.GetFloat(PreferenceKeys.NoteDelay(CytoidApplication.CurrentLevel), PlayerPrefs.GetFloat("user_offset")).ToString(); } }
private IEnumerator Start() { if (PlayerPrefs.GetInt("autoplay") == 1) { autoPlay = true; } CytoidApplication.SetAutoRotation(false); SetAllowPause(false); OnScreenChainNotes = new List <NoteView>(); OnScreenHoldNotes = new List <NoteView>(); OnScreenRegularAndHoldNotes = new List <NoteView>(); #if UNITY_EDITOR autoPlay = true; if (!string.IsNullOrEmpty(editorLevelOverride)) { CytoidApplication.CurrentLevel = CytoidApplication.Levels.Find(it => string.Equals(it.title, editorLevelOverride, StringComparison.OrdinalIgnoreCase)); CytoidApplication.CurrentChartType = editorChartTypeOverride; } // Still null? Fallback if (CytoidApplication.CurrentLevel == null) { CytoidApplication.CurrentLevel = CytoidApplication.Levels.Find(it => string.Equals(it.title, editorLevelFallback, StringComparison.OrdinalIgnoreCase)); CytoidApplication.CurrentChartType = editorChartTypeFallback; } if (Math.Abs(editorStartAtOverride - startAt) > 0.00001f) { startAt = editorStartAtOverride; } #endif var level = CytoidApplication.CurrentLevel; ThemeController.Instance.Init(level); DisplayDifficultyView.Instance.SetDifficulty(CytoidApplication.CurrentChartType, level.GetDifficulty(CytoidApplication.CurrentChartType)); titleText.text = level.title; isInversed = PlayerPrefsExt.GetBool("inverse"); // Override options? if (ZPlayerPrefs.GetBool(PreferenceKeys.WillOverrideOptions(level))) { isInversed = ZPlayerPrefs.GetBool(PreferenceKeys.WillInverse(level)); } // Chart and background are already loaded Chart = level.charts.Find(it => it.type == CytoidApplication.CurrentChartType).chart; PlayData = new PlayData(Chart); CytoidApplication.CurrentPlayData = PlayData; // Load audio clip if (level.isInternal || Application.platform != RuntimePlatform.Android) { var www = new WWW((level.isInternal && Application.platform == RuntimePlatform.Android ? "" : "file://") + level.basePath + level.GetMusicPath(CytoidApplication.CurrentChartType)); yield return(www); clip = CytoidApplication.ReadAudioClipFromWWW(www); audioSource.clip = clip; } // Don't continue until faded in backgroundOverlayMask.willFadeIn = true; while (backgroundOverlayMask.IsFading) { yield return(null); } yield return(null); // Init notes NoteViews = new OrderedDictionary(); foreach (var id in Chart.chronologicalIds) { var note = Chart.notes[id]; // if (note.time <= startAt) continue; var prefab = singleNotePrefab; switch (note.type) { case NoteType.Hold: prefab = holdNotePrefab; break; case NoteType.Chain: prefab = chainNotePrefab; break; } var noteView = Instantiate(prefab, transform).GetComponent <NoteView>(); noteView.Init(Chart, note); NoteViews.Add(id, noteView); } foreach (NoteView note in NoteViews.Values) { note.OnAllNotesInitialized(); } // Register handlers LeanTouch.OnFingerDown += OnFingerDown; LeanTouch.OnFingerSet += OnFingerSet; LeanTouch.OnFingerUp += OnFingerUp; // Release unused assets Resources.UnloadUnusedAssets(); // Init scanner Instantiate(scannerPrefab, transform); if (level.isInternal || Application.platform != RuntimePlatform.Android) { audioSource.time = startAt; var userOffset = PlayerPrefs.GetFloat("user_offset", 0.2f); // Override options? if (ZPlayerPrefs.GetBool(PreferenceKeys.WillOverrideOptions(level))) { userOffset = ZPlayerPrefs.GetFloat(PreferenceKeys.NoteDelay(level)); } const float delay = 1f; audioSource.PlayDelayed(delay); StartTime = Time.time + Chart.offset + userOffset + delay; } else { anaId = ANAMusic.load(level.basePath + level.GetMusicPath(CytoidApplication.CurrentChartType), true, true, id => { StartCoroutine(OnAndroidPlayerLoaded()); }); } }
private IEnumerator Start() { IsRanked = PlayerPrefsExt.GetBool(PreferenceKeys.RankedMode()); if (!LocalProfile.Exists()) { IsRanked = false; } if (!IsRanked) { levelInfoIndicator.transform.SetLocalX(rankedIndicator.transform.localPosition.x); rankedIndicator.SetActive(false); } if (PlayerPrefs.GetInt("autoplay") == 1 && !IsRanked) { autoPlay = true; } if (PlayerPrefsExt.GetBool("larger_hitboxes")) { hitboxMultiplier = 1.33f; } showEarlyLateIndicator = PlayerPrefsExt.GetBool("early_late_indicator"); CytoidApplication.SetAutoRotation(false); SetAllowPause(false); OnScreenChainNotes = new List <NoteView>(); OnScreenHoldNotes = new List <NoteView>(); OnScreenRegularAndHoldNotes = new List <NoteView>(); #if UNITY_EDITOR autoPlay = true; if (!string.IsNullOrEmpty(editorLevelOverride)) { CytoidApplication.CurrentLevel = CytoidApplication.Levels.Find(it => string.Equals(it.title, editorLevelOverride, StringComparison.OrdinalIgnoreCase)); CytoidApplication.CurrentChartType = editorChartTypeOverride; } // Still null? Fallback if (CytoidApplication.CurrentLevel == null) { CytoidApplication.CurrentLevel = CytoidApplication.Levels.Find(it => string.Equals(it.title, editorLevelFallback, StringComparison.OrdinalIgnoreCase)); CytoidApplication.CurrentChartType = editorChartTypeFallback; } if (Math.Abs(editorStartAtOverride - startAt) > 0.00001f) { startAt = editorStartAtOverride; } #endif var level = CytoidApplication.CurrentLevel; if (!level.ChartsLoaded) { level.LoadCharts(); } ThemeController.Instance.Init(level); DisplayDifficultyView.Instance.SetDifficulty(CytoidApplication.CurrentChartType, level.GetDifficulty(CytoidApplication.CurrentChartType)); titleText.text = level.title; isInversed = PlayerPrefsExt.GetBool("inverse"); // Override options? if (ZPlayerPrefs.GetBool(PreferenceKeys.WillOverrideOptions(level))) { isInversed = ZPlayerPrefs.GetBool(PreferenceKeys.WillInverse(level)); } // Chart and background are already loaded if (CytoidApplication.CurrentChartType == null) { CytoidApplication.CurrentChartType = level.charts[0].type; } Chart = level.charts.Find(it => it.type == CytoidApplication.CurrentChartType).chart; PlayData = new PlayData(Chart, IsRanked); CytoidApplication.CurrentPlayData = PlayData; if (IsRanked) { CytoidApplication.CurrentRankedPlayData = RankedPlayData; } // Load audio clip if (level.is_internal || Application.platform != RuntimePlatform.Android) { var www = new WWW((level.is_internal && Application.platform == RuntimePlatform.Android ? "" : "file://") + level.basePath + level.GetMusicPath(CytoidApplication.CurrentChartType)); yield return(www); clip = CytoidApplication.ReadAudioClipFromWWW(www); audioSource.clip = clip; } // Don't continue until faded in backgroundOverlayMask.willFadeIn = true; while (backgroundOverlayMask.IsFading) { yield return(null); } yield return(null); // Init notes NoteViews = new OrderedDictionary(); foreach (var id in Chart.chronologicalIds) { var note = Chart.notes[id]; // if (note.time <= startAt) continue; var prefab = singleNotePrefab; switch (note.type) { case NoteType.Hold: prefab = holdNotePrefab; break; case NoteType.Chain: prefab = chainNotePrefab; break; } var noteView = Instantiate(prefab, transform).GetComponent <NoteView>(); noteView.Init(Chart, note); NoteViews.Add(id, noteView); } foreach (NoteView note in NoteViews.Values) { note.OnAllNotesInitialized(); } // Register handlers LeanTouch.OnFingerDown += OnFingerDown; LeanTouch.OnFingerSet += OnFingerSet; LeanTouch.OnFingerUp += OnFingerUp; // Release unused assets Resources.UnloadUnusedAssets(); // Init scanner Instantiate(scannerPrefab, transform); if (level.is_internal || Application.platform != RuntimePlatform.Android) { audioSource.time = startAt; var userOffset = PlayerPrefs.GetFloat("user_offset", 0.2f); // Override options? if (ZPlayerPrefs.GetBool(PreferenceKeys.WillOverrideOptions(level))) { userOffset = ZPlayerPrefs.GetFloat(PreferenceKeys.NoteDelay(level)); } const float delay = 1f; audioSource.PlayDelayed(delay); StartTime = Time.time + Chart.offset + userOffset + delay; } else { anaId = ANAMusic.load(level.basePath + level.GetMusicPath(CytoidApplication.CurrentChartType), true, true, id => { StartCoroutine(OnAndroidPlayerLoaded()); }); } // Ranked if (!LocalProfile.Exists()) { RankedPlayData.user = "******"; RankedPlayData.password = ""; } else { RankedPlayData.user = LocalProfile.Instance.username; RankedPlayData.password = LocalProfile.Instance.password; } RankedPlayData.start = TimeExt.Millis(); RankedPlayData.id = level.id; RankedPlayData.type = CytoidApplication.CurrentChartType; RankedPlayData.mods = ""; RankedPlayData.version = level.version; RankedPlayData.chart_checksum = Chart.checksum; RankedPlayData.device.width = Screen.width; RankedPlayData.device.height = Screen.height; RankedPlayData.device.dpi = (int)Screen.dpi; RankedPlayData.device.model = SystemInfo.deviceModel; // Ranked /*#if UNITY_EDITOR * StartCoroutine(EndGame()); #endif*/ }