diff --git a/addons/escoria-core/game/core-scripts/behaviors/movable.gd b/addons/escoria-core/game/core-scripts/behaviors/movable.gd index c0890533..8f526f61 100644 --- a/addons/escoria-core/game/core-scripts/behaviors/movable.gd +++ b/addons/escoria-core/game/core-scripts/behaviors/movable.gd @@ -28,7 +28,6 @@ var pose_scale : int func _ready(): parent.add_user_signal("arrived") - last_scale = parent.scale func _process(time): if Engine.is_editor_hint(): @@ -122,11 +121,21 @@ func teleport(target, angle : Object = null) -> void: func walk_to(pos : Vector2, p_walk_context = null): if not parent.terrain: return walk_stop(parent.get_position()) - - if parent.interact_status == parent.INTERACT_STATES.INTERACT_WALKING: - return - if parent.interact_status == parent.INTERACT_STATES.INTERACT_STARTED: - parent.interact_status = parent.INTERACT_STATES.INTERACT_WALKING + + if parent.task == parent.PLAYER_TASKS.WALK: + if walk_context.has("target_object") and p_walk_context.has("target_object"): + if walk_context["target_object"] == p_walk_context["target_object"]: + walk_context["fast"] = p_walk_context["fast"] + return true + elif walk_context.has("target") and p_walk_context.has("target"): + if walk_context["target"] == p_walk_context["target"]: + walk_context["fast"] = p_walk_context["fast"] + return true + else: +# return false + pass + if parent.task == parent.PLAYER_TASKS.NONE: + parent.task = parent.PLAYER_TASKS.WALK walk_path = parent.terrain.get_terrain_path(parent.get_position(), pos) walk_context = p_walk_context if walk_path.size() == 0: @@ -152,7 +161,7 @@ func walk(target_pos, p_speed, context = null): # PRIVATE FUNCTION func walk_stop(pos): parent.position = pos - parent.interact_status = parent.INTERACT_STATES.INTERACT_NONE +# parent.interact_status = parent.INTERACT_STATES.INTERACT_NONE walk_path = [] if parent.orig_speed: diff --git a/addons/escoria-core/game/core-scripts/escitem.gd b/addons/escoria-core/game/core-scripts/escitem.gd index 82bbc72e..730b38c1 100644 --- a/addons/escoria-core/game/core-scripts/escitem.gd +++ b/addons/escoria-core/game/core-scripts/escitem.gd @@ -71,19 +71,8 @@ var terrain : ESCTerrain # If the terrain node type is scalenodes var terrain_is_scalenodes : bool var check_maps = true -var pose_scale : int -var last_scale : Vector2 var collision -# WALKING -# State machine defining the current interact state of the player -enum INTERACT_STATES { - INTERACT_STARTED, #  - INTERACT_NONE, # - INTERACT_WALKING # Player is walking -} -var interact_status # Current interact status, type INTERACT_STATES - export(int) var speed : int = 300 export(float) var v_speed_damp : float = 1.0 var orig_speed : float @@ -93,7 +82,7 @@ enum PLAYER_TASKS { WALK, SLIDE } -var task # type PLAYER_TASKS +onready var task = PLAYER_TASKS.NONE # type PLAYER_TASKS var params_queue : Array @@ -103,6 +92,7 @@ var size : Vector2 var last_deg : int var last_dir : int + func _ready(): assert(!global_id.empty()) @@ -143,7 +133,7 @@ func _ready(): connect("body_exited", self, "element_exited") if !is_exit: - last_scale = scale + Movable.last_scale = scale Movable.update_terrain() @@ -153,7 +143,7 @@ func get_animation_player(): if n is AnimationPlayer: animation_sprite = n return animation_sprite - + """ Initialize the interact_position attribute by searching for a Position2D @@ -180,7 +170,7 @@ func init_interact_position_with_node(): func manage_input(viewport : Viewport, event : InputEvent, shape_idx : int): if event is InputEventMouseButton: -# var p = get_global_mouse_position() + if event.doubleclick: if event.button_index == BUTTON_LEFT: emit_signal("mouse_double_left_clicked_item", global_id, event) @@ -188,7 +178,7 @@ func manage_input(viewport : Viewport, event : InputEvent, shape_idx : int): if event.is_pressed(): if event.button_index == BUTTON_LEFT: emit_signal("mouse_left_clicked_item", global_id, event) - if event.button_index == BUTTON_RIGHT: + elif event.button_index == BUTTON_RIGHT: emit_signal("mouse_right_clicked_item", global_id, event) diff --git a/addons/escoria-core/game/core-scripts/escplayer.gd b/addons/escoria-core/game/core-scripts/escplayer.gd index ccf42aaf..157c198f 100644 --- a/addons/escoria-core/game/core-scripts/escplayer.gd +++ b/addons/escoria-core/game/core-scripts/escplayer.gd @@ -33,15 +33,7 @@ enum PLAYER_TASKS { WALK, SLIDE } -var task # type PLAYER_TASKS - -# State machine defining the current interact state of the player -enum INTERACT_STATES { - INTERACT_STARTED, #  - INTERACT_NONE, # - INTERACT_WALKING # Player is walking -} -var interact_status # Current interact status, type INTERACT_STATES +onready var task = PLAYER_TASKS.NONE # type PLAYER_TASKS enum Directions { @@ -126,8 +118,9 @@ func _ready(): return terrain = escoria.room_terrain + Movable.last_scale = scale - set_process(true) +# set_process(true) func _process(time): @@ -164,7 +157,7 @@ func teleport(target, angle : Object = null) -> void: func walk_to(pos : Vector2, p_walk_context = null): - Movable.walk_to(pos, p_walk_context) + return Movable.walk_to(pos, p_walk_context) func set_angle(deg : int, immediate = true): diff --git a/addons/escoria-core/game/escoria.gd b/addons/escoria-core/game/escoria.gd index dfe9c503..a13d1a1a 100644 --- a/addons/escoria-core/game/escoria.gd +++ b/addons/escoria-core/game/escoria.gd @@ -134,7 +134,7 @@ func do(action : String, params : Array = []) -> void: var is_fast : bool = false if params.size() > 2 and params[2] == true: is_fast = true - var walk_context = {"fast": is_fast} + var walk_context = {"fast": is_fast, "target": target_position} moving_obj.walk_to(target_position, walk_context) # Walk to object from its id @@ -237,15 +237,24 @@ func ev_left_click_on_item(obj, event, default_action = false): destination_position = event.position dont_interact = true - main.current_scene.player.walk_to(destination_position, walk_context) + # Use esc_runner for this? + var is_already_walking = main.current_scene.player.walk_to(destination_position, walk_context) # Wait for the player to arrive before continuing with action. var context = yield(main.current_scene.player, "arrived") - if context.target_object != walk_context.target_object: - dont_interact = true + printt("context arrived: ", context) + if context.has("target_object") and walk_context.has("target_object"): + if (context.target_object.global_id != walk_context.target_object.global_id) \ + or (context.target_object.global_id == walk_context.target_object.global_id and is_already_walking): + dont_interact = true + elif context.has("target") and walk_context.has("target"): + if (context.target.global_id != walk_context.target.global_id) \ + or (context.target.global_id == walk_context.target.global_id and is_already_walking): + dont_interact = true # If no interaction should happen after player has arrived, leave immediately. if dont_interact: + print("DONT INTERACT WAS TRUE") return var player_global_pos = main.current_scene.player.global_position diff --git a/game/rooms/room7/room7.tscn b/game/rooms/room7/room7.tscn index 4d853db0..ac3ab23f 100644 --- a/game/rooms/room7/room7.tscn +++ b/game/rooms/room7/room7.tscn @@ -373,6 +373,10 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Line2D" type="Line2D" parent="Hotspots/trigger_left"] +points = PoolVector2Array( 718.237, 1756.04, 724.544, 1950.34, 815.761, 1947.51, 801.579, 1756.32, 719.359, 1756.32 ) +width = 2.0 + [node name="trigger_right" type="Area2D" parent="Hotspots"] position = Vector2( 220, 0 ) script = ExtResource( 7 ) @@ -402,6 +406,10 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Line2D" type="Line2D" parent="Hotspots/trigger_right"] +points = PoolVector2Array( 1089.37, 1757.17, 1097.85, 1949.99, 1187.37, 1947.87, 1174.21, 1755.79, 1090.78, 1756.18 ) +width = 2.0 + [node name="light_left" type="Area2D" parent="Hotspots"] position = Vector2( 412, 0 ) script = ExtResource( 7 ) diff --git a/game/rooms/room8/room8.tscn b/game/rooms/room8/room8.tscn index 7a2b0bec..88922deb 100644 --- a/game/rooms/room8/room8.tscn +++ b/game/rooms/room8/room8.tscn @@ -159,6 +159,7 @@ interact_positions = { } [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/m_door"] +visible = false polygon = PoolVector2Array( 557.522, 348.813, 551.222, 42.6524, 743.99, 43.9123, 750.289, 345.033 ) [node name="Position2D" type="Position2D" parent="Hotspots/m_door"] diff --git a/game/start_game.esc b/game/start_game.esc index 3016fcd7..2ca77478 100755 --- a/game/start_game.esc +++ b/game/start_game.esc @@ -16,11 +16,11 @@ #change_scene res://game/rooms/room5/room5.tscn # 6/ character room -#change_scene res://game/rooms/room6/room6.tscn +change_scene res://game/rooms/room6/room6.tscn # 7/ long room with camera shift to object 2 if look on object 1 # and stairs with camera shift too -change_scene res://game/rooms/room7/room7.tscn +#change_scene res://game/rooms/room7/room7.tscn # 8/ puzzle in superposed scene #change_scene res://game/rooms/room8/room8.tscn