Beispiel #1
0
    //判断Note是否被击中
    protected bool IsNoteHit(int index)
    {
        Note note = Player.Song.Notes[index];

        //如果没有按下这个音符,它不能被击中
        if (!ControlInput.WasButtonJustPressed(note.StringIndex))
        {
            return(false);
        }

        //如果它已经被击中一次了,不能判断为击中
        if (HasHitNoteOnStringIndexThisFrame[note.StringIndex])
        {
            return(false);
        }

        //如果Renderer状态变化则之前就被击中了
        if (NoteObjects[index].GetComponent <Renderer>().enabled == false)
        {
            return(false);
        }

        //检查Note是否在击中区域
        if (IsInHitZone(NoteObjects[index]))
        {
            //设置此标志,为了防止两个音符被同一个按钮击中
            HasHitNoteOnStringIndexThisFrame[note.StringIndex] = true;
            return(true);
        }

        //如果没在范围内,则返回没被击中
        return(false);
    }