public enum Direction extends Enum<Direction>
| Enum Constant and Description |
|---|
EAST |
NORTH |
NORTH_EAST |
NORTH_WEST |
SOUTH |
SOUTH_EAST |
SOUTH_WEST |
WEST |
| Modifier and Type | Field and Description |
|---|---|
static char |
FIRST_CHAR |
static char |
LAST_CHAR |
| Modifier and Type | Method and Description |
|---|---|
static Direction |
byChar(@IntRange(from=97L,to=104L) char c)
Get the direction by its char value
|
int |
nextCellIncrement(@Positive int mapWidth)
Get the increment to apply to cell id for get the next cell on the direction
Ex:
MapCell current = map.get(123);
MapCell east = map.get(Direction.EAST.nextCellIncrement(map.dimensions().width()) + current.id());
|
Direction |
opposite()
Get the opposite direction
|
Direction |
orthogonal()
Get the orthogonal direction
|
boolean |
restricted()
Does the direction is restricted
A restricted direction can be used in fight, or by monsters's sprites
Restricted direction do not allow diagonal
|
static Direction[] |
restrictedDirections()
Get the restricted directions (i.e. can be used on fight)
Note: a new array is always returned
|
char |
toChar()
Get the char value of the direction
|
static Direction |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Direction[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Direction EAST
public static final Direction SOUTH_EAST
public static final Direction SOUTH
public static final Direction SOUTH_WEST
public static final Direction WEST
public static final Direction NORTH_WEST
public static final Direction NORTH
public static final Direction NORTH_EAST
public static final char FIRST_CHAR
public static final char LAST_CHAR
public static Direction[] values()
for (Direction c : Direction.values()) System.out.println(c);
public static Direction valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is null@Pure public char toChar()
@Pure public Direction opposite()
@Pure public Direction orthogonal()
@Pure public boolean restricted()
@Pure public int nextCellIncrement(@Positive int mapWidth)
mapWidth - The map width@Pure public static Direction byChar(@IntRange(from=97L,to=104L) char c)
c - The direction character value@SideEffectFree public static Direction[] restrictedDirections()
Copyright © 2022. All rights reserved.