Beispiel #1
0
    public void Setup(GameData data)
    {
        _data = data;

        _level = new LevelManager();

        _board = new BoardModel(Constants.WIDTH, Constants.HEIGHT);

        _activeBricks = new ActiveBricks();

        _UI = GameObject.FindObjectOfType <GameUI>();
        _UI.Setup(this);

        _display = _UI.brickDisplay;
        _display.Setup(_data.GetTileSet(_level.Level));

        _randomizer = new Randomizer(_data);
        _input      = new InputManager(this);

        _score       = 0;
        _rowsCleared = 0;

        NewShape();

        _display.UpdateDisplay(_board, _activeBricks);
    }
Beispiel #2
0
    public void FrameUpdate()
    {
        _frame += 1;

        if (!_gameOver)
        {
            bool inputLock = true;

            if (_areDelay <= 0)
            {
                inputLock = false;

                if (_softDropEnabled)
                {
                    _gravityCount += _level.Gravity / 2;
                }
                else
                {
                    _gravityCount += 1;
                }

                if (_gravityCount >= _level.Gravity)
                {
                    GravityUpdate();
                    _gravityCount = 0;
                }
            }

            _input.Update(inputLock);


            if (_areDelay > 0)
            {
                _areDelay -= 1;
                if (_areDelay <= 0)
                {
                    //Next Level!
                    if (_rowsCleared >= _level.PassAmount)
                    {
                        _level.PassLevel();
                        _display.SetTileSet(_data.GetTileSet(_level.Level));
                    }
                    NewShape();
                }
            }
        }

        if (_boardDrity)
        {
            _display.UpdateDisplay(_board, _activeBricks);
            _boardDrity = false;
        }
    }
Beispiel #3
0
    public void UpdateDisplay(TileSet tileSet)
    {
        if (_display == null)
        {
            _display = this.GetComponent <BrickDisplay>();
            _display.Setup(tileSet);
        }

        if (_display != null && Shape != null)
        {
            _display.SetTileSet(tileSet);
            BoardModel board = new BoardModel(Shape.Size, Shape.Size);
            Shape.ApplyToBoard(board, 0);
            _display.UpdateDisplay(board);
        }
    }