/// <summary> /// Sets up event listeners when a new machine is entered. /// </summary> /// <param name="machine"></param> protected virtual void EnterGame(PinballGameMachine machine) { }
/// <summary> /// Removes event listeners when a machine is left /// </summary> /// <param name="machine"></param> protected virtual void LeaveGame(PinballGameMachine machine) { }
protected override void LeaveGame(PinballGameMachine machine) { machine.Input.KeyDown -= OnKeyDown; machine.Input.KeyUp -= OnKeyUp; }
protected override void EnterGame(PinballGameMachine machine) { machine.Input.KeyDown += OnKeyDown; machine.Input.KeyUp += OnKeyUp; }
protected override void LeaveGame(PinballGameMachine machine) { // Unbind key event machine.Input.KeyDown -= Charge; machine.Input.KeyUp -= Discharge; }
protected override void EnterGame(PinballGameMachine machine) { // Bind key event machine.Input.KeyDown += Charge; machine.Input.KeyUp += Discharge; }
/// <summary> /// Starts a new game. /// </summary> public void Start() { lock (this) { if (Machine != null) { Machine.Dispose(); } Machine = new PinballGameMachine(OriginalMachine); Machine.prepareForLaunch(); Status = GameStatus.Playing; Machine.Input.Enabled = true; Score = 0; Lives = TOTAL_LIVES; // Wire up event handlers Machine.Collision += OnScore; Machine.GameOver += OnGameOver; Machine.IntroduceBall(); Lives--; } }