private void OnEndGame() { foreach (Line line in lines) { line.Clear(); } stopWatch.Reset(); OnChangeResume?.Invoke(false); }
private void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { if (stopWatch.IsRunning) { stopWatch.Stop(); } else { stopWatch.Start(); } OnChangeResume?.Invoke(!stopWatch.IsRunning); } if (Input.GetKeyDown(KeyCode.Insert)) { isVisibleBgNote = !isVisibleBgNote; OnVisibleBgNote?.Invoke(isVisibleBgNote); } if (!stopWatch.IsRunning) { return; } elapsedMilliSeconds = stopWatch.ElapsedMilliseconds; // ex) 66 = 1,000 / 15 long elapsedBit = elapsedMilliSeconds / milliSecondsPerBit; while (currentTotalBit < elapsedBit) { AddBitCount(1); if (!musicInfo.NoteInfoList.ContainsKey(currentNode)) { continue; } LinkedList <NoteInfo> noteList = musicInfo.NoteInfoList[currentNode][currentBit]; if (noteList == null) { continue; } foreach (var noteInfo in noteList) { // 노트가 생성되고 HitLine에 도달할때까지의 시간 long hitMilliSeconds = (currentTotalBit + GameManager.Instance.musicStatus.noteDelayBit) * milliSecondsPerBit - elapsedMilliSeconds; lines[noteInfo.LineIndex].SpawnNote(noteInfo, hitMilliSeconds); } } }
private void OnStartGame() { foreach (Line line in lines) { line.Clear(); } CurrentScore = 0; currentHitCounts.Clear(); musicInfo = GameManager.Instance.musicStatus.GetMusicInfo(); maxTotalBit = 0; foreach (int node in musicInfo.NoteInfoList.Keys) { maxTotalBit = Mathf.Max(maxTotalBit, node * MusicStatus.DividePerNode); } foreach (HitRateForUI info in hitRateTexts) { info.CountText.text = "0"; } // 라인 활성화, 키설정 { KeyInfo keyInfo = keyInfos.Find(info => { return(info.KeyCodes.Count == musicInfo.EnableLines.Count); }); int enableLineIndex = 0; for (int i = 0; i < lines.Count; ++i) { bool isEnable = musicInfo.EnableLines.Contains(i); lines[i].gameObject.SetActive(isEnable); if (isEnable) { if (keyInfo.KeyCodes == null) { Debug.LogError("[OnStartGame] keyCodes is null. lineCount = " + musicInfo.EnableLines.Count); continue; } lines[i].keyCode = keyInfo.KeyCodes[enableLineIndex]; UnityEngine.UI.Image image = lines[i].GetComponent <UnityEngine.UI.Image>(); if (image != null) { image.color = lineColors[enableLineIndex % lineColors.Count]; } ++enableLineIndex; } } } // ex) 480 = 60000 / 125 milliSecondsPerNode = 60000 / musicInfo.Bpm; // ex) 15 = 480 / 32 milliSecondsPerBit = milliSecondsPerNode / MusicStatus.DividePerNode * 4; // 임시로 4배속 처리 currentNode = 0; currentBit = 0; currentTotalBit = 0; stopWatch.Reset(); stopWatch.Start(); OnChangeResume?.Invoke(false); }