示例#1
0
    private void GenerateStartingRoad()
    {
        //Cleaner and usign SpawnTileAtEndOfRoad()
        Vector3 roadStart = _player.transform.position - new Vector3(0, 0.5f, 0);

        _startingTile = new Tile(Instantiate(_roadManager.GetStartingTile(), transform.position, new Quaternion(0, 180, 0, 0)));
        SpawnTile(_startingTile, _activeRoadTiles, roadStart);
        _startingTile.GO.GetComponent <Movement>().Speed = _roadSpeed * _speedModifier * _powerSpeedModifier;

        //special case for tile 1 == can not be a jump tile.
        int randomRoadFromPool = _roadManager.GenerateRandomTile(_roadTilePool, _tileCount, _roadTilePool.Count - _roadTilesWithJump.Count - _innerCityRoadTilesWithJump.Count);

        SpawnTile(_roadTilePool[randomRoadFromPool], _activeRoadTiles, _activeRoadTiles[_activeRoadTiles.Count - 1].GO.transform.position - new Vector3(_roadTilePool[randomRoadFromPool].GO.transform.localScale.x - _roadSpeed * _speedModifier * Time.deltaTime, 0, 0));
        _roadTilePool[randomRoadFromPool].GO.SetActive(true);
        _roadTilePool[randomRoadFromPool].GO.GetComponent <Movement>().Speed = _roadSpeed * _speedModifier * _powerSpeedModifier;
        _tileCount++;

        for (int i = 1; i < _roadPiecesOnScreen; i++)
        {
            SpawnTileAtEndOfRoad();
        }
    }