private void Update() { // flippers will be handled via script later, but until scripting works, do it here. if (Input.GetKeyDown("left shift")) { _tableApi.Flipper("LeftFlipper")?.RotateToEnd(); } if (Input.GetKeyUp("left shift")) { _tableApi.Flipper("LeftFlipper")?.RotateToStart(); } if (Input.GetKeyDown("right shift")) { _tableApi.Flipper("RightFlipper")?.RotateToEnd(); } if (Input.GetKeyUp("right shift")) { _tableApi.Flipper("RightFlipper")?.RotateToStart(); } if (Input.GetKeyUp("b")) { _ballManager.CreateBall(new DebugBallCreator()); } if (Input.GetKeyUp("n")) { _ballManager.CreateBall(new DebugBallCreator(Table.Width / 2f, Table.Height / 2f - 300f, 0, -5)); //_tableApi.Flippers["LeftFlipper"].RotateToEnd(); } if (Input.GetKeyDown(KeyCode.Return)) { _tableApi.Plunger("Plunger")?.PullBack(); } if (Input.GetKeyUp(KeyCode.Return)) { _tableApi.Plunger("Plunger")?.Fire(); } }
public void Switch(string id, bool normallyClosed) { switch (id) { case SwLeftFlipper: // todo remove when solenoids are done if (normallyClosed) { _leftFlipper?.RotateToEnd(); } else { _leftFlipper?.RotateToStart(); } OnCoilChanged?.Invoke(this, new CoilEventArgs(CoilLeftFlipper, normallyClosed)); break; case SwRightFlipper: // todo remove when solenoids are done if (normallyClosed) { _rightFlipper?.RotateToEnd(); } else { _rightFlipper?.RotateToStart(); } OnCoilChanged?.Invoke(this, new CoilEventArgs(CoilRightFlipper, normallyClosed)); break; case SwPlunger: OnCoilChanged?.Invoke(this, new CoilEventArgs(CoilAutoPlunger, normallyClosed)); break; case SwCreateBall: { if (normallyClosed) { _ballManager.CreateBall(new DebugBallCreator()); } break; } } }
public virtual void OnAwake(TableApi table, BallManager ballManager) { // table.Plunger("Plunger").Init += (sender, args) => { // KickNewBallToPlunger(table); // }; // // table.Kicker("Drain").Hit += (sender, args) => { // ((KickerApi)sender).DestroyBall(); // KickNewBallToPlunger(table); // }; table.Init += (sender, args) => { ballManager.CreateBall(new DebugBallCreator(200f, 620f)); ballManager.CreateBall(new DebugBallCreator(330f, 360f)); ballManager.CreateBall(new DebugBallCreator(400f, 700f)); ballManager.CreateBall(new DebugBallCreator(620f, 820f)); ballManager.CreateBall(new DebugBallCreator(720f, 400f)); ballManager.CreateBall(new DebugBallCreator(830f, 870f)); ballManager.CreateBall(new DebugBallCreator(470f, 230f)); ballManager.CreateBall(new DebugBallCreator(620f, 1200f)); }; }
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)); }
public void Switch(string id, bool normallyClosed) { _switchStatus[id] = normallyClosed; if (!_switchTime.ContainsKey(id)) { _switchTime[id] = new Stopwatch(); } if (normallyClosed) { _switchTime[id].Restart(); } else { _switchTime[id].Stop(); } Logger.Info("Switch {0} is {1}.", id, normallyClosed ? "closed" : "open after " + _switchTime[id].ElapsedMilliseconds + "ms"); switch (id) { case SwLeftFlipper: if (normallyClosed) { OnCoilChanged?.Invoke(this, new CoilEventArgs(CoilLeftFlipperMain, true)); } else { OnCoilChanged?.Invoke(this, _switchStatus[SwLeftFlipperEos] ? new CoilEventArgs(CoilLeftFlipperHold, false) : new CoilEventArgs(CoilLeftFlipperMain, false) ); } break; case SwLeftFlipperEos: OnCoilChanged?.Invoke(this, new CoilEventArgs(CoilLeftFlipperMain, false)); OnCoilChanged?.Invoke(this, new CoilEventArgs(CoilLeftFlipperHold, true)); break; case SwRightFlipper: if (normallyClosed) { OnCoilChanged?.Invoke(this, new CoilEventArgs(CoilRightFlipperMain, true)); } else { OnCoilChanged?.Invoke(this, _switchStatus[SwRightFlipperEos] ? new CoilEventArgs(CoilRightFlipperHold, false) : new CoilEventArgs(CoilRightFlipperMain, false) ); } break; case SwRightFlipperEos: OnCoilChanged?.Invoke(this, new CoilEventArgs(CoilRightFlipperMain, false)); OnCoilChanged?.Invoke(this, new CoilEventArgs(CoilRightFlipperHold, true)); break; case SwPlunger: OnCoilChanged?.Invoke(this, new CoilEventArgs(CoilAutoPlunger, normallyClosed)); break; case SwCreateBall: { if (normallyClosed) { _ballManager.CreateBall(new DebugBallCreator()); } break; } } }
public void CreateBall() { _ballManager.CreateBall(Item, 25f, 1f, Entity); }