Interaction wheel
do interaction
This commit is contained in:
@@ -7,7 +7,7 @@ var last_direction = 0
|
||||
var interaction_location: Vector2i
|
||||
var _interaction_options: InteractionWheel
|
||||
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
@onready var sprite: AnimatedSprite2D = $Sprite
|
||||
@onready var interaction_timer: Timer = $InteractionTimer
|
||||
const INTERACTION_WHEEL = preload("res://scene/interaction_wheel.tscn")
|
||||
|
||||
@@ -19,15 +19,14 @@ func _physics_process(delta: float) -> void:
|
||||
if input_direction:
|
||||
if _interaction_options:
|
||||
_interaction_options.queue_free()
|
||||
_interaction_options = null
|
||||
animation_player.current_animation = "walk"
|
||||
animation_player.play()
|
||||
last_direction = input_direction.angle() + 3 * PI / 2
|
||||
_on_interation_options_closed()
|
||||
sprite.play("walk")
|
||||
last_direction = input_direction.angle() + PI / 2
|
||||
rotation = last_direction
|
||||
interaction_location = Grid.world_to_grid(position) + Vector2i(input_direction.round())
|
||||
Grid.set_selected_tile(interaction_location)
|
||||
else:
|
||||
animation_player.stop()
|
||||
sprite.stop()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("select") and not _interaction_options:
|
||||
@@ -35,10 +34,11 @@ func _input(event: InputEvent) -> void:
|
||||
if interactions.size() > 0:
|
||||
_interaction_options = INTERACTION_WHEEL.instantiate()
|
||||
_interaction_options.initialize(interaction_location, interactions)
|
||||
_interaction_options.closed.connect(_on_interation_options_closed)
|
||||
add_sibling(_interaction_options)
|
||||
|
||||
func _finished_interaction(results: Dictionary) -> void:
|
||||
print("interaction finished: %s" % results)
|
||||
func _on_interation_options_closed() -> void:
|
||||
_interaction_options = null
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event is InputEventMouseButton:
|
||||
|
||||
Reference in New Issue
Block a user