Ejemplo n.º 1
0
        private static void SetEventToPutHold(
            MadcaDisplay display, NoteBook noteBook, IReadOnlyList <IReadOnlyScore> scores, OperationManager opManager, IReadOnlyEditorStatus status)
        {
            var box    = display.PictureBox;
            var env    = display.EditorLaneEnvironment;
            var holder = display.KeyTokenHolder;

            var     key = new KeyToken();
            HoldEnd end = null;

            box.MouseDown += (s, e) =>
            {
                if (holder.Locked)
                {
                    return;
                }
                if (status.EditorMode != EditorMode.Add || status.NoteMode != NoteMode.Hold)
                {
                    return;
                }
                var area = env.GetEditorLaneRegion(e.Location);
                if (area == EditorLaneRegion.Lane && e.Button == MouseButtons.Left)
                {
                    var res = PositionConverter.ConvertRealToVirtual(env, e.Location, status.BeatStride, scores, out Position position);
                    if (!res)
                    {
                        return;
                    }
                    var hold = new Hold(position.Lane, position.Timing, position.Timing + status.BeatStride, new NoteSize(status.NoteSize));
                    end = hold.HoldEnd;
                    opManager.AddAndInvokeOperation(new AddHoldOperation(noteBook, hold));
                    holder.Lock(key);
                }
            };

            box.MouseMove += (s, e) =>
            {
                if (!holder.CanUnLock(key))
                {
                    return;
                }
                var res = PositionConverter.ConvertRealToVirtual(env, e.Location, status.BeatStride, scores, out Position position);
                if (!res)
                {
                    return;
                }
                end.ReLocate(position.Lane, position.Timing);
            };

            box.MouseUp += (s, e) =>
            {
                if (!holder.UnLock(key))
                {
                    return;
                }
                end = null;
            };
        }
Ejemplo n.º 2
0
    public void DropObject()
    {
        _holdableObject.StopHold();
        _holdableObject = null;

        AudioManager.Instance.PlaySound(gameObject, _dropSound);

        HoldEnd?.Invoke();
    }
Ejemplo n.º 3
0
 private void OnHoldEnd(HoldInfo holdInfo)
 {
     HoldEnd?.Invoke(holdInfo);
 }