Navigation acceptable
parent
2fd955c362
commit
1e85465873
|
@ -56,7 +56,6 @@ func _process(_delta):
|
|||
|
||||
if len(player_navigation_path) > 0:
|
||||
PlayerChar.target = player_navigation_path[0]
|
||||
pass
|
||||
|
||||
|
||||
func get_tile_type(world_coord: Vector2):
|
||||
|
@ -83,7 +82,7 @@ func populate_ocean_grid():
|
|||
for island in Islands.get_children():
|
||||
for tile in island.tiles.keys():
|
||||
var grid_coords = Globals.WorldToHex(tile + island.offset_world)
|
||||
Globals.OceanGrid.add_obstacles(grid_coords)
|
||||
Globals.OceanGrid.add_obstacles(grid_coords, 5)
|
||||
|
||||
|
||||
func check_island_location_valid(new_island):
|
||||
|
@ -100,6 +99,9 @@ func check_island_location_valid(new_island):
|
|||
|
||||
|
||||
func generate():
|
||||
PlayerChar.transform.origin = Vector2.ZERO
|
||||
PlayerChar.position = Vector2.ZERO
|
||||
|
||||
var rng = RandomNumberGenerator.new()
|
||||
rng.randomize()
|
||||
|
||||
|
@ -144,8 +146,13 @@ func update_player_navigation_target(target_world: Vector2):
|
|||
|
||||
var path = Globals.OceanGrid.find_path(start_coord, goal_coord)
|
||||
player_navigation_path = []
|
||||
for p in path:
|
||||
player_navigation_path.append(Globals.HexToWorld(p.axial_coords))
|
||||
for target in path:
|
||||
var target_world_coord = Globals.HexToWorld(target.axial_coords)
|
||||
var target_type = get_tile_type(target_world_coord)
|
||||
if target_type == "Sand":
|
||||
break
|
||||
|
||||
player_navigation_path.append(target_world_coord)
|
||||
|
||||
if len(player_navigation_path) > 1:
|
||||
PlayerChar.target = player_navigation_path[1]
|
||||
|
|
Loading…
Reference in New Issue