Beispiel #1
0
    private ChunkElement GetNextElement()
    {
        UpdateChunk();
        ChunkElement element = _activeChunk.elements[_chunkElementIndex];

        _chunkElementIndex++;
        return(element);
    }
Beispiel #2
0
    private void Generate(Vector3 spawnDirection, bool animate = true)
    {
        bool offStartingBlock = _tileFactorySettings.startingCounter >= _tileFactorySettings.startingTiles.Count;

        if (offStartingBlock)
        {
            ChunkElement element = GetNextElement();
            _tileFactorySettings.randomTiles  = element.tiles;
            _obstacleFactorySettings.builders = element.obstacleBuilders;
        }

        Tile previousTile = _tiles.Last.Value;
        Tile nextTile     = _tileFactory.Create();

        _tiles.AddLast(nextTile);

        Vector3 pTilePos  = previousTile.transform.position;
        Vector3 pTileSize = previousTile.meshCollider.bounds.size;

        Quaternion nextRotation = previousTile.transform.rotation * Quaternion.Euler(spawnDirection);

        Vector3 nextOffset = nextRotation * nextTile.placementOffset;

        nextOffset = Vector3.Scale(pTileSize, nextOffset);

        nextTile.transform.position = pTilePos + nextOffset;
        nextTile.transform.rotation = nextRotation;

        if (offStartingBlock &&
            _obstacleFactorySettings.builders.Count > 0)
        {
            IBuilder pattern = _spawnPatternFactory.Create();
            pattern.SpawnForTile(nextTile);
        }

        if (animate)
        {
            nextTile.AnimateReveal();
        }
    }
 public ChunkElementRenderRule(ChunkElement parent)
 {
     m_Parent = parent;
 }