From 3f736cd3db63f106eac02f220477b4a0f3b0eceb Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Thu, 31 Aug 2017 17:59:51 +0200 Subject: Implement room creation --- .../map/layers/HoverTileLayerComponent.js | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/components/map/layers/HoverTileLayerComponent.js (limited to 'src/components/map/layers') 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 + } + + 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 ( + + onClick(positionX, positionY)} + /> + + ); +}; + +export default HoverTileLayerComponent; -- cgit v1.2.3