public void DestroyAdjacentMatchingBalls(DemoBall demoBall) { if (DebugConsole.IsVisible) { return; } if (GameIsOver) { return; } int colorIndex = demoBall.BallColorIndex; Debug.Log("Clicked on ball with color " + colorIndex); float limitSquared = Mathf.Pow(1.1f, 2); HashSet <DemoBall> matchedBalls = new HashSet <DemoBall> { demoBall }; int matchedBallCount; do { matchedBallCount = matchedBalls.Count; FindAdjacentMatchingBalls(matchedBalls, colorIndex, limitSquared); } while (matchedBallCount != matchedBalls.Count); Debug.Log(string.Format("Destroying {0} balls", matchedBalls.Count)); foreach (var ball in matchedBalls) { Destroy(ball.gameObject); BallsDestroyedThisLevel++; BallGameSaveSystem.BallsCollected++; } if (BallsDestroyedThisLevel >= BallTargetThisLevel) { EndOfRound(); } else { TurnsLeft--; if (TurnsLeft == 0) { EndGame(); } } }
public void BallCollected(DemoBall ball) { _balls.Remove(ball); }
public void RegisterBall(DemoBall demoBall) { _balls.Add(demoBall); }
public void RegisterBall(DemoBall demoBall) { _balls.Add(demoBall); }
public void DestroyAdjacentMatchingBalls(DemoBall demoBall) { if (DebugConsole.IsVisible) return; if (GameIsOver) return; int colorIndex = demoBall.BallColorIndex; Debug.Log("Clicked on ball with color " + colorIndex); float limitSquared = Mathf.Pow(1.1f, 2); HashSet<DemoBall> matchedBalls = new HashSet<DemoBall> {demoBall}; int matchedBallCount; do { matchedBallCount = matchedBalls.Count; FindAdjacentMatchingBalls(matchedBalls, colorIndex, limitSquared); } while (matchedBallCount != matchedBalls.Count); Debug.Log(string.Format("Destroying {0} balls", matchedBalls.Count)); foreach (var ball in matchedBalls) { Destroy(ball.gameObject); BallsDestroyedThisLevel++; BallGameSaveSystem.BallsCollected++; } if (BallsDestroyedThisLevel >= BallTargetThisLevel) { EndOfRound(); } else { TurnsLeft--; if (TurnsLeft == 0) { EndGame(); } } }
public void BallCollected(DemoBall ball) { _balls.Remove(ball); }