Пример #1
0
 private void Start()
 {
     parentObj   = MusicManager.instance.parentObj;
     originYPos  = parentObj.transform.position.y;
     currentBPM  = SetBPMS();
     currentSTOP = SetStops();
 }
Пример #2
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();
        }
    }
Пример #3
0
    private BPMS GetBPM(NotesInfo info, bool isLN = false)
    {
        BPMS bpm = 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_BPM.Count; i++)
        {
            if (pos < data_BPM[i].changeTiming)
            {
                if (i == 0)
                {
                    bpm = data_BPM[i];
                }
                else
                {
                    bpm = data_BPM[i - 1];
                }
                break;
            }
        }
        if (bpm == null)
        {
            bpm = data_BPM[data_BPM.Count - 1];
        }

        return(bpm);
    }
Пример #4
0
    private BPMS SetBPMS()
    {
        BPMS data = MusicManager.instance.data_BPM[nextNum_BPM];

        movePerSec = data.BPM / 100f / (240f / data.BPM);
        Debug.Log(GetTime("sec") + ":SetBPMS:" + data.BPM);
        nextNum_BPM++;
        return(data);
    }
Пример #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);
            }
        }
    }
Пример #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);
    }
Пример #7
0
 void vm_GetResult(BPMS.Model.Result rlt)
 {
     this.Dispatcher.Invoke(new Action(() =>
     {
         if (rlt.IsSuccess)
         {
             if (User.Current.IsMultiRole)
             {
                 LoginSelectRoleWindow selRole = new LoginSelectRoleWindow();
                 selRole.ShowDialog();
             }
             else
             {
                 MainWindow main = new MainWindow();
                 main.Show();
             }
             this.Close();
         }
         else
         {
             MessageDxUtil.ShowWarning(rlt.Message);
         }
     }));
 }
Пример #8
0
    //譜面読み込み
    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];
            }
        }
    }
Пример #9
0
    /// <summary>
    /// BPMを入れるよ
    /// </summary>
    /// <param name="contents">情報</param>
    /// <returns></returns>
    private List <BPMS> BreakContents_BPM(string contents)
    {
        List <BPMS>   bpms          = new List <BPMS>();
        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("=");
            BPMS  bpm        = new BPMS();
            float currentBpm = float.Parse(str.Substring(equal + 1, str.Length - equal - 1));
            bpm.BPM = currentBpm;
            bpm.scoreLengthPerBar = currentBpm / scoreLengthThumbnail;
            string timing = str.Substring(0, equal);

            if (timing.Contains("-"))
            {
                int pos = timing.IndexOf("-");
                bpm.changeTiming_Bar = int.Parse(timing.Substring(0, pos));
                bpm.changeTiming_Th  = int.Parse(timing.Substring(pos + 1, timing.Length - pos - 1));
            }
            else
            {
                bpm.changeTiming_Bar = int.Parse(timing);
            }
            bpms.Add(bpm);

            if (minBPM == 0.0f)
            {
                minBPM = bpm.BPM;
            }
            else if (minBPM > bpm.BPM)
            {
                minBPM = bpm.BPM;
            }

            if (maxBPM == 0.0f)
            {
                maxBPM = bpm.BPM;
            }
            else if (maxBPM < bpm.BPM)
            {
                maxBPM = bpm.BPM;
            }
        }
        return(bpms);
    }