コード例 #1
0
        // Retrieves a frehsly activated Note Object from the pool.
        public Note GetFreshNoteObject(KoreographyEvent evt)
        {
            Note   retObj;
            string payload = evt.GetTextValue();

            if (payload.Contains("s"))
            {
                retObj = GameObject.Instantiate <Note>(sliderNoteObjectArchetype);
            }
            else if (payload.Contains("e"))
            {
                retObj = GameObject.Instantiate <Note>(endNoteObjectArchetype);
            }
            else if (payload.Contains("v"))
            {
                retObj = GameObject.Instantiate <Note>(voiceNoteObjectArchetype);
            }
            else
            {
                retObj = GameObject.Instantiate <Note>(noteObjectArchetype);
            }
            //if (noteObjectPool.Count > 0) {
            //    retObj = noteObjectPool.Pop();
            //} else {
            //    retObj = GameObject.Instantiate<Note>(noteObjectArchetype);
            //}

            retObj.gameObject.SetActive(true);
            retObj.enabled = true;

            return(retObj);
        }
コード例 #2
0
    void OnEventEasyChange(KoreographyEvent evt)
    {
        string txt = evt.GetTextValue();

        if (m_PreSample == evt.StartSample)
        {
            return;
        }
        m_PreSample = evt.StartSample;

        string[] values = txt.Split(',');

        if (values.Length < 3)
        {
            return;
        }

        MusicEventData data = new MusicEventData();

        data.oper      = (MusicOper)int.Parse(values[0]);
        data.player    = (MusicPlayer)int.Parse(values[1]);
        data.content   = values[2];
        data.sampleLen = (evt.EndSample - evt.StartSample) / (float)Koreographer.GetSampleRate(m_AudioClip.name);

        //data.oper = MusicOper.LongUp;
        //data.sampleLen = 1.5f;

        //Debug.Log(txt + "   " + data.sampleLen);

        if (EventChangeHandler != null)
        {
            EventChangeHandler(data);
        }
    }
コード例 #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;
                }
            }
        }
コード例 #4
0
ファイル: UIMessageSetter.cs プロジェクト: joeygoode/BeatDown
        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;
                }
            }
        }
コード例 #5
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;
         }
     }
 }
コード例 #6
0
 void OnGUI()
 {
     if (curTextEvent != null)
     {
         // Use the entire screen size as the draw surface. Draw location is determined by
         //	the GUIStyle.
         GUI.Box(new Rect(0, 0, Screen.width, Screen.height), curTextEvent.GetTextValue(), style);
     }
 }
コード例 #7
0
    /// <summary>
    /// 前奏动画触发
    /// </summary>
    /// <param name="koreoEvent"></param>
    private void AnimatorEventHandler(KoreographyEvent koreoEvent)
    {
        string[] strs = koreoEvent.GetTextValue().Split('_');
        if (isPracticeEnd)
        {
            if (koreoEvent.GetTextValue() == "Over" && m_ScoreUIMgr != null)
            {
                m_ScoreUIMgr.gameObject.SetActive(true);
                m_ScoreUIMgr.SetScoreUI(m_ACount, m_BCount, m_CCount, m_DCount, m_NodeCount);
                return;
            }
            else
            {
                m_NodeCount++;
            }
        }

        if (strs[1] != null)
        {
            CreateAudience(Int32.Parse(strs[0]), strs[1], strs[2]);
        }
    }
コード例 #8
0
    private void MusicResponse(KoreographyEvent evt)
    {
        eventPayloadText = evt;

        switch (eventPayloadText.GetTextValue())
        {
        case "outro":
            if (!m_activateSpawn)
            {
                m_activateSpawn = true;
            }
            StartCoroutine(SpawnMiniSolarSystems());
            break;
        }
    }
コード例 #9
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++;
            }
        }
    }
コード例 #10
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;
                }
            }
        }
コード例 #11
0
    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;
            }
        }
    }
コード例 #12
0
ファイル: MusicCtrl.cs プロジェクト: BishopLXX/Musicciit
    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;
            }
        }
    }
