Beispiel #1
0
    public void TakeHit(SwordHitboxType hitboxIndex)
    {
        if (isPlayingSong)
        {
            KoreographyTrack track = null;
            switch (hitboxIndex)
            {
            case SwordHitboxType.Box1:
                track = track1;
                break;

            case SwordHitboxType.Box2:
                track = track2;
                break;

            case SwordHitboxType.Box3:
                track = track3;
                break;
            }

            KoreographyEvent koreographyEvent = new KoreographyEvent();
            koreographyEvent.StartSample = koreographer.GetMusicSampleTime("m_envir_anvil");

            track.AddEvent(koreographyEvent);
        }
    }
Beispiel #2
0
    void InitMusic()
    {
        MusicManager.Instance.EventChangeHandler += OnEventChangeHandler;

        AudioClip audioClip = SongManager.Instance.GetAudioClip(m_GuanKa.song.id);

        Track track = null;

        foreach (var tr in m_GuanKa.song.songTracks)
        {
            if (tr.trackLevel == (int)m_GuanKa.level)
            {
                track = tr;
            }
        }
        KoreographyTrack graphyTrack = null;

        if (track != null)
        {
            graphyTrack = SongManager.Instance.GetTrack(track.id);
        }
        MusicManager.Instance.AudioClip = audioClip;
        MusicManager.Instance.Track     = graphyTrack;

        Debug.Log("load music complete");
    }
Beispiel #3
0
    public bool AddTrack(KoreographyTrack track)
    {
        bool bDidAdd = false;
        if (CanAddTrack(track))
        {
            track.SourceClip = SourceClip;
            mTracks.Add(track);

            bDidAdd = true;
        }
        return bDidAdd;
    }
    //获取注册时间列表
    private void LoadEventSampleTime()
    {
        KoreographyTrack        rhythmTrack = playingKoreo.GetTrackByID(eventID);
        List <KoreographyEvent> rawEvents   = rhythmTrack.GetAllEvents();

        for (int i = 0; i < rawEvents.Count; i++)
        {
            TwoDData temp = new TwoDData {
                beginTime = rawEvents[i].StartSample, typeEnum = rawEvents[i].GetIntValue()
            };
            eventSampleTimeList.Add(temp);
        }
    }
Beispiel #5
0
    void OnLoadKoreographyTrackComplete(UnityEngine.AsyncOperation oper)
    {
        KoreographyTrack track = null;

        if (m_AssetBundleRequest.asset.GetType().Equals(typeof(KoreographyTrack)))
        {
            track = (KoreographyTrack)m_AssetBundleRequest.asset;
        }

        if (m_AudioTrackCache.ContainsKey(m_CurrentLoadingTrack.id))
        {
            m_AudioTrackCache.Remove(m_CurrentLoadingTrack.id);
        }
        m_AudioTrackCache.Add(m_CurrentLoadingTrack.id, track);

        LoadAllToMemery();
    }
Beispiel #6
0
    public bool DoGUI(Rect displayRect, KoreographyTrack track, bool isSelected)
    {
        bool bDidEdit = false;
        Color originalBG = GUI.backgroundColor;
        GUI.backgroundColor = isSelected ? Color.green : originalBG;

        GUI.changed = false;
        string newVal = EditorGUI.TextField(displayRect, TextVal);
        if (GUI.changed)
        {
            Undo.RecordObject(track, "Modify Text Payload");
            TextVal = newVal;
            GUI.changed = false;
            bDidEdit = true;
        }

        GUI.backgroundColor = originalBG;
        return bDidEdit;
    }
Beispiel #7
0
 public static void Draw(Rect displayRect, KoreographyTrack track, KoreographyEvent drawEvent, bool isSelected = false)
 {
     if (drawEvent.IsOneOff())
     {
         DrawOneOff(displayRect, drawEvent, isSelected);
     }
     else
     {
         if (drawEvent.Payload != null)
         {
             if (drawEvent.Payload.DoGUI(displayRect, track, isSelected))
             {
                 GUI.changed = false;
                 EditorUtility.SetDirty(track);
             }
         }
         else
         {
             DrawNoPayload(displayRect, drawEvent, isSelected);
         }
     }
 }
