//譜面読み込み void SonglistReadin() { TextAsset textasset = new TextAsset(); textasset = Resources.Load("SONGS/" + SongKeyword + "." + SongHard, typeof(TextAsset)) as TextAsset; string TextLines = textasset.text; TextLines = ScriptString.RemoveSlash(TextLines); //コメントの場所を取り除く //TextLines = ScriptString.RemoveSpace(TextLines); //スペースがある場所を取り除く TextLines = ScriptString.RemoveTab(TextLines); //タッブがある場所を取り除く TextLines = ScriptString.RemoveEnter(TextLines); //複数のエンターの場所を取り除く string[] s = TextLines.Split('\n'); drbfile.onpuWeightCount = 0; for (int i = 0; i < s.Length; i++) { //空き行を抜く if (s[i] == "") { continue; } //命令行を認識 if (s[i].Substring(0, 1) == "#") { //OFFSET認識 if (s[i].Substring(0, Mathf.Min(s[i].Length, "#OFFSET".Length)) == "#OFFSET") { string ss = s[i]; ss = ss.Replace("#OFFSET=", ""); ss = ss.Replace(";", ""); drbfile.offset = float.Parse(ss); } //BEAT認識 if (s[i].Substring(0, Mathf.Min(s[i].Length, "#BEAT".Length)) == "#BEAT") { string ss = s[i]; ss = ss.Replace("#BEAT=", ""); ss = ss.Replace(";", ""); drbfile.beat = float.Parse(ss); } //BPM_NUMBER認識 //if (s[i].Substring(0, "#BPM_NUMBER".Length) == "#BPM_NUMBER") //{ // string ss = s[i]; // ss = ss.Replace("#BPM_NUMBER=", ""); // ss = ss.Replace(";", ""); // drbfile.bpms = new List<BPMS>(); //} //SCN認識 //if (s[i].Substring(0, "#SCN".Length) == "#SCN") //{ // string ss = s[i]; // ss = ss.Replace("#SCN=", ""); // ss = ss.Replace(";", ""); // drbfile.scns = new List<SCNS>(); //} //BPM [i]認識 if (s[i].Substring(0, Mathf.Min(s[i].Length, ("#BPM [" + drbfile.bpms.Count + "]").Length)) == ("#BPM [" + drbfile.bpms.Count + "]")) { string ss = s[i]; string ss2 = s[i + 1]; ss = ss.Replace("#BPM [" + drbfile.bpms.Count + "]=", ""); ss = ss.Replace(";", ""); ss2 = ss2.Replace("#BPMS[" + drbfile.bpms.Count + "]=", ""); ss2 = ss2.Replace(";", ""); BPMS bpms = new BPMS(); bpms.bpm = float.Parse(ss); bpms.bpms = float.Parse(ss2); drbfile.bpms.Add(bpms); } //SC [i]認識 if (s[i].Substring(0, Mathf.Min(s[i].Length, ("#SC [" + drbfile.scns.Count + "]").Length)) == ("#SC [" + drbfile.scns.Count + "]")) { string ss = s[i]; string ss2 = s[i + 1]; ss = ss.Replace("#SC [" + drbfile.scns.Count + "]=", ""); ss = ss.Replace(";", ""); ss2 = ss2.Replace("#SCI[" + drbfile.scns.Count + "]=", ""); ss2 = ss2.Replace(";", ""); SCNS sc = new SCNS(); sc.sc = float.Parse(ss); sc.sci = float.Parse(ss2); drbfile.scns.Add(sc); } //NoteDesigner認識; if (s[i].Substring(0, Mathf.Min(s[i].Length, "#NDNAME".Length)) == "#NDNAME") { string ss = s[i]; ss = ss.Replace("#NDNAME=", ""); ss = ss.Replace(";", ""); ss = ss.Replace("\'", ""); drbfile.ndname = ss; } } //ノーツ行を認識 else { //Notesデータ取得 string ss = s[i].Replace("<", ""); string[] sss = ss.Substring(0, ss.Length - 2).Split('>'); TheOnpu onpu = new TheOnpu(); onpu.id = int.Parse(sss[0]); onpu.kind = int.Parse(sss[1]); if (onpu.kind == 12) { onpu.kind = 6; } if (onpu.kind == 8) { onpu.kind = 7; } onpu.ichi = float.Parse(sss[2]); onpu.pos = float.Parse(sss[3]); onpu.width = float.Parse(sss[4]); onpu.nsc = sss[5]; onpu.isnadnsc = sss[5].Contains(":"); if (!onpu.isnadnsc) { onpu.insc = float.Parse(sss[5]); } onpu.insc = onpu.insc == 0.0f ? 1.0f : onpu.insc; onpu.parent = int.Parse(sss[6]); if (sss.Length > 7) { onpu.mode = sss[7]; } else { onpu.mode = "n"; } if (onpu.mode == "P") { onpu.isnadnsc = true; } //ミラー処理 if (GameMirror) { onpu.pos = 16 - onpu.pos - onpu.width; if (onpu.kind == 13 || onpu.kind == 14) { onpu.kind = onpu.kind == 13 ? 14 : 13; } } drbfile.onpu.Add(onpu); drbfile.onpuWeightCount += OnpuWeight[onpu.kind]; } } }
// Use this for initialization void Start() { //メモリ解放 Resources.UnloadUnusedAssets(); hpManager.manager = this; hpManager.Init(hp, hpmax); backgroundStartPos = ImageBackground.transform.position; //曲ロード BGMManager.clip = null; BGMManager.clip = Resources.Load <AudioClip>("SONGS/" + SongKeyword + "." + SongHard); if (BGMManager.clip == null) { BGMManager.clip = Resources.Load <AudioClip>("SONGS/" + SongKeyword); } //SCORE初期化 SCORE_INIT(); //曲データ表示 if (textSongTitle) { textSongTitle.text = SongTitle; } if (textSongArtist) { textSongArtist.text = SongArtist; } if (textDif) { textDif.text = "Tier " + SongHard; textDif.color = TierColor[SongHard]; } if (sprSongImage) { sprSongImage.sprite = Resources.Load <Sprite>("IMAGES/" + SongKeyword); } //譜面読み込み drbfile = new DRBFile(); drbfile.bpms = new List <BPMS>(); drbfile.scns = new List <SCNS>(); drbfile.onpu = new List <TheOnpu>(); SonglistReadin(); //簡単整理 drbfile.bpms.Sort((a, b) => Mathf.RoundToInt(a.bpms * 1000.0f - b.bpms * 1000.0f)); drbfile.scns.Sort((a, b) => Mathf.RoundToInt(a.sci * 1000.0f - b.sci * 1000.0f)); drbfile.onpu.Sort((a, b) => Mathf.RoundToInt(a.ichi * 1000.0f - b.ichi * 1000.0f)); //複雑整理01:onpuのparentを探す for (int i = 0; i < drbfile.onpu.Count; i++) { for (int j = 0; j < drbfile.onpu.Count; j++) { if (drbfile.onpu[i].parent == drbfile.onpu[j].id) { drbfile.onpu[i].parent = j; break; } } } //複雑整理02:scによってdms算出 //bpm Keyframe[] BPMKeyframe = new Keyframe[drbfile.bpms.Count + 1]; BPMKeyframe[0] = new Keyframe(0.0f, drbfile.offset * 1000.0f); float[] BPM_REALTIME = new float[drbfile.bpms.Count + 1]; for (int i = 0; i < drbfile.bpms.Count; i++) { if (i == 0) { BPM_REALTIME[i] = drbfile.offset * 1000.0f; } else { BPM_REALTIME[i] = (drbfile.bpms[i].bpms - drbfile.bpms[i - 1].bpms) * (60 / drbfile.bpms[i - 1].bpm * 4 * drbfile.beat) * 1000.0f + BPM_REALTIME[i - 1]; } } BPM_REALTIME[drbfile.bpms.Count] = (10000 - drbfile.bpms[drbfile.bpms.Count - 1].bpms) * (60 / drbfile.bpms[drbfile.bpms.Count - 1].bpm * 4 * drbfile.beat) * 1000.0f + BPM_REALTIME[drbfile.bpms.Count - 1]; for (int i = 1; i < drbfile.bpms.Count; i++) { BPMKeyframe[i] = new Keyframe(drbfile.bpms[i].bpms, BPM_REALTIME[i]); } BPMKeyframe[drbfile.bpms.Count] = new Keyframe(10000, BPM_REALTIME[drbfile.bpms.Count]); LinearKeyframe(BPMKeyframe); BPMCurve = new AnimationCurve(BPMKeyframe); //SC if (drbfile.scns.Count == 0) { SCNS sCNS = new SCNS(); sCNS.sc = 1; sCNS.sci = 0; drbfile.scns.Add(sCNS); } float[] SCR = new float[drbfile.scns.Count + 1]; for (int i = 0; i < drbfile.scns.Count; i++) { if (i == 0) { SCR[i] = BPMCurve.Evaluate(drbfile.scns[i].sci); } else { SCR[i] = SCR[i - 1] + (BPMCurve.Evaluate(drbfile.scns[i].sci) - BPMCurve.Evaluate(drbfile.scns[i - 1].sci)) * drbfile.scns[i - 1].sc; } } SCR[drbfile.scns.Count] = SCR[drbfile.scns.Count - 1] + (BPMCurve.Evaluate(10000) - BPMCurve.Evaluate(drbfile.scns[drbfile.scns.Count - 1].sci)) * drbfile.scns[drbfile.scns.Count - 1].sc; Keyframe[] SCKeyframe = new Keyframe[drbfile.scns.Count + 2]; SCKeyframe[0] = new Keyframe(-10000.0f, -10000.0f); SCKeyframe[1] = new Keyframe(0.0f, 0.0f); for (int i = 0; i < drbfile.scns.Count; i++) { SCKeyframe[i + 1] = new Keyframe(BPMCurve.Evaluate(drbfile.scns[i].sci), SCR[i]); } SCKeyframe[drbfile.scns.Count + 1] = new Keyframe(BPMCurve.Evaluate(10000), SCR[drbfile.scns.Count]); LinearKeyframe(SCKeyframe); SCCurve = new AnimationCurve(SCKeyframe); //msデータ代入、効果音入れ //BGMManager.clip ac_hit = Resources.Load <AudioClip>("SE/hit"); ac_flick = Resources.Load <AudioClip>("SE/flick"); ac_gameover = Resources.Load <AudioClip>("SE/gameover"); float[] f_song = new float[BGMManager.clip.samples * BGMManager.clip.channels], f_hit = new float[ac_hit.samples * ac_hit.channels], f_flick = new float[ac_flick.samples * ac_flick.channels]; BGMManager.clip.GetData(f_song, 0); ac_hit.GetData(f_hit, 0); ac_flick.GetData(f_flick, 0); //音量半分下がる for (int i = 0; i < f_song.Length; i++) { f_song[i] *= 0.5f; } List <int> list_hit = new List <int>(), list_flick = new List <int>(); for (int i = 0; i < drbfile.onpu.Count; i++) { //音符ごと位置計算 drbfile.onpu[i].ms = BPMCurve.Evaluate(drbfile.onpu[i].ichi); drbfile.onpu[i].dms = SCCurve.Evaluate(BPMCurve.Evaluate(drbfile.onpu[i].ichi)); } for (int i = 0; i < drbfile.onpu.Count; i++) { //parentms位置計算 if (isTail(drbfile.onpu[i].kind)) { drbfile.onpu[i].parent_ms = drbfile.onpu[drbfile.onpu[i].parent].ms; drbfile.onpu[i].parent_dms = drbfile.onpu[drbfile.onpu[i].parent].dms; drbfile.onpu[i].parent_pos = drbfile.onpu[drbfile.onpu[i].parent].pos; drbfile.onpu[i].parent_width = drbfile.onpu[drbfile.onpu[i].parent].width; } } //gater音を入れる if (GameEffectGaterLevel >= 1) { for (int i = 0; i < drbfile.onpu.Count; i++) { if (isBitCrash(drbfile.onpu[i].kind)) { int end = (int)(BGMManager.clip.samples * BGMManager.clip.channels * (drbfile.onpu[i].ms / 1000.0f / BGMManager.clip.length)); int start = (int)(BGMManager.clip.samples * BGMManager.clip.channels * (drbfile.onpu[drbfile.onpu[i].parent].ms / 1000.0f / BGMManager.clip.length)); if (end >= BGMManager.clip.samples * BGMManager.clip.channels) { continue; } //後ろ半分無音にする start = (end - start) / 2 + start; for (int c = start; c < end; c++) { f_song[c] *= (10.0f - GameEffectGaterLevel) / 10.0f; } } } } //タップ音を強行入れる for (int i = 0; i < drbfile.onpu.Count; i++) { if (isTapSound(drbfile.onpu[i].kind)) { int start = (int)(BGMManager.clip.samples * BGMManager.clip.channels * (drbfile.onpu[i].ms / 1000.0f / BGMManager.clip.length)); if (start + f_hit.Length >= BGMManager.clip.samples * BGMManager.clip.channels) { continue; } if (!list_hit.Contains(start)) { list_hit.Add(start); for (int c = 0; c < f_hit.Length; c++) { if (start + c < f_song.Length) { f_song[start + c] += f_hit[c] * 0.5f * ((GameEffectTap + 3) / 10.0f); } } } } } //フリック音を強行入れる for (int i = 0; i < drbfile.onpu.Count; i++) { if (isFlick(drbfile.onpu[i].kind)) { int start = (int)(BGMManager.clip.samples * BGMManager.clip.channels * (drbfile.onpu[i].ms / 1000.0f / BGMManager.clip.length)); if (start + f_flick.Length >= BGMManager.clip.samples * BGMManager.clip.channels) { continue; } if (!list_flick.Contains(start)) { list_flick.Add(start); for (int c = 0; c < f_flick.Length; c++) { if (start + c < f_song.Length) { f_song[start + c] += f_flick[c] * 0.5f * ((GameEffectTap + 3) / 10.0f); } } } } } BGMManager.clip.SetData(f_song, 0); BGMManager.Play(); BGMManager.Pause(); //複雑整理03:ノーツ別front,back判定範囲算出 for (int i = 0; i < drbfile.onpu.Count; i++) { isCreated.Add(false); } //カメラ高さ調整 for (int i = 0; i < drbfile.onpu.Count; i++) { if (drbfile.onpu[i].pos < 0) { int s = (int)(drbfile.onpu[i].ms / 1000.0f); HgtList[s + 0] = Mathf.Max(drbfile.onpu[i].pos / (-16.0f), HgtList[s + 0]); HgtList[s + 1] = Mathf.Max(drbfile.onpu[i].pos / (-16.0f), HgtList[s + 1]); if (drbfile.onpu[i].pos < -8) { HgtList[s - 1] = Mathf.Max(drbfile.onpu[i].pos / (-32.0f), HgtList[s - 1]); HgtList[s + 2] = Mathf.Max(drbfile.onpu[i].pos / (-32.0f), HgtList[s + 2]); } } if (drbfile.onpu[i].pos + drbfile.onpu[i].width > 16) { int s = (int)(drbfile.onpu[i].ms / 1000.0f); HgtList[s + 0] = Mathf.Max((drbfile.onpu[i].pos + drbfile.onpu[i].width - 16.0f) / 16.0f, HgtList[s + 0]); HgtList[s + 1] = Mathf.Max((drbfile.onpu[i].pos + drbfile.onpu[i].width - 16.0f) / 16.0f, HgtList[s + 1]); if (drbfile.onpu[i].pos > 24) { HgtList[s - 1] = Mathf.Max((drbfile.onpu[i].pos + drbfile.onpu[i].width - 16.0f) / 32.0f, HgtList[s - 1]); HgtList[s + 2] = Mathf.Max((drbfile.onpu[i].pos + drbfile.onpu[i].width - 16.0f) / 32.0f, HgtList[s + 2]); } } } //高さカーブ生成 for (int i = 0; i < 1000; i++) { HeightCurve.AddKey(i, HgtList[i]); } //タップだけ判定範囲を保護する for (int i = 0; i < drbfile.onpu.Count; i++) { if (isTap(drbfile.onpu[i].kind)) { for (int j = 0; j < drbfile.onpu.Count; j++) { //相手側は全ノーツ //if (isTap(drbfile.onpu[j].kind)) { //距離近い、そして、重ねていると if (isCovering(drbfile.onpu[i], drbfile.onpu[j]) && Mathf.Abs(drbfile.onpu[j].ms - drbfile.onpu[i].ms) < GDms * 2.0f) { ////Back //if (drbfile.onpu[j].ms > drbfile.onpu[i].ms) //{ // drbfile.onpu[i].back = Mathf.Min(drbfile.onpu[i].back, (drbfile.onpu[j].ms - drbfile.onpu[i].ms) * 0.5f); //} ////Front //if (drbfile.onpu[j].ms < drbfile.onpu[i].ms) //{ // drbfile.onpu[i].front = Mathf.Min(drbfile.onpu[i].front, (drbfile.onpu[i].ms - drbfile.onpu[j].ms) * 0.5f); //} //isNear if (drbfile.onpu[j].ms < drbfile.onpu[i].ms) { drbfile.onpu[i].isNear = true; } //コメント:等しい場合は保護範囲外 } } } } } HPMask.color = new Color(1.0f, 1.0f, 1.0f, 0.0f); HPMask.gameObject.SetActive(false); //背景 //スコアコンボ表示 if (PlayerComboDisp > ComboDisp.COMBO) { objCombo[0].GetComponent <Text>().color = new Color(1.0f, 1.0f, 1.0f, 1.0f); objCombo[1].GetComponent <Text>().color = new Color(1.0f, 0.0f, 0.0f, 1.0f); objCombo[2].GetComponent <Text>().color = new Color(0.0f, 1.0f, 1.0f, 1.0f); objCombo[3].GetComponent <Text>().color = new Color(1.0f, 1.0f, 1.0f, 1.0f); } if (PlayerComboDisp == ComboDisp.SCORE) { objCombo[0].GetComponent <Text>().text = "0"; objCombo[1].GetComponent <Text>().text = "0"; objCombo[2].GetComponent <Text>().text = "0"; objCombo[3].GetComponent <Text>().text = "SCORE"; } if (PlayerComboDisp == ComboDisp.MSCORE) { objCombo[0].GetComponent <Text>().text = "3,000,000"; objCombo[1].GetComponent <Text>().text = "3,000,000"; objCombo[2].GetComponent <Text>().text = "3,000,000"; objCombo[3].GetComponent <Text>().text = "- SCORE"; } StartCoroutine(Init()); }