diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-08-31 17:59:51 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:05:50 +0200 |
| commit | 3f736cd3db63f106eac02f220477b4a0f3b0eceb (patch) | |
| tree | 80afa73f8c4d281b2fccba8ad2baa7c10f7e7e84 /src/components/map/layers | |
| parent | b17f1d8cb4815f57a4b7043cc91b867ec3cbc867 (diff) | |
Implement room creation
Diffstat (limited to 'src/components/map/layers')
| -rw-r--r-- | src/components/map/layers/HoverTileLayerComponent.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/components/map/layers/HoverTileLayerComponent.js b/src/components/map/layers/HoverTileLayerComponent.js new file mode 100644 index 00000000..691b9733 --- /dev/null +++ b/src/components/map/layers/HoverTileLayerComponent.js @@ -0,0 +1,27 @@ +import React from 'react'; +import {Layer} from "react-konva"; +import HoverTile from "../elements/HoverTile"; +import {TILE_SIZE_IN_PIXELS} from "../MapConstants"; + +const HoverTileLayerComponent = ({mainGroupX, mainGroupY, mouseX, mouseY, currentRoomInConstruction, isValid, onClick}) => { + if (currentRoomInConstruction === -1) { + return <Layer/> + } + + const positionX = Math.floor((mouseX - mainGroupX) / TILE_SIZE_IN_PIXELS); + const positionY = Math.floor((mouseY - mainGroupY) / TILE_SIZE_IN_PIXELS); + const pixelX = positionX * TILE_SIZE_IN_PIXELS + mainGroupX; + const pixelY = positionY * TILE_SIZE_IN_PIXELS + mainGroupY; + const validity = isValid(positionX, positionY); + + return ( + <Layer> + <HoverTile + pixelX={pixelX} pixelY={pixelY} + isValid={validity} onClick={() => onClick(positionX, positionY)} + /> + </Layer> + ); +}; + +export default HoverTileLayerComponent; |
