gai-godot-games/pathfinding-algorithms/scenes/mario-party/tile_indicator.gd

27 lines
778 B
GDScript
Raw Normal View History

2024-11-19 13:52:51 +01:00
extends Area2D
signal indicator_clicked()
var pos: Vector2 = Vector2()
var type: String = ""
func _input_event(viewport: Viewport, event: InputEvent, shape_idx: int) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
indicator_clicked.emit(pos, type)
func set_data(p: Vector2, t: String) -> void:
pos = p
type = t
func get_type() -> String:
return type
func set_display_type(t: String) -> void:
if t == "node":
$Sprite2D.texture = preload("res://scenes/mario-party/img/tile_node.png") as Texture
elif t == "player_movement":
$Sprite2D.texture = preload("res://scenes/mario-party/img/tile_highlight.png") as Texture
else:
push_error("Invalid type: %s" % t)