Bob a des dialogues conditionels
This commit is contained in:
@@ -13,6 +13,9 @@ var humanInteractionTarget: Human = null
|
||||
@onready var state_machine := animation_tree.get("parameters/HumanState/playback") as AnimationNodeStateMachinePlayback
|
||||
@onready var interactionZone : InteractionZone = $"interaction zone"
|
||||
|
||||
var interactionClueFor : Human
|
||||
var interactionPaused= false
|
||||
|
||||
signal start_intracting
|
||||
|
||||
var last_facing_direction = Vector2(0,1) # facing south
|
||||
@@ -31,6 +34,11 @@ func face(whereToFace: Vector2) -> void:
|
||||
func decideAction() -> void:
|
||||
pass
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if interactionPaused and interactionClueFor:
|
||||
interactionPaused = false
|
||||
enable_interaction_clue(interactionClueFor)
|
||||
|
||||
func updateFacingDirectionInAnimationTree():
|
||||
animation_tree.set("parameters/HumanState/grabing/blend_position", last_facing_direction)
|
||||
animation_tree.set("parameters/HumanState/idling/blend_position", last_facing_direction)
|
||||
@@ -67,15 +75,24 @@ func _on_area_2d_body_entered(body: Node2D) -> void:
|
||||
|
||||
func start_interaction(askingForInteraction: Human):
|
||||
emit_signal("start_intracting", askingForInteraction)
|
||||
disable_interaction_clue()
|
||||
interactionPaused = true
|
||||
pause_or_stop_interaction_clue()
|
||||
|
||||
func stop_interaction():
|
||||
humanInteractionTarget = null
|
||||
|
||||
func get_feet_global_position():
|
||||
return global_position + Vector2(0, 43)
|
||||
|
||||
|
||||
func pause_or_stop_interaction_clue():
|
||||
if interactionZone:
|
||||
var mat = $Sprite2D.get("material") as ShaderMaterial
|
||||
if mat:
|
||||
mat.set_shader_parameter("line_thickness", 0)
|
||||
interactionZone.disable_interaction_clue()
|
||||
|
||||
func enable_interaction_clue(from: Human):
|
||||
interactionClueFor = from
|
||||
if interactionZone:
|
||||
var mat = $Sprite2D.get("material") as ShaderMaterial
|
||||
if mat:
|
||||
@@ -83,8 +100,6 @@ func enable_interaction_clue(from: Human):
|
||||
interactionZone.enable_interaction_clue(from)
|
||||
|
||||
func disable_interaction_clue():
|
||||
if interactionZone:
|
||||
var mat = $Sprite2D.get("material") as ShaderMaterial
|
||||
if mat:
|
||||
mat.set_shader_parameter("line_thickness", 0)
|
||||
interactionZone.disable_interaction_clue()
|
||||
interactionClueFor = null
|
||||
interactionPaused = false
|
||||
pause_or_stop_interaction_clue()
|
||||
|
||||
Reference in New Issue
Block a user