Beispiel #1
0
    void movePlatform(KoreographyEvent evt)
    {
        //Debug.Log("move platform entered");

        // If we go into this code, we are either currently at bottom or regular platform positions
        if (moveUpwards)
        {
            if ((platformOriginalHeight.y - transform.position.y) < .5)
            {
                // move from platform original position to top position

                // start at original platform position
                startMarker = platformOriginalHeight;
                // end at top position
                endMarker = points[1];
                startTime = Time.time;
                // Now that we are at the top, set values so we can go back down
                moveUpwards   = false;
                moveDownwards = true;
            }
            else
            {
                // move from bottom position to platform original position

                // end at regular platform height
                endMarker = platformOriginalHeight;
                // start at bottom position
                startMarker = points[0];
                startTime   = Time.time;
            }
        }
        // If we go into this code, we are either currently at top or regular platform positions
        else if (moveDownwards)
        {
            if ((transform.position.y - platformOriginalHeight.y) < .5)
            {
                // move from original platform position to bottom position

                // start at original platform position
                startMarker = platformOriginalHeight;
                // end at bottom platform position
                endMarker = points[0];
                startTime = Time.time;

                // Now that we are at the bottom, set values so we can go back up
                moveUpwards   = true;
                moveDownwards = false;
            }
            else
            {
                // move from top position to original platform position

                // end at original platform position
                endMarker = platformOriginalHeight;
                // start at top platform position
                startMarker = points[1];
                startTime   = Time.time;
            }
        }
    }
        // Update is called once per frame
        void SpawnFundo(KoreographyEvent evt)
        {
            int valor = evt.GetIntValue();

            if (valor == 3)
            {
                Instantiate(fundos [0], transform.position, transform.rotation);
            }
            else if (valor == 4)
            {
                Instantiate(fundos [1], transform.position, transform.rotation);
            }
            else if (valor == 5)
            {
                Vector3 pos = new Vector3(-0.2f, -5.8f, 58.7f);
                Instantiate(fundos [2], pos, transform.rotation);
            }
            else if (valor == 6)
            {
                Vector3 pos = new Vector3(-0.2f, -5.8f, 58.6f);
                Instantiate(fundos [3], pos, transform.rotation);
            }
            //Fim da demo

            /*else if (valor == 7) {
             *      Instantiate (fundos [4], transform.position, transform.rotation);
             * }*/
        }
Beispiel #3
0
    private void BallEvent(KoreographyEvent koreographyEvent)
    {
        Color ballColor = new Color(123f, 100f, 233f, 0.3f);

        ballRender.material.color = ballColor;
        Invoke("BallReset", 0.2f);
    }
    //检测是否生成下一个新音符
    void CheckSpawnNext()
    {
        int samplesToTarget = GetSpawnSampleOffset();

        int currentTime = gameController.DelayedSampleTime;

        while (pendingEventIdx < laneEvents.Count &&
               laneEvents[pendingEventIdx].StartSample < currentTime + samplesToTarget)
        {
            KoreographyEvent evt       = laneEvents[pendingEventIdx];
            int        noteNum         = evt.GetIntValue();
            NoteObject newObj          = gameController.GetFreshNoteObject();
            bool       isLongNoteStart = false;
            bool       isLongNoteEnd   = false;
            if (noteNum > 6)
            {
                isLongNoteStart = true;
                noteNum         = noteNum - 6;
                if (noteNum > 6)
                {
                    isLongNoteEnd   = true;
                    isLongNoteStart = false;
                    noteNum         = noteNum - 6;
                }
            }
            newObj.Initialize(evt, noteNum, this, gameController, isLongNoteStart, isLongNoteEnd);
            trackedNotes.Enqueue(newObj);
            pendingEventIdx++;
        }
    }
