Exemplo n.º 1
0
    protected virtual void StartCurSentence()
    {
        if (m_CurSentenceIndex >= CorePlayData.CurrentSong.NonRhythmSenteces.Count)
        {
            m_Status = Status.Finish;
            CorePlayManager.Instance.GameFinish();
            return;
        }

        m_CurrentStreamSentence = CorePlayData.CurrentSong.NonRhythmSenteces[m_CurSentenceIndex];
        m_CurSentenceLength     = m_CurrentStreamSentence.Duration;
        switch (m_CurrentStreamSentence.Type)
        {
        case SentenceType.NonRhythmCommon:
            m_Status = Status.Reading;

            PlayAudio();
            break;

        case SentenceType.NonRhythmVoice:
            m_Status = Status.WaitForSpeech;
            if (string.IsNullOrEmpty(m_CurrentStreamSentence.Speaker) == false)
            {
                AudioCategory ac          = AudioController.GetCategory("AudioWords");
                var           obj_speaker = ac.Play(m_CurrentStreamSentence.Speaker);
                obj_speaker.completelyPlayedDelegate = PlayNonRhythmVoice;
                m_Timer = 0;
            }
            else
            {
                PlayNonRhythmVoice();
            }
            break;
        }
    }
Exemplo n.º 2
0
    void RepeatVoice(StreamSentence sentence)
    {
        m_Status = Status.RepeatingVoice;
        m_WaitingForRepeatFinish = true;
        CorePlayManager.Instance.ShowHorn();

        if (m_AudioRepeatList.Count > 0)
        {
            // 暂时不支持拼字
            AudioCategory ac  = AudioController.GetCategory("AudioWords");
            var           obj = ac.Play(m_AudioRepeatList[0]);
            //LogManager.Log ("play : " , m_AudioRepeatList[0]);

            if (obj != null)
            {
                obj.completelyPlayedDelegate = (v) => {
                    MicManager.Instance.Play(sentence.needRecord, RepeatVoiceFinish, sentence.Sentence[0].Key);
                };
            }
        }
        else
        {
            MicManager.Instance.Play(sentence.needRecord, RepeatVoiceFinish, sentence.Sentence[0].Key);
        }
    }