コード例 #13
0
    void Start()
    {
        //Find the animator for the dancing man.
        this.animationTarget = GameObject.FindObjectOfType <Animator>();

        InitializeLeadIn();

        // Initialize all the Lanes.
        for (int i = 0; i < noteLanes.Count; ++i)
        {
            noteLanes[i].Initialize(this);
        }

        // Initialize events.
        playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0);
        // Grab all the events out of the Koreography.
        KoreographyTrackBase    rhythmTrack = playingKoreo.GetTrackByID(eventID);
        List <KoreographyEvent> rawEvents   = rhythmTrack.GetAllEvents();

        InitializeMetronomeIfPresent(rawEvents);
        for (int i = 0; i < rawEvents.Count; ++i)
        {
            KoreographyEvent evt     = rawEvents[i];
            string           payload = evt.GetTextValue();

            // Find the right lane.
            for (int j = 0; j < noteLanes.Count; ++j)
            {
                LaneControllerBeatInfinity lane = noteLanes[j];
                if (lane.DoesMatchPayload(payload))
                {
                    // Add the object for input tracking.
                    lane.AddEventToLane(evt);

                    // Break out of the lane searching loop.
                    break;
                }
            }
        }
    }
コード例 #14
0
        void Start()
        {
            InitializeLeadIn();

            // Initialize all the Lanes.
            for (int i = 0; i < noteLanes.Count; ++i)
            {
                noteLanes[i].Initialize(this);
            }
            Debug.Log(noteLanes.Count);//6

            // Initialize events.
            playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0);

            // Grab all the events out of the Koreography.
            KoreographyTrack        rhythmTrack = playingKoreo.GetTrackByID(eventID);
            List <KoreographyEvent> rawEvents   = rhythmTrack.GetAllEvents();

            for (int i = 0; i < rawEvents.Count; ++i)
            {
                KoreographyEvent evt     = rawEvents[i];
                string           payload = evt.GetTextValue();

                // Find the right lane.
                for (int j = 0; j < noteLanes.Count; ++j)
                {
                    LaneController lane = noteLanes[j];
                    if (lane.DoesMatchPayload(payload))
                    {
                        // Add the object for input tracking.
                        lane.AddEventToLane(evt);

                        // Break out of the lane searching loop.
                        break;
                    }
                }
            }
        }
コード例 #15
0
        void OnFeedLine(KoreographyEvent koreoEvt)
        {
            string lyrics = koreoEvt.GetTextValue();

            // Only animate when we're adding to the last slot.
            //  This allows us to pre-load a few lines so they
            //  appear immediately.
            if (lineAddIdx == textLines.Count - 1)
            {
                textLines[lineAddIdx].SetTextState(lyrics, 0f, 0);
                animCom.Play("KaraokeLineFeed", 0, 0f);
            }
            else
            {
                string[] lyricLines = lyrics.Split(new string[] { "\\n" }, System.StringSplitOptions.RemoveEmptyEntries);

                foreach (string line in lyricLines)
                {
                    textLines[lineAddIdx].SetTextState(line, 0f, 0);
                    lineAddIdx++;
                }
            }
        }
