private bool CheckGenerateBall(BallController ball) { if (CountLeftBall(ball, 1) > 2 || CountDownBall(ball, 1) > 2) { return(false); } return(true); }
private int CountDownBall(BallController ball, int count) { if (ball.Positinon.Y > 0) { var newBall = _balls[ball.Positinon.X, ball.Positinon.Y - 1]; if (ball.TypeBall == newBall.TypeBall) { return(CountDownBall(newBall, count + 1)); } } return(count); }
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 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 void OnSuccessBall(GamePole.BallController ball) { _ball = ball; }
public MoveReverce(BallController ball) { _ball = ball; _ballkoord = ball.View.Ball.anchoredPosition; _ballPoint = ball.Positinon; }