Example #1
0
 private void OnSplitterSwitchChanged(object sender, SwitchEventArgs args)
 {
     OnSwitchChanged?.Invoke(this, args);
 }
Example #2
0
        public void Switch(string id, bool isClosed)
        {
            if (!_switchTime.ContainsKey(id))
            {
                _switchTime[id] = new Stopwatch();
            }

            if (isClosed)
            {
                _switchTime[id].Restart();
            }
            else
            {
                _switchTime[id].Stop();
            }
            Logger.Info("Switch {0} is {1}.", id, isClosed ? "closed" : "open after " + _switchTime[id].ElapsedMilliseconds + "ms");

            switch (id)
            {
            case SwLeftFlipper:
            case SwLeftFlipperEos:
            case SwRightFlipper:
            case SwRightFlipperEos:
                Flip(id, isClosed);
                break;

            case SwTrough4:
                if (isClosed)
                {
                    OnCoilChanged?.Invoke(this, new CoilEventArgs(CoilTroughEject, true));
                    _player.ScheduleAction(100, () => OnCoilChanged?.Invoke(this, new CoilEventArgs(CoilTroughEject, false)));
                }
                break;

            case SwRedBumper:
                OnLampChanged?.Invoke(this, new LampEventArgs(LampRedBumper, isClosed ? 1 : 0));
                break;

            case SwCreateBall: {
                if (isClosed)
                {
                    _ballManager.CreateBall(new DebugBallCreator(630, _playfieldComponent.Height / 2f, _playfieldComponent.TableHeight));
                }
                break;
            }

            case SwCannon: {
                SetCoil(CoilMotorStart, true);
                break;
            }

            case SwMotorStart: {
                if (isClosed)
                {
                    SetCoil(CoilMotorStart, false);
                }
                break;
            }

            case SwMotorEnd: {
                break;
            }
            }

            OnSwitchChanged?.Invoke(this, new SwitchEventArgs2(id, isClosed));
        }
Example #3
0
    private void SetPressed(bool pressed)
    {
        _switch.Value = pressed;

        OnSwitchChanged?.Invoke();
    }