public static List <Cell> GetNeighbours(Cell cell) { List <Cell> neighbours = new List <Cell>(); foreach (var direction in ORTHOGONAL) { Vector3Int center = cell.AsVector3Int(); Vector3Int directionVector = Vector3Int.right * direction.x + Vector3Int.up * direction.y; Cell neighbour = GridHolder.GetCell(center + directionVector) as Cell; if (neighbour != null) { neighbours.Add(neighbour); } } if (selectedStyle == Style.Diagonal || selectedStyle == Style.Euclidian) { foreach (var direction in DIAGONALS) { Vector3Int center = cell.AsVector3Int(); Vector3Int directionVector = Vector3Int.right * direction.x + Vector3Int.up * direction.y; Cell neighbour = GridHolder.GetCell(center + directionVector) as Cell; if (neighbour != null) { neighbours.Add(neighbour); } } } return(neighbours.Count > 0 ? neighbours : null); }
private Cell LookForPlayer() { if (Vector3.Distance(transform.position, player.gameObject.transform.position) <= ruleSet.LIGHT_RADIUS) { if (Physics.Linecast(transform.position, player.transform.position, out hit, searchMask)) { if (hit.collider.gameObject == player.gameObject) { return(GridHolder.GetCell(player.pos.GetAsVector3Int())); } } } return(null); }
public static List <Cell> PathfindBetween(Vector3Int start, Vector3Int goal) { return(PathfindBetween(GridHolder.GetCell(start), GridHolder.GetCell(goal))); }
public void TargetSteppedOnBranch(Vector3Int pos) { ChangeMode(Modes.Hunt); searchCell = GridHolder.GetCell(pos); timeSinceSpotted = 0; }