private void UpdateCornerMarker(Vector3Int mouseCornerPosition) { if (showCornerMarker) { cornerMarker.SetActive(true); cornerMarker.transform.position = HexConverter.CornerCoordToCartesianCoord(mouseCornerPosition, 0.1f); } else { cornerMarker.SetActive(false); } }
void Update() { if (!hexMouse.CursorIsOnMap) { return; // if we are not on the map we won't do anything so we can return } Vector3Int mouseTilePosition = hexMouse.TileCoord; Vector3Int mouseEdgePosition = hexMouse.ClosestEdgeCoord; Vector3Int mouseCornerPosition = hexMouse.ClosestCornerCoord; //update the marker positions tileMarker.transform.position = HexConverter.TileCoordToCartesianCoord(mouseTilePosition, 0.1f); //we put our tile marker on the tile our mouse is on edgeMarker.transform.position = HexConverter.EdgeCoordToCartesianCoord(mouseEdgePosition); // we put our edge marker on the closest edge of our mouse position edgeMarker.transform.rotation = Quaternion.Euler(0, hexMap.EdgesByPosition[mouseEdgePosition].EdgeAlignmentAngle, 0); //we set the rotation of the edge marker cornerMarker.transform.position = HexConverter.CornerCoordToCartesianCoord(mouseCornerPosition); if (Input.GetMouseButtonDown(0)) // change a tile when clicked on it { Tile <int> t = hexMap.TilesByPosition[mouseTilePosition]; //we select the tile our mouse is on int curValue = t.Data; //we grab the current value of the tile t.Data = ((curValue + 1) % 4); //we increment it and use modulo to keep it between 0 and 3 tileObjects[t.Index].GetComponent <Renderer>().material = materials[t.Data]; // we update the material of the GameObject representing the tile based on the new value } }