public static void Rename(List <FileInfo> listOfSelectedFiles, int roundRobinValue, Dictionary <string, bool> dynamicsCheckBoxStates, Note _selectedStartingNote, Note _selectedEndingNote, string _fileName, string fileFormat, Dictionary <string, bool> dynamicsStates) { int fileCount = 0; if (_fileName.Contains(".")) { _fileName = FileNaming.removeFormat(_fileName); } List <Note> notesBetween = NoteGenerator.createNotes(_selectedStartingNote, _selectedEndingNote); List <string> namingOrder = FileNaming.namingOrder(notesBetween, roundRobinValue, dynamicsCheckBoxStates); string folderPath = listOfSelectedFiles[0].DirectoryName; foreach (FileInfo file in listOfSelectedFiles) { if (fileCount + 1 > namingOrder.Count) { break; } string newFileName = _fileName + $"({fileCount}) " + namingOrder[fileCount] + fileFormat; string temppath = Path.Combine(folderPath, newFileName); file.MoveTo(temppath); fileCount++; } }
void Update() { if (GlobalSingleton.GetHealth() < 0) { return; } if (hitCooldown > 0) { hitCooldown -= Time.deltaTime; } beat += GlobalSingleton.GetBPM() * 0.0166666666666f * Time.deltaTime; if (beat > DESTROY_BEAT + sustainLength) { NoteGenerator.RemoveNote(this); Destroy(gameObject); return; } if (beat > lateDistance && !playerMissed && !playerHit) { GlobalSingleton.GetShake().StartShake(0.5f, 0.1f); MissNote(0); } if (beat > lateDistance && lastNote) { lastNote = false; if (numMissed <= 0) { GlobalSingleton.IncreaseScore(); } numMissed = 0; } if (beat >= COMPUTER_BEAT && !computerHit) { computerHit = true; StartCoroutine(PlayNote()); } if (beat >= HIDDING_BEAT && !hideHit && hideNote) { hideHit = true; for (int i = 0; i < noteColors.Length; ++i) { StartCoroutine(HitchLib.Tweening.FadeTo(noteColors[i], 60f / GlobalSingleton.GetBPM(), HitchLib.Easing.EASE_LINEAR, 0)); } StartCoroutine(HitchLib.Tweening.FadeTo(keyText, 60f / GlobalSingleton.GetBPM(), HitchLib.Easing.EASE_LINEAR, 0)); } float yPos = BEAT_PLAYER_Y - (beat * BEAT_SIZE); Vector3 pos = rTrans.localPosition; pos.y = yPos * GlobalSingleton.GetTimelineScale(); rTrans.localPosition = pos; }
// Start is called before the first frame update void Start() { ng = gameObject.GetComponent <NoteGenerator>(); bpm = ng.bpm; multiple = ng.multiple; }
// Start is called before the first frame update void Start() { ng = GameObject.Find("NoteGenerator").GetComponent <NoteGenerator>(); startPos = ng.setStartPos(startPos); transform.position = new Vector3(0, startPos.y + 20, -1); }
private void GenerateNotes(SearchSettings searchSettings, IProgress <string> progress) { progress.Report(string.Format("{0}: Rozpoczęto generowanie not.\n", DateTime.Now.ToLongTimeString())); NoteGenerator noteGenerator = new NoteGenerator(); string outputPath = searchSettings.InputFileDir; noteGenerator.GenerateNotes(outputPath, _companiesReadFromFile, _verificationResult.WhiteListCompVerResult, searchSettings.ExportToPdf); progress.Report(string.Format("{0}: Zakończono generowanie not.\n", DateTime.Now.ToLongTimeString())); }
public static BindableCollection <Note> Notes() { BindableCollection <Note> output = new BindableCollection <Note>(); List <Note> listOfNotes = NoteGenerator.createListOfNotes(); foreach (var note in listOfNotes) { output.Add(note); } return(output); }
public void TestCreateNotes(string[] timeTags, string[] noteTexts) { var lyric = new Lyric { Text = "カラオケ", TimeTags = TestCaseTagHelper.ParseTimeTags(timeTags), }; var generator = new NoteGenerator(new NoteGeneratorConfig()); var notes = generator.CreateNotes(lyric); //var notes = LyricUtils.CreateDefaultNotes(lyric); Assert.AreEqual(notes.Select(x => x.Text).ToArray(), noteTexts); }
private void Start() { ng = GameObject.Find("NoteGenerator").GetComponent <NoteGenerator>(); startPos = ng.setStartPos(startPos); if (gameObject.name == "HitLine1") { transform.position = new Vector3(-6, startPos.y + 30, 0); } else if (gameObject.name == "HitLine2") { transform.position = new Vector3(6, startPos.y + 30, 0); } hitSoundManager = GetComponent <AudioSource>(); }
//private const int powerVal = 50; // Start is called before the first frame update private void Start() { player = GameObject.FindGameObjectWithTag("Player"); songController = player.GetComponent <SongController>(); audioSource = player.GetComponent <AudioSource>(); noteGenerator = GetComponent <NoteGenerator>(); SongStatsHandler songStatsHandler = new SongStatsHandler(); songStatsHandler.ClearData(GameData.currentSongStats); accuracyText.text = ""; //hitOffset = noteGenerator.hitOffset; //perfectOffset = hitOffset - 0.1f; //greatOffset = hitOffset - 0.25f; }
void Start() { SongObjectScript song = findSong(); audioSource = song.GetAudioSource(); Debug.Log(song.GetBPM()); song.PlayAudio(); // Process audio as it plays if (realTimeSamples) { realTimeSpectrum = new float[1024]; realTimeSpectralFluxAnalyzer = new SpectralFluxAnalyzer(); realTimePlotController = GameObject.Find("RealtimePlot").GetComponent <NoteGenerator> (); this.sampleRate = AudioSettings.outputSampleRate; } // Preprocess entire audio file upfront if (preProcessSamples) { preProcessedSpectralFluxAnalyzer = new SpectralFluxAnalyzer(); preProcessedPlotController = GameObject.Find("PreprocessedPlot").GetComponent <NoteGenerator>(); // Need all audio samples. If in stereo, samples will return with left and right channels interweaved // [L,R,L,R,L,R] multiChannelSamples = new float[audioSource.clip.samples * audioSource.clip.channels]; numChannels = audioSource.clip.channels; numTotalSamples = audioSource.clip.samples; clipLength = audioSource.clip.length; // We are not evaluating the audio as it is being played by Unity, so we need the clip's sampling rate this.sampleRate = audioSource.clip.frequency; audioSource.clip.GetData(multiChannelSamples, 0); Debug.Log("GetData done"); Thread bgThread = new Thread(this.getFullSpectrumThreaded); Debug.Log("Starting Background Thread"); bgThread.Start(); } }
public void AutoGenerateNotes(Lyric[] lyrics) { changeHandler.BeginChange(); // clear exist notes if from those var matchedNotes = beatmap.HitObjects.OfType <Note>().Where(x => lyrics.Contains(x.ParentLyric)).ToArray(); beatmap.RemoveRange(matchedNotes); // todo : should get the config from setting. var config = new NoteGeneratorConfig(); var generator = new NoteGenerator(config); foreach (var lyric in lyrics) { var notes = generator.CreateNotes(lyric); beatmap.AddRange(notes); } changeHandler.EndChange(); }
// Start is called before the first frame update protected void Start() { noteGenerator = GameObject.FindGameObjectWithTag("GameController").GetComponent <NoteGenerator>(); scoreHandler = GameObject.FindGameObjectWithTag("GameController").GetComponent <ScoreHandler>(); activator = GameObject.FindGameObjectWithTag("Player"); isDespawning = false; noteSpeed = noteGenerator.noteSpeed; hitOffset = noteGenerator.hitOffset; greatHitOffset = noteGenerator.greatHitOffset; perfectHitOffset = noteGenerator.perfectHitOffset; switch (noteType) { case SongParser.NoteType.Fire: keyToPress = GameData.currentSavedData.keyBindings["FireKey"]; break; case SongParser.NoteType.Air: keyToPress = GameData.currentSavedData.keyBindings["AirKey"]; break; case SongParser.NoteType.Water: keyToPress = GameData.currentSavedData.keyBindings["WaterKey"]; break; case SongParser.NoteType.Earth: keyToPress = GameData.currentSavedData.keyBindings["EarthKey"]; break; //default: // keyToPress = KeyCode.W; // break; } // Debug.Log(keyToPress.ToString()); }
public void Restart() { RestartGame = false; ShopSystem.MyInventory.Clear(); FindObjectOfType <metalStatScript>().ResetAmount(); FindObjectOfType <moneyStatScript>().ResetAmount(); FindObjectOfType <angstStatScript>().ResetAmount(); FindObjectOfType <fameStatScript>().ResetAmount(); FindObjectOfType <energyStatScript>().ResetAmount(); NoteGenerator.Reset(); TimingString.Reset(); ToEndGame = false; day = 1; week = 1; if (SceneManager.GetActiveScene().name != HUBScene) { LoadHUB(); } }
public static async Task <ExcelContentTableImportResults> ImportExcelContentTable(IXLRange toProcess, IProgress <string> progress) { if (toProcess == null || toProcess.Rows().Count() < 2) { return new ExcelContentTableImportResults { HasError = true, ErrorNotes = "Nothing to process", ToUpdate = new List <ExcelImportContentUpdateSuggestion>() } } ; var headerInfo = new ExcelHeaderRow(toProcess.Row(1)); var errorNotes = new List <string>(); var updateList = new List <ExcelImportContentUpdateSuggestion>(); var db = await Db.Context(); var lastRow = toProcess.Rows().Last().RowNumber(); progress?.Report($"{lastRow} to Process"); foreach (var loopRow in toProcess.Rows().Skip(1)) { var importResult = await ImportContentFromExcelRow(headerInfo, loopRow); if (importResult.hasError) { errorNotes.Add($"Excel Row {loopRow.RowNumber()} - {importResult.errorNotes}"); continue; } try { Db.DefaultPropertyCleanup(importResult.processContent); importResult.processContent.Tags = Db.TagListCleanup(importResult.processContent.Tags); } catch { await EventLogContext.TryWriteDiagnosticMessageToLog( $"Excel Row {loopRow.RowNumber()} - Excel Import via dynamics - Tags threw an error on ContentId {importResult.processContent.ContentId ?? "New Entry"} - property probably not present", "Excel Import"); continue; } Guid contentId = importResult.processContent.ContentId; int contentDbId = importResult.processContent.Id; string differenceString; if (contentDbId > 0) { var currentDbEntry = await db.ContentFromContentId(contentId); var compareLogic = new CompareLogic { Config = { MembersToIgnore = new List <string> { "LastUpdatedBy" }, MaxDifferences= 100 } }; ComparisonResult comparisonResult = compareLogic.Compare(currentDbEntry, importResult.processContent); if (comparisonResult.AreEqual) { progress?.Report( $"Excel Row {loopRow.RowNumber()} of {lastRow} - No Changes - Title: {currentDbEntry.Title}"); continue; } var friendlyReport = new UserFriendlyReport(); differenceString = friendlyReport.OutputString(comparisonResult.Differences); importResult.processContent.LastUpdatedOn = DateTime.Now; } else { differenceString = "New Entry"; } GenerationReturn validationResult; switch (importResult.processContent) { case PhotoContent p: validationResult = await PhotoGenerator.Validate(p, UserSettingsSingleton.CurrentSettings().LocalMediaArchivePhotoContentFile(p)); break; case FileContent f: validationResult = await FileGenerator.Validate(f, UserSettingsSingleton.CurrentSettings().LocalMediaArchiveFileContentFile(f)); break; case ImageContent i: validationResult = await ImageGenerator.Validate(i, UserSettingsSingleton.CurrentSettings().LocalMediaArchiveImageContentFile(i)); break; case PointContentDto pc: validationResult = await PointGenerator.Validate(pc); break; case PostContent pc: validationResult = await PostGenerator.Validate(pc); break; case LinkContent l: validationResult = await LinkGenerator.Validate(l); break; case NoteContent n: validationResult = await NoteGenerator.Validate(n); break; default: validationResult = await GenerationReturn.Error("Excel Import - No Content Type Generator found?"); break; } if (validationResult.HasError) { errorNotes.Add($"Excel Row {loopRow.RowNumber()} - {validationResult.GenerationNote}"); progress?.Report($"Excel Row {loopRow.RowNumber()} of {lastRow} - Validation Error."); continue; } updateList.Add(new ExcelImportContentUpdateSuggestion { DifferenceNotes = differenceString, Title = importResult.processContent.Title, ToUpdate = importResult.processContent }); progress?.Report( $"Excel Row {loopRow.RowNumber()} of {lastRow} - Adding To Changed List ({updateList.Count}) - Title: {importResult.processContent.Title}"); } if (!errorNotes.Any()) { var internalContentIdDuplicates = updateList.Select(x => x.ToUpdate).GroupBy(x => x.ContentId) .Where(x => x.Count() > 1).Select(x => x.Key).Cast <Guid>().ToList(); if (internalContentIdDuplicates.Any()) { return new ExcelContentTableImportResults { HasError = true, ErrorNotes = $"Content Ids can only appear once in an update list - {string.Join(", ", internalContentIdDuplicates)}", ToUpdate = updateList } } ; var internalSlugDuplicates = updateList.Select(x => x.ToUpdate).Where(x => !(x is LinkContent)) .GroupBy(x => x.Slug).Where(x => x.Count() > 1).Select(x => x.Key).Cast <string>().ToList(); if (internalSlugDuplicates.Any()) { return new ExcelContentTableImportResults { HasError = true, ErrorNotes = $"This import appears to create duplicate slugs - {string.Join(", ", internalSlugDuplicates)}", ToUpdate = updateList } } ; } return(new ExcelContentTableImportResults { HasError = errorNotes.Any(), ErrorNotes = string.Join(Environment.NewLine, errorNotes), ToUpdate = updateList }); }
public static async Task <(bool hasError, string errorMessage)> SaveAndGenerateHtmlFromExcelImport( ExcelContentTableImportResults contentTableImportResult, IProgress <string> progress) { var errorList = new List <string>(); var totalToUpdate = contentTableImportResult.ToUpdate.Count; var currentUpdate = 0; foreach (var loopUpdates in contentTableImportResult.ToUpdate) { currentUpdate++; progress?.Report($"Excel Import Update {currentUpdate} of {totalToUpdate}"); GenerationReturn generationResult; switch (loopUpdates.ToUpdate) { case PhotoContent photo: { generationResult = (await PhotoGenerator.SaveAndGenerateHtml(photo, UserSettingsSingleton.CurrentSettings().LocalMediaArchivePhotoContentFile(photo), false, null, progress)).generationReturn; break; } case FileContent file: { generationResult = (await FileGenerator.SaveAndGenerateHtml(file, UserSettingsSingleton.CurrentSettings().LocalMediaArchiveFileContentFile(file), false, null, progress)).generationReturn; break; } case ImageContent image: { generationResult = (await ImageGenerator.SaveAndGenerateHtml(image, UserSettingsSingleton.CurrentSettings().LocalMediaArchiveImageContentFile(image), false, null, progress)).generationReturn; break; } case PointContentDto point: { generationResult = (await PointGenerator.SaveAndGenerateHtml(point, null, progress)) .generationReturn; break; } case PostContent post: { generationResult = (await PostGenerator.SaveAndGenerateHtml(post, null, progress)) .generationReturn; break; } case NoteContent note: { generationResult = (await NoteGenerator.SaveAndGenerateHtml(note, null, progress)) .generationReturn; break; } case LinkContent link: { generationResult = (await LinkGenerator.SaveAndGenerateHtml(link, null, progress)) .generationReturn; break; } default: generationResult = await GenerationReturn.Error("Excel Import - No Content Type Generator found?"); break; } if (!generationResult.HasError) { progress?.Report( $"Updated Content Id {loopUpdates.ToUpdate.ContentId} - Title {loopUpdates.Title} - Saved"); } else { errorList.Add( $"Updating Failed: Content Id {loopUpdates} - Title {loopUpdates.Title} - Failed:{Environment.NewLine}{generationResult.GenerationNote}"); } } if (errorList.Any()) { return(true, string.Join(Environment.NewLine, errorList)); } return(false, string.Empty); }
//bool isPlaying; // Use this for initialization void Start() { /* this part used to load seleted song */ /* { "Tags": [], // 标签 "Creator": "", // 制作者 "GameObject": { // 游戏物件,如落键,转盘 "Hard": [], "Easy": [[0, 10000, 1, 1], // [类型, 时间, 位置, 速度] [0, 10000, 2, 1], [0, 15000, 1, 1], [0, 16000, 2, 1]], "Normal": [] }, "Artist": "", // 艺术家 "Difficulty": { // 难度设定 "Speed": 1 }, "Source": "", // 来源 "Version": "", // 版本 "Title": "", // 谱面标题 "Audio": { // 音频文件信息 "Length": 0, "Name": "" } "Background": { // 背景信息 "Enable": false, // 是否启用 "Type": "", // 类型 0-图片 1-视频 "Name": "" // 文件名 } "SoundEffect": { "Enable": false, "SE": [] } } */ /*******/ PlayerPrefs.SetInt ("GameStarted", 1); enableSE = PlayerPrefs.GetInt ("enableSE") != 0; enableBG = PlayerPrefs.GetInt ("enableBG") != 0; this.beatmapName = PlayerPrefs.GetString ("song"); Debug.Log (" Play " + this.beatmapName); this.difficulty = PlayerPrefs.GetInt ("Difficulty"); /*******/ //beatmapName = "Nya"; //difficulty = 0; //beatmapName = "MirrorNight"; //difficulty = 2; //beatmapName = "LetItGo"; //difficulty = 2; loadFail = true; // Asume load fail // Get beatmap from file TextAsset f = Resources.Load ("Music/" + beatmapName + "/beatmap") as TextAsset; if (f == null) // load fail return; Debug.Log ("Beatmap load success"); string s = f.ToString (); //Debug.Log (s); Beatmap = JSON.Parse (s); if (Beatmap == null) // load fail return; Debug.Log ("Beatmap parse success"); music = GetComponent<AudioSource> (); music.clip = Resources.Load ("Music/" + beatmapName + "/" + Beatmap ["Audio"] ["Name"]) as AudioClip; // No name-extension if (music.clip == null) // load fail return; Debug.Log ("audio load success"); if (Beatmap ["SoundEffect"] ["Enable"].AsBool) { defaultSE = false; SEname = Beatmap ["SoundEffect"] ["Name"]; Debug.Log ("use custom SE"); } else { defaultSE = true; Debug.Log ("use default SE"); } //defaultBG = true; useMovBG = false; usePicBG = false; if (enableBG) { if (Beatmap ["Background"] ["Enable"].AsBool) { Destroy (GameObject.Find ("SpaceGenetator")); //defaultBG = false; switch (Beatmap ["Background"] ["Type"].AsInt) { case 0: // use Picture as background usePicBG = true; Debug.Log ("use custom pic BG"); break; case 1: // use video as background mov = Resources.Load ("Music/" + beatmapName + "/" + Beatmap ["Background"] ["Name"]) as MovieTexture; if (mov == null) // load fail return; (GameObject.Find ("Backgound").GetComponent ("VideoPlayer") as VideoPlayer).movTexture = mov; useMovBG = true; Debug.Log ("use custom mov BG"); break; default: break; } } else { // use default space background Destroy (GameObject.Find ("Backgound")); Debug.Log ("use default BG"); } } else { Destroy (GameObject.Find ("Backgound")); Destroy (GameObject.Find ("SpaceGenetator")); Debug.Log ("not use BG"); } Debug.Log ("background load success"); switch (difficulty) { case 0: HitObjects = Beatmap ["GameObject"] ["Easy"].AsArray; break; case 1: HitObjects = Beatmap ["GameObject"] ["Normal"].AsArray; break; case 2: HitObjects = Beatmap ["GameObject"] ["Hard"].AsArray; break; default: return; } if (HitObjects == null) return; Debug.Log ("hitObjects load success"); CoverMesh = GameObject.Find ("Cover").GetComponent<TextMesh> (); CoverColor = new Color (CoverMesh.color.r, CoverMesh.color.g, CoverMesh.color.b, 1); CoverTimer = 0.5f; CoverDone = false; loadFail = false; // load success Debug.Log ("load success"); NGDL = GameObject.Find ("NoteGeneratorDL").GetComponent ("NoteGenerator") as NoteGenerator; NGDR = GameObject.Find ("NoteGeneratorDR").GetComponent ("NoteGenerator") as NoteGenerator; //NGRU = GameObject.Find ("NoteGeneratorRU").GetComponent ("NoteGenerator") as NoteGenerator; NGRD = GameObject.Find ("NoteGeneratorRD").GetComponent ("NoteGenerator") as NoteGenerator; //NGLU = GameObject.Find ("NoteGeneratorLU").GetComponent ("NoteGenerator") as NoteGenerator; NGLD = GameObject.Find ("NoteGeneratorLD").GetComponent ("NoteGenerator") as NoteGenerator; SG = GameObject.Find ("SpinnerGenerator").GetComponent ("SpinnerGenerator") as SpinnerGenerator; TD = GameObject.Find ("TapDetector").GetComponent ("TapDetector") as TapDetector; // Init i = 0; now = HitObjects [0].AsArray; pause = gameover = false; ScoreCounter = ComboCounter = MaxCombo = PerfectCount = GoodCount = BadCount = MissCount = 0; ScoreNow = 0; ScoreText.text = "Score: " + ScoreCounter.ToString (); ComboText.text = "Combo: " + ComboCounter.ToString (); ScoreText.fontSize = ComboText.fontSize = (int)(Screen.width * 0.03f); PauseButton.onClick.AddListener (PauseResume); StopButton.onClick.AddListener (StopGame); Timer = 0f; NotesBeforeDone = false; if (now [1].AsFloat - 7 / now [3].AsFloat < 0) { Timer = Mathf.Abs (now [1].AsFloat - 7 / now [3].AsFloat); NotesBeforeDone = false; } else { StartGame (); } }
//bool isPlaying; // Use this for initialization void Start() { /* * this part used to load seleted song */ /* * { * "Tags": [], // 标签 * "Creator": "", // 制作者 * "GameObject": { // 游戏物件,如落键,转盘 * "Hard": [], * "Easy": [[0, 10000, 1, 1], // [类型, 时间, 位置, 速度] * [0, 10000, 2, 1], * [0, 15000, 1, 1], * [0, 16000, 2, 1]], * "Normal": [] * }, * "Artist": "", // 艺术家 * "Difficulty": { // 难度设定 * "Speed": 1 * }, * "Source": "", // 来源 * "Version": "", // 版本 * "Title": "", // 谱面标题 * "Audio": { // 音频文件信息 * "Length": 0, * "Name": "" * } * "Background": { // 背景信息 * "Enable": false, // 是否启用 * "Type": "", // 类型 0-图片 1-视频 * "Name": "" // 文件名 * } * "SoundEffect": { * "Enable": false, * "SE": [] * } * } */ /*******/ PlayerPrefs.SetInt("GameStarted", 1); enableSE = PlayerPrefs.GetInt("enableSE") != 0; enableBG = PlayerPrefs.GetInt("enableBG") != 0; this.beatmapName = PlayerPrefs.GetString("song"); Debug.Log(" Play " + this.beatmapName); this.difficulty = PlayerPrefs.GetInt("Difficulty"); /*******/ //beatmapName = "Nya"; //difficulty = 0; //beatmapName = "MirrorNight"; //difficulty = 2; //beatmapName = "LetItGo"; //difficulty = 2; loadFail = true; // Asume load fail // Get beatmap from file TextAsset f = Resources.Load("Music/" + beatmapName + "/beatmap") as TextAsset; if (f == null) // load fail { return; } Debug.Log("Beatmap load success"); string s = f.ToString(); //Debug.Log (s); Beatmap = JSON.Parse(s); if (Beatmap == null) // load fail { return; } Debug.Log("Beatmap parse success"); music = GetComponent <AudioSource> (); music.clip = Resources.Load("Music/" + beatmapName + "/" + Beatmap ["Audio"] ["Name"]) as AudioClip; // No name-extension if (music.clip == null) // load fail { return; } Debug.Log("audio load success"); if (Beatmap ["SoundEffect"] ["Enable"].AsBool) { defaultSE = false; SEname = Beatmap ["SoundEffect"] ["Name"]; Debug.Log("use custom SE"); } else { defaultSE = true; Debug.Log("use default SE"); } //defaultBG = true; useMovBG = false; if (enableBG) { if (Beatmap ["Background"] ["Enable"].AsBool) { Destroy(GameObject.Find("SpaceGenetator")); //defaultBG = false; switch (Beatmap ["Background"] ["Type"].AsInt) { case 0: // use Picture as background // TODO: Load picture background Debug.Log("use custom pic BG"); break; case 1: // use video as background mov = Resources.Load("Music/" + beatmapName + "/" + Beatmap ["Background"] ["Name"]) as MovieTexture; if (mov == null) // load fail { return; } (GameObject.Find("Backgound").GetComponent("VideoPlayer") as VideoPlayer).movTexture = mov; useMovBG = true; Debug.Log("use custom mov BG"); break; default: break; } } else { // use default space background Destroy(GameObject.Find("Backgound")); Debug.Log("use default BG"); } } else { Destroy(GameObject.Find("Backgound")); Destroy(GameObject.Find("SpaceGenetator")); Debug.Log("not use BG"); } Debug.Log("background load success"); switch (difficulty) { case 0: HitObjects = Beatmap ["GameObject"] ["Easy"].AsArray; break; case 1: HitObjects = Beatmap ["GameObject"] ["Normal"].AsArray; break; case 2: HitObjects = Beatmap ["GameObject"] ["Hard"].AsArray; break; default: return; } if (HitObjects == null) { return; } Debug.Log("hitObjects load success"); CoverMesh = GameObject.Find("Cover").GetComponent <TextMesh> (); CoverColor = new Color(CoverMesh.color.r, CoverMesh.color.g, CoverMesh.color.b, 1); CoverTimer = 0.5f; CoverDone = false; loadFail = false; // load success Debug.Log("load success"); NGDL = GameObject.Find("NoteGeneratorDL").GetComponent("NoteGenerator") as NoteGenerator; NGDR = GameObject.Find("NoteGeneratorDR").GetComponent("NoteGenerator") as NoteGenerator; //NGRU = GameObject.Find ("NoteGeneratorRU").GetComponent ("NoteGenerator") as NoteGenerator; NGRD = GameObject.Find("NoteGeneratorRD").GetComponent("NoteGenerator") as NoteGenerator; //NGLU = GameObject.Find ("NoteGeneratorLU").GetComponent ("NoteGenerator") as NoteGenerator; NGLD = GameObject.Find("NoteGeneratorLD").GetComponent("NoteGenerator") as NoteGenerator; SG = GameObject.Find("SpinnerGenerator").GetComponent("SpinnerGenerator") as SpinnerGenerator; TD = GameObject.Find("TapDetector").GetComponent("TapDetector") as TapDetector; // Init i = 0; now = HitObjects [0].AsArray; pause = gameover = false; ScoreCounter = ComboCounter = MaxCombo = PerfectCount = GoodCount = BadCount = MissCount = 0; ScoreNow = 0; ScoreText.text = "Score: " + ScoreCounter.ToString(); ComboText.text = "Combo: " + ComboCounter.ToString(); ScoreText.fontSize = ComboText.fontSize = (int)(Screen.width * 0.03f); PauseButton.onClick.AddListener(PauseResume); StopButton.onClick.AddListener(StopGame); Timer = 0f; NotesBeforeDone = false; if (now [1].AsFloat - 7 / now [3].AsFloat < 0) { Timer = Mathf.Abs(now [1].AsFloat - 7 / now [3].AsFloat); NotesBeforeDone = false; } else { StartGame(); } }
private void processNotes(Beatmap beatmap, IList <string> lines) { var noteGenerator = new NoteGenerator(new NoteGeneratorConfig()); // Remove all karaoke note beatmap.HitObjects.RemoveAll(x => x is Note); var lyrics = beatmap.HitObjects.OfType <Lyric>().ToList(); for (int l = 0; l < lyrics.Count; l++) { var lyric = lyrics[l]; var line = lines.ElementAtOrDefault(l)?.Split('=').Last(); // Create default note if not exist if (string.IsNullOrEmpty(line)) { beatmap.HitObjects.AddRange(noteGenerator.CreateNotes(lyric)); continue; } var notes = line.Split(','); var defaultNotes = noteGenerator.CreateNotes(lyric).ToList(); var minNoteNumber = Math.Min(notes.Length, defaultNotes.Count); // Process each note for (int i = 0; i < minNoteNumber; i++) { var note = notes[i]; var defaultNote = defaultNotes[i]; // Support multi note in one time tag, format like ([1;0.5;か]|1#|...) if (!note.StartsWith("(", StringComparison.Ordinal) || !note.EndsWith(")", StringComparison.Ordinal)) { // Process and add note applyNote(defaultNote, note); beatmap.HitObjects.Add(defaultNote); } else { float startPercentage = 0; var rubyNotes = note.Replace("(", "").Replace(")", "").Split('|'); for (int j = 0; j < rubyNotes.Length; j++) { string rubyNote = rubyNotes[j]; string tone; float percentage = (float)Math.Round((float)1 / rubyNotes.Length, 2, MidpointRounding.AwayFromZero); string ruby = defaultNote.AlternativeText?.ElementAtOrDefault(j).ToString(); // Format like [1;0.5;か] if (note.StartsWith("[", StringComparison.Ordinal) && note.EndsWith("]", StringComparison.Ordinal)) { var rubyNoteProperty = note.Replace("[", "").Replace("]", "").Split(';'); // Copy tome property tone = rubyNoteProperty[0]; // Copy percentage property if (rubyNoteProperty.Length >= 2) { float.TryParse(rubyNoteProperty[1], out percentage); } // Copy text property if (rubyNoteProperty.Length >= 3) { ruby = rubyNoteProperty[2]; } } else { tone = rubyNote; } // Split note and apply them var splitDefaultNote = NoteUtils.SliceNote(defaultNote, startPercentage, percentage); startPercentage += percentage; if (!string.IsNullOrEmpty(ruby)) { splitDefaultNote.Text = ruby; } // Process and add note applyNote(splitDefaultNote, tone); beatmap.HitObjects.Add(splitDefaultNote); } } } } void applyNote(Note note, string noteStr, string ruby = null, double?duration = null) { if (noteStr == "-") { note.Display = false; } else { note.Display = true; note.Tone = convertTone(noteStr); } if (!string.IsNullOrEmpty(ruby)) { note.Text = ruby; } if (duration != null) { note.Duration = duration.Value; } //Support format : 1 1. 1.5 1+ 1# Tone convertTone(string tone) { var half = false; if (tone.Contains(".") || tone.Contains("#")) { half = true; // only get digit part tone = tone.Split('.').FirstOrDefault()?.Split('#').FirstOrDefault(); } if (!int.TryParse(tone, out int scale)) { throw new ArgumentOutOfRangeException($"{tone} does not support in {nameof(KaraokeLegacyBeatmapDecoder)}"); } return(new Tone { Scale = scale, Half = half }); } } }