Beispiel #5
0
 void FireEventDebugLog(KoreographyEvent koreoEvent)
 {
     EventFrame = Time.frameCount;
     Go.SetActive(true);
     Go2.SetActive(true);
     //if KoreographyColor is true, check color is equal to the color value of the koreography event.
     //If not, check color is red.
     if (KoreographyColor == true)
     {
         // Debug.Log(Check.GetComponent<SpriteRenderer>().color);
         Check.GetComponent <SpriteRenderer>().color = koreoEvent.GetColorValue();
         // Debug.Log("Koreography Event Fired: " + koreoEvent.StartSample);
         // Debug.Log(koreoEvent.GetColorValue());
         //  Debug.Log(Check.GetComponent<SpriteRenderer>().color);
         // Debug.Log("");
     }
     else
     {
         Check.GetComponent <SpriteRenderer>().color = Color.red;
     }
     if (KoreographyColor2 == true)
     {
         //Debug.Log(Check.GetComponent<SpriteRenderer>().color);
         Check2.GetComponent <SpriteRenderer>().color = koreoEvent.GetColorValue();
         // Debug.Log("Koreography Event Fired: " + koreoEvent.StartSample);
         //  Debug.Log(koreoEvent.GetColorValue());
         // Debug.Log(Check.GetComponent<SpriteRenderer>().color);
     }
     else
     {
         Check2.GetComponent <SpriteRenderer>().color = Color.red;
     }
 }
Beispiel #6
0
    private void BallJump(KoreographyEvent koreographyEvent)
    {
        Vector3 vel = rigidbodyCom.velocity;

        vel.y = jumpSpeed;
        rigidbodyCom.velocity = vel;
    }
Beispiel #7
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);
        }
    }
Beispiel #8
0
    private void BallJump(KoreographyEvent koreographyEvent)
    {
        Vector3 velocity = m_rd.velocity;

        velocity.y    = m_fJumpSpeed;
        m_rd.velocity = velocity;
    }
        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;
                }
            }
        }
Beispiel #10
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;
                }
            }
        }
 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;
         }
     }
 }
Beispiel #12
0
 void OnKoreographerTime(KoreographyEvent kevent, int sampleTime, int sampleDelta)
 {
     if (kevent.Payload != null && kevent.Payload as CurvePayload != null)
     {
         SetValue(GetMinMaxValue(rangeMin, rangeMax, (kevent.Payload as CurvePayload).GetValueAtDelta(kevent.GetEventDeltaAtSampleTime(sampleTime))));
     }
 }
Beispiel #13
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);
         }
     }
 }
Beispiel #14
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);
        }
    }
 //Cambia el color de un material
 public void ChangeLightColor(KoreographyEvent koreoEvent)
 {
     if (koreoEvent.HasColorPayload())
     {
         lightManager.ChangeLightColors();
     }
 }
Beispiel #16
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);
        }
Beispiel #17
0
    private void Beat(KoreographyEvent koreoEvent)
    {
        int beatNum = koreoEvent.GetIntValue();

        if (beatNum == 1)
        {
            playAni.SetTrigger("clap01");
            playAni.ResetTrigger("clap02");
            playAni.ResetTrigger("clap03");
            playAni.ResetTrigger("auto");
            beatHit.Play();
        }
        else if (beatNum == 2)
        {
            playAni.SetTrigger("clap02");
            playAni.ResetTrigger("clap01");
            playAni.ResetTrigger("clap03");
            playAni.ResetTrigger("auto");
            beatHit.Play();
        }
        else if (beatNum == 3)
        {
            beatHit.Play();
        }
    }
Beispiel #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);
    }
Beispiel #19
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;
     }
 }
Beispiel #20
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;
     }
 }
Beispiel #21
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;
     }
 }
Beispiel #22
0
 void onDamageableEvent(KoreographyEvent evt)
 {
     if (mvt.State == EnemyState.COMBAT)
     {
         Instantiate(targetRingPrefab, this.transform.position, Quaternion.identity);
         StartCoroutine("CanHitWindow");
     }
 }
 private void ChangeCube(KoreographyEvent koreoEvent, int sampleTime, int sampleDelta, DeltaSlice deltaSlice)
 {
     if (koreoEvent.HasCurvePayload())
     {
         float curveValue = koreoEvent.GetValueOfCurveAtTime(sampleTime);
         transform.localScale = Vector3.one * Mathf.Lerp(minScale, maxScale, curveValue);
     }
 }
Beispiel #24
0
 void SpawnCube(KoreographyEvent evt)
 {
     count--;
     if (count > 0)
     {
         Instantiate(cube, this.transform.position, Quaternion.Euler(new Vector3(30, 30, 0)));
     }
 }
