public List <Tile> GetTilesInRange(Tile tile, int range, bool canMoveThroughOccupied) { List <Tile> hoverTiles = FindTilesWithinRange.Find(tileMap, tile, range, 0, canMoveThroughOccupied); //Debug.Log(hoverTiles.Count + "!"); return(hoverTiles); }
// Update is called once per frame void Update() { if (true) { return; } RaycastHit hitInfo = new RaycastHit(); bool hit = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo, raycastTileMask); //if (true && !done ) { // List<Tile> path = FindShortestPath.Find(tileMap, test1, test2); // Debug.Log("path length " + path.Count); // path.ForEach((t) => t.OnCursorOver()); // done = true; // return; //} if (hit) { //Debug.Log("Hit " + hitInfo.transform.gameObject.name); Tile tile = hitInfo.collider.GetComponent <Tile> (); if (tile != null) { Debug.Log("found tile"); tile.OnCursorOver(); List <Tile> hoverTiles = FindTilesWithinRange.Find(tileMap, tile, 2, 0); foreach (Tile hoverTile in currentHoverTiles) { hoverTile.OnCursorOff(); } currentHoverTiles = hoverTiles; foreach (Tile hoverTile in currentHoverTiles) { hoverTile.OnCursorOver(); } } if (currentHoverTile == null) { currentHoverTile = tile; } else if (currentHoverTile != null && tile != currentHoverTile) { currentHoverTile.OnCursorOff(); currentHoverTile = tile; } } else { //Debug.Log("No hit"); if (currentHoverTile != null) { currentHoverTile.OnCursorOff(); currentHoverTile = null; } } }