コード例 #1
0
 protected void RaisePlayerWinByClearingArena(BilliardPlayEventArgs e)
 {
     if (OnPlayerWinByClearingArena != null)
     {
         OnPlayerWinByClearingArena(this, e);
     }
 }
コード例 #2
0
 protected void RaiseBadBreak(BilliardPlayEventArgs e)
 {
     if (OnBadBreak != null)
     {
         OnBadBreak(this, e);
     }
 }
コード例 #3
0
 protected void RaisePlayerScratchOnDeathBall(BilliardPlayEventArgs e)
 {
     if (OnPlayerScratchOnDeathBall != null)
     {
         OnPlayerScratchOnDeathBall(this, e);
     }
 }
コード例 #4
0
 protected void RaisePlayerIllegallyPocketDeathBall(BilliardPlayEventArgs e)
 {
     if (OnPlayerIllegallyPocketDeathBall != null)
     {
         OnPlayerIllegallyPocketDeathBall(this, e);
     }
 }
コード例 #5
0
 protected void RaisePlayerScratch(BilliardPlayEventArgs e)
 {
     if (OnPlayerScratch != null)
     {
         OnPlayerScratch(this, e);
     }
 }
コード例 #6
0
 protected void RaisePlayerScoredForEnemy(BilliardPlayEventArgs e)
 {
     if (OnPlayerScoredForEnemy != null)
     {
         OnPlayerScoredForEnemy(this, e);
     }
 }
コード例 #7
0
 protected void RaiseAllianceDecided(BilliardPlayEventArgs e)
 {
     if (OnAllianceDecided != null)
     {
         OnAllianceDecided(this, e);
     }
 }
コード例 #8
0
        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));
            }
        }
コード例 #9
0
        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));
            }
        }
コード例 #10
0
 public GameOverEventArgs(BilliardPlayEventArgs e, GameMode mode, Player winner) : this(e.Player, e.Ball, mode, winner)
 {
 }
コード例 #11
0
        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);
            }
        }