protected void RaisePlayerWinByClearingArena(BilliardPlayEventArgs e) { if (OnPlayerWinByClearingArena != null) { OnPlayerWinByClearingArena(this, e); } }
protected void RaiseBadBreak(BilliardPlayEventArgs e) { if (OnBadBreak != null) { OnBadBreak(this, e); } }
protected void RaisePlayerScratchOnDeathBall(BilliardPlayEventArgs e) { if (OnPlayerScratchOnDeathBall != null) { OnPlayerScratchOnDeathBall(this, e); } }
protected void RaisePlayerIllegallyPocketDeathBall(BilliardPlayEventArgs e) { if (OnPlayerIllegallyPocketDeathBall != null) { OnPlayerIllegallyPocketDeathBall(this, e); } }
protected void RaisePlayerScratch(BilliardPlayEventArgs e) { if (OnPlayerScratch != null) { OnPlayerScratch(this, e); } }
protected void RaisePlayerScoredForEnemy(BilliardPlayEventArgs e) { if (OnPlayerScoredForEnemy != null) { OnPlayerScoredForEnemy(this, e); } }
protected void RaiseAllianceDecided(BilliardPlayEventArgs e) { if (OnAllianceDecided != null) { OnAllianceDecided(this, e); } }
private void CheckForWinCondition(object sender, BilliardPlayEventArgs e) { if (ObjectBallsInPlay.Count == 0) { Player winner = (from player in _players where player.BallAlliance == e.Ball.BallAlliance select player).First(); //GameOverState state = (winner == CurrentPlayer) ? GameOverState.Win : GameOverState.Lose; //RaiseGameOver(new GameOverEventArgs(CurrentPlayer, e.Ball, state)); RaiseGameOver(new GameOverEventArgs(e, this, winner)); } }
private void CheckForWinCondition(object sender, BilliardPlayEventArgs e) { /* * var balls = from ball in (from o in GameObject.FindGameObjectsWithTag("Ball") select o.GetComponent<BilliardBall>()) * where ball.BallType == BallType.Object * select ball; */ var balls = from ball in Component.FindObjectsOfType <BilliardBall>() where ball.BallType == BallType.Object select ball; if (balls.Count() == 0) { RaiseGameOver(new GameOverEventArgs(e, this, e.Player)); } }
public GameOverEventArgs(BilliardPlayEventArgs e, GameMode mode, Player winner) : this(e.Player, e.Ball, mode, winner) { }
protected override void CallOnBallPocketed(BallPocketedEventArgs e) { RaiseBallPocketed(e); var args = new BilliardPlayEventArgs(CurrentPlayer, e.Ball); if (e.Ball.BallType == BallType.Cue) { RaisePlayerScratch(args); return; } //WriteableAllBallsInPlay.Remove(e.Ball); if (e.Ball.IsDeathBall && !DeathBallShotAllowed(CurrentPlayer)) { if (IsBreak) { RaiseBadBreak(args); return; } RaisePlayerIllegallyPocketDeathBall(args); return; } if (e.Ball.IsDeathBall && CalledPocket != e.PocketIndex) { RaisePlayerIllegallyPocketDeathBall(args); return; } if (CurrentPlayer.BallAlliance == null) { var alliances = new List <BallAlliance>(new BallAlliance[] { BallAlliance.Solids, BallAlliance.Stripes }); CurrentPlayer.BallAlliance = e.Ball.BallAlliance; alliances.Remove(e.Ball.BallAlliance); OtherPlayer.BallAlliance = alliances[0]; RaisePlayerScored(args); RaiseAllianceDecided(args); } if (e.Ball.BallAlliance == CurrentPlayer.BallAlliance) { RaisePlayerScored(args); } else if (e.Ball.IsDeathBall) { // Player pockets the death ball legally in a game where both players share one death ball. if (e.Ball.BallAlliance == BallAlliance.Neutral) { RaisePlayerScored(args); } // Player pockets opponent's death ball in a game where each player has their own death ball. else { RaisePlayerIllegallyPocketDeathBall(args); } } else { RaisePlayerScoredForEnemy(args); } }