示例#1
0
 public void replaceTiles(ref TileRenderData renderData)
 {
     if (this.isFilled)
     {
         renderData.objectTile = this.tileSinkFilled;
     }
 }
示例#2
0
 public void replaceTiles(ref TileRenderData renderData)
 {
     if (this.isOn)
     {
         renderData.objectTile = this.onTile;
     }
 }
示例#3
0
 public void replaceTiles(ref TileRenderData renderData)
 {
     if (this.isTripped)
     {
         renderData.floorOverlayTile =
             this.rotation.axis == EnumAxis.X ?
             this._trippedTileX :
             this._trippedTileY;
     }
 }
示例#4
0
    protected override void applyPreviewSprites(ref Sprite floorOverlaySprite, ref Sprite objectSprite, ref Sprite overlaySprite)
    {
        if (this._cell == null)
        {
            Debug.LogWarning("Can not display preview for BuildableTile " + this.name + ", it has no cell set");
            return;
        }

        TileRenderData dt = this._cell.getRenderData(Rotation.fromEnum(this.displayRotation));

        floorOverlaySprite = TileSpriteGetter.retrieveSprite(dt.floorOverlayTile);
        objectSprite       = TileSpriteGetter.retrieveSprite(dt.objectTile);
        overlaySprite      = TileSpriteGetter.retrieveSprite(dt.overlayTile);
    }
示例#5
0
    private void renderTile(int x, int y)
    {
        CellState state = this.cellStateGetterFunc != null?this.cellStateGetterFunc(x, y) : null;

        if (state == null)
        {
            return;
        }

        CellData   data = state.data;
        Vector3Int pos  = new Vector3Int(x, y, 0);

        // Draw the floor:
        if (this.floorTilemap != null)
        {
            Color floorTint = this.floorTintGetterFunc != null?this.floorTintGetterFunc(x, y) : Color.white;

            TileBase tile;
            if (data.isSolid)
            {
                // Floor not visible
                tile = null;
            }
            else
            {
                // Floor is visible, draw dirt/grass
                tile = this.floorGetterFunc != null?this.floorGetterFunc(x, y) : null;
            }

            this.floorTilemap.SetTile(pos, tile);
            this.floorTilemap.SetColor(pos, floorTint);
        }

        TileRenderData dt = data.getRenderData(state.rotation);


        // If the Cell's behavior implements IRenderTileOverride, let it adject the tile, even if the tile is rotatable.
        if (state.hasBehavior() && state.behavior is IRenderTileOverride)
        {
            ((IRenderTileOverride)state.behavior).replaceTiles(ref dt);
        }


        // Draw floor overlay:
        if (this.floorOverlayTilemap != null)
        {
            this.floorOverlayTilemap.SetTile(pos, dt.floorOverlayTile);
        }


        // Draw Object Tile:
        if (this.objectMap != null)
        {
            this.objectMap.GetTileFlags(pos);

            // Set the tile on the map.
            this.objectMap.SetTile(pos, dt.objectTile);

            // Set the tile's transform.
            this.objectMap.SetTransformMatrix(pos, dt.getMatrix());

            // Color
            if (data.recieveHardnessColorMod)
            {
                Color hardnessColorMod = this.hardnessColorModGetterFunc != null?this.hardnessColorModGetterFunc(x, y) : Color.white;

                this.colorSquare(this.objectMap, pos, hardnessColorMod);
            }
        }


        // Draw Overlay Tile:
        if (this.overlayMap != null)
        {
            this.overlayMap.SetTile(pos, dt.overlayTile);
        }
    }