Ejemplo n.º 1
0
 private void UpdateText(KoreographyEvent koreoEvent,
                         int sampleTime,
                         int sampleDelta,
                         DeltaSlice deltaSlice)
 {
     // 判断当前事件是否有文本负荷
     if (koreoEvent.HasTextPayload())
     {
         // 更新文本的条件
         // 1.当前存储的事件为空
         // 2.事件叠加时取后面的事件
         if (m_keCurEvent == null || m_keCurEvent.StartSample < koreoEvent.StartSample)
         {
             // 更新文本
             m_text.text = koreoEvent.GetTextValue();
             // 保存此次检测到的事件
             m_keCurEvent = koreoEvent;
         }
         // 存储的最后一拍的时间 < 当前拍子的时间
         if (m_keCurEvent.EndSample < sampleTime)
         {
             // 滞空
             m_text.text  = string.Empty;
             m_keCurEvent = null;
         }
     }
 }
Ejemplo n.º 2
0
        void UpdateText(KoreographyEvent evt, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
        {
            // Verify that we have Text in the Payload.
            if (evt.HasTextPayload())
            {
                // Set the text if we have a text event!
                // We can get multiple events called at the same time (if they overlap in the track).
                //  In this case, we prefer the event with the most recent start sample.
                if (curTextEvent == null ||
                    (evt != curTextEvent && evt.StartSample > curTextEvent.StartSample))
                {
                    guiTextCom.text = evt.GetTextValue();

                    // Store for later comparison.
                    curTextEvent = evt;
                }

                // Clear out the text if our event ended this musical frame.
                if (curTextEvent.EndSample < sampleTime)
                {
                    guiTextCom.text = string.Empty;

                    // Remove so that the above timing logic works when the audio loops/jumps.
                    curTextEvent = null;
                }
            }
        }
Ejemplo n.º 3
0
        void UpdateText(KoreographyEvent evt, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
        {
            // Verify that we have Text in the Payload.
            if (evt.HasTextPayload())
            {
                // Set the text if we have a text event!
                // We can get multiple events called at the same time (if they overlap in the track).
                //  In this case, we prefer the event with the most recent start sample.
                if (curTextEvent == null ||
                    (evt != curTextEvent && evt.StartSample > curTextEvent.StartSample))
                {
                    guiTextCom.text = evt.GetTextValue();

                    // Store for later comparison.
                    curTextEvent = evt;
                }

                // Clear out the text if our event ended this musical frame.
                if (curTextEvent.EndSample < sampleTime)
                {
                    guiTextCom.text = string.Empty;

                    // Remove so that the above timing logic works when the audio loops/jumps.
                    curTextEvent = null;
                }
            }
        }
Ejemplo n.º 4
0
 void AdjustLight(KoreographyEvent evt, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
 {
     if (evt.HasIntPayload())
     {
         if (evt.GetIntValue() == 1)
         {
             lights[0].SetActive(true);
             lights[1].SetActive(true);
             lights[2].SetActive(false);
             lights[3].SetActive(false);
         }
         else if (evt.GetIntValue() == 2)
         {
             lights[0].SetActive(false);
             lights[1].SetActive(false);
             lights[2].SetActive(true);
             lights[3].SetActive(true);
         }
         else if (evt.GetIntValue() == 3)
         {
             lights[0].SetActive(true);
             lights[1].SetActive(true);
             lights[2].SetActive(true);
             lights[3].SetActive(true);
         }
         else
         {
             lights[0].SetActive(false);
             lights[1].SetActive(false);
             lights[2].SetActive(false);
             lights[3].SetActive(false);
         }
     }
 }
Ejemplo n.º 5
0
 void SetColor(KoreographyEvent evt, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
 {
     if (evt.HasCurvePayload())
     {
         float curveValue = evt.GetValueOfCurveAtTime(sampleTime);
         spriteRenderer.color = startColor * (1 - curveValue) + curveValue * targetColor;
     }
 }
Ejemplo n.º 6
0
 void SetPosition(KoreographyEvent evt, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
 {
     if (evt.HasCurvePayload())
     {
         float curveValue = evt.GetValueOfCurveAtTime(sampleTime);
         transform.position = startPosition * (1 - curveValue) + curveValue * endPosition;
     }
 }
Ejemplo n.º 7
0
 void SetScale(KoreographyEvent evt, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
 {
     if (evt.HasCurvePayload())
     {
         float curveValue = evt.GetValueOfCurveAtTime(sampleTime);
         transform.localScale = startScale * (1 - curveValue) + curveValue * targetScale;
     }
 }
Ejemplo n.º 8
0
 private void ChangeCubeScale(KoreographyEvent koreoEvent,
                              int sampleTime,
                              int sampleDelta,
                              DeltaSlice deltaSlice)
 {
     if (koreoEvent.HasCurvePayload())
     {
         float fCurValue = koreoEvent.GetValueOfCurveAtTime(sampleTime);  // 返回0~1之间的值
         transform.localScale = Vector3.one * Mathf.Lerp(m_minScale, m_maxScale, fCurValue);
     }
 }
Ejemplo n.º 9
0
        void AdjustScale(KoreographyEvent evt, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
        {
            if (evt.HasCurvePayload())
            {
                // Get the value of the curve at the current audio position.  This will be a
                //  value between [0, 1] and will be used, below, to interpolate between
                //  minScale and maxScale.
                float curveValue = evt.GetEventDeltaAtSampleTime(sampleTime);

                transform.localScale = Vector3.one * Mathf.Lerp(minScale, maxScale, curveValue);
            }
        }
Ejemplo n.º 10
0
        void AdjustScale(KoreographyEvent evt, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
        {
            if (evt.HasCurvePayload())
            {
                // Get the value of the curve at the current audio position.  This will be a
                //  value between [0, 1] and will be used, below, to interpolate between
                //  minScale and maxScale.
                float curveValue = evt.GetValueOfCurveAtTime(sampleTime);

                transform.localScale = Vector3.one * Mathf.Lerp(minScale, maxScale, curveValue);
            }
        }
Ejemplo n.º 11
0
 private void ChangeColor(KoreographyEvent koreoEvent,
                          int sampleTime,
                          int sampleDelta,
                          DeltaSlice deltaSlice)
 {
     if (koreoEvent.HasColorPayload())
     {
         Color targetColor = koreoEvent.GetColorValue();
         ApplyColorToObjects(targetColor);
     }
     else if (koreoEvent.HasGradientPayload())
     {
         Color targetColor = koreoEvent.GetColorOfGradientAtTime(sampleTime);
         ApplyColorToObjects(targetColor);
     }
 }
Ejemplo n.º 12
0
    void UpdateText(KoreographyEvent evt, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
    {
        // Verify that we have Text in the Payload.
        if (evt.HasTextPayload())
        {
            // Set the text if we have a text event!
            // We can get multiple events called at the same time (if they overlap in the track).
            //  In this case, we prefer the event with the most recent start sample.
            if (curTextEvent == null ||
                (evt != curTextEvent && evt.StartSample > curTextEvent.StartSample))
            {
                string text = evt.GetTextValue();
                Debug.Log(text);
                if (text == "left")
                {
                    spawnRend.sharedMaterial = green;
                    Invoke("Green", moveTime);
                }
                else if (text == "right")
                {
                    spawnRend.sharedMaterial = yellow;
                    Invoke("Yellow", moveTime);
                }
                else
                {
                    spawnRend.sharedMaterial = red;
                    Invoke("Red", moveTime);
                }
                cubeSpawn.createCube(text);
                // Store for later comparison.
                curTextEvent = evt;
            }

            // Clear out the text if our event ended this musical frame.
            if (curTextEvent.EndSample < sampleTime)
            {
                // guiTextCom.text = string.Empty;

                // Remove so that the above timing logic works when the audio loops/jumps.
                curTextEvent = null;
            }
        }
    }
 void AdjustColor(KoreographyEvent evt, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
 {
     // We have prepared two kinds of events that work with this system:
     //  1) OneOffs that store a Color.
     //  2) Spans that store a Gradient.
     // Ensure that we have the correct types before proceeding!
     if (evt.IsOneOff() && evt.HasColorPayload())
     {
         // This is a simple Color Payload.
         Color targetColor = evt.GetColorValue();
         ApplyColorToObjects(ref targetColor);
     }
     else if (!evt.IsOneOff() && evt.HasGradientPayload())
     {
         // Access the color specified at the current music-time.  This is what
         //  drives musical color animations from gradients!
         Color targetColor = evt.GetColorOfGradientAtTime(sampleTime);
         ApplyColorToObjects(ref targetColor);
     }
 }
Ejemplo n.º 14
0
 void AdjustColor(KoreographyEvent evt, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
 {
     // We have prepared two kinds of events that work with this system:
     //  1) OneOffs that store a Color.
     //  2) Spans that store a Gradient.
     // Ensure that we have the correct types before proceeding!
     if (evt.IsOneOff() && evt.HasColorPayload())
     {
         // This is a simple Color Payload.
         Color targetColor = evt.GetColorValue();
         ApplyColorToObjects(ref targetColor);
     }
     else if (!evt.IsOneOff() && evt.HasGradientPayload())
     {
         // Access the color specified at the current music-time.  This is what
         //  drives musical color animations from gradients!
         Color targetColor = evt.GetColorOfGradientAtTime(sampleTime);
         ApplyColorToObjects(ref targetColor);
     }
 }
Ejemplo n.º 15
0
/*    void TestPayload(KoreographyEvent evt)
 *  {
 *      print(evt.GetIntValue() + " " + Time.time);
 *  }*/

    void TestOffset(KoreographyEvent evt, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
    {
        /*print("OffSet " + Time.time);
         * print(sampleTime);
         * print(sampleDelta);*/
        if (evt.HasCurvePayload())
        {
            //print("Scale Start");
            // Get the value of the curve at the current audio position.  This will be a
            //  value between [0, 1] and will be used, below, to interpolate between
            //  minScale and maxScale.
            float curveValue = Mathf.Clamp(evt.GetValueOfCurveAtTime(sampleTime), 0.5f, 1);
            print(curveValue);


            //transform.position = new Vector3(Random.Range(0 , 5), 0, Random.Range(-5 , 0));

            //interim = Vector3.one * Mathf.Lerp(minScale, maxScale, curveValue);
            //interim.y = 1.2f;
            transform.localScale *= curveValue;
        }
    }
Ejemplo n.º 16
0
    /// <summary>
    /// 节点判断触发
    /// </summary>
    /// <param name="koreoEvent"></param>
    /// <param name="sampleTime"></param>
    /// <param name="sampleDelta"></param>
    /// <param name="deltaSlice"></param>
    private void MusicEventHandler(KoreographyEvent koreoEvent, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
    {
        string[] strs = koreoEvent.GetTextValue().Split('_');

        if (strs[2] == eventIndex)
        {
            if (!guitarAnimIsTrigger)
            {
                guitarAnimIsTrigger = true;
                MessageCenter.Dispatcher((short)MusicMsgType.Guitar, new KeyValuesUpdate(strs[1], null));
            }

            if (strs[0] == "0" && (Input.GetKey(KeyCode.Q) || lastAudience == "A"))
            {
                JudgeCommon(strs, koreoEvent, sampleTime);
            }

            if (strs[0] == "1" && (Input.GetKey(KeyCode.W) || lastAudience == "B"))
            {
                JudgeCommon(strs, koreoEvent, sampleTime);
            }

            if (strs[0] == "2" && (Input.GetKey(KeyCode.E) || lastAudience == "C"))
            {
                JudgeCommon(strs, koreoEvent, sampleTime);
            }

            if (strs[0] == "3" && (Input.GetKey(KeyCode.R) || lastAudience == "D"))
            {
                JudgeCommon(strs, koreoEvent, sampleTime);
            }

            int single = (koreoEvent.EndSample - koreoEvent.StartSample) / 8;
            int point  = koreoEvent.EndSample - single;
            if (sampleTime > point && ordinaryOne && !isSucceed)
            {
                ordinaryOne = false;
                selfAnim.SetTrigger("Miss");
                MessageCenter.Dispatcher((short)MusicMsgType.RankCount, new KeyValuesUpdate("C", null));
                if (lifeTime > 0)
                {
                    StartCoroutine(RecycleTime(lifeTime)); //Invoke("RecycleTime", lifeTime);
                }
                //if (isPracticeEnd)
                //    m_CCount++;
            }
        }
    }
    private void UpdateText(KoreographyEvent koreoEvent, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
    {
        if (koreoEvent.HasTextPayload())
        {
            if (curKoreoEvent == null || (koreoEvent != curKoreoEvent && koreoEvent.StartSample > curKoreoEvent.StartSample))
            {
                text.text     = koreoEvent.GetTextValue();
                curKoreoEvent = koreoEvent;
            }

            if (koreoEvent.StartSample < curKoreoEvent.StartSample)
            {
                text.text     = string.Empty;
                curKoreoEvent = null;
            }
        }
    }
Ejemplo n.º 18
0
    void FireEventDebugLog(KoreographyEvent koreoEvent, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
    {
        Debug.Log("Koreography Event Fired");

        Debug.Log("Sample Time: " + sampleTime + "\nSample delta: " + sampleDelta + "\nPrevious Frame: " + (sampleTime - sampleDelta));
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("F**K THIS");
            GameObject.Find("Text").GetComponent <Text>().text = "JA THIS MOFO";
        }

        if (koreoEvent.IsOneOff() && koreoEvent.HasColorPayload())
        {
            // This is a simple Color Payload.
            Color targetColor = koreoEvent.GetColorValue();
            ApplyColorToObjects(ref targetColor);
        }
        else if (!koreoEvent.IsOneOff() && koreoEvent.HasGradientPayload())
        {
            // Access the color specified at the current music-time.  This is what
            //  drives musical color animations from gradients!
            Color targetColor = koreoEvent.GetColorOfGradientAtTime(sampleTime);
            ApplyColorToObjects(ref targetColor);
        }

        Color targetColor1 = koreoEvent.GetColorValue();

        ApplyColorToObjects(ref targetColor1);
    }
Ejemplo n.º 19
0
        void OnLyricEvent(KoreographyEvent koreoEvt, int sampleTime, int sampleDelta, DeltaSlice slice)
        {
            string lyric = koreoEvt.GetTextValue();

            float percent = koreoEvt.GetEventDeltaAtSampleTime(sampleTime);

            for (int i = 0; i < textLines.Count; ++i)
            {
                KaraokeTextLine curLine = textLines[i];
                if (!curLine.IsLineFull())
                {
                    curLine.FillKaraokeSection(lyric, percent);
                    break;
                }
            }
        }