drawing treasure on map
parent
6661c3073d
commit
c94209ba7b
|
@ -4,7 +4,6 @@ var tiles = {}
|
|||
var offset_world = Vector2.ZERO
|
||||
var center_coord = Vector2.ZERO
|
||||
var center_world_coord = Vector2.ZERO
|
||||
var tile_local_coords = []
|
||||
var rect_local = Rect2()
|
||||
var radius_world = 0.0
|
||||
var is_active = false
|
||||
|
@ -13,6 +12,8 @@ var landing_site_world = null
|
|||
var ship_anchor_world = null
|
||||
var obstacles_local_coords = {}
|
||||
|
||||
var treasure_local_coords = null
|
||||
var highlight_treasure = false
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
@ -45,7 +46,6 @@ func calc_bbox():
|
|||
var coords = tiles.keys()
|
||||
for coord in coords:
|
||||
var local_coords = (coord)
|
||||
tile_local_coords.append(local_coords)
|
||||
if local_coords.x < coord_min.x:
|
||||
coord_min.x = local_coords.x
|
||||
if local_coords.y < coord_min.y:
|
||||
|
@ -163,6 +163,10 @@ func _draw():
|
|||
draw_set_transform (coord + offset_world, 0, Vector2.ONE)
|
||||
draw_polygon(HexTileDrawer.HexPoints, HexTileDrawer.get_tile_color(tiles[coord]))
|
||||
|
||||
if treasure_local_coords and highlight_treasure:
|
||||
draw_set_transform (treasure_local_coords + offset_world, 0, Vector2.ONE)
|
||||
draw_polygon(HexTileDrawer.HexPoints, HexTileDrawer.create_color_array("#922"))
|
||||
|
||||
draw_set_transform(transform.origin + offset_world, transform.get_rotation(), transform.get_scale())
|
||||
|
||||
if Globals.debug_nav and is_active:
|
||||
|
|
|
@ -153,10 +153,19 @@ func check_island_location_valid(new_island):
|
|||
return true
|
||||
|
||||
|
||||
func render_treasure_map():
|
||||
if treasure_map_rendered == false:
|
||||
treasure_map_rendered = true
|
||||
func place_treasure():
|
||||
assert (treasure_island != null)
|
||||
var island_tile_coords = treasure_island.tiles.keys()
|
||||
var grass_tiles = []
|
||||
for coord in island_tile_coords:
|
||||
if treasure_island.tiles[coord] == "Grass":
|
||||
grass_tiles.append(coord)
|
||||
|
||||
treasure_island.treasure_local_coords = grass_tiles[randi() % len(grass_tiles)]
|
||||
|
||||
treasure_island.update()
|
||||
|
||||
func render_treasure_map():
|
||||
IslandMapRenderer.render_target_update_mode = Viewport.UPDATE_ONCE
|
||||
IslandMapRenderer.render_target_clear_mode = Viewport.CLEAR_MODE_ONLY_NEXT_FRAME
|
||||
var camera = IslandMapRenderer.get_node("Camera2D")
|
||||
|
@ -165,6 +174,8 @@ func render_treasure_map():
|
|||
camera.offset = treasure_island.center_world_coord
|
||||
var island = Island.new()
|
||||
island.tiles = treasure_island.tiles.duplicate()
|
||||
island.treasure_local_coords = treasure_island.treasure_local_coords
|
||||
island.highlight_treasure = true
|
||||
island.name = "island"
|
||||
|
||||
for child in IslandMapRenderer.get_children():
|
||||
|
@ -185,7 +196,6 @@ func generate():
|
|||
PlayerChar.target = Vector2.ZERO
|
||||
|
||||
treasure_island = null
|
||||
treasure_map_rendered = false
|
||||
|
||||
var rng = RandomNumberGenerator.new()
|
||||
rng.randomize()
|
||||
|
@ -226,6 +236,8 @@ func generate():
|
|||
num_islands = Islands.get_child_count()
|
||||
treasure_island = Islands.get_child(randi() % num_islands)
|
||||
|
||||
place_treasure()
|
||||
|
||||
render_treasure_map()
|
||||
|
||||
populate_ocean_nav_grid()
|
||||
|
|
Loading…
Reference in New Issue