public bool ValidateMove(Vector3 targetLocation, bool isPlayer, List <TileType> tileTypes) { // can be null as it loads if (grid == null) { return(false); } Vector3Int tilePos = grid.WorldToCell(targetLocation); //Debug.Log("***************************************************"); //Debug.Log("targetLoc: " + targetLocation + " targetCell: " + tilePos + " count: " + grid.transform.childCount); for (int i = 0; i < grid.transform.childCount; i++) { GameObject child = grid.transform.GetChild(i).gameObject; Tilemap tilemap = child.GetComponent <Tilemap>(); //Debug.Log("tilemap: " + tilemap.name + ", rule: " + rule); SuperTile tile = tilemap.GetTile <SuperTile>(tilePos); if (tile != null) { GridTile gridTile = getTileProperties(tile); //Debug.Log("Tile matched"); if (gridTile.cost >= 0) { if (isPlayer) { if (gridTile.tileType == TileType.LOCATION) { foreach (GameObject location in locations) { if (Vector3.Distance(location.transform.position, targetLocation) <= 0.05f) { //Debug.Log("Enter location: " + location.name); saveLoadHandler.Save(); StartCoroutine(LoadLocationScene(location.name)); return(true); } } return(false); } else { questHandler.IncrementTime(gridTile.cost); return(true); } } else { return(true); } } else { // only allow the first rule to be processed return(false); } } } return(false); }