Deleted ESCHotspot (use ESCItem instead)

Moved duplicated movement code from ESCPlayer and ESCItem/ESCHotspot to its own script.
Added talking animations management.
Fixed bug: character was turning to last_direction after talking, if coming from another direction than speaking direction.
Continued removing unfree stuff.
This commit is contained in:
Julian Murgia
2021-01-12 23:05:23 +01:00
parent 933122f085
commit ff56816205
73 changed files with 1211 additions and 1652 deletions

View File

@@ -1,8 +1,8 @@
extends RichTextLabel
signal dialog_line_finished
#signal dialog_line_started
#signal dialog_line_finished
export(String) var current_character
onready var tween = $Tween
onready var text_node = self
@@ -10,6 +10,10 @@ export(float, 0.0, 0.3) var text_speed_per_character = 0.1
export(float) var fast_text_speed_per_character = 0.25
export(float) var max_time_to_text_disappear = 2.0
# Current character speaking, to keep track of reference for animation purposes
var current_character
func _ready():
bbcode_enabled = true
$Tween.connect("tween_completed", self, "_on_dialog_line_typed")
@@ -29,15 +33,17 @@ func say(character : String, params : Dictionary) :
return
# Position the RichTextLabel on the character's dialog position, if any.
var character_node = escoria.esc_runner.get_object(character)
rect_position = character_node.get_node("dialog_position").get_global_transform_with_canvas().origin
current_character = escoria.esc_runner.get_object(character)
rect_position = current_character.get_node("dialog_position").get_global_transform_with_canvas().origin
rect_position.x -= rect_size.x / 2
current_character.start_talking()
# Set text color to color set in the actor
var text_color = character_node.dialog_color
var text_color = current_character.dialog_color
var text_color_html = text_color.to_html(false)
text_node.bbcode_text = "[center][color=#" + text_color_html + "]".format(text_color_html) + params["line"] + "[/color][center]"
text_node.bbcode_text = "[center][color=#" + text_color_html + "]".format([text_color_html]) + params["line"] + "[/color][center]"
text_node.percent_visible = 0.0
var time_show_full_text = text_speed_per_character * len(params["line"])
@@ -61,7 +67,7 @@ func _on_dialog_line_typed(object, key):
$Timer.connect("timeout", self, "_on_dialog_finished")
func _on_dialog_finished():
# emit_signal("dialog_line_finished")
current_character.stop_talking()
escoria.esc_level_runner.finished()
escoria.dialog_player.is_speaking = false
escoria.current_state = escoria.GAME_STATE.DEFAULT

View File

@@ -2,13 +2,14 @@
[ext_resource path="res://addons/escoria-core/game/core-scripts/escterrain.gd" type="Script" id=1]
[ext_resource path="res://addons/escoria-core/game/core-scripts/escbackground.gd" type="Script" id=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/eschotspot.gd" type="Script" id=3]
[ext_resource path="res://addons/escoria-core/game/core-scripts/escitem.gd" type="Script" id=3]
[ext_resource path="res://addons/escoria-core/game/core-scripts/escroom.gd" type="Script" id=4]
[sub_resource type="NavigationPolygon" id=1]
[node name="room" type="Node2D"]
script = ExtResource( 4 )
camera_limits = [ Rect2( 0, 0, 1289, 555 ) ]
[node name="ESCBackground" type="TextureRect" parent="."]
margin_right = 40.0
@@ -27,9 +28,9 @@ navpoly = SubResource( 1 )
[node name="Hotspots" type="Node2D" parent="."]
[node name="ESCHotspot" type="Area2D" parent="Hotspots"]
[node name="ESCItem" type="Area2D" parent="Hotspots"]
script = ExtResource( 3 )
dialog_color = Color( 1, 1, 1, 1 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/ESCHotspot"]
polygon = PoolVector2Array( 105, 65, 157, 47, 186, 118, 87, 134, 77, 87 )
interact_positions = {
"default": null
}