2022-08-25 15:33:44 +02:00
|
|
|
extends Spatial
|
|
|
|
|
2022-09-15 13:16:12 +02:00
|
|
|
onready var hexgrid = preload("res://addons/gdhexgrid/HexGrid.gd").new()
|
|
|
|
onready var HexTile3D = preload("res://scenes/HexTile3D.tscn")
|
|
|
|
onready var tiles = $Tiles
|
2022-08-25 17:06:26 +02:00
|
|
|
onready var fps_label = $CanvasLayer/HBoxContainer/FPSLabel
|
|
|
|
onready var player_pos_label = $CanvasLayer/HBoxContainer/PlayerPos
|
2022-08-25 23:40:19 +02:00
|
|
|
onready var tile_pos_label = $CanvasLayer/HBoxContainer/TilePos
|
2022-09-15 12:32:45 +02:00
|
|
|
onready var Island = preload("res://scenes/Island.gd")
|
2022-08-25 17:06:26 +02:00
|
|
|
onready var player = $Player
|
2022-09-15 12:32:45 +02:00
|
|
|
onready var world = $World
|
2022-08-25 17:06:26 +02:00
|
|
|
|
|
|
|
var player_velocity = Vector3.ZERO
|
2022-09-15 14:15:23 +02:00
|
|
|
var player_speed = 5
|
2022-08-25 17:06:26 +02:00
|
|
|
var target_coordinate = Vector3.ZERO
|
2022-11-20 20:13:42 +01:00
|
|
|
var is_first_process = true
|
2022-09-21 14:09:31 +02:00
|
|
|
|
2022-08-25 15:33:44 +02:00
|
|
|
func _ready():
|
2022-11-20 20:13:42 +01:00
|
|
|
print("_ready(): ", OS.get_ticks_msec())
|
2022-09-15 12:32:45 +02:00
|
|
|
for node in world.get_children():
|
|
|
|
if node is Island:
|
|
|
|
node.generate()
|
|
|
|
node.connect("island_tile_selected", self, "on_island_tile_selected")
|
|
|
|
node.connect("island_tile_hover", self, "on_island_tile_hover")
|
2022-08-25 17:06:26 +02:00
|
|
|
|
|
|
|
|
2022-10-08 14:14:20 +02:00
|
|
|
func _process(_delta):
|
2022-11-20 20:13:42 +01:00
|
|
|
if is_first_process:
|
|
|
|
print("_process(): ", OS.get_ticks_msec())
|
|
|
|
is_first_process = false
|
2022-08-25 17:06:26 +02:00
|
|
|
fps_label.text = "FPS: " + str(Performance.get_monitor(Performance.TIME_FPS))
|
|
|
|
player_pos_label.text = "Pos: " + str(player.transform.origin)
|
2022-10-07 16:14:05 +02:00
|
|
|
|
|
|
|
# query world what is happening on
|
2022-08-25 17:06:26 +02:00
|
|
|
|
|
|
|
|
2022-09-15 12:32:45 +02:00
|
|
|
func on_island_tile_selected(island, tile):
|
|
|
|
target_coordinate = tile.global_transform.origin
|
2022-09-21 14:09:31 +02:00
|
|
|
player.set_movable_target(tile.global_transform.origin)
|
2022-08-25 17:06:26 +02:00
|
|
|
var position_error = target_coordinate - player.transform.origin
|
2022-09-15 12:32:45 +02:00
|
|
|
print ("clicked on tile " + str(target_coordinate) + " error: " + str(position_error))
|
2022-08-25 17:06:26 +02:00
|
|
|
|
2022-08-25 23:40:19 +02:00
|
|
|
|
2022-10-08 14:14:20 +02:00
|
|
|
func on_island_tile_hover(_island, tile):
|
2022-09-15 12:32:45 +02:00
|
|
|
tile_pos_label.text = "TilePos: " + str(tile.global_transform.origin)
|