Esempio n. 1
0
        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();
                }
            }
        }
Esempio n. 2
0
 public void BallCollected(DemoBall ball)
 {
     _balls.Remove(ball);
 }
Esempio n. 3
0
 public void RegisterBall(DemoBall demoBall)
 {
     _balls.Add(demoBall);
 }
Esempio n. 4
0
		public void RegisterBall(DemoBall demoBall)
		{
			_balls.Add(demoBall);
		}
Esempio n. 5
0
		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();
				}
			}
		}
Esempio n. 6
0
		public void BallCollected(DemoBall ball)
		{
			_balls.Remove(ball);
		}