コード例 #16
0
ファイル: BeatTest.cs プロジェクト: DaisyLi0117/musicProject
    private void PlayerBeat(KoreographyEvent koreoEvent)
    {
        string ScoreJudge = koreoEvent.GetTextValue();

        if (ScoreJudge == "Perfect")
        {
            if (Input.GetMouseButtonDown(0) && ifTest != 1)
            {
                testButton("Perfect");
                ifTest           = 1;
                currentFire     += maxFire * (1 / numFire);//增加鬼畜值
                PERFECThit      += 1;
                PERFECTText.text = "PERFECT HIT: " + PERFECThit.ToString();
                if (ifpre3 == true)
                {
                    pre3Num += 1;
                }
            }
        }
        else if (ScoreJudge == "Good")
        {
            if (Input.GetMouseButtonDown(0) && ifTest != 1)
            {
                if (ifpre3 == true)
                {
                    pre3Num += 1;

                    testButton("Perfect");
                    ifTest           = 1;
                    currentFire     += maxFire * (1 / numFire);//增加鬼畜值
                    PERFECThit      += 1;
                    PERFECTText.text = "PERFECT HIT: " + PERFECThit.ToString();
                }
                else
                {
                    testButton("Good");
                    ifTest         = 1;
                    currentHealth -= maxHealth * (2 / numHealth);
                    GOODhit       += 1;
                    GOODText.text  = "GOOD HIT: " + GOODhit.ToString();
                }
            }
        }
        else if (ScoreJudge == "OK")
        {
            if (Input.GetMouseButtonDown(0) && ifTest != 1)
            {
                if (ifpre3 == true)
                {
                    pre3Num += 1;

                    testButton("Perfect");
                    ifTest           = 1;
                    currentFire     += maxFire * (1 / numFire);//增加鬼畜值
                    PERFECThit      += 1;
                    PERFECTText.text = "PERFECT HIT: " + PERFECThit.ToString();
                }
                else
                {
                    testButton("OK");
                    ifTest         = 1;
                    currentHealth -= maxHealth * (3 / numHealth);
                    OKhit         += 1;
                    OKText.text    = "OK HIT: " + OKhit.ToString();
                }
            }
        }
        else if (ScoreJudge == "Awh")
        {
            if (Input.GetMouseButtonDown(0) && ifTest != 1)
            {
                if (ifpre3 == true)
                {
                    pre3Num += 1;

                    testButton("Perfect");
                    ifTest           = 1;
                    currentFire     += maxFire * (1 / numFire);//增加鬼畜值
                    PERFECThit      += 1;
                    PERFECTText.text = "PERFECT HIT: " + PERFECThit.ToString();
                }
                else
                {
                    if (ifImmune == false)
                    {
                        testButton("Awh");//AWH还需要一个特殊的动画,之后有图了再修改触发器
                        ifTest         = 1;
                        currentHealth -= maxHealth * (5 / numHealth);
                        AWHhit        += 1;
                        AWHText.text   = "AWH HIT: " + AWHhit.ToString();
                    }
                    else if (ifImmune == true)
                    {
                        testButton("免疫");////还需要一个特殊的动画,之后有图了再修改触发器
                        ifTest   = 1;
                        ifImmune = false;
                    }
                }
            }
        }
        else if (ScoreJudge == "Miss")
        {
            if (ifTest == 0)
            {
                scoreText.text = "Miss";
                playAni.SetTrigger("auto");
                playAni.ResetTrigger("clap01");
                playAni.ResetTrigger("clap02");
                playAni.ResetTrigger("clap03");
                currentHealth -= maxHealth * (5 / numHealth);
                MISShit       += 1;
                MISSText.text  = "MISS HIT: " + MISShit.ToString();
            }
        }
        else if (ScoreJudge == "zero")
        {
            ifTest         = 0;
            currentHealth -= 0f;
        }
        else if (ScoreJudge == "END")
        {
            Debug.Log("!!!!!!!!1");
            gameover.SetActive(true);
            //Time.timeScale = 0f;
            theMusic.Pause();
            result.text = "WIN";
        }
    }
コード例 #17
0
        void Start()
        {
            gameManager = GameObject.Find("GameManager");
            //PlayerPrefs.SetFloat("noteSpeed", noteSpeed);
            //PlayerPrefs.SetFloat("hitDelay", hitDelay);
            noteSpeed = PlayerPrefs.GetFloat("noteSpeed", 6f);
            hitDelay  = PlayerPrefs.GetFloat("hitDelay", 0.08f);
            gameManager.transform.position = new Vector3(0, (float)(-noteSpeed * hitDelay - (2 + 0.5) * noteSpeed / 6), 0);//holy shit
            string songName;

            if (PlayerPrefs.GetString("PlayMode", "Play") == "Play")
            {
                songName = PlayerPrefs.GetString("SongName", GameStatics.songs[0].PlayBackName);
                eventID  = PlayerPrefs.GetString("Difficulty", "Easy");
            }
            else
            {
                songName = GameStatics.testSong.PlayBackName;
                eventID  = "Easy";
            }
            Debug.Log(songName);
            simpleMusicPlayer = GameObject.Find(songName).GetComponent <SimpleMusicPlayer>();
            audioCom          = GameObject.Find(songName).GetComponent <AudioSource>();

            Koreographer.Instance.EventDelayInSeconds = 0f;
            InitializeLeadIn();

            // Initialize all the Lanes.
            for (int i = 0; i < noteLanes.Count; ++i)
            {
                noteLanes[i].Initialize(this);
            }
            //Debug.Log(noteLanes.Count);//9

            // Initialize events.

            if (songName == GameStatics.songs[0].PlayBackName)
            {
                playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0);
            }
            else
            {
                playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(1);
            }

            //playingKoreo = Koreographer.Instance.

            // Grab all the events out of the Koreography.
            KoreographyTrack        rhythmTrack = playingKoreo.GetTrackByID(eventID);//Easy or Hard
            List <KoreographyEvent> rawEvents   = rhythmTrack.GetAllEvents();

            Debug.Log(rawEvents.Count);

            for (int i = 0; i < rawEvents.Count; ++i)
            {
                KoreographyEvent evt     = rawEvents[i];
                string           payload = evt.GetTextValue();

                // Find the right lane.
                for (int j = 0; j < noteLanes.Count; ++j)
                {
                    Lane lane = noteLanes[j];
                    if (lane.DoesMatchPayload(payload))
                    {
                        // Add the object for input tracking.
                        lane.AddEventToLane(evt);

                        // Break out of the lane searching loop.
                        //break;
                    }
                }
            }
        }