Exemplo n.º 3
0
        public JsonResult Upload(string searchResalt)
        {
            var list = new List <Sentence>();
            HttpPostedFileBase upload = Request.Files[0];

            if (upload != null)
            {
                // получаем имя файла
                //string fileName = System.IO.Path.GetFileName(upload.FileName);
                // сохраняем файл в папку Files в проекте
                //upload.SaveAs(Server.MapPath("~/Files/" + "New3 " + fileName));

                System.IO.StreamReader reader = new System.IO.StreamReader(Request.Files[0].InputStream);

                StreamSentence streamSentence = new StreamSentence(reader);

                while (!streamSentence.isEnd)
                {
                    streamSentence.GetNextSentence();

                    int count = streamSentence.sentence.CountWord(searchResalt);

                    if (count > 0)
                    {
                        sqlSR.Create(new Sentence {
                            Count = count, Text = streamSentence.sentence
                        });
                        sqlSR.Save();

                        list.Add(new Sentence {
                            Count = count, Text = streamSentence.sentence
                        });
                    }
                }
            }


            return(Json(list, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
    void StartReadCurSentence()
    {
        m_Status      = Status.ReadContent;
        m_WrongNumber = 0;
        m_CurGroup    = CorePlayData.CurrentSong.StreamSentences[m_CurrentSentenceIndex];
        if (m_CurrentSentenceIndex > 0 && CorePlayData.CurrentSong.StreamSentences[m_CurrentSentenceIndex - 1].CalckSentence)
        {
            m_SentenceCheckResult = RuntimeConst.BossWarLose;
        }
        m_CurrentBossSentence   = m_CurGroup.GetOneSentence();
        m_CurrentSentenceLength = m_CurGroup.TimeLength * 0.001f * m_MoreTimeParam;
        switch (m_CurGroup.Type)

        {
        case SentenceType.Common:
            CreateSentence();
            //m_BossWarNode.ShowTip();
            //m_TapCreator.ShowWord();
            m_TapCreator.SetClickable();
            PlayAudio();
            break;

        case SentenceType.Voice:
            if (m_CurrentSentenceIndex == 0 ||
                (m_CurrentSentenceIndex > 0 && CorePlayData.CurrentSong.StreamSentences[m_CurrentSentenceIndex - 1].Type == SentenceType.Common))
            {
                //CorePlayManager.Instance.VoiceUIFadeIn(CreateVoice);
                VoiceController.Show(CreateVoice);
            }
            else
            {
                CreateVoice();
            }
            ReadContentFinish(null);
            StaticMonoBehaviour.Instance.StartCoroutine(DelayCheckMissleCreate(m_CurrentSentenceLength - 1));
            break;
        }
    }
Exemplo n.º 5
0
    static SongObject ParseOSU(TextAsset textAsset, string fileName)
    {
        SongObject  songObj      = new SongObject();
        CollectType _collectType = CollectType.General;

        string[] contents = textAsset.text.Split('\n');
        Dictionary <string, string> result = new Dictionary <string, string> ();

        result.Add("Title:", fileName);

        List <HitObject> tmpHitObject = new List <HitObject> ();
        int  k = 0;
        bool nextSentenceAheadIn = false;
        bool streamSentenceEdit  = false;


        for (int i = 0; i < contents.Length; i++)
        {
            string oneLine = contents[i].Trim();

            //空行和注释行 不解析
            if (string.IsNullOrEmpty(oneLine) || oneLine.StartsWith("//", StringComparison.Ordinal))
            {
                continue;
            }

            if (oneLine.Contains("[HitObjects]"))
            {
                _collectType = CollectType.HitObject;
                continue;
            }
            if (oneLine.Contains("[SentenceInfo]"))
            {
                _collectType = CollectType.SentenceInfo;
                continue;
            }

            switch (_collectType)
            {
            case CollectType.General:
                for (int j = 0; j < m_Fields.Length; j++)
                {
                    if (oneLine.Contains(m_Fields[j]))
                    {
                        result.Add(m_Fields[j], oneLine.Replace(m_Fields[j], ""));
                    }
                }
                break;

            case CollectType.SentenceInfo:
                if (!streamSentenceEdit)
                {                        //
                    #region 普通句子
                    SentenceObj sentenceobjs = new SentenceObj();

                    if (oneLine.Contains("@@VoiceStart"))
                    {
                        sentenceobjs.Type = SentenceType.KeyVoiceStart;
                        string[]  stringArray   = oneLine.Split(',');
                        int       sentenceStart = int.Parse(stringArray[1]);
                        InOutTime inOut         = new InOutTime(sentenceStart, sentenceStart);
                        sentenceobjs.m_InOutTime = inOut;
                        songObj.SentenceObjs.Add(sentenceobjs);
                        _collectType = CollectType.KeyAndVoice;
                        // LogManager.Log(oneLine , "     ///  _collectType = CollectType.KeyAndVoice");
                        continue;
                    }

                    if (oneLine.Contains("@@"))
                    {
                        sentenceobjs.Type = SentenceType.BossStart;
                        string[] stringArray = oneLine.Replace("@@", "").Split(',');
                        if (stringArray.Length != 2)
                        {
                            LogManager.LogError("boss战起始时间和延迟播放音乐配置错误");
                        }
                        int       sentenceStart = int.Parse(stringArray[0]);
                        int       musicDelay    = int.Parse(stringArray[1]);
                        InOutTime inOut         = new InOutTime(sentenceStart, sentenceStart);
                        sentenceobjs.m_InOutTime  = inOut;
                        songObj.BossWarMusicDelay = musicDelay;
                        streamSentenceEdit        = true;
                        songObj.SentenceObjs.Add(sentenceobjs);
                        continue;
                    }


                    string[] parse     = oneLine.Split(',');
                    int      startTime = int.Parse(parse[0]);
                    int      endTime   = int.Parse(parse[1]);


                    if (parse[2].Contains("#"))
                    {
                        sentenceobjs.Type = SentenceType.Voice;
                        parse[2]          = parse[2].Replace("#", "");
                    }
                    else
                    {
                        sentenceobjs.Type = SentenceType.Common;
                    }

                    string[] param         = parse[2].Split('$');
                    string[] wordShow      = parse[3].Split('$');
                    string[] wordSoundFile = null;
                    if (parse.Length >= 5)
                    {
                        wordSoundFile = parse[4].Split('$');
                    }
                    for (int j = 0; j < param.Length; j++)
                    {
                        if (k >= tmpHitObject.Count)
                        {
                            LogManager.LogError("OSU文件中hitObject数目 与 txt文件中的单词数量不匹配");
                            return(null);
                        }

                        try
                        {
                            ClickObj click = new ClickObj(param[j], tmpHitObject[k].Position, wordShow[j]);
                            click.m_ClickTimes = 1;
                            sentenceobjs.ClickAndHOList.ClickObjs.Add(click);
                            tmpHitObject[k].Word = param[j];
                            if (wordSoundFile != null && wordSoundFile.Length > 0)
                            {
                                if (wordSoundFile.Length == param.Length)
                                {
                                    tmpHitObject[k].SonudFile = wordSoundFile[j];
                                }
                                else
                                {
                                    LogManager.LogError(string.Format("行 {0} 有错误:句子单词个数 与 单词语音文件数量不匹配", (i + 1)));
                                    return(null);
                                }
                            }
                            sentenceobjs.ClickAndHOList.HitObjects.Add(tmpHitObject[k]);
                            k++;
                        }
                        catch (Exception e)
                        {
                            LogManager.LogError("the wrong line is:", (i + 1).ToString());
                            LogManager.LogError(e);
                            LogManager.LogError(e.StackTrace);
                        }
                    }

                    InOutTime inOutTime = new InOutTime(startTime, endTime);
                    sentenceobjs.m_InOutTime = inOutTime;
                    //判断这一句是否应该延迟删除,下一句是否应该提前出现

                    if (endTime - sentenceobjs.ClickAndHOList.HitObjects[sentenceobjs.ClickAndHOList.HitObjects.Count - 1].StartMilliSecond < CorePlaySettings.Instance.m_MinIntervalBeforeSentenceEnd)
                    {                            //这一句延迟删除,下一句提前出现
                        if (nextSentenceAheadIn)
                        {
                            sentenceobjs.m_InOutTime.InOut = EffectInOutTiming.Both;
                        }
                        else
                        {
                            sentenceobjs.m_InOutTime.InOut = EffectInOutTiming.DelayOut;
                            nextSentenceAheadIn            = true;
                        }
                    }
                    else
                    {
                        if (nextSentenceAheadIn)
                        {
                            sentenceobjs.m_InOutTime.InOut = EffectInOutTiming.AheadIn;
                            nextSentenceAheadIn            = false;
                        }
                    }

                    songObj.SentenceObjs.Add(sentenceobjs);
                    #endregion
                }
                else
                {
                    #region boss句子
                    string[]            parse = oneLine.Split(',');
                    StreamSentenceGroup group = new StreamSentenceGroup();
                    if (parse.Length == 5 && parse[4].Equals("BB"))
                    {
                        group.CalckSentence = true;
                    }
                    else
                    {
                        group.CalckSentence = false;
                    }
                    group.SetTimeLength(int.Parse(parse[0]));
                    if (parse[1].Contains("#"))
                    {
                        group.SetSentenceType(SentenceType.Voice);
                        parse[1] = parse[1].Replace("#", "");
                    }
                    else
                    {
                        group.SetSentenceType(SentenceType.Common);
                    }
                    string[] matchSentences = parse[1].Replace("@@", "").Split('|');
                    string[] showSentences  = parse[2].Split('|');
                    string[] fileNames      = parse[3].Split('|');
                    if (matchSentences.Length != showSentences.Length || showSentences.Length != fileNames.Length)
                    {
                        LogManager.LogError("TXT文件 第 ", (i + 1).ToString(), "行报错:断句数量不匹配");
                        return(null);
                    }
                    else
                    {
                        int sentenceNumber = matchSentences.Length;
                        for (int line = 0; line < sentenceNumber; line++)
                        {
                            StreamSentence bossSentence = new StreamSentence();
                            bossSentence.SetAudioFileName(fileNames[line].ToLower());
                            string[] words     = matchSentences[line].Split('$');
                            string[] showWords = showSentences[line].Split('$');

                            if (words.Length != showWords.Length)
                            {
                                LogManager.LogError("TXT文件 第 ", (i + 1).ToString(), "行报错:单词数量不匹配 ",
                                                    words.Length.ToString(), "/" + showWords.Length.ToString());
                                return(null);
                            }
                            else
                            {
                                for (int index = 0; index < words.Length; index++)
                                {
                                    KeyValuePair <string, string> kv = new KeyValuePair <string, string> (words[index], showWords[index]);
                                    bossSentence.AddToSentence(kv);
                                }
                            }
                            group.AddSentence(bossSentence);
                        }
                    }

                    songObj.StreamSentences.Add(group);
                    #endregion
                }
                break;

            case CollectType.HitObject:
                if (oneLine.Contains("C") || oneLine.Contains("P") || oneLine.Contains("L") || oneLine.Contains("B"))
                {                        //2017年10月28日版本先不做这些功能
                    continue;
                }
                else
                {
                    string[] param = oneLine.Split(',');
                    if (param.Length != 6)
                    {
                        LogManager.LogError("data parse error: the data file is  --", fileName);
                    }
                    else
                    {
                        Vector2 pos       = new Vector2(int.Parse(param[0]), int.Parse(param[1]));
                        int     startTime = int.Parse(param[2]);
                        int     type      = int.Parse(param[3]);
                        int     soundType = int.Parse(param[4]);

                        HitObject ho = new HitObject(pos, startTime, type, soundType);

                        tmpHitObject.Add(ho);
                    }
                }
                break;

            case CollectType.KeyAndVoice:
                //LogManager.Log(oneLine , " |||||  case CollectType.KeyAndVoice:");

                string[] parses = oneLine.Split(',');
                if (parses.Length < 3)
                {
                    LogManager.LogError("TXT文件 第 ", (i + 1).ToString(), "行报错:分段不够");
                    return(null);
                }

                StreamSentence ss = new StreamSentence();
                ss.SetDuration(int.Parse(parses[0]) * 0.001f);
                if (parses[1].StartsWith("#", StringComparison.Ordinal))
                {
                    //parses[1] = parses[1].Substring(1);
                    parses[1] = parses[1].Replace("#", "");
                    //LogManager.Log ("   需要录音 = " , parses[1]);
                    ss.needRecord = true;
                    ss.SetType(SentenceType.NonRhythmVoice);
                    //if (parses[1].StartsWith ("#", StringComparison.Ordinal))
                    //{
                    //	parses[1] = parses[1].Substring (1);
                    //	ss.needRecord = true;
                    //}
                }
                else
                {
                    ss.SetType(SentenceType.NonRhythmCommon);
                }

                if (parses.Length == 4)
                {
                    string[] tempAudios = parses[3].Split('|');
                    if (string.IsNullOrEmpty(tempAudios[0]) == false)
                    {
                        ss.SetAudioFileName(tempAudios[0].ToLower());
                    }
                    if (tempAudios.Length == 2 && string.IsNullOrEmpty(tempAudios[1]) == false)
                    {
                        ss.Speaker = tempAudios[1];
                    }
                    //ss.SetAudioFileName(parses[3]);
                }

                string[] firstWords = parses[1].Split('$');
                string[] clickWords = parses[2].Split('$');

                if (firstWords.Length != clickWords.Length)
                {
                    LogManager.LogError("TXT文件 第 ", (i + 1).ToString(), "行报错:单词数量不匹配");
                    return(null);
                }
                else
                {
                    for (int index = 0; index < firstWords.Length; index++)
                    {
                        KeyValuePair <string, string> kv = new KeyValuePair <string, string> (firstWords[index], clickWords[index]);
                        ss.AddToSentence(kv);
                        //ClickObj click = new ClickObj(kv.Key, tmpHitObject[k].Position, kv.Value);
                        //ClickObj click = new ClickObj(kv.Key, Vector2.zero, kv.Value);
                        //click.m_ClickTimes = 1;
                        //ss.ClickAndHOList.ClickObjs.Add(click);
                        //tmpHitObject[k].Word = kv.Key;
                        //ss.ClickAndHOList.HitObjects.Add(tmpHitObject[k]);
                        //k++;
                    }
                }
                songObj.NonRhythmSenteces.Add(ss);
                break;
            }
        }

        songObj.SetContents(result);

        return(songObj);
    }
Exemplo n.º 6
0
 public void AddSentence(StreamSentence sentence)
 {
     m_Group.Add(sentence);
 }