protected virtual void ProcessEvents(CorePlayTimerEvent te)
    {
        switch (te.m_Type)
        {
        case CorePlayTimerEvent.EventType.CreateTapSentence:
            m_TapCreator.CreateWords(CorePlayData.CurrentSong.SentenceObjs[te.m_SentenceIndex], te.m_SentenceIndex);
            break;

        case CorePlayTimerEvent.EventType.HighLightTap:
            m_TapCreator.HighLightWord(CorePlayData.CurrentSong.SentenceObjs[te.m_SentenceIndex].ClickAndHOList.HitObjects, te.m_HOIndex, 0);
            AudioController.Play("dong");
            break;

        case CorePlayTimerEvent.EventType.StartPlayMusic:
            StartCurrentSong();
            break;
        }
    }
    public Queue <CorePlayTimerEvent> GetTimerEventQueue()
    {//按照事件发生的顺序来写入timer event 队列。
        Queue <CorePlayTimerEvent> queue = new Queue <CorePlayTimerEvent>();

        int bpmDelta = (int)(CorePlayData.CurrentSong.BPM / 60f / 2f * 1000);

        #region CalcIntrada

        CorePlayTimerEvent playMusic = new CorePlayTimerEvent(0, CorePlayTimerEvent.EventType.StartPlayMusic, 0, 0);
        queue.Enqueue(playMusic);

        #endregion

        int preTime = bpmDelta > CorePlaySettings.Instance.m_PreShowTimeLength ? CorePlaySettings.Instance.m_PreShowTimeLength : bpmDelta;

        #region Sentence And HighLight

        for (int i = 0; i < CorePlayData.CurrentSong.SentenceObjs.Count; i++)
        {
            SentenceObj so = CorePlayData.CurrentSong.SentenceObjs[i];

            switch (so.Type)
            {
            case SentenceType.Common:
                int preShowTime = so.m_InOutTime.StartTime - preTime;

                CorePlayTimerEvent startTapSentence = new CorePlayTimerEvent(preShowTime, CorePlayTimerEvent.EventType.CreateTapSentence, i, 0);
                queue.Enqueue(startTapSentence);

                for (int j = 0; j < so.ClickAndHOList.HitObjects.Count; j++)
                {
                    CorePlayTimerEvent highLightTap = new CorePlayTimerEvent(so.ClickAndHOList.HitObjects[j].StartMilliSecond, CorePlayTimerEvent.EventType.HighLightTap, i, j);
                    queue.Enqueue(highLightTap);
                }
                break;
            }
        }
        #endregion

        return(queue);
    }
