} // end GetMouseWorldPosition //We're gonna rock on down to AI avenue //checks if the position you clicked on is a valid tile public int validatePos(Vector3Int mousePos) { //the closed list that holds the valid positions int energy = activeUnit.currentEnergy; rangeList = astar.CharAlgorithm(activeUnit.currentPosition, mousePos, tilemapFloor, energy);//movement list for (int a = 0; a < 2; a++) { if (RedTeam[a].currentPosition == mousePos || BlueTeam[a].currentPosition == mousePos) { return(-1); } } //if in the list it's valid for (int i = 0; i < rangeList.Count; i++) { if (rangeList[i].pos == mousePos) { return(rangeList[i].G); } } return(-1); }//end validatePos