Beispiel #25
0
    //这个是注册的事件,参数必须要有KoreographyEvent这个类型。
    public void Onclick(KoreographyEvent koreographyEvent)
    {
        GameObject CubeEffect = Instantiate(PreEffect[PreEffectNum]);

        CubeEffect.transform.position = startPos;
        CubeEffect.transform.LookAt(endPos);
        CubeEffect.GetComponent <Rigidbody>().AddForce(CubeEffect.transform.forward * 2000);
    }
Beispiel #26
0
        void AddImpulse(KoreographyEvent evt)
        {
            // Add impulse by overriding the Vertical component of the Velocity.
            Vector3 vel = rigidbodyCom.velocity;
            vel.y = jumpSpeed;

            rigidbodyCom.velocity = vel;
        }
Beispiel #27
0
 private void transformGameObject(KoreographyEvent evt)
 {
     laneNum = Mathf.Floor(evt.GetFloatValue() - 67f) % 4f;
     Debug.Log(laneNum);
     position = new Vector3(laneNum * 3.55f - 4.35f, 0f, 0f);
     rotation = Quaternion.Euler(Vector3.zero);
     Instantiate(cube, position, rotation, gameObject.transform);
 }
Beispiel #28
0
    public static void DrawOneOff(Rect displayRect, KoreographyEvent drawEvent, bool isSelected = false)
    {
        Color originalBG = GUI.backgroundColor;
        GUI.backgroundColor = isSelected ? Color.green : Color.red;

        GUI.Box(displayRect, "");

        GUI.backgroundColor = originalBG;
    }
        void AddImpulse(KoreographyEvent evt)
        {
            // Add impulse by overriding the Vertical component of the Velocity.
            Vector3 vel = rigidbodyCom.velocity;

            vel.y = jumpSpeed;

            rigidbodyCom.velocity = vel;
        }
        // Prepares the Note Object for use.
        public void Initialize(KoreographyEvent evt, Color color, LaneController laneCont, RhythmGameController gameCont)
        {
            trackedEvent   = evt;
            visuals.color  = color;
            laneController = laneCont;
            gameController = gameCont;

            UpdatePosition();
        }
    public void SpawnNote(KoreographyEvent evt)
    {
        GameObject bl = Instantiate(bulletPrefab, transform.position, bulletPrefab.transform.rotation);

        Destroy(bl.GetComponent <Animator>());
        bl.GetComponent <SpriteRenderer>().sprite = bulletSprite;
        bl.GetComponent <Bullet>().velocity       = Random.insideUnitCircle.normalized * 5f;
        bl.transform.localScale = new Vector3(0.9f, 0.9f, 1);
    }
Beispiel #32
0
 public void OnBeatHit(KoreographyEvent evt)
 {
     beatHit.Raise();
     beatEventIndex++;
     foreach (IndicatorManager manager in indicatorManagers)
     {
         manager.BeatIterate();
     }
 }
Beispiel #33
0
    void FireEvent(KoreographyEvent koreoEvent)
    {
        int payLoad = 1;

        if (koreoEvent.Payload is IntPayload)
        {
            FireCurrentWeapon(((IntPayload)koreoEvent.Payload).IntVal);
        }
    }
Beispiel #34
0
 void FireEventDebugLog(KoreographyEvent koreoEvent)
 {
     Debug.Log("KoreographyEventFired.");
     if (onBeat == true) {
         onBeat = false;
     }
     else {
         onBeat = true;
     }
 }
Beispiel #35
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);
            }
        }
Beispiel #36
0
    public static void DrawNoPayload(Rect displayRect, KoreographyEvent drawEvent, bool isSelected = false)
    {
        Color originalBG = GUI.backgroundColor;
        GUI.backgroundColor = isSelected ? Color.green : Color.red;

        GUIStyle labelSkin = GUI.skin.GetStyle("Label");
        TextAnchor originalAlign = labelSkin.alignment;
        labelSkin.alignment = TextAnchor.MiddleCenter;

        GUI.Box(displayRect, "No Payload");

        labelSkin.alignment = originalAlign;

        GUI.backgroundColor = originalBG;
    }
        void OnParticleControlEvent(KoreographyEvent evt)
        {
            // If two Koreography span events overlap, this can be called twice in the same frame.
            //  This check ensures that we only ask the particle system to emit once for any frame.
            if (Time.frameCount != lastEmitFrame)
            {
                // Spans get called over a specified amount of music time.  Use Koreographer's beat delta
                //  to calculate the number of particles to emit this frame based on the "particlesPerBeat"
                //  rate configured in the Inspector.
                int particleCount = (int)(particlesPerBeat * Koreographer.GetBeatTimeDelta());

                // Emit the calculated number of particles!
                particleCom.Emit(particleCount);

                lastEmitFrame = Time.frameCount;
            }
        }
