Enable unit selection and path visualization logic via Cursor interactions.
This commit is contained in:
@@ -23,24 +23,10 @@ var aStarGrid: AStarGrid2D:
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
# add_child(_MovingMarker)
|
||||
# _MovingMarker.hide()
|
||||
#
|
||||
# create unit at local position (50, 50) => eg mouse position
|
||||
_createUnit(GroundLayer.local_to_map(Vector2i(50, 50)))
|
||||
# create unit at map position (50, 50) => tile x = 50, y = 50 in the map
|
||||
_createUnit(GroundLayer.map_to_local(Vector2i(25,25)))
|
||||
|
||||
for unit in _Units:
|
||||
add_child(unit)
|
||||
|
||||
# $CameraController.position = get_viewport().get_camera_2d().get_screen_center_position()
|
||||
var firstUnit: Node2D = _Units[0]
|
||||
# if firstUnit.is_node_ready():
|
||||
# UnitCamera.target = _Units[0].get_path_to(get_parent())
|
||||
# UnitCamera.target_node = _Units[0]
|
||||
|
||||
$Player.setup($Map.getGrid())
|
||||
if $Player.is_node_ready():
|
||||
$Player.setup($Map.getGrid())
|
||||
$GameBoard/Cursor.moved.connect($Player.setTarget)
|
||||
$GameBoard/Cursor.accept_pressed.connect($Player.selectedUnit)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
@@ -57,6 +43,9 @@ func _input(event: InputEvent) -> void:
|
||||
# _MovingMarker.global_position = _getMousePosition(event).position
|
||||
_MovingMarker.position = GroundLayer.local_to_map(event.position)
|
||||
_MovingMarker.show()
|
||||
|
||||
func selectUnitAt(cell: Vector2i):
|
||||
pass
|
||||
|
||||
|
||||
func _getScreenCenter():
|
||||
|
||||
Reference in New Issue
Block a user