public bool CheckAllBall(BallController[,] newGamePole)
        {
            for (int y = 0; y < _ballPole.GetLength(0) - 1; y++)
            {
                for (int x = 0; x < _ballPole.GetLength(0) - 1; x++)
                {
                    ReverceBall(x, y, x + 1, y);
                    if (_checkBall.CheckChangedBall(_ballPole[x, y], newGamePole, false))
                    {
                        ReverceBall(x, y, x + 1, y);
                        CallSuccessBall(_ballPole[x + 1, y]);
                        return(true);
                    }
                    if (_checkBall.CheckChangedBall(_ballPole[x + 1, y], newGamePole, false))
                    {
                        ReverceBall(x, y, x + 1, y);
                        CallSuccessBall(_ballPole[x, y]);
                        return(true);
                    }



                    ReverceBall(x, y, x + 1, y);

                    ReverceBall(x, y, x, y + 1);

                    if (_checkBall.CheckChangedBall(_ballPole[x, y], newGamePole, false))
                    {
                        ReverceBall(x, y, x, y + 1);
                        CallSuccessBall(_ballPole[x, y + 1]);
                        return(true);
                    }

                    if (_checkBall.CheckChangedBall(_ballPole[x, y + 1], newGamePole, false))
                    {
                        ReverceBall(x, y, x, y + 1);
                        CallSuccessBall(_ballPole[x, y]);
                        return(true);
                    }

                    ReverceBall(x, y, x, y + 1);
                }
            }
            foreach (var ball in newGamePole)
            {
                if (_checkBall.CheckChangedBall(ball, newGamePole, false))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #2
0
 private void GenerateLine()
 {
     for (int i = 0; i < _ballPole.GetLength(0); i++)
     {
         if (_ballPole[i, 0] == null)
         {
             _changed        = true;
             _ballPole[i, 0] = _getBall(new BallPoint(i, 0));
         }
     }
 }
예제 #3
0
 private void FallAll()
 {
     _fallChanged = false;
     for (int y = _ballPole.GetLength(1) - 1; y >= 0; y--)
     {
         for (int x = 0; x < _ballPole.GetLength(0); x++)
         {
             var ball = _ballPole[x, y];
             if (ball != null)
             {
                 if (FallBall(ball))
                 {
                     _fallChanged = true;
                 }
             }
         }
     }
     if (!_fallChanged)
     {
         CallFallComplete();
     }
 }
예제 #4
0
        public void DestroyAllBall()
        {
            bool changed = false;

            for (int y = _ballPole.GetLength(1) - 1; y >= 0; y--)
            {
                for (int x = 0; x < _ballPole.GetLength(0); x++)
                {
                    var ball = _ballPole[x, y];
                    if (ball != null && ball.IsDestroed)
                    {
                        changed = true;
                        _isDestroy++;
                        ball.BallDestroedEnd += OnBallDestroedEnd;
                        ball.Destroy();
                    }
                }
            }
            if (!changed)
            {
                CallDestroyComplete(false);
            }
        }
예제 #5
0
        private BallController GetGeneratedBall(BallPoint position)
        {
            int            x = position.X;
            int            y = _generatedBall.GetLength(1) - 1;
            BallController ball;

            do
            {
                ball = _generatedBall[x, y];
                _generatedBall[x, y] = null;
                y--;
            } while (ball == null);
            _gamePoleView.AddBall(ball.View);
            InitBall(ball, position.X, position.Y);
            return(ball);
        }