Beispiel #8
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;
                    }
                }
            }
        }
    void Start()
    {
        InitializeLeadIn();
        for (int i = 0; i < noteLines.Count; i++)
        {
            noteLines[i].Initialize(this);//音轨初始化
        }
        //获取到koreography对象
        playingKoreo = Koreographer.Instance.GetKoreographyAtIndex(0);
        KoreographyTrack rhythmTrack = playingKoreo.GetTrackByID(eventID);
        //获取事件
        List <KoreographyEvent> rawEvents = rhythmTrack.GetAllEvents();

        for (int i = 0; i < rawEvents.Count; i++)
        {
            KoreographyEvent evt = rawEvents[i];
            int noteID           = evt.GetIntValue();
            //遍历所有音轨
            for (int j = 0; j < noteLines.Count; j++)
            {
                LaneController lane = noteLines[j];
                if (noteID > 6)
                {
                    noteID = noteID - 6;
                    if (noteID > 6)
                    {
                        noteID = noteID - 6;
                    }
                }
                if (lane.DoesMatch(noteID))
                {
                    lane.AddEventToLane(evt);
                    break;
                }
            }
        }
        hitWindowRangeInSamples = (int)(SampleRate * hitWindowRangeInMS * 0.0001f);
    }
Beispiel #10
0
 public bool CanAddTrack(KoreographyTrack track)
 {
     return (track.SourceClip == null || track.SourceClip == track.SourceClip) && !DoesTrackWithEventIDExist(track.EventID);
 }
Beispiel #11
0
 public void RemoveTrack(KoreographyTrack track)
 {
     mTracks.Remove(track);
 }
Beispiel #12
0
 public int GetIndexOfTrack(KoreographyTrack track)
 {
     return mTracks.IndexOf(track);
 }
Beispiel #13
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;
                    }
                }
            }
        }
Beispiel #14
0
    public bool DoGUI(Rect displayRect, KoreographyTrack track, bool isSelected)
    {
        //		bool bDidEdit = false;
        Color originalBG = GUI.backgroundColor;

        // 10,000 is the MAXIMUM width that a CurveField works at.  Try larger and it will crash Unity.
        if (displayRect.width <= 10000f)
        {
            GUI.backgroundColor = isSelected ? Color.green : originalBG;

            GUI.changed = false;
            AnimationCurve newCurve = EditorGUI.CurveField(displayRect, CurveData);
            if (GUI.changed)
            {
                // Attempting to Undo a curve (at least up to Unity 4.5.x) results in
                //  nearly undefined operations including, but not limited to:
                //  - Addition/Deletion of keys to/from curve not recorded in Undo stack.
                //  - Potentially [based on key addition/deletion interactions] stomp
                //		all over the Undo stack (at least that's what it looks like).
        //				if (CurveData.length == newCurve.length)
        //				{
        //					Undo.RecordObject(track, "Modify Curve Payload");
        //					bDidEdit = true;
        //				}

                // Normally this is handled externally.  However, we always return false
                //  so we should set the dirty bit here.
                EditorUtility.SetDirty(track);

                CurveData = newCurve;
                GUI.changed = false;
            }
        }
        else
        {
            GUI.backgroundColor = isSelected ? SelectedCurveBGColor : CurveBGColor;

            GUI.Box(displayRect, string.Empty);
        }

        GUI.backgroundColor = originalBG;
        //		return bDidEdit;
        return false;
    }
Beispiel #15
0
 public override void Dispose()
 {
     Koreographer.Instance.UnregisterForAllEvents(this);
     m_AudioClip = null;
     m_Track     = null;
 }
Beispiel #16
0
 public void SetEventTrack(KoreographyTrack newEventTrack)
 {
     trackDisplay.EventTrack = newEventTrack;
 }