Ejemplo n.º 1
0
    private void FixedUpdate()
    {
        time = _audioSource.time + MusicManager.instance.data_OFFSET;
        float fixTime = time;

        if (time >= currentSTOP.stopTiming_Time)
        {
            time = currentSTOP.stopTiming_Time - currentSTOP.totalStopTime;
        }
        else
        {
            time -= currentSTOP.totalStopTime;
        }

        Vector3 pos = parentObj.transform.position;

        pos.y = originYPos -
                ((time - currentBPM.currentTime) * movePerSec * currentBPM.correctionNum + currentBPM.currentLength_Total)
                * MusicManager.instance.multi;
        parentObj.transform.position = pos;

        if (MusicManager.instance.data_BPM.Count > nextNum_BPM &&
            time >= MusicManager.instance.data_BPM[nextNum_BPM].currentTime)
        {
            currentBPM = SetBPMS();
        }

        if (MusicManager.instance.data_STOP.Count > nextNum_Stop &&
            _audioSource.time >= currentSTOP.stopTiming_AfterTime)
        {
            currentSTOP = SetStops();
        }
    }
Ejemplo n.º 2
0
 private void Start()
 {
     parentObj   = MusicManager.instance.parentObj;
     originYPos  = parentObj.transform.position.y;
     currentBPM  = SetBPMS();
     currentSTOP = SetStops();
 }
Ejemplo n.º 3
0
    private STOPS GetStop(NotesInfo info, bool isLN = false)
    {
        STOPS stop = null;

        float pos = info.bar + ((float)info.th / info.barOriginTh);

        if (isLN)
        {
            pos = info.LNend_bar + (info.LNend_th / info.LNend_barOriginTh);
        }

        for (int i = 0; i < data_STOP.Count; i++)
        {
            if (pos <= data_STOP[i].stopTiming)
            {
                if (i == 0)
                {
                    stop = data_STOP[i];
                }
                else
                {
                    stop = data_STOP[i /* - 1*/];
                }
                break;
            }
            stop = data_STOP[i];
        }
        if (stop == null)
        {
            stop = data_STOP[data_STOP.Count - 1];
        }

        return(stop);
    }
