Example #1
0
    private void Start()
    {
        _currentBoardScalar = (float)DefaultNumTilesX / Width;
        _currentTileSpacing = DefaultTileSpacing * _currentBoardScalar;
        transform.position  = new Vector2(-(_currentTileSpacing * Width * .5f - (_currentTileSpacing * .5f)),
                                          transform.position.y + (_currentTileSpacing * .5f));

        _objectives[0].ObjectiveCount = MissionRed;
        _objectives[1].ObjectiveCount = MissionPurple;
        _objectives[2].ObjectiveCount = MissionGreen;
        _objectives[3].ObjectiveCount = MissionBlue;
        _objectives[4].ObjectiveCount = MissionYellow;

        _stateRed    = MissionRed;
        _statePurple = MissionPurple;
        _stateYellow = MissionYellow;
        _stateGreen  = MissionGreen;
        _stateBlue   = MissionBlue;

        _progressHandler.Load();


        if (TimeAttackTime > 0)
        {
            _timeAttack    = true;
            Time.timeScale = 0f;
            _gameStopped   = true;

            _startScreen.SetActive(true);
        }


        TimeAttackEndScreen.Start();
        ObjectivesEndScreen.Start();
        _boardUiHandler.Setup(
            _timeAttack,
            (_timeAttack) ? _progressHandler.GetTimeAttackScore() : ObjectiveScore,
            (_timeAttack) ? _progressHandler.GetTimeAttackChain() : 0);


        var distance        = 0;
        var definitionIndex = 0;

        foreach (var objective in _objectives)
        {
            objective.Setup(distance, TileDefinitions[definitionIndex]);

            if (objective.ObjectiveCount > 0)
            {
                distance++;
            }

            definitionIndex++;
        }


        _lineRenderer            = GetComponent <LineRenderer>();
        _lineRenderer.startWidth = 0.1f;
        _lineRenderer.endWidth   = 0.1f;

        _tiles = new Tile[Width, Height];

        FillBoard(!_timeAttack);
        UpdateScore();
    }