コード例 #1
0
    public void InitBalls(LevelProfile level)
    {
        if (_gridManager == null)
        {
            _gridManager       = new GridManager(12, level.numRows + level.extraRows, CELL_SIZE_X, CELL_SIZE_Y);
            _numberOfDiffColor = level.GetNumColor();
        }

        _bottomRow              = level.numRows - 1;
        _lastRowToPushDown      = Mathf.FloorToInt((850 - Deadline.transform.localPosition.y) / CELL_SIZE_Y) - level.extraRows;
        PivotGrid.localPosition = new Vector2(PivotGrid.localPosition.x, (Deadline.localPosition.y + ((level.numRows + level.extraRows - 1) * CELL_SIZE_Y)) + 10);

        for (int i = 1; i < _gridManager.GetGridSizeX() - 1; i++)
        {
            for (int j = 0; j < level.numRows; j++)
            {
                if (_gridManager.IsValidGridPosition(i, j))
                {
                    Ball ball = instantiateNewBall(randomBallColor());
                    assignBallToGrid(ball, i, j);
                    if (ball != null)
                    {
                        ball.FixPosition();
                    }
                }
            }
        }
    }
コード例 #2
0
    // Update is called once per frame
    //void Update()
    //{
    //}

    #region Logic ball

    public void InitBalls(LevelProfile level)
    {
        if (_gridManager == null)
        {
            _gridManager = new GridManager(8, 14, 120, 100);

            if (level is ProceduralLevelProfile)
            {
                _secondaryGridManager = new GridManager(8, 14, 120, 100, new Vector2(0, -_gridManager.GetCellSizeY() / 2 * 27 - _gridManager.GetCellSizeY() / 2.0f));
            }

            _numberOfInitRow   = level.GetInitRow();
            _numberOfDiffColor = level.GetNumColor();
        }

        for (int i = 0; i < _gridManager.GetGridSizeX(); i++)
        {
            for (int j = 0; j < _numberOfInitRow; j++)
            {
                if (_gridManager.IsValidGridPosition(i, j))
                {
                    Ball ball = instantiateNewBall(randomBallColor(_numberOfDiffColor + 1));
                    assignBallToGrid(ball, i, j);
                    ball.FixPosition();
                }
            }
        }
    }
コード例 #3
0
    public void InitBalls(LevelProfile level)
    {
        if (_gridManager == null)
        {
            _gridManager       = new GridManager(7, 14, 120, 100);
            _numberOfInitRow   = level.GetInitRow();
            _numberOfDiffColor = level.GetNumColor();
        }

        for (int i = 0; i < _gridManager.GetGridSizeX(); i++)
        {
            for (int j = 0; j < _numberOfInitRow; j++)
            {
                if (_gridManager.IsValidGridPosition(i, j))
                {
                    Ball ball = instantiateNewBall(randomBallColor(_numberOfDiffColor + 1));
                    assignBallToGrid(ball, i, j);
                    ball.FixPosition();
                }
            }
        }
    }