public override void Touch(Vector2 touchScreenPosition) { // Do nothing rankedNoteData.press_time = TimeExt.Millis(); rankedNoteData.press_x = (int)touchScreenPosition.x; rankedNoteData.press_y = (int)touchScreenPosition.y; }
private IEnumerator ProceedToResultCoroutine() { if (GameOptions.Instance.UseAndroidNativeAudio) { while (ANAMusic.isPlaying(NativeAudioId)) { yield return(null); } } else { var exitTime = UnityEngine.Time.time; while (AudioSource.isPlaying && UnityEngine.Time.time - exitTime < 10) { yield return(null); } } if (Play.IsRanked) { RankedPlayData.end = TimeExt.Millis(); RankedPlayData.score = (long)Play.Score; RankedPlayData.accuracy = (int)(Play.Tp * 1000000); RankedPlayData.max_combo = Play.MaxCombo; RankedPlayData.perfect = Play.NoteRankings.Values.Count(grading => grading == NoteGrade.Perfect); RankedPlayData.great = Play.NoteRankings.Values.Count(grading => grading == NoteGrade.Great); RankedPlayData.good = Play.NoteRankings.Values.Count(grading => grading == NoteGrade.Good); RankedPlayData.bad = Play.NoteRankings.Values.Count(grading => grading == NoteGrade.Bad); RankedPlayData.miss = Play.NoteRankings.Values.Count(grading => grading == NoteGrade.Miss); RankedPlayData.checksum = Checksum.From(RankedPlayData); } else { UnrankedPlayData.score = (long)Play.Score; UnrankedPlayData.accuracy = (int)(Play.Tp * 1000000); UnrankedPlayData.max_combo = Play.MaxCombo; UnrankedPlayData.perfect = Play.NoteRankings.Values.Count(grading => grading == NoteGrade.Perfect); UnrankedPlayData.great = Play.NoteRankings.Values.Count(grading => grading == NoteGrade.Great); UnrankedPlayData.good = Play.NoteRankings.Values.Count(grading => grading == NoteGrade.Good); UnrankedPlayData.bad = Play.NoteRankings.Values.Count(grading => grading == NoteGrade.Bad); UnrankedPlayData.miss = Play.NoteRankings.Values.Count(grading => grading == NoteGrade.Miss); UnrankedPlayData.checksum = Checksum.From(UnrankedPlayData); } // Destroy all game notes foreach (var entry in GameNotes) { var note = entry.Value; if (note == null) { continue; } Destroy(note.gameObject); } View.OnProceedToResult(); }
private void Pause() { if (CytoidApplication.CurrentLevel == null || IsEnded) { return; } RankedPlayData.pauses.Add(new RankedPlayData.Pause { start = TimeExt.Millis() }); IsPaused = true; willPause = false; UnpauseCountdown = -1; if (CytoidApplication.UseDoozyUI) { UIManager.ShowUiElement("PauseBackground", "Game", true); UIManager.ShowUiElement("PauseRoot", "Game", true); } if (!CytoidApplication.CurrentLevel.is_internal && Application.platform == RuntimePlatform.Android) { ANAMusic.pause(anaId); } else { audioSource.Pause(); } if (!CytoidApplication.CurrentLevel.is_internal && Application.platform == RuntimePlatform.Android) { pausedAt = ANAMusic.getCurrentPosition(anaId) / 1000f; } else { pausedAt = audioSource.time; } foreach (var fingerIndex in holdingNotes.Keys) { var holdNote = holdingNotes[fingerIndex]; holdNote.StopHolding(); } holdingNotes.Clear(); SetAllowPause(false); if (unpauseCoroutine != null) { StopCoroutine(unpauseCoroutine); } }
public virtual void Touch(Vector2 screenPos) { if (!Game.IsLoaded || !Game.IsPlaying) { return; } var grading = CalculateGrading(); if (grading == NoteGrade.Undetermined) { return; } RankData.press_time = TimeExt.Millis(); RankData.press_x = (int)screenPos.x; RankData.press_y = (int)screenPos.y; Clear(grading); }
public virtual void Touch(Vector2 touchScreenPosition) { if (!game.IsLoaded || game.IsPaused) { return; } if (this is ChainNoteView && CalculateGrading() == NoteGrading.Undetermined) { return; } rankedNoteData.press_time = TimeExt.Millis(); rankedNoteData.press_x = (int)touchScreenPosition.x; rankedNoteData.press_y = (int)touchScreenPosition.y; Clear(CalculateGrading()); if (hitSoundSource.clip != null) { hitSoundSource.Play(); } }
private IEnumerator EndCoroutine() { yield return(new WaitForSeconds(6f)); RankedPlayData.end = TimeExt.Millis(); action = Action.Result; if (CytoidApplication.UseDoozyUI) { // Comment out this section and the import if DoozyUI not used UIManager.HideUiElement("ScoreText", "Game"); UIManager.HideUiElement("ComboText", "Game"); UIManager.HideUiElement("TpText", "Game"); UIManager.HideUiElement("TitleText", "Game"); UIManager.HideUiElement("Mask", "Game"); } else { DoAction(); } }
//Convert single event public LineDTO[] Convert(Event @event, string bookmakerName) { Lines = new List <LineDTO>(); var teamMatch = TeamRegex.Match(@event.name); var teamScore = ScoreRegex.Match(@event.liveStatus.score.Replace("*", "")); var lineTemplate = new LineDTO { Team1 = teamMatch.Groups["home"].Value, Team2 = teamMatch.Groups["away"].Value, BookmakerName = bookmakerName, Score1 = System.Convert.ToInt32(teamScore.Groups["homeScore"].Value), Score2 = System.Convert.ToInt32(teamScore.Groups["awayScore"].Value), SportKind = Helper.ConvertSport(@event.league.sport.name), EventDate = TimeExt.FromUnixTime(@event.kickoff) }; foreach (var market in @event.markets) { //исключаем угловые if (StopWords.Any(s => market.name.ContainsIgnoreCase(s))) { continue; } foreach (var runner in market.runners) { try { Convert(@event, market, runner, lineTemplate); } catch (Exception e) { Log.Info("LeonBets error" + e.Message + " " + e.StackTrace + (e.InnerException != null ? e.InnerException.Message : "")); } } } return(Lines.ToArray()); }
protected virtual void OnFingerSet(LeanFinger finger) { if (IsCompleted || IsFailed) { return; } var pos = Camera.main.orthographic ? Camera.main.ScreenToWorldPoint(finger.ScreenPosition) : Camera.main.ScreenToWorldPoint(new Vector3(finger.ScreenPosition.x, finger.ScreenPosition.y, 10)); // Query flick note if (flickingNotes.ContainsKey(finger.Index)) { var flickingNote = flickingNotes[finger.Index]; var cleared = flickingNote.UpdateFingerPosition(pos); if (cleared) { flickingNotes.Remove(finger.Index); } } // Query drag notes foreach (var note in touchableDragNotes) { if (note == null) { continue; } if (note.DoesCollide(pos)) { note.Touch(finger.ScreenPosition); break; // Query other notes too! } } // If this is a new finger if (!holdingNotes.ContainsKey(finger.Index)) { var heldNew = false; // If the finger holds a new note // Query unheld hold notes foreach (var note in touchableHoldNotes) { if (note == null) { continue; } if (note.DoesCollide(pos)) { holdingNotes.Add(finger.Index, note); note.StartHoldingBy(finger.Index); heldNew = true; break; } } // Query held hold notes (i.e. multiple fingers on the same hold note) if (!heldNew) { foreach (var holdNote in holdingNotes.Values) { if (holdNote.DoesCollide(pos)) { holdingNotes.Add(finger.Index, holdNote); holdNote.StartHoldingBy(finger.Index); break; } } } } else // The finger is already holding a note { var holdNote = holdingNotes[finger.Index]; var released = false; if (holdNote.IsCleared) // If cleared { holdingNotes.Remove(finger.Index); released = true; } else if (!holdNote.DoesCollide(pos)) // If holding elsewhere { holdNote.StopHoldingBy(finger.Index); holdingNotes.Remove(finger.Index); released = true; } if (released) { holdNote.RankData.release_time = TimeExt.Millis(); holdNote.RankData.release_x = (int)finger.ScreenPosition.x; holdNote.RankData.release_y = (int)finger.ScreenPosition.y; } } }
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(); }
public static void Update(GameTime gameTime, float elapsedTime) { TimeExt.Update(gameTime, elapsedTime); InputExt.UpdateStates(); }
private void OnFingerSet(LeanFinger finger) { var pos = Camera.main.ScreenToWorldPoint(finger.ScreenPosition); // Query chain notes foreach (var noteView in OnScreenChainNotes) { if (noteView == null) { continue; } if (noteView.OverlapPoint(pos)) { noteView.Touch(finger.ScreenPosition); break; // Note that we want to query hold notes as well so break only } } if (!holdingNotes.ContainsKey(finger.Index)) { var newHold = false; // Query again, this time looking for (unholded) hold notes foreach (var noteView in OnScreenHoldNotes) { if (noteView == null) { continue; } if (noteView.OverlapPoint(pos)) { holdingNotes.Add(finger.Index, (HoldNoteView)noteView); ((HoldNoteView)noteView).StartHoldBy(finger.Index); newHold = true; break; } } if (!newHold) { foreach (var entry in holdingNotes) { var noteView = entry.Value; if (noteView.OverlapPoint(pos)) { holdingNotes.Add(finger.Index, noteView); noteView.StartHoldBy(finger.Index); break; } } } } else { // Holding the note already var holdNote = holdingNotes[finger.Index]; var released = false; // If note cleared if (holdNote.cleared) { holdingNotes.Remove(finger.Index); released = true; } else // If holding elsewhere if (!holdNote.OverlapPoint(pos)) { holdNote.StopHoldBy(finger.Index); holdingNotes.Remove(finger.Index); released = true; } if (released) { holdNote.rankedNoteData.release_time = TimeExt.Millis(); holdNote.rankedNoteData.release_x = (int)finger.ScreenPosition.x; holdNote.rankedNoteData.release_y = (int)finger.ScreenPosition.y; } } }
private void Unpause() { RankedPlayData.pauses.Last().end = TimeExt.Millis(); unpauseCoroutine = UnpauseCoroutine(); StartCoroutine(unpauseCoroutine); }
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*/ }