Beispiel #38
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);
     }
 }
Beispiel #39
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 #40
0
    /**
     * Adds an event to the track.  The event is inserted in order by
     * sample time.  The event is NOT added if it is a OneOff event
     * and another OneOff event exists at the same time.
     *
     * TODO: Remove the "no duplicate OneOffs" requirement(?).
     */
    // Editor only?
    public bool AddEvent(KoreographyEvent addEvent)
    {
        // Check/verify that the event fits within the song?

        bool bAdd = true;

        if (addEvent.IsOneOff())
        {
            KoreographyEvent sameStartEvent = GetEventAtStartSample(addEvent.StartSample);
            if (sameStartEvent != null && sameStartEvent.IsOneOff())
            {
                // Disallow the add!
                bAdd = false;
            }
        }

        if (bAdd)
        {
            mEventList.Add(addEvent);
            EnsureEventOrder();
        }

        return bAdd;
    }
Beispiel #41
0
    void EndNewEvent(int rawSamplePos)
    {
        // End and commit the current event!
        if (bSnapTimingToBeat)
        {
            int beatSample = editKoreo.GetSampleOfNearestBeat(rawSamplePos, snapSubBeatCount);

            if (bCreateOneOff)
            {
                // Add intermediary OneOff events!
                AddBeatAlignedOneOffEventsToRange(buildEvent.StartSample, rawSamplePos, snapSubBeatCount);
            }
            else
            {
                // Do things a bit differently if we're using the mouse to draw.
                if (!Event.current.isMouse)
                {
                    if (buildEvent.StartSample > rawSamplePos || buildEvent.StartSample == beatSample)
                    {
                        buildEvent.EndSample = editKoreo.GetSampleOfNearestBeat(buildEvent.StartSample + (int)editKoreo.GetSamplesPerBeat(rawSamplePos, snapSubBeatCount));
                    }
                    else
                    {
                        buildEvent.EndSample = beatSample;
                    }
                }
                else
                {
                    // Set the StartSample and then ensure that we've quantized the EndSample.
                    //  Inverse the operation based on how the *raw* sample pos compares to
                    //  the StartSample.
                    if (rawSamplePos <= buildEvent.StartSample)
                    {
                        buildEvent.StartSample = beatSample;
                        buildEvent.EndSample = editKoreo.GetSampleOfNearestBeat(buildEvent.EndSample, snapSubBeatCount);
                    }
                    else
                    {
                        buildEvent.StartSample = editKoreo.GetSampleOfNearestBeat(buildEvent.StartSample, snapSubBeatCount);
                        buildEvent.EndSample = beatSample;
                    }

                    // We may have snapped ourselves into OneOff.  Detect and adjust for this.
                    if (buildEvent.IsOneOff())
                    {
                        buildEvent.EndSample = editKoreo.GetSampleOfNearestBeat(buildEvent.StartSample + (int)editKoreo.GetSamplesPerBeat(buildEvent.EndSample, snapSubBeatCount));
                    }
                }
            }
        }
        else
        {
            // This should only happen with mouse input.
            if (rawSamplePos <= buildEvent.StartSample)
            {
                buildEvent.StartSample = rawSamplePos;
            }
            else
            {
                buildEvent.EndSample = rawSamplePos;
            }
        }

        // All above code flows end in actually updating the event's EndSample.  Mark this as dirty.
        EditorUtility.SetDirty(editTrack);

        buildEvent = null;
    }
Beispiel #42
0
    KoreographyEvent GetNewEvent(int startSampleLoc)
    {
        KoreographyEvent newEvt = new KoreographyEvent();
        AttachPayloadToEvent(newEvt);
        newEvt.StartSample = startSampleLoc;

        if (!bCreateOneOff)
        {
            newEvt.EndSample += 1;			// Spans have a span of at least 1.
        }

        return newEvt;
    }
