public NewGenerateController(GenerateBalls generateBalls, GamePoleView gamePoleView, BallController[,] ballPole, BallSpritesViewDescription spritesViewDescription, MovedController movedController) { _generateBalls = generateBalls; _gamePoleView = gamePoleView; _ballPole = ballPole; _spritesViewDescription = spritesViewDescription; _movedController = movedController; }
public BallController[,] GenerateAll() { _balls = new BallController[_sizeGamePole.X, _sizeGamePole.Y]; _generatePosition = new BallPoint(0, 0); do { _balls[_generatePosition.X, _generatePosition.Y] = NextBall(); } while (NextPosition()); return(_balls); }
public void SetGenerator(bool newGeneration) { if (newGeneration) { _generatedBall = _generateBalls.GenerateAll(); _getBall = GetGeneratedBall; } else { _getBall = GetNewBall; } }
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); }
public GamePoleStateControler(DestroyControllerBall destroyControllerBall, FallControllerBall fallControllerBall, MovedController movedController, NewGenerateController newGenerateController, CheckChangedBallController checkChangedBallController, BallController[,] balls, HintControler hintControler) { _destroyControllerBall = destroyControllerBall; _fallControllerBall = fallControllerBall; _movedController = movedController; _newGenerateController = newGenerateController; _checkChangedBallController = checkChangedBallController; _balls = balls; _hintControler = hintControler; _movedController.EndBallMoved += OnEndBallMoved; newGenerateController.SetGenerator(true); }
public GamePoleController(HintView hintView, GamePoleView gamePole, BallPool ballPool, BallSpritesViewDescription spritesViewDescription, MiningSceneViewDescription miningViewDescription, MonoBehaviour monoBehaviour) { _balls = new BallController[gamePole.CountHorCell, gamePole.CountVertCell]; var checkBall = new CheckBall(new BallPoint(gamePole.CountHorCell, gamePole.CountVertCell)); var movedController = new MovedController(_balls, gamePole, checkBall); var destroyControler = new DestroyControllerBall(_balls, movedController, ballPool); var checkChangedBallController = new CheckChangedBallController(_balls, checkBall); var fallBallContorller = new FallControllerBall(_balls, movedController); var generateBalls = new GenerateBalls(new BallPoint(gamePole.CountHorCell, gamePole.CountVertCell), miningViewDescription, ballPool); var newGenerateController = new NewGenerateController(generateBalls, gamePole, _balls, spritesViewDescription, movedController); var hintController = new HintControler(hintView, checkChangedBallController, monoBehaviour); _gamePoleStateControler = new GamePoleStateControler(destroyControler, fallBallContorller, movedController, newGenerateController, checkChangedBallController, _balls, hintController); _gamePoleStateControler.GameOver += CallGameOver; gamePole.Activate(); _gamePoleStateControler.StartGame(); }
public bool CheckChangedBall(BallController ball, BallController[,] newGamePole, bool destoed) { bool change = false; ICollection <BallController> balls = new List <BallController> { ball }; CountLeftBall(ball, balls, newGamePole); CountRightBall(ball, balls, newGamePole); if (balls.Count > 2) { change = true; if (destoed) { foreach (var destroedBall in balls) { destroedBall.IsDestroed = true; } } } balls = new List <BallController> { ball }; CountDownBall(ball, balls, newGamePole); CountUpBall(ball, balls, newGamePole); if (balls.Count > 2) { change = true; if (destoed) { foreach (var destroedBall in balls) { destroedBall.IsDestroed = true; } } } balls.Clear(); return(change); }
private ICollection <BallController> CountUpBall(BallController ball, ICollection <BallController> balls, BallController[,] newGamePole) { if (ball.Positinon.Y < _sizeGamePole.Y - 1) { var newBall = newGamePole[ball.Positinon.X, ball.Positinon.Y + 1]; if (newBall != null && ball.TypeBall == newBall.TypeBall) { balls.Add(newBall); return(CountUpBall(newBall, balls, newGamePole)); } } return(balls); }
private ICollection <BallController> CountLeftBall(BallController ball, ICollection <BallController> balls, BallController[,] newGamePole) { if (ball.Positinon.X > 0) { var newBall = newGamePole[ball.Positinon.X - 1, ball.Positinon.Y]; if (newBall != null && ball.TypeBall == newBall.TypeBall) { balls.Add(newBall); return(CountLeftBall(newBall, balls, newGamePole)); } } return(balls); }
public CheckChangedBallController(BallController[,] ballPole, CheckBall checkBall) { _ballPole = ballPole; _checkBall = checkBall; }
public MovedController(BallController[,] ballPole, GamePoleView gamePole, CheckBall checkBall) { _ballPole = ballPole; _gamePole = gamePole; _checkBall = checkBall; }
public FallControllerBall(BallController[,] ballPole, MovedController movedController) { _ballPole = ballPole; _movedController = movedController; }
public DestroyControllerBall(BallController[,] ballPole, MovedController movedController, BallPool ballPool) { _ballPole = ballPole; _movedController = movedController; _ballPool = ballPool; }