private void Start() { CytoidApplication.RefreshCurrentLevel(); RefreshLevels(); StartCoroutine(DetectNotInstalledLevels()); Login(true); }
public IEnumerator LoadMusicPreview(Level level) { // Load preview var www = new WWW((level.is_internal && Application.platform == RuntimePlatform.Android ? "" : "file://") + level.basePath + level.music_preview.path); yield return(www); while (alphaMask.IsFading) { yield return(null); } yield return(null); // Wait an extra frame var clip = CytoidApplication.ReadAudioClipFromWWW(www); if (clip == null) { yield break; } audioSource.clip = clip; audioSource.loop = true; audioSource.Play(); www.Dispose(); OnLevelLoaded(); }
private IEnumerator Start() { CytoidApplication.RefreshCurrentLevel(); RefreshLevels(); Login(true); StartCoroutine(LoadAvatarCoroutine()); yield return(null); // Wait for one frame StartCoroutine(DetectNotInstalledLevels()); }
public void DeleteCurrentLevel() { //DontDestroyOnLoad(GameObject.FindGameObjectWithTag("UIManager")); CytoidApplication.DeleteLevel(CytoidApplication.CurrentLevel); }
protected override void Awake() { base.Awake(); CytoidApplication.SetAutoRotation(true); CytoidApplication.ResetResolution(); var ringColorDef = "#FFFFFF"; var ringColorAltDef = "#FFFFFF"; var fillColorDef = "#6699CC"; var fillColorAltDef = "#FF3C38"; SetDefaultPref("main offset", Application.platform == RuntimePlatform.Android ? 0f : 0.1f); SetDefaultPref("headset offset", -0.05f); SetDefaultPref("show_scanner", true); SetDefaultPref("inverse", false); SetDefaultPref("ring_color", ringColorDef); SetDefaultPref("ring_color_alt", ringColorAltDef); SetDefaultPref("fill_color", fillColorDef); SetDefaultPref("fill_color_alt", fillColorAltDef); SetDefaultPref("hit_sound", "None"); var list = HitSounds.ToList(); list.Insert(0, new HitSound { Name = "None" }); HitSounds = list.ToArray(); UpdateHitSound(HitSounds[1], save: false); var userHitSound = PlayerPrefs.GetString("hit_sound"); for (var index = 0; index < HitSounds.Length; index++) { if (HitSounds[index].Name == userHitSound) { UpdateHitSound(HitSounds[index]); HitSoundIndex = index; } } mainOffsetInput.text = PlayerPrefs.GetFloat("main offset").ToString(); headsetOffsetInput.text = PlayerPrefs.GetFloat("headset offset").ToString(); earlyLateIndicatorToggle.isOn = PlayerPrefsExt.GetBool("early_late_indicator"); largerHitboxesToggle.isOn = PlayerPrefsExt.GetBool("larger_hitboxes"); mainOffsetInput.onEndEdit.AddListener(text => { float offset; if (!float.TryParse(text, out offset)) { mainOffsetInput.text = PlayerPrefs.GetFloat("main offset").ToString(); } else { PlayerPrefs.SetFloat("main offset", offset); } }); chartRelativeOffsetInput.onEndEdit.AddListener(text => { float offset; if (!float.TryParse(text, out offset)) { chartRelativeOffsetInput.text = ZPlayerPrefs.GetFloat(PreferenceKeys.ChartRelativeOffset(CytoidApplication.CurrentLevel.id)).ToString(); } else { ZPlayerPrefs.SetFloat(PreferenceKeys.ChartRelativeOffset(CytoidApplication.CurrentLevel.id), offset); } }); headsetOffsetInput.onEndEdit.AddListener(text => { float offset; if (!float.TryParse(text, out offset)) { headsetOffsetInput.text = PlayerPrefs.GetFloat("headset offset").ToString(); } else { PlayerPrefs.SetFloat("headset offset", offset); } }); usernameInput.text = PlayerPrefs.GetString(PreferenceKeys.LastUsername()); passwordInput.text = PlayerPrefs.GetString(PreferenceKeys.LastPassword()); if (!PlayerPrefs.HasKey("ranked")) { PlayerPrefsExt.SetBool("ranked", false); } rankStatusText.text = OnlinePlayer.Authenticated && PlayerPrefsExt.GetBool("ranked") ? "On" : "Off"; // Initialize background blackout.SetActive(false); var backgrounds = GameObject.FindGameObjectsWithTag("Background"); if (backgrounds.Length > 1) // Already have persisted background? (i.e. returning from Game/GameResult scene) { var localBackground = backgrounds.ToList().Find(it => it.scene == gameObject.scene); // Destroy local background Destroy(localBackground); // Setup the persisted background BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); } else // Setup the local background { BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); } if (OnlinePlayer.Authenticated && OnlinePlayer.AvatarTexture != null) { LoadedAvatar = true; } if (Application.platform == RuntimePlatform.Android) { headsetOffsetInput.gameObject.SetActive(false); LayoutRebuilder.ForceRebuildLayoutImmediate(headsetOffsetInput.transform.parent.GetComponent <RectTransform>()); } EventKit.Subscribe <string>("meta reloaded", OnLevelMetaReloaded); }
protected virtual IEnumerator Start() { // Load level if (CytoidApplication.CurrentLevel != null) { Level = CytoidApplication.CurrentLevel; } else { Level = JsonConvert.DeserializeObject <Level>( File.ReadAllText(Application.persistentDataPath + "/player/level.json")); Level.BasePath = Application.persistentDataPath + "/player/"; CytoidApplication.CurrentChartType = Level.charts[0].type; var www = new WWW("file://" + Level.BasePath + Level.background.path); yield return(www); yield return(null); // Wait an extra frame www.LoadImageIntoTexture(CytoidApplication.BackgroundTexture); var backgroundSprite = Sprite.Create(CytoidApplication.BackgroundTexture, new Rect(0, 0, CytoidApplication.BackgroundTexture.width, CytoidApplication.BackgroundTexture.height), new Vector2(0, 0)); var background = GameObject.FindGameObjectWithTag("Background"); if (background != null) { background.GetComponent <Image>().sprite = backgroundSprite; // Fill the screen by adapting to the aspect ratio background.GetComponent <AspectRatioFitter>().aspectRatio = (float)CytoidApplication.BackgroundTexture.width / CytoidApplication.BackgroundTexture.height; yield return(null); // Wait an extra frame } www.Dispose(); Resources.UnloadUnusedAssets(); CytoidApplication.CurrentLevel = Level; } // System settings CytoidApplication.SetAutoRotation(false); if (Application.platform == RuntimePlatform.Android && !Level.IsInternal) { print("Using Android Native Audio"); GameOptions.Instance.UseAndroidNativeAudio = true; } // Load chart print("Loading chart"); if (CytoidApplication.CurrentChartType == null) { CytoidApplication.CurrentChartType = Level.charts[0].type; } var chartSection = Level.charts.Find(it => it.type == CytoidApplication.CurrentChartType); string chartText; if (Application.platform == RuntimePlatform.Android && Level.IsInternal) { var chartWww = new WWW(Level.BasePath + chartSection.path); yield return(chartWww); chartText = Encoding.UTF8.GetString(chartWww.bytes); } else { chartText = File.ReadAllText(Level.BasePath + chartSection.path, Encoding.UTF8); } Chart = new Chart( chartText, 0.8f + (5 - (int)PlayerPrefs.GetFloat("horizontal margin", 3) - 1) * 0.025f, (5.5f + (5 - (int)PlayerPrefs.GetFloat("vertical margin", 3)) * 0.5f) / 9.0f ); // Load audio print("Loading audio"); var audioPath = Level.BasePath + Level.GetMusicPath(CytoidApplication.CurrentChartType); if (GameOptions.Instance.UseAndroidNativeAudio) { NativeAudioId = ANAMusic.load(audioPath, true); Length = ANAMusic.getDuration(NativeAudioId); } else { var www = new WWW( (Level.IsInternal && Application.platform == RuntimePlatform.Android ? "" : "file://") + audioPath); yield return(www); AudioSource.clip = www.GetAudioClip(); Length = AudioSource.clip.length; www.Dispose(); } // Game options var options = GameOptions.Instance; options.HitboxMultiplier = PlayerPrefsExt.GetBool("larger_hitboxes") ? 1.5555f : 1.3333f; options.ShowEarlyLateIndicator = PlayerPrefsExt.GetBool("early_late_indicator"); options.ChartOffset = PlayerPrefs.GetFloat("main offset", 0); options.ChartOffset += ZPlayerPrefs.GetFloat(PreferenceKeys.ChartRelativeOffset(Level.id), 0); if (Application.platform != RuntimePlatform.Android && Headset.Detect()) { options.ChartOffset += ZPlayerPrefs.GetFloat("headset offset"); } if (CytoidApplication.CurrentHitSound.Name != "None") { #if (UNITY_IOS || UNITY_ANDROID) && !UNITY_EDITOR options.HitSound = NativeAudio.Load("Hits/" + CytoidApplication.CurrentHitSound.Name + ".wav"); #endif } Play.Init(Chart); print("Chart checksum: " + Chart.Checksum); // Rank data if (Play.IsRanked) { RankedPlayData = new RankedPlayData(); RankedPlayData.user = OnlinePlayer.Name; RankedPlayData.password = OnlinePlayer.Password; RankedPlayData.start = TimeExt.Millis(); RankedPlayData.id = Level.id; RankedPlayData.type = CytoidApplication.CurrentChartType; RankedPlayData.mods = string.Join(",", Array.ConvertAll(Play.Mods.ToArray(), mod => mod.ToString())); 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; CytoidApplication.CurrentRankedPlayData = RankedPlayData; CytoidApplication.CurrentUnrankedPlayData = null; } else { UnrankedPlayData = new UnrankedPlayData(); UnrankedPlayData.user = OnlinePlayer.Authenticated ? OnlinePlayer.Name : "local"; UnrankedPlayData.password = OnlinePlayer.Authenticated ? OnlinePlayer.Password : ""; UnrankedPlayData.id = Level.id; UnrankedPlayData.type = CytoidApplication.CurrentChartType; UnrankedPlayData.version = Level.version; UnrankedPlayData.chart_checksum = Chart.Checksum; CytoidApplication.CurrentRankedPlayData = null; CytoidApplication.CurrentUnrankedPlayData = UnrankedPlayData; } // Touch handlers if (!Mod.Auto.IsEnabled()) { LeanTouch.OnFingerDown += OnFingerDown; LeanTouch.OnFingerSet += OnFingerSet; LeanTouch.OnFingerUp += OnFingerUp; } yield return(new WaitForSeconds(0.2f)); View.OnStart(); IsLoaded = true; EventKit.Broadcast("game loaded"); // Wait for Storyboard while (!StoryboardController.Instance.Loaded) { yield return(null); } yield return(new WaitForSeconds(0.3f)); StartGame(); }
private void Start() { CytoidApplication.ResetResolution(); IsUploading = false; SuccessfullyUploaded = false; BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); // HIGHLIGHT Resources.UnloadUnusedAssets(); // HIGHLIGHT if (OnlinePlayer.Authenticated) { StartCoroutine(AutoUpload()); } else { uploadButton.gameObject.SetActive(false); } var play = CytoidApplication.CurrentPlay; var score = play.Score; var tp = play.Tp; var maxCombo = play.MaxCombo; titleText.text = CytoidApplication.CurrentLevel.title; var intScore = Mathf.FloorToInt((float)score); scoreText.text = intScore.ToString("D6"); if (intScore == 1000000) { scoreText.color = Convert.HexToColor("#ffc107"); } else if (intScore > 999000) { scoreText.color = Convert.HexToColor("#007bff"); } var text = ""; if (Math.Abs(tp - 100) < 0.000001) { text += "Full accuracy"; } else { text += (Math.Floor(tp * 100) / 100).ToString("0.00") + "% accuracy"; } text += " / "; if (maxCombo == play.NoteCleared) { text += "Full combo"; } else { text += maxCombo + " max combo"; } tpComboText.text = text; var info = string.Format( "<b>Perfect</b> {0} <b>Great</b> {1} <b>Good</b> {2} <b>Bad</b> {3} <b>Miss</b> {4}", play.NoteRankings.Values.Count(grading => grading == NoteGrade.Perfect), play.NoteRankings.Values.Count(grading => grading == NoteGrade.Great), play.NoteRankings.Values.Count(grading => grading == NoteGrade.Good), play.NoteRankings.Values.Count(grading => grading == NoteGrade.Bad), play.NoteRankings.Values.Count(grading => grading == NoteGrade.Miss) ); if (PlayerPrefsExt.GetBool("early_late_indicator")) { info += string.Format("\n<alpha=#38>( <b>Early</b> {0} <b>Late</b> {1} <b>Average Timing Error</b> {2}{3:0.000}s <b>Standard Timing Error</b> {4:0.000}s )", play.Early, play.Late, play.AvgTimeOff > 0 ? "+" : "", play.AvgTimeOff, play.StandardTimeOff); } infoText.text = info; DisplayDifficultyView.Instance.SetDifficulty(CytoidApplication.CurrentLevel, CytoidApplication.CurrentLevel.charts.Find(it => it.type == CytoidApplication.CurrentChartType)); var ranked = CytoidApplication.CurrentRankedPlayData != null; // Save stats var oldScore = ZPlayerPrefs.GetFloat(PreferenceKeys.BestScore(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType, ranked)); var oldAccuracy = ZPlayerPrefs.GetFloat(PreferenceKeys.BestAccuracy(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType, ranked)); var newBest = false; if (score > oldScore) { newBest = true; ZPlayerPrefs.SetFloat( PreferenceKeys.BestScore(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType, ranked), (float)score); var clearType = string.Empty; if (play.Mods.Contains(Mod.AP)) { clearType = "AP"; } if (play.Mods.Contains(Mod.FC)) { clearType = "FC"; } if (play.Mods.Contains(Mod.Hard)) { clearType = "Hard"; } if (play.Mods.Contains(Mod.ExHard)) { clearType = "ExHard"; } ZPlayerPrefs.SetString( PreferenceKeys.BestClearType(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType, ranked), clearType ); } if (tp > oldAccuracy) { newBest = true; ZPlayerPrefs.SetFloat( PreferenceKeys.BestAccuracy(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType, ranked), (float)tp); } if (newBest) { EventKit.Broadcast("new best"); } var playCount = ZPlayerPrefs.GetInt( PreferenceKeys.PlayCount(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType), defaultValue: 0); ZPlayerPrefs.SetInt( PreferenceKeys.PlayCount(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType), playCount + 1); }
protected override void Awake() { base.Awake(); CytoidApplication.SetAutoRotation(true); var userOffsetDef = Application.platform == RuntimePlatform.Android ? 0.12f : 0.2f; var ringColorDef = "#FFFFFF"; var ringColorAltDef = "#FFFFFF"; var fillColorDef = "#6699CC"; var fillColorAltDef = "#FF3C38"; SetDefaultPref("user_offset", userOffsetDef); SetDefaultPref("show_scanner", true); SetDefaultPref("inverse", false); SetDefaultPref("ring_color", ringColorDef); SetDefaultPref("ring_color_alt", ringColorAltDef); SetDefaultPref("fill_color", fillColorDef); SetDefaultPref("fill_color_alt", fillColorAltDef); SetDefaultPref("hit_sound", "None"); var list = HitSounds.ToList(); list.Insert(0, new HitSound { Name = "None", Clip = null }); HitSounds = list.ToArray(); UpdateHitSound(HitSounds[1], save: false); var userHitSound = PlayerPrefs.GetString("hit_sound"); for (var index = 0; index < HitSounds.Length; index++) { if (HitSounds[index].Name == userHitSound) { UpdateHitSound(HitSounds[index]); HitSoundIndex = index; } } userOffsetInput.text = PlayerPrefs.GetFloat("user_offset").ToString(); showScannerToggle.isOn = PlayerPrefsExt.GetBool("show_scanner"); earlyLateIndicatorToggle.isOn = PlayerPrefsExt.GetBool("early_late_indicator"); largerHitboxesToggle.isOn = PlayerPrefsExt.GetBool("larger_hitboxes"); isInversedToggle.isOn = PlayerPrefsExt.GetBool("inverse"); ringColorInput.text = PlayerPrefs.GetString("ring_color"); ringColorAltInput.text = PlayerPrefs.GetString("ring_color_alt"); fillColorInput.text = PlayerPrefs.GetString("fill_color"); fillColorAltInput.text = PlayerPrefs.GetString("fill_color_alt"); userOffsetInput.onEndEdit.AddListener(text => { float offset; if (!float.TryParse(text, out offset)) { userOffsetInput.text = userOffsetDef.ToString(); } }); overrideOptionsToggle.onValueChanged.AddListener(selected => { ZPlayerPrefs.SetBool(PreferenceKeys.WillOverrideOptions(CytoidApplication.CurrentLevel), selected); }); localIsInversedToggle.onValueChanged.AddListener(selected => { ZPlayerPrefs.SetBool(PreferenceKeys.WillInverse(CytoidApplication.CurrentLevel), selected); }); localUserOffsetInput.onEndEdit.AddListener(text => { float offset; if (!float.TryParse(text, out offset)) { localUserOffsetInput.text = userOffsetInput.text; } else { ZPlayerPrefs.SetFloat(PreferenceKeys.NoteDelay(CytoidApplication.CurrentLevel), offset); } }); ringColorInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { ringColorInput.text = ringColorDef; } }); ringColorAltInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { ringColorAltInput.text = ringColorAltDef; } }); fillColorInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { fillColorInput.text = fillColorDef; } }); fillColorAltInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { fillColorAltInput.text = fillColorAltDef; } }); usernameInput.text = PlayerPrefs.GetString(PreferenceKeys.LastUsername()); passwordInput.text = PlayerPrefs.GetString(PreferenceKeys.LastPassword()); if (!PlayerPrefs.HasKey(PreferenceKeys.RankedMode())) { PlayerPrefsExt.SetBool(PreferenceKeys.RankedMode(), false); } rankStatusText.text = "Off"; // Initialize background blackout.SetActive(false); var backgrounds = GameObject.FindGameObjectsWithTag("Background"); if (backgrounds.Length > 1) // Already have persisted background? (i.e. returning from Game/GameResult scene) { var localBackground = backgrounds.ToList().Find(it => it.scene == gameObject.scene); // Destroy local background Destroy(localBackground); // Setup the persisted background BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); } else // Setup the local background { BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); } }
public void DeleteCurrentLevel() { CytoidApplication.DeleteLevel(CytoidApplication.CurrentLevel); }
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*/ }
protected override void Awake() { base.Awake(); CytoidApplication.SetAutoRotation(true); var userOffsetDef = Application.platform == RuntimePlatform.Android ? 0.12f : 0.2f; var ringColorDef = "#FFFFFF"; var ringColorAltDef = "#FFFFFF"; var fillColorDef = "#6699CC"; var fillColorAltDef = "#FF3C38"; SetDefaultPref("user_offset", userOffsetDef); SetDefaultPref("show_scanner", true); SetDefaultPref("inverse", false); SetDefaultPref("ring_color", ringColorDef); SetDefaultPref("ring_color_alt", ringColorAltDef); SetDefaultPref("fill_color", fillColorDef); SetDefaultPref("fill_color_alt", fillColorAltDef); userOffsetInput.text = PlayerPrefs.GetFloat("user_offset").ToString(); showScannerToggle.isOn = PlayerPrefsExt.GetBool("show_scanner"); isInversedToggle.isOn = PlayerPrefsExt.GetBool("inverse"); ringColorInput.text = PlayerPrefs.GetString("ring_color"); ringColorAltInput.text = PlayerPrefs.GetString("ring_color_alt"); fillColorInput.text = PlayerPrefs.GetString("fill_color"); fillColorAltInput.text = PlayerPrefs.GetString("fill_color_alt"); userOffsetInput.onEndEdit.AddListener(text => { float offset; if (!float.TryParse(text, out offset)) { userOffsetInput.text = userOffsetDef.ToString(); } }); overrideOptionsToggle.onValueChanged.AddListener(selected => { ZPlayerPrefs.SetBool(PreferenceKeys.WillOverrideOptions(CytoidApplication.CurrentLevel), selected); }); localIsInversedToggle.onValueChanged.AddListener(selected => { ZPlayerPrefs.SetBool(PreferenceKeys.WillInverse(CytoidApplication.CurrentLevel), selected); }); localUserOffsetInput.onEndEdit.AddListener(text => { float offset; if (!float.TryParse(text, out offset)) { localUserOffsetInput.text = userOffsetInput.text; } else { ZPlayerPrefs.SetFloat(PreferenceKeys.NoteDelay(CytoidApplication.CurrentLevel), offset); } }); ringColorInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { ringColorInput.text = ringColorDef; } }); ringColorAltInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { ringColorAltInput.text = ringColorAltDef; } }); fillColorInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { fillColorInput.text = fillColorDef; } }); fillColorAltInput.onEndEdit.AddListener(text => { try { Convert.HexToColor(text); } catch (Exception) { fillColorAltInput.text = fillColorAltDef; } }); // Initialize background blackout.SetActive(false); var backgrounds = GameObject.FindGameObjectsWithTag("Background"); if (backgrounds.Length > 1) // Already have persisted background? (i.e. returning from Game/GameResult scene) { var localBackground = backgrounds.ToList().Find(it => it.scene == gameObject.scene); // Destroy local background Destroy(localBackground); // Setup the persisted background BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); } else // Setup the local background { BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene); } }