Example #3
0
    public Queue <CorePlayTimerEvent> GetTimerEventQueue()
    {    //按照事件发生的顺序来写入timer event 队列。
        Queue <CorePlayTimerEvent> queue = new Queue <CorePlayTimerEvent>();

        int bpmDelta = (int)(CorePlayData.CurrentSong.BPM / 60f / 2f * 1000);

        #region CalcIntrada
        if (CorePlayData.CurrentSong.SentenceObjs[0].Type != SentenceType.BossStart)
        {
            CorePlayTimerEvent playMusic = new CorePlayTimerEvent(0, CorePlayTimerEvent.EventType.StartPlayMusic, 0, 0);
            queue.Enqueue(playMusic);
            int startCountTime            = CorePlayData.CurrentSong.SentenceObjs[0].m_InOutTime.StartTime - (bpmDelta * 4);
            CorePlayTimerEvent startCount = new CorePlayTimerEvent(startCountTime, CorePlayTimerEvent.EventType.StartCount, 0, 0);
            queue.Enqueue(startCount);
        }
        #endregion

        #region Sentence And HighLight
        bool voiceShowing = false;
        //int beatMS = (int)(60000 - CorePlayData.CurrentSong.BPM);
        for (int i = 0; i < CorePlayData.CurrentSong.SentenceObjs.Count; i++)
        {
            SentenceObj so = CorePlayData.CurrentSong.SentenceObjs[i];

            switch (so.Type)
            {
            case SentenceType.Common:
                int preShowTime = so.m_InOutTime.StartTime - CorePlaySettings.Instance.m_PreShowTimeLength;
                if (voiceShowing)
                {
                    CorePlayTimerEvent endVoiceBG = new CorePlayTimerEvent(preShowTime, CorePlayTimerEvent.EventType.EndVoiceUI, 0, 0);
                    queue.Enqueue(endVoiceBG);
                    CorePlayTimerEvent endVoiceCheck = new CorePlayTimerEvent(preShowTime, CorePlayTimerEvent.EventType.EndVoiceChecker, 0, 0);
                    queue.Enqueue(endVoiceCheck);
                    voiceShowing = false;
                }

                // 1 创建 句子 事件
                CorePlayTimerEvent startTapSentence = new CorePlayTimerEvent(preShowTime, CorePlayTimerEvent.EventType.CreateTapSentence, i, 0);
                queue.Enqueue(startTapSentence);

                // 2 检查 点击 事件
                CorePlayTimerEvent startTapSentenceCheck = new CorePlayTimerEvent(preShowTime, CorePlayTimerEvent.EventType.StartTapChecker, i, 0);
                queue.Enqueue(startTapSentenceCheck);

                //float higlLightTime = 0;
                for (int j = 0; j < so.ClickAndHOList.HitObjects.Count; j++)
                {
                    //higlLightTime = temp * 0.001f;
                    int highLightTimer = so.ClickAndHOList.HitObjects[j].StartMilliSecond - CorePlaySettings.Instance.m_PreShowTimeLength;
                    // 3 读!! 单词 事件
                    CorePlayTimerEvent highLightTap = new CorePlayTimerEvent(highLightTimer, CorePlayTimerEvent.EventType.HighLightTap, i, j, 0.4f);
                    queue.Enqueue(highLightTap);
                }

                break;

            case SentenceType.BossStart:
                CorePlayTimerEvent bossStart = new CorePlayTimerEvent(so.m_InOutTime.StartTime, CorePlayTimerEvent.EventType.StartBoss, 0, 0);
                queue.Enqueue(bossStart);
                break;

            case SentenceType.Voice:
                int preVoiceShowTime = so.m_InOutTime.StartTime - CorePlaySettings.Instance.m_PreShowTimeLength;
                if (!voiceShowing)
                {
                    // 00 显示 UI
                    CorePlayTimerEvent startVoiceBG = new CorePlayTimerEvent(preVoiceShowTime, CorePlayTimerEvent.EventType.StartVoiceUI, 0, 0);
                    queue.Enqueue(startVoiceBG);
                    voiceShowing = true;
                }

                // 1 创建 句子 事件
                CorePlayTimerEvent startVoiceSentence = new CorePlayTimerEvent(preVoiceShowTime, CorePlayTimerEvent.EventType.CreateVoiceSentence, i, 0);
                queue.Enqueue(startVoiceSentence);

                // 2 检查 "语音" 事件  ( 普通关 每句 )
                CorePlayTimerEvent startVoiceSentenceCheck = new CorePlayTimerEvent(so.m_InOutTime.StartTime, CorePlayTimerEvent.EventType.StartVoiceChecker, i, 0);
                queue.Enqueue(startVoiceSentenceCheck);

                for (int j = 0; j < so.ClickAndHOList.HitObjects.Count; j++)
                {
                    int ms = (int)(CorePlayData.TB * CorePlaySettings.Instance.m_VoiceTBParam * 1000);
                    int highLightVoiceTime = so.ClickAndHOList.HitObjects[j].StartMilliSecond - ms;
                    //LogManager.Log("  读!! 单词 事件 = " , j , "  / " , so.HitObjects[j].StartMilliSecond , "/ " , ms);
                    // 3 读!! 单词 事件
                    CorePlayTimerEvent highLightVoice = new CorePlayTimerEvent(highLightVoiceTime, CorePlayTimerEvent.EventType.HighLightVoice, i, j);
                    queue.Enqueue(highLightVoice);
                }
                break;

            case SentenceType.KeyVoiceStart:
                CorePlayTimerEvent keyVoice = new CorePlayTimerEvent(so.m_InOutTime.StartTime, CorePlayTimerEvent.EventType.StartKeyVoice, 0, 0);
                queue.Enqueue(keyVoice);
                break;
            }
        }
        #endregion

        return(queue);
    }
    private void ProcessEvents(CorePlayTimerEvent te)
    {
        switch (te.m_Type)
        {
        case CorePlayTimerEvent.EventType.CreateTapSentence:
            //Debug.Log("CreateTapSentence = " + te.m_Timer + " / time = " + Time.time);
            m_TapCreator.CreateWords(CorePlayData.CurrentSong.SentenceObjs[te.m_SentenceIndex], te.m_SentenceIndex);
            break;

        case CorePlayTimerEvent.EventType.CreateVoiceSentence:
            m_VoiceCreator.CreateWords(CorePlayData.CurrentSong.SentenceObjs[te.m_SentenceIndex], te.m_SentenceIndex);
            //Debug.Log(" 0 = 普通模式 开始录音" + "  / " + Time.frameCount);
            StartMicRecord();
            break;

        case CorePlayTimerEvent.EventType.EndVoiceChecker:
            Debug.Log(" 1 = 普通模式 结束录音");
            StopMicRecord();
            break;

        case CorePlayTimerEvent.EventType.EndVoiceUI:
            m_VoiceCreator.BGFadeOut();
            if (m_StartAutoPlay)
            {
                m_AutoPlay.Show();
            }
            break;

        case CorePlayTimerEvent.EventType.HighLightTap:
            string word = CorePlayData.CurrentSong.SentenceObjs[te.m_SentenceIndex].ClickAndHOList.HitObjects[te.m_HOIndex].Word.ToLower();
            m_TapCreator.HighLightWord(CorePlayData.CurrentSong.SentenceObjs[te.m_SentenceIndex].ClickAndHOList.HitObjects, te.m_HOIndex, te.m_HighLightTime);
            m_InputCheck.SetCurHOIndex(te.m_SentenceIndex, te.m_HOIndex);
            if (m_StartAutoPlay)
            {
                ClickObj co = CorePlayData.CurrentSong.SentenceObjs[te.m_SentenceIndex].ClickAndHOList.ClickObjs[te.m_HOIndex];
                m_AutoPlay.Simulate(CorePlaySettings.Instance.m_PreShowTimeLength * RuntimeConst.MSToSecond, co.m_Position);
            }
            StartCoroutine(HOPointTimeLogic(CorePlayData.CurrentSong.SentenceObjs[te.m_SentenceIndex].ClickAndHOList.HitObjects[te.m_HOIndex]));
            break;

        case CorePlayTimerEvent.EventType.HighLightVoice:
            m_VoiceCreator.HighLightWord(CorePlayData.CurrentSong.SentenceObjs[te.m_SentenceIndex].ClickAndHOList.HitObjects, te.m_HOIndex);
            break;

        case CorePlayTimerEvent.EventType.StartCount:
            CorePlayIntrada intrada = new CorePlayIntrada(CorePlayData.BMPDelta, () => { m_IntradaStatus = IntradaStatus.Played; });
            intrada.Show();
            m_IntradaStatus = IntradaStatus.Playing;
            break;

        case CorePlayTimerEvent.EventType.StartPlayMusic:
            StartCurrentSong();
            break;

        case CorePlayTimerEvent.EventType.StartTapChecker:
            // Temp Event
            CorePlaySceneManager.checkSentenceEvent.Invoke();
            int sentenceLength = CorePlayData.CurrentSong.SentenceObjs[te.m_SentenceIndex].m_InOutTime.EndTime -
                                 CorePlayData.CurrentSong.SentenceObjs[te.m_SentenceIndex].m_InOutTime.StartTime;
            int timeLength = sentenceLength +
                             CorePlaySettings.Instance.m_PreShowTimeLength;
            m_InputCheck.CreateCheckSentenceWithMS(CorePlayData.CurrentSong.SentenceObjs[te.m_SentenceIndex].ClickAndHOList.HitObjects, te.m_SentenceIndex, sentenceLength);
            float duration = timeLength * 0.001f;
            StartCoroutine(SentenceCheck(te.m_SentenceIndex, duration));
            break;

        case CorePlayTimerEvent.EventType.StartVoiceChecker:
            CreateVoiceCheck(te.m_SentenceIndex);
            break;

        case CorePlayTimerEvent.EventType.StartVoiceUI:
            m_VoiceCreator.BGFadeIn();
            if (m_StartAutoPlay)
            {
                m_AutoPlay.Close();
            }
            break;

        case CorePlayTimerEvent.EventType.StartBoss:
            StartBossWarLogic();
            break;

        case CorePlayTimerEvent.EventType.StartKeyVoice:
            StartKeyAndVoice();
            break;
        }
    }