Ejemplo n.º 1
0
        public BuildingPlacer(
            BuildingFromSpawnerGetter buildingFromSpawnerGetter,
            TerrainHitter terrainHitter,
            Camera cameraComponent,
            BuildingList buildingList,
            BuildingsDisplayer buildingsDisplayer,
            BuildingCollisionDetector buildingCollisionDetector,
            BuildingByTypeSpawner buildingByTypeSpawner,
            MapLayerMatrixManager mapLayerMatrixManager,
            MapLayerMatrix mapLayerMatrixWallsEditor
            )
        {
            _buildingFromSpawnerGetter = buildingFromSpawnerGetter;
            _terrainHitter             = terrainHitter;
            _cameraComponent           = cameraComponent;
            _buildingList              = buildingList;
            _buildingsDisplayer        = buildingsDisplayer;
            _buildingCollisionDetector = buildingCollisionDetector;
            _buildingByTypeSpawner     = buildingByTypeSpawner;

            _mapLayerMatrixManager     = mapLayerMatrixManager;
            _mapLayerMatrixWallsEditor = mapLayerMatrixWallsEditor;
        }
Ejemplo n.º 2
0
    public void Awake()
    {
        //config
        var terrainData = terrain.terrainData;

        int mapWidth  = terrainData.heightmapResolution;
        int mapHeight = terrainData.heightmapResolution;

        //lists
        var buildingList = new BuildingList();

        //matrices
        var mapLayerMatrixManager = new MapLayerMatrixManager();

        var mapLayerMatrixBuildings   = new MapLayerMatrix((short)mapWidth, (short)mapHeight);
        var mapLayerMatrixWalls       = new MapLayerMatrix((short)mapWidth, (short)mapHeight);
        var mapLayerMatrixWallsEditor = new MapLayerMatrix((short)mapWidth, (short)mapHeight);

        var terrainHitter = new TerrainHitter();

        cameraManager.Init(terrainHitter);
        var terrainPositionsFromCameraBoundariesGetter = new TerrainPositionsFromCameraBoundariesGetter(terrainHitter, cameraComponent);

        buildingsTypesList.Init();

        var buildingAreaGetter       = new BuildingAreaGetter(buildingsTypesList);
        var buildingMapMatrixUpdater = new BuildingMapMatrixUpdater(
            buildingAreaGetter,
            mapLayerMatrixManager,
            mapLayerMatrixBuildings
            );

        var wallSpawner = new WallSpawner(
            buildingList,
            buildingMapMatrixUpdater,
            wallData,
            mapLayerMatrixManager,
            mapLayerMatrixWalls
            );

        var towerSpawner = new TowerSpawner(buildingList, buildingMapMatrixUpdater);
        var buildingFromSpawnerGetter = new BuildingFromSpawnerGetter(wallSpawner, towerSpawner);

        var wallSidesUpdater = new WallSidesUpdater(
            mapLayerMatrixManager,
            mapLayerMatrixWallsEditor,
            mapLayerMatrixWalls
            );

        //displayers
        var buildingsDisplayer = new BuildingsDisplayer(objectPoolerManager, buildingList, wallSidesUpdater);

        objectPoolerDisplayer.Init(terrainPositionsFromCameraBoundariesGetter, buildingsDisplayer);

        var buildingCollisionDetector = new BuildingCollisionDetector(
            buildingAreaGetter,
            mapLayerMatrixManager,
            mapLayerMatrixBuildings
            );

        var buildingByTypeSpawner = new BuildingByTypeSpawner(wallSpawner, towerSpawner);

        var buildingPlacer = new BuildingPlacer(
            buildingFromSpawnerGetter,
            terrainHitter,
            cameraComponent,
            buildingList,
            buildingsDisplayer,
            buildingCollisionDetector,
            buildingByTypeSpawner,
            mapLayerMatrixManager,
            mapLayerMatrixWallsEditor
            );

        viewManager.Init(buildingsTypesList, buildingPlacer, canvas);
    }