Пример #1
0
        void IApi.OnInit(BallManager ballManager)
        {
            base.OnInit(ballManager);
            Init?.Invoke(this, EventArgs.Empty);

            _mainCoil = new DeviceCoil(Player, OnMainCoilEnabled, OnMainCoilDisabled);
            _holdCoil = new DeviceCoil(Player, OnHoldCoilEnabled, OnHoldCoilDisabled);
        }
Пример #2
0
        void IApi.OnInit(BallManager ballManager)
        {
            _teleporterCoil = new DeviceCoil(_player, OnTeleport);
            _fromKicker     = _player.TableApi.Kicker(_component.FromKicker);
            _toKicker       = _player.TableApi.Kicker(_component.ToKicker);

            Init?.Invoke(this, EventArgs.Empty);
        }
Пример #3
0
        void IApi.OnInit(BallManager ballManager)
        {
            base.OnInit(ballManager);
            Init?.Invoke(this, EventArgs.Empty);

            PullCoil = new DeviceCoil(Player, PullBack, Fire);
            FireCoil = new DeviceCoil(Player, Fire);
        }
        void IApi.OnInit(BallManager ballManager)
        {
            _enabled     = false;
            _currentStep = 0;
            _direction   = Direction.Forward;

            _motorCoil = new DeviceCoil(_player, OnMotorCoilEnabled, OnMotorCoilDisabled);

            _marks    = _component.Marks.ToDictionary(m => m.SwitchId, m => m);
            _switches = _component.Marks.ToDictionary(m => m.SwitchId, m => new DeviceSwitch(m.SwitchId, false, SwitchDefault.NormallyOpen, _player));
            var i = 0;

            foreach (var sw in _switches.Values)
            {
                sw.SetSwitch(i == 0);
                i++;
            }

            Init?.Invoke(this, EventArgs.Empty);
        }
Пример #5
0
 void IApi.OnInit(BallManager ballManager)
 {
     LifterCoil = new DeviceCoil(_player, OnLifterCoilEnabled, OnLifterCoilDisabled);
     _gateApi   = _player.TableApi.Gate(_gateComponent);
     Init?.Invoke(this, EventArgs.Empty);
 }
Пример #6
0
        void IApi.OnInit(BallManager ballManager)
        {
            base.OnInit(ballManager);

            // reference playfield elements
            _drainSwitch = TableApi.Switch(MainComponent.PlayfieldEntrySwitch, MainComponent.PlayfieldEntrySwitchItem);
            _ejectCoil   = TableApi.Coil(MainComponent.PlayfieldExitKicker, MainComponent.PlayfieldExitKickerItem);
            _ejectKicker = TableApi.Kicker(MainComponent.PlayfieldExitKicker);

            // setup entry handler
            if (_drainSwitch != null)
            {
                _drainSwitch.Switch += OnEntry;
            }

            // setup switches
            if (MainComponent.Type != TroughType.ModernOpto && MainComponent.Type != TroughType.ModernMech)
            {
                EntrySwitch = CreateSwitch(TroughComponent.EntrySwitchId, false, SwitchDefault.NormallyOpen);
                _switchLookup[TroughComponent.EntrySwitchId] = EntrySwitch;
            }

            if (MainComponent.Type == TroughType.TwoCoilsOneSwitch)
            {
                _stackSwitches = new[] {
                    CreateSwitch(TroughComponent.TroughSwitchId, false, SwitchDefault.NormallyOpen)
                };
                _switchLookup[TroughComponent.TroughSwitchId] = StackSwitch();
            }
            else
            {
                _stackSwitches = new DeviceSwitch[MainComponent.SwitchCount];

                // ball_switch_# switches created in TroughComponent
                var ballSwitchRegex = new Regex(@"^ball_switch_(\d+)$");
                foreach (var @switch in MainComponent.AvailableSwitches)
                {
                    var match = ballSwitchRegex.Match(@switch.Id);
                    if (match.Success)
                    {
                        int.TryParse(match.Groups[1].Value, out int id);
                        if (id > 0)
                        {
                            _stackSwitches[id - 1]    = CreateSwitch(@switch.Id, false, MainComponent.Type == TroughType.ModernOpto ? SwitchDefault.NormallyClosed : SwitchDefault.NormallyOpen);
                            _switchLookup[@switch.Id] = _stackSwitches[id - 1];
                        }
                    }
                }

                // pull next ball on modern
                if (MainComponent.Type == TroughType.ModernOpto || MainComponent.Type == TroughType.ModernMech)
                {
                    _stackSwitches[MainComponent.SwitchCount - 1].Switch += OnLastStackSwitch;
                }
            }

            if (MainComponent.JamSwitch)
            {
                JamSwitch = CreateSwitch(TroughComponent.JamSwitchId, false, MainComponent.Type == TroughType.ModernOpto ? SwitchDefault.NormallyClosed : SwitchDefault.NormallyOpen);
                _switchLookup[TroughComponent.JamSwitchId] = JamSwitch;
            }

            // setup coils
            EntryCoil = new DeviceCoil(Player, OnEntryCoilEnabled);
            ExitCoil  = new DeviceCoil(Player, () => EjectBall());

            // fill up the ball stack
            var ballCount = MainComponent.Type == TroughType.ClassicSingleBall ? 1 : MainComponent.BallCount;

            for (var i = 0; i < ballCount; i++)
            {
                AddBall();
            }

            // finally, emit the event for anyone else to chew on
            Init?.Invoke(this, EventArgs.Empty);
        }