private Hex getTargetHex(Point point) { Hex targetHex = null; // Generally the target will be a game entity instead of a blank hex. // Check to see if the point hits a game entity first GameEntity targetGameEntity = MyBoard.findGameEntityAtPoint(point); if (targetGameEntity != null) { // The point hits a game entity. // First determine if this game entity can be attacked. if (targetGameEntity.MyEntityType == GameEntity.EntityType.Player && ((Player)targetGameEntity).IsActive) { // Find out what hex it is own and return that as the target targetHex = MyBoard.getHex(targetGameEntity); if (!MyBoard.isActiveHex(targetHex)) { targetHex = null; } } } else { // The point doesn't hit a game entity, so find the hex the user clicked on if (isPointOnBoard(point)) { targetHex = findActiveHex(point); } } return(targetHex); }
private Hex getTargetHex(Point point) { Hex targetHex = null; // Check to see if the point hits a game entity first GameEntity targetGameEntity = MyBoard.findGameEntityAtPoint(point); if (targetGameEntity != null) { // The point hits a game entity. // First determine if the player can walk over the game entity. // If the player has died, we will allow the player to walk over the player if (targetGameEntity.MyEntityType == GameEntity.EntityType.Player && !((Player)targetGameEntity).IsActive) { // Find out what hex it is own and return that as the target targetHex = MyBoard.getHex(targetGameEntity); if (!MyBoard.isActiveHex(targetHex)) { targetHex = null; } } } else { // The point doesn't hit a game entity, so find the hex the user clicked on if (isPointOnBoard(point)) { targetHex = findActiveHex(point); } } return(targetHex); }