Ejemplo n.º 4
0
    private STOPS SetStops()
    {
        STOPS data = MusicManager.instance.data_STOP[nextNum_Stop];

        Debug.Log(GetTime("sec") + ":SetStops:" + data.stopTiming_Time);
        nextNum_Stop++;
        return(data);
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 譜面を生成するよ
    /// </summary>
    private void GenerateScore()
    {
        if (data_BPM.Count == 0)
        {
            Debug.LogWarning("BPM情報が見つかりませんでした");
            return;
        }

        Init_noteObjects();

        float offset = data_OFFSET;

        float[] xPos = { -7.0f, -5.0f, -3.0f, -1.0f };
        for (int x = 0; x < data_MusicScore.Length; x++)
        {
            for (int y = 0; y < data_MusicScore[x].Count; y++)
            {
                NotesInfo info = data_MusicScore[x][y];
                BPMS      bpm  = GetBPM(info);
                STOPS     stop = GetStop(info);

                GameObject obj        = Instantiate(notesPrefab);
                float      noteBarPos = (float)info.bar + (float)info.th / (float)info.barOriginTh;

                NotesScript note = obj.AddComponent <NotesScript>();
                note.stopdata = stop;

                note.notesTiming = bpm.currentTime + 240f / bpm.BPM * (noteBarPos - bpm.changeTiming);
                note.type        = info.type;
                obj.transform.SetParent(parentObj.transform);

                float yPos = bpm.currentLength_Total + (noteBarPos - bpm.changeTiming) * bpm.scoreLengthPerBar * bpm.correctionNum;

                obj.transform.localPosition = new Vector3(xPos[x], yPos * multi, 0f);

                if (info.type == ScoreIndex.LONG)
                {
                    GameObject obj2 = Instantiate(notesPrefab);
                    noteBarPos = (float)info.LNend_bar + (float)info.LNend_th / (float)info.LNend_barOriginTh;

                    note.LNendObj = obj2;
                    note.lr       = obj.AddComponent <LineRenderer>();
                    note          = obj2.AddComponent <NotesScript>();

                    note.type        = ScoreIndex.LONG_END;
                    note.notesTiming = bpm.currentTime + 240f / bpm.BPM * (noteBarPos - bpm.changeTiming);
                    obj2.transform.SetParent(parentObj.transform);
                    yPos = bpm.currentLength_Total + (noteBarPos - bpm.changeTiming) * bpm.scoreLengthPerBar * bpm.correctionNum;

                    obj2.transform.localPosition = new Vector3(xPos[x], yPos * multi, 0f);
                    obj2.transform.SetParent(obj.transform);
                }

                noteObjects[x].Enqueue(obj);
            }
        }
    }
Ejemplo n.º 6
0
    private void STOPData_Add(List <int> data)
    {
        for (int i = 0; i < data_STOP.Count; i++)
        {
            data_STOP[i].stopTiming_OriginTh = data[data_STOP[i].stopTiming_Bar];
            data_STOP[i].stopTiming          = data_STOP[i].stopTiming_Bar +
                                               ((float)data_STOP[i].stopTiming_Th / data_STOP[i].stopTiming_OriginTh);

            NotesInfo info = new NotesInfo();

            info.bar         = data_STOP[i].stopTiming_Bar;
            info.th          = data_STOP[i].stopTiming_Th;
            info.barOriginTh = data_STOP[i].stopTiming_OriginTh;

            BPMS bpm = GetBPM(info);

            float afterPos  = data_STOP[i].stopTiming;
            float beforePos = bpm.changeTiming;

            data_STOP[i].stopTiming_Time = bpm.currentTime +
                                           240f / bpm.BPM * (afterPos - beforePos);

            data_STOP[i].stopTiming_AfterTime = data_STOP[i].stopTiming_Time + data_STOP[i].stopTime;

            if (i == 0)
            {
                continue;
            }

            data_STOP[i].totalStopTime         = data_STOP[i - 1].stopTime + data_STOP[i - 1].totalStopTime;
            data_STOP[i].stopTiming_Time      += data_STOP[i].totalStopTime;
            data_STOP[i].stopTiming_AfterTime += data_STOP[i].totalStopTime;
        }

        STOPS addData = new STOPS();

        addData.stopTiming_Time = float.MaxValue;
        if (data_STOP.Count == 0)
        {
            data_STOP.Add(addData);
            return;
        }
        STOPS basestop = data_STOP[data_STOP.Count - 1];

        addData.totalStopTime = basestop.totalStopTime + basestop.stopTime;
        data_STOP.Add(addData);
    }
Ejemplo n.º 7
0
    private List <STOPS> BreakContents_STOP(string contents)
    {
        List <STOPS>  stops         = new List <STOPS>();
        List <string> breakContents = new List <string>();
        int           index         = 0;

        for (int i = 0; i < contents.Length; i++)
        {
            if (contents.Substring(i, 1) == ",")
            {
                breakContents.Add(contents.Substring(index, i - index));
                index = i + 1;
            }
        }

        breakContents.Add(contents.Substring(index, contents.Length - index));

        foreach (string str in breakContents)
        {
            if (str.Contains("=") == false)
            {
                break;
            }

            int   equal    = str.IndexOf("=");
            STOPS stop     = new STOPS();
            float stopTime = float.Parse(str.Substring(equal + 1, str.Length - equal - 1));

            stop.stopTime = stopTime;

            string timing = str.Substring(0, equal);

            if (timing.Contains("-"))
            {
                int pos = timing.IndexOf("-");
                stop.stopTiming_Bar = int.Parse(timing.Substring(0, pos));
                stop.stopTiming_Th  = int.Parse(timing.Substring(pos + 1, timing.Length - pos - 1));
            }
            else
            {
                stop.stopTiming_Bar = int.Parse(timing);
            }
            stops.Add(stop);
            Debug.Log(stop.stopTiming_Bar + ":" + stop.stopTiming_Th + "=" + stop.stopTime);
        }
        return(stops);
    }