コード例 #1
0
        private void PlayChord(int idx)
        {
            UIChord.I.idx = idx;
            var chord = new ChordRT(loader.chords[idx], secondPerNote);

            chord.playNote = PlayPitch;
            chord.holdNote = HoldPitch;
            chordPlaying   = chord;
        }
コード例 #2
0
        private void Input()
        {
            if (Events.Shift)
            {
                scaleCurr = scaleMid + 1;
            }
            else if (Events.Ctrl)
            {
                scaleCurr = scaleMid - 1;
            }
            else
            {
                scaleCurr = scaleMid;
            }
            src.UnHold();
            foreach (var grid in grids)
            {
                foreach (var gup in grid.gridUnitProp)
                {
                    gup.clickable = true;
                }
            }
            piano.notePress = new List <Note>();
            for (int i = 0; i < keys.Length; i++)
            {
                var idx  = PitchTool.Pitch12To8_5_Align(i);
                var grid = idx > 0 ? 0 : 1;
                if (Events.KeyDown(keys[i]))
                {
                    PlayPitch(i);
                    grids[grid].gridUnitProp[Mathf.Abs(idx) - 1].clickable = false;
                }
                if (Events.Key(keys[i]))
                {
                    grids[grid].gridUnitProp[Mathf.Abs(idx) - 1].clickable = false;
                    HoldPitch(i);
                }
            }
            // 支持同时按下的按键数量取决键盘设备(的电路设计?),一般为2~5个键,
            // 不包括Shift和Ctrl,这类特殊键一般可以额外同时按下。
            // A~Z字母键能确保2个键同时按下,3个及以上就“不一定”了。
            // 据说专门的游戏可以支持更多键。
            // 比如我的键盘可以同时按 QRXC 四个键, 但按不了 QRV、QRB。
            scaleCurr--;
            for (int i = 0; i < keysLow.Length; i++)
            {
                if (Events.KeyDown(keysLow[i]))
                {
                    PlayPitch(i);
                }
                if (Events.Key(keysLow[i]))
                {
                    HoldPitch(i);
                }
            }
            for (int i = 0; i < keysChord.Length; i++)
            {
                if (Events.KeyDown(keysChord[i]))
                {
                    PlayChord(i);
                }
            }
            if (Events.KeyDown(KeyCode.CapsLock))
            {
                UIChord.I.scaleShift = !UIChord.I.scaleShift;
            }
            if (Events.KeyDown(KeyCode.F1, KeyCode.F5))
            {
                loader.Start();
            }
            if (Events.KeyDown(KeyCode.BackQuote, KeyCode.Alpha1))
            {
                if (chordIdx > 0 && chordIdx - 1 < loader.chordParser.chordArr.Count)
                {
                    PlayChordArr(chordIdx - 1);
                }
            }
            else if (Events.KeyDown(KeyCode.Space))
            {
                chordIdx++;
                if (chordIdx > 0 && chordIdx - 1 < loader.chordParser.chordArr.Count)
                {
                    PlayChordArr(chordIdx - 1);
                }
            }

            if (chordPlaying != null && chordPlaying.notes.NotEmpty())
            {
                chordPlaying.Update();
                if (chordPlaying.t >= chordPlaying.endTime.Last())
                {
                    chordPlaying = null;
                }
            }
        }