Beispiel #1
0
    IEnumerator MoveToStart(Note note)
    {
        float currMusicTime = Analyzer.TimeSeconds();
        float targetTime = (1f - TimeTilShow) * Analyzer.TimeSeconds(note.frameIndex);
        float normtarget = targetTime - currMusicTime;

        List<SpriteRenderer> sprites = new List<SpriteRenderer>();
        sprites.AddRange(note.GetComponents<SpriteRenderer>());
        sprites.AddRange(note.GetComponentsInChildren<SpriteRenderer>());

        for(int i = 0; i < sprites.Count; ++i)
        {
            sprites[i].enabled = true;
        }
               
        if (NoteOrigin != null)
            note.transform.position = NoteOrigin.position;

        Vector3 startPos = note.transform.position;
        Vector3 endPos = GetNotePos(note.Type) + new Vector3(0, NoteYStart);

        Vector3 startSize = Vector3.zero;
        Vector3 endSize = note.transform.localScale;

        float currtime = 0;

        while(currtime <= 1)
        {
            note.transform.position = Vector3.Lerp(startPos, endPos, currtime);
            note.transform.localScale = Vector3.Lerp(startSize, endSize, currtime);

            float normCurrTime = Analyzer.TimeSeconds() - currMusicTime;
            currtime = normCurrTime / normtarget;

            yield return null;
        }

        yield return DoMove(note);
    }