Пример #1
0
        private void Awake()
        {
            _cellGenerator      = new GridCellGenerator(GridCellPrefab, GridSize * ChunkSize);
            _loadedChunkSlots   = new GridChunk[3, 3];
            _focalChunkPosition = new Vector2Int(GridSize / 2, GridSize / 2);
            _focalChunkBounds   = new Bounds((Vector2)CenterScenePosition, new Vector2(ChunkSize, ChunkSize));

            _camera = GetComponent <CameraMovement>();
        }
Пример #2
0
        public GridChunk(int chunkSize, Vector2Int chunkPosition, Vector2 scenePosition, GridCellGenerator cellGenerator)
        {
            _chunkSize = chunkSize;

            ChunkPosition = chunkPosition;

            _container = new GameObject();

            _cells = new GridCell[chunkSize, chunkSize];

            ForEachCell(position =>
            {
                var gridPosition = (chunkPosition * _chunkSize) + position;
                var cell         = cellGenerator.GetCell(gridPosition, position, _container.transform);
                _cells[position.x, position.y] = cell;
            });

            MoveTo(scenePosition);
        }