Beispiel #43
0
    void BeginNewEvent(int samplePos)
    {
        if (bSnapTimingToBeat)
        {
            samplePos = editKoreo.GetSampleOfNearestBeat(samplePos, snapSubBeatCount);
        }

        buildEvent = GetNewEvent(samplePos);

        Undo.RecordObject(editTrack, "Add New Event");

        // Might not actually add it.  Don't worry for now.
        if (editTrack.AddEvent(buildEvent))
        {
            // This only needs to happen here for OneOff events.
            EditorUtility.SetDirty(editTrack);
        }

        if (bCreateOneOff && !bSnapTimingToBeat)
        {
            buildEvent = null;
        }
    }
Beispiel #44
0
 public bool RemoveEvent(KoreographyEvent removeEvent)
 {
     return mEventList.Remove(removeEvent);
 }
Beispiel #45
0
    public void Trigger(KoreographyEvent evt, int sampleTime, int sampleDelta)
    {
        if (basicEvent != null)
        {
            basicEvent(evt);
        }

        if (timedEvent != null)
        {
            timedEvent(evt, sampleTime, sampleDelta);
        }
    }
Beispiel #46
0
 public int GetIDForEvent(KoreographyEvent e)
 {
     // Returns -1 if not in the list!
     return mEventList.IndexOf(e);
 }
 void OnKoreoEvent(KoreographyEvent e)
 {
     Debug.Log("Event!");
       if (HueEffectToFire != null)
      HueEffectToFire.TriggerEffect();
 }
Beispiel #48
0
 public KoreographyEvent GetCopy()
 {
     KoreographyEvent newEvt = new KoreographyEvent();
     newEvt.StartSample = StartSample;
     newEvt.EndSample = EndSample;
     newEvt.Payload = (Payload != null) ? Payload.GetCopy() : null;
     return newEvt;
 }
Beispiel #49
0
 void AttachPayloadToEvent(KoreographyEvent koreoEvent)
 {
     AttachPayloadToEvent(koreoEvent, currentPayloadTypeIdx < 0 ? null : payloadTypes[currentPayloadTypeIdx]);
 }
Beispiel #50
0
 public static int CompareByStartSample(KoreographyEvent first, KoreographyEvent second)
 {
     if (first.StartSample < second.StartSample)
     {
         return -1;
     }
     else if (first.StartSample == second.StartSample)
     {
         return 0;
     }
     else
     {
         return 1;
     }
 }
Beispiel #51
0
    // Adds a new beat-aligned OneOff event to the current track in the following manner: (startSample, endSample].
    void AddBeatAlignedOneOffEventsToRange(int startSample, int endSample, int subBeats = 0)
    {
        bool bDidAddAnEvent = false;

        for (int i = startSample + (int)editKoreo.GetSamplesPerBeat(startSample, subBeats); i <= endSample; i = i + (int)editKoreo.GetSamplesPerBeat(i, subBeats))
        {
            // This also iterates our current "buildEvent" to the most recent OneOff made!
            buildEvent = GetNewEvent(editKoreo.GetSampleOfNearestBeat(i, subBeats));

            if (editTrack.AddEvent(buildEvent))
            {
                bDidAddAnEvent = true;
            }
        }

        if (bDidAddAnEvent)
        {
            EditorUtility.SetDirty(editTrack);
        }
    }
Beispiel #52
0
    void AttachPayloadToEvent(KoreographyEvent koreoEvent, System.Type payloadType)
    {
        if (payloadType == null)
        {
            // No payload for this sucker!
            koreoEvent.Payload = null;
        }
        else if (koreoEvent.Payload == null || koreoEvent.Payload.GetType() != payloadType)
        {
            // GameObjects or Components can only be properly created with Object.Instantiate and require
            //  a base object to clone anyway.
            // This isn't actually true.  We *could* use EditorUtility.CreateGameObjectWithHideFlags.  Not
            //  sure of the implications of this, however.

            if (payloadType.IsSubclassOf(typeof(ScriptableObject)))
            {
                koreoEvent.Payload = ScriptableObject.CreateInstance(payloadType) as KoreographyPayload;
            }
            else
            {
                koreoEvent.Payload = System.Activator.CreateInstance(payloadType) as KoreographyPayload;
            }
        }
    }