Ejemplo n.º 1
0
    void AddNewNoteAtCurrentTime(int stringIndex)
    {
        float currentBeat = Mathf.Round((SongPlayer.GetCurrentBeat(true) + 1) * 4) / 4;

        Note note = SongPlayer.Song.Notes.Find(item => item.Time == currentBeat && item.StringIndex == stringIndex);

        if (note == null)
        {
            SongPlayer.Song.AddNote(currentBeat, stringIndex);
        }
        else
        {
            Debug.Log("There is already a note at " + currentBeat + " on string " + stringIndex);
        }
    }
Ejemplo n.º 2
0
    protected IEnumerator TrailHitRoutine(int noteIndex, GameObject trail)
    {
        Note note = Player.Song.Notes[noteIndex];

        //更新尾带的颜色
        trail.GetComponent <Renderer>().material.color = Colors[note.StringIndex];

        //按住的特效
        ControlInput.GetStringButton(note.StringIndex).transform.Find("Sparks").GetComponent <ParticleEmitter>().emit = true;
        ControlInput.GetStringButton(note.StringIndex).transform.Find("Sparks").GetComponent <ParticleEmitter>().GetComponent <Renderer>().enabled = true;

        Vector3 trailScale    = trail.transform.localScale;
        Vector3 trailPosition = trail.transform.localPosition;

        //只要特定的按钮被按下,必须一直按着直到尾带结束,否则会敲不中
        while (ControlInput.IsButtonPressed(note.StringIndex) &&
               Player.GetCurrentBeat() + 1 <= note.Time + note.Length)
        {
            //计算尾带的实际距离
            float progress = Mathf.Clamp01((1 + Player.GetCurrentBeat() - note.Time) / note.Length);

            //收缩尾带,调整位置
            trail.transform.localScale    = new Vector3(trailScale.x, trailScale.y, trailScale.z * (1 - progress));
            trail.transform.localPosition = new Vector3(trailPosition.x, trailPosition.y + trailPosition.y * progress, trailPosition.z);



            yield return(null);
        }

        //结束或者没按中隐藏
        trail.GetComponent <Renderer>().enabled = false;

        //取消特效
        ControlInput.GetStringButton(note.StringIndex).transform.Find("Sparks").GetComponent <ParticleEmitter>().emit = false;
        ControlInput.GetStringButton(note.StringIndex).transform.Find("Sparks").GetComponent <ParticleEmitter>().GetComponent <Renderer>().enabled = false;
    }