public void Awake()
    {
        var noiseGenerator = new NoiseGenerator(
            Mathf.RoundToInt(terrain.terrainData.size.x),
            Mathf.RoundToInt(terrain.terrainData.size.z)
            );

        //lists
        var buildingList = new BuildingList();
        var personList   = new PersonList();

        peopleManager.Init(personList);

        var mapGenerator = new MapGenerator(terrain.terrainData, noiseGenerator, buildingList, personList);

        mapGenerator.Generate();

        var terrainHitter = new TerrainHitter();

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

        //displayers
        var buildingsDisplayer = new BuildingsDisplayer(objectPoolerManager, buildingList);
        var peopleDisplayer    = new PeopleDisplayer(objectPoolerManager, personList);

        objectPoolerDisplayer.Init(terrainPositionsFromCameraBoundariesGetter, buildingsDisplayer, peopleDisplayer);
    }
        public void Init(
            TerrainPositionsFromCameraBoundariesGetter terrainPositionsFromCameraBoundariesGetter,
            BuildingsDisplayer buildingsDisplayer
            )
        {
            _terrainPositionsFromCameraBoundariesGetter = terrainPositionsFromCameraBoundariesGetter;

            _displayers.Add(buildingsDisplayer);
        }
Пример #3
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);
    }