public List <Note> NoteObjMake(ObaMusicData obaMusicData) //実際にオブジェクトを生成する部分 { splitText = obaMusicData.noteData.Split(char.Parse("\n")); //テキストを改行ごとに分ける rowLength = obaMusicData.noteData.Split('\n').Length; barTime = 60 / (obaMusicData.BPM / 4); rowNum = 0; for (int i = 1; i <= (rowLength / 2); i++) { if (i == 1) { Debug.Log("real start 1 = " + Time.time); } MakeOneBar(i, obaMusicData.waitTime, i, obaMusicData); } return(noteList); }
public bool MakeOneBar(int skipBar, float wait, int barNumber, ObaMusicData obaMusicData) //1小節分のオブジェクトを生成する { Vector3 pos, size; pos.y = 0; size.x = 0.3f; size.y = 1; Note n; NoteMove nm; string lineData; //各行のデータを入れる GameObject obj; if (SearchWord("--") == false) { return(false); } int startline = rowNum; //Debug.Log("startline is " + startline); rowNum++; if (SearchWord("--") == false) { return(false); } //Debug.Log("textNum is " + textNum); float interval = barTime / (rowNum - startline - 1); //(textNum - startline - 1)は行の数 float laneWidth = width / obaMusicData.splitLane; for (int i = 0; (startline + 1 + i) < rowNum; i++) { /*Debug.Log("小節の中の" + (i + 1) + "行目");*/ lineData = (Regex.Replace(splitText[startline + 1 + i], @"[^0-9A-Za-z]", "")); Debug.Log("lineData is" + lineData); for (int l = 0; l < lineData.Length; l++) { if ((lineData[l] > '0' && lineData[l] <= '0' + obaMusicData.splitLane) || (lineData[l] - 'a' >= 0 && lineData[l] - 'a' + '9' + 1 <= '0' + obaMusicData.splitLane)) //数字の範囲の場合 || アルファベットの場合|| { noteNum++; obj = Instantiate(Pref); pos.x = (hitPos - (skipBar * barTime * NoteMaster.speed) - (i * interval * NoteMaster.speed) - (wait * NoteMaster.speed)); //判定ラインから操作されるまでの時間(ここまでの小節分の時間+この小節内でどれくらい待つか+waittime分) Debug.Log("pos.x = " + pos.x); pos.z = lineData[l] <= '9' ? (float)(lineData[l] - '1') / 2 * laneWidth + left + (l + 0.5f) * laneWidth : (float)(lineData[l] - 'a' + 9) / 2 * laneWidth + left + (l + 0.5f) * laneWidth; //数字:アルファベット 位置とサイズを決定 obj.transform.position = pos; size.z = lineData[l] <= '9'? (lineData[l] - '0') * laneWidth - 0.1f : ((lineData[l] - 'a' + 10) * laneWidth - 0.1f); obj.transform.localScale = size; Debug.Log("objsize = " + size.z); nm = obj.GetComponent <NoteMove>(); nm.SetSpeed(NoteMaster.speed); n = obj.GetComponent <Note>(); n.noteType = GetNoteType(l, lineData[l] - '0'); n.noteMove = nm; n.justTime = obaMusicData.waitTime + (barNumber * barTime) + (i * interval); n.noteNum = noteNum; if (isAssist) { ChangeColor(noteNum, obj); } noteList.Add(n); } else if (lineData[l] != '0') { break; } } } return(true); }