Пример #1
0
 /// <summary>
 /// Próbuje przypisać pozycje dla piłki, zwraca true jeżeli się powiedzie
 /// </summary>
 /// <param name="ball"></param>
 /// <param name="row"></param>
 /// <param name="column"></param>
 /// <returns></returns>
 private bool TrySetBallPosition(BallPrefabController ball, Vector2Int position)
 {
     if (IsPositionExistAndEmpty(position))
     {
         balls[position.x, position.y] = ball;
         ball.Set(position, GetBallPosition(position.x, position.y));
         return(true);
     }
     return(false);
 }
Пример #2
0
        /// <summary>
        /// Rozpoczyna emitowanie kólek
        /// </summary>
        /// <returns></returns>
        public IEnumerator StartEmit()
        {
            if (Screen.orientation == ScreenOrientation.Portrait ||
                Screen.orientation == ScreenOrientation.PortraitUpsideDown)
            {
                columns = PORTRAIT_COLUMNS;
            }
            else
            {
                columns = LANDSCAPE_COLUMNS;
            }

            rows = BALLS_TO_EMIT / columns;
            //TODO hardcoding
            ballsRows = rows * ALL_ROWS_MULTIPLIER + 1;

            balls           = new BallPrefabController[ballsRows, columns];
            usedBalls       = new List <BallPrefabController>(ballsRows * columns);
            usedPlayerBalls = new List <PlayerBallPrefabController>(10);

            ballConfigurations =
                new Dictionary <BallConfiguration, int>(configurations.Count);
            foreach (BallConfiguration ballConfiguration in configurations)
            {
                ballConfigurations.Add(ballConfiguration, 0);
            }

            for (int row = 0; row < rows; row++)
            {
                for (int column = 0; column < columns; column++)
                {
                    BallPrefabController newBall = Instantiate(ballPrefab);
                    newBall.transform.SetParent(transform, false);
                    balls[row, column] = newBall;
                    newBall.Set(new Vector2Int(row, column), GetBallPosition(row, column),
                                GetRandomBallConfiguration());
                    yield return(null);
                }
            }
            nextBallEmit = Random.Range(ADD_BALL_MIN, ADD_BALL_MAX);

            playerBallEmiter.StartEmit();
        }