diff --git a/.import/8_way_sprite.png-554307c32b89d6eb23c7824829cc57c7.md5 b/.import/8_way_sprite.png-554307c32b89d6eb23c7824829cc57c7.md5 new file mode 100644 index 00000000..0b2d9a27 --- /dev/null +++ b/.import/8_way_sprite.png-554307c32b89d6eb23c7824829cc57c7.md5 @@ -0,0 +1,3 @@ +source_md5="775884bdfb6cd21d97cfad838c21e9bf" +dest_md5="b8102f3923312032218142342933c554" + diff --git a/.import/8_way_sprite.png-554307c32b89d6eb23c7824829cc57c7.stex b/.import/8_way_sprite.png-554307c32b89d6eb23c7824829cc57c7.stex new file mode 100644 index 00000000..9d14c0f0 Binary files /dev/null and b/.import/8_way_sprite.png-554307c32b89d6eb23c7824829cc57c7.stex differ diff --git a/.import/8_way_sprite.png-568812e1f2395752d16a96c6a8b85ab2.md5 b/.import/8_way_sprite.png-568812e1f2395752d16a96c6a8b85ab2.md5 new file mode 100644 index 00000000..0b2d9a27 --- /dev/null +++ b/.import/8_way_sprite.png-568812e1f2395752d16a96c6a8b85ab2.md5 @@ -0,0 +1,3 @@ +source_md5="775884bdfb6cd21d97cfad838c21e9bf" +dest_md5="b8102f3923312032218142342933c554" + diff --git a/.import/8_way_sprite.png-568812e1f2395752d16a96c6a8b85ab2.stex b/.import/8_way_sprite.png-568812e1f2395752d16a96c6a8b85ab2.stex new file mode 100644 index 00000000..9d14c0f0 Binary files /dev/null and b/.import/8_way_sprite.png-568812e1f2395752d16a96c6a8b85ab2.stex differ diff --git a/.import/8_way_sprite2.png-208869c14a08e9fa1067beb6f0fdb0d5.md5 b/.import/8_way_sprite2.png-208869c14a08e9fa1067beb6f0fdb0d5.md5 new file mode 100644 index 00000000..3c44c607 --- /dev/null +++ b/.import/8_way_sprite2.png-208869c14a08e9fa1067beb6f0fdb0d5.md5 @@ -0,0 +1,3 @@ +source_md5="a011714e553b5c8beb096dd703e70e04" +dest_md5="39bd434472a546b20bf160ae00fdab6f" + diff --git a/.import/8_way_sprite2.png-cfac9cc3a5414bcc272f0544c1fc73e3.md5 b/.import/8_way_sprite2.png-cfac9cc3a5414bcc272f0544c1fc73e3.md5 new file mode 100644 index 00000000..0b2d9a27 --- /dev/null +++ b/.import/8_way_sprite2.png-cfac9cc3a5414bcc272f0544c1fc73e3.md5 @@ -0,0 +1,3 @@ +source_md5="775884bdfb6cd21d97cfad838c21e9bf" +dest_md5="b8102f3923312032218142342933c554" + diff --git a/.import/8_way_sprite2.png-cfac9cc3a5414bcc272f0544c1fc73e3.stex b/.import/8_way_sprite2.png-cfac9cc3a5414bcc272f0544c1fc73e3.stex new file mode 100644 index 00000000..9d14c0f0 Binary files /dev/null and b/.import/8_way_sprite2.png-cfac9cc3a5414bcc272f0544c1fc73e3.stex differ diff --git a/.import/8_way_stand.png-b515f1b5bf6c623a8ad87a36d1232ab1.md5 b/.import/8_way_stand.png-b515f1b5bf6c623a8ad87a36d1232ab1.md5 new file mode 100644 index 00000000..4c0aa643 --- /dev/null +++ b/.import/8_way_stand.png-b515f1b5bf6c623a8ad87a36d1232ab1.md5 @@ -0,0 +1,3 @@ +source_md5="bcaaa988ed64c0174f02d3b1972db74d" +dest_md5="a887d7411163c6854ce75592f9e4c0e4" + diff --git a/.import/8_way_stand.png-b515f1b5bf6c623a8ad87a36d1232ab1.stex b/.import/8_way_stand.png-b515f1b5bf6c623a8ad87a36d1232ab1.stex new file mode 100644 index 00000000..6f740446 Binary files /dev/null and b/.import/8_way_stand.png-b515f1b5bf6c623a8ad87a36d1232ab1.stex differ diff --git a/.import/8_way_stand.png-bd624ae15a01b85e2dc1bdd162820a10.md5 b/.import/8_way_stand.png-bd624ae15a01b85e2dc1bdd162820a10.md5 new file mode 100644 index 00000000..4c0aa643 --- /dev/null +++ b/.import/8_way_stand.png-bd624ae15a01b85e2dc1bdd162820a10.md5 @@ -0,0 +1,3 @@ +source_md5="bcaaa988ed64c0174f02d3b1972db74d" +dest_md5="a887d7411163c6854ce75592f9e4c0e4" + diff --git a/.import/8_way_stand.png-bd624ae15a01b85e2dc1bdd162820a10.stex b/.import/8_way_stand.png-bd624ae15a01b85e2dc1bdd162820a10.stex new file mode 100644 index 00000000..6f740446 Binary files /dev/null and b/.import/8_way_stand.png-bd624ae15a01b85e2dc1bdd162820a10.stex differ diff --git a/.import/8_way_walk.png-1bdb405563d96a981227d9d82934482d.md5 b/.import/8_way_walk.png-1bdb405563d96a981227d9d82934482d.md5 new file mode 100644 index 00000000..a8693137 --- /dev/null +++ b/.import/8_way_walk.png-1bdb405563d96a981227d9d82934482d.md5 @@ -0,0 +1,3 @@ +source_md5="92d6832e31847a4bdde34770570c29e0" +dest_md5="f5faae0fbb55fa2cfe197f51e7357794" + diff --git a/.import/8_way_walk.png-1bdb405563d96a981227d9d82934482d.stex b/.import/8_way_walk.png-1bdb405563d96a981227d9d82934482d.stex new file mode 100644 index 00000000..7665a9d8 Binary files /dev/null and b/.import/8_way_walk.png-1bdb405563d96a981227d9d82934482d.stex differ diff --git a/.import/8_way_walk.png-ecdd71f288ccb9d3bbd77c0a124c4d5c.md5 b/.import/8_way_walk.png-ecdd71f288ccb9d3bbd77c0a124c4d5c.md5 new file mode 100644 index 00000000..05a9b4ec --- /dev/null +++ b/.import/8_way_walk.png-ecdd71f288ccb9d3bbd77c0a124c4d5c.md5 @@ -0,0 +1,3 @@ +source_md5="6dc49a667ea96b23d7150c05c0dbdc14" +dest_md5="b1a2c1b0d821a5bf36393622e6e4c030" + diff --git a/.import/8_way_walk.png-ecdd71f288ccb9d3bbd77c0a124c4d5c.stex b/.import/8_way_walk.png-ecdd71f288ccb9d3bbd77c0a124c4d5c.stex new file mode 100644 index 00000000..5c29f812 Binary files /dev/null and b/.import/8_way_walk.png-ecdd71f288ccb9d3bbd77c0a124c4d5c.stex differ diff --git a/.import/walk_template.png-29480f47ba9c811f125e3de60628819b.md5 b/.import/walk_template.png-29480f47ba9c811f125e3de60628819b.md5 new file mode 100644 index 00000000..a8693137 --- /dev/null +++ b/.import/walk_template.png-29480f47ba9c811f125e3de60628819b.md5 @@ -0,0 +1,3 @@ +source_md5="92d6832e31847a4bdde34770570c29e0" +dest_md5="f5faae0fbb55fa2cfe197f51e7357794" + diff --git a/.import/walk_template.png-29480f47ba9c811f125e3de60628819b.stex b/.import/walk_template.png-29480f47ba9c811f125e3de60628819b.stex new file mode 100644 index 00000000..7665a9d8 Binary files /dev/null and b/.import/walk_template.png-29480f47ba9c811f125e3de60628819b.stex differ diff --git a/addons/escoria-core/game/core-scripts/esc/esc_compiler.gd b/addons/escoria-core/game/core-scripts/esc/esc_compiler.gd index 521455cd..cf2d57ac 100644 --- a/addons/escoria-core/game/core-scripts/esc/esc_compiler.gd +++ b/addons/escoria-core/game/core-scripts/esc/esc_compiler.gd @@ -42,7 +42,7 @@ var commands = { "cut_scene": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL, TYPE_BOOL, TYPE_BOOL] }, "debug": { "min_args": 1 }, "dec_global": { "min_args": 2, "types": [TYPE_STRING, TYPE_INT] }, - "dialog_config": { "min_args": 3, "types": [TYPE_STRING, TYPE_BOOL, TYPE_BOOL] }, +# "dialog_config": { "min_args": 3, "types": [TYPE_STRING, TYPE_BOOL, TYPE_BOOL] }, "enable_terrain": { "min_args": 1, "types": [TYPE_STRING]}, "game_over": { "min_args": 1, "types": [TYPE_BOOL] }, "inc_global": { "min_args": 2, "types": [TYPE_STRING, TYPE_INT] }, diff --git a/addons/escoria-core/game/core-scripts/esc/esc_runner.gd b/addons/escoria-core/game/core-scripts/esc/esc_runner.gd index 3baf8401..852baa94 100644 --- a/addons/escoria-core/game/core-scripts/esc/esc_runner.gd +++ b/addons/escoria-core/game/core-scripts/esc/esc_runner.gd @@ -272,6 +272,13 @@ func set_global(name, val, force_change_reserved : bool = false): # printt("global changed at global_vm, emitting for ", name, val) emit_signal("global_changed", name) +func set_globals(pattern : String, val): + for key in globals: + if key.match(pattern): + set_global(key, val) +# globals[key] = val +# emit_signal("global_changed", key) + func dec_global(name, diff): var global = get_global(name) global = int(global) if global else 0 @@ -282,12 +289,6 @@ func inc_global(name, diff): global = int(global) if global else 0 set_global(name, str(global + diff)) -func set_globals(pat, val): - for key in globals: - if key.match(pat): - globals[key] = val - emit_signal("global_changed", key) - func is_global_equal_to(name, val): var global = get_global(name) if global and val and global == val: @@ -353,14 +354,27 @@ func change_scene(params, context, run_events=true): if !game_scene: escoria.report_errors("esc_runner.gd:change_scene()", ["Failed loading scene " + ProjectSettings.get_setting("escoria/ui/game_scene")]) - # Load room scene var room_scene = res_room.instance() if room_scene: room_scene.add_child(game_scene) room_scene.move_child(game_scene, 0) - escoria.main.set_scene(room_scene, run_events) + var events = escoria.main.set_scene(room_scene, run_events) + + # If scene was never visited, add "ready" event to the events stack + if !scenes_cache.has(room_scene.global_id) \ + and "ready" in events: + run_event(events["ready"]) + + # :setup is pretty much required in the code, but fortunately + # we can help out with cases where one isn't necessary otherwise + if not "setup" in events: + var fake_setup = escoria.esc_compiler.compile_str(":setup\n") + events["setup"] = fake_setup["setup"] + # Finally we add the setup on to of the events stack so that it is ran first + run_event(events["setup"]) + escoria.inputs_manager.is_hotspot_focused = false if !scenes_cache_list.has(params[0]): scenes_cache_list.push_back(params[0]) @@ -628,3 +642,17 @@ func object_exit_scene(name : String): printt("Object " + name + " removed from scene.") objects.erase(name) +#func jump(p_label): +# while stack.size() > 0: +# var top = stack[stack.size()-1] +# printt("top labels: ", top.labels, p_label) +# if p_label in top.labels: +# top.ip = top.labels[p_label] +# return +# else: +# if top.break_stop || stack.size() == 1: +# report_errors("", ["Label not found: "+p_label+", can't jump"]) +# stack.remove(stack.size()-1) +# break +# else: +# stack.remove(stack.size()-1) diff --git a/addons/escoria-core/game/core-scripts/esc/esc_runner_level.gd b/addons/escoria-core/game/core-scripts/esc/esc_runner_level.gd index d7916d3f..28b7b84b 100644 --- a/addons/escoria-core/game/core-scripts/esc/esc_runner_level.gd +++ b/addons/escoria-core/game/core-scripts/esc/esc_runner_level.gd @@ -5,14 +5,19 @@ extends Node var current_context onready var esc_runner = get_parent() + func _ready(): pass + func finished(context = null): if context != null: context.waiting = false else: current_context.waiting = false + + if escoria.current_state == escoria.GAME_STATE.WAIT: + escoria.current_state = escoria.GAME_STATE.DEFAULT func check_obj(name, cmd): @@ -22,6 +27,7 @@ func check_obj(name, cmd): return false return true + func resume(context): current_context = context if context.waiting: @@ -49,6 +55,7 @@ func resume(context): context.ip = 0 return esctypes.EVENT_LEVEL_STATE.RETURN + func run(context): var cmd = context.instructions[context.ip] if cmd.name == "label": @@ -70,25 +77,53 @@ func dialog_line_finished() -> void: escoria.dialog_player.is_speaking = false escoria.current_state = escoria.GAME_STATE.DEFAULT + """ +accept_input [ALL|NONE|SKIP] +What type of input does the game accept. ALL is the default, SKIP allows skipping +of dialog but nothing else, NONE denies all input. Including opening the menu etc. +SKIP and NONE also disable autosaves. Note that SKIP gets reset to ALL when the +event is done, but NONE persists. This allows you to create cut scenes with SKIP +where the dialog can be skipped, but also initiate locked-down cutscenes with +accept_input NONE in :setup and accept_input ALL later in :ready. """ -func accept_input(): +func accept_input(command_params : Array): +# var p_input = command_params[0] +# var input = escoria.esc_runner.acceptable_inputs["INPUT_" + p_input] +# escoria.esc_runner.set_accept_input(input) pass """ """ func autosave(): +# escoria.request_autosave() pass """ +anim object name [reverse] [flip_x] [flip_y] +Executes the animation specificed with the "name" parameter on the object, +without blocking. The next command in the event will be executed immediately after. +Optional parameters: + reverse plays the animation in reverse when true + flip_x flips the x axis of the object's sprites when true (object's root node needs to be Node2D) + flip_y flips the y axis of the object's sprites when true (object's root node needs to be Node2D) """ -func anim(): - pass +func anim(command_params : Array): + if !check_obj(command_params[0], "anim"): + return esctypes.EVENT_LEVEL_STATE.RETURN + private_play_animation(command_params) + return esctypes.EVENT_LEVEL_STATE.RETURN """ +Groups Commands can be grouped using the character ">" to start a group, and +incrementing the indentation of the commands that belong to the group. Example: + > + set_global door_open true + animation player pick_up + # end of group """ func branch(command_params : Array): var branch_ev = esctypes.ESCEvent.new("branch", command_params, []) @@ -96,65 +131,104 @@ func branch(command_params : Array): """ +camera_push target [time] [type] +Push camera to target. Target must have camera_pos set. +If it's of type Camera2D, its zoom will be used as well as position. +- A time value of 0 will set the camera immediately. +- type is any of the Tween.TransitionType values without the prefix, eg. LINEAR, + QUART or CIRC; defaults to QUART. """ -func camera_push(): - pass +func camera_push(command_params : Array): + var target = escoria.esc_runner.get_object(command_params[0]) + var time = command_params[1] if command_params.size() > 1 else 1 + var type = command_params[2] if command_params.size() > 2 else "QUAD" + escoria.main.current_scene.game.get_node("camera").push(target, time, type) """ +camera_set_drag_margin_enabled h v +- "h" and "v" are booleans for whether or not horizontal and vertical drag +margins are enabled. You will likely want to set them false for advanced camera +motions and true for regular gameplay and/or tracking NPCs. """ func camera_set_drag_margin_enabled(): pass """ +camera_set_pos speed x y +Moves the camera to a position defined by "x" and "y", at the speed defined by +"speed" in pixels per second. If speed is 0, camera is teleported to the position. """ func camera_set_pos(): pass """ +camera_set_target speed object [object2 object3 ...] +Configures the camera to follow 1 or more objects, using "speed" as speed limit. +This is the default behavior (default follow object is "player"). +If there's more than 1 object, the camera follows the average position of all +the objects specified. """ func camera_set_target(): pass """ +camera_set_zoom magnitude [time] +Zooms the camera in/out to the desired magnitude. Values larger than 1 zooms +the camera out, and smaller values zooms in, relative to the default value of 1. +An optional time in seconds controls how long it takes for the camera to zoom +into position. """ func camera_set_zoom(): pass """ +camera_set_zoom_height pixels [time] +Similar to the command abo/ve, but uses pixel height instead of magnitude to zoom. """ func camera_set_zoom_height(): pass """ +camera_shift x y [time] [type] +Shift camera by x and y pixels over time seconds. +- type is any of the Tween.TransitionType values without the prefix, eg. LINEAR, + QUART or CIRC; defaults to QUART. """ func camera_shift(): pass + """ +change_scene path [run_events] +Loads a new scene, specified by "path". +The run_events variable is a boolean (default true) which you never want to set +manually! It's there only to benefit save games, so they don't conflict with the +scene's events. """ -func change_scene(params): +func change_scene(command_params : Array): # Savegames must have events disabled, so saving the game adds a false to params var run_events = true - if params.size() == 2: - run_events = bool(params[1]) + if command_params.size() == 2: + run_events = bool(command_params[1]) # looking for localized string format in scene. this should be somewhere else - var sep = params[0].find(":\"") + var sep = command_params[0].find(":\"") if sep >= 0: - var path = params[0].substr(sep + 2, params[0].length() - (sep + 2)) + var path = command_params[0].substr(sep + 2, command_params[0].length() - (sep + 2)) escoria.esc_runner.call_deferred("change_scene", [path], current_context, run_events) else: - escoria.esc_runner.call_deferred("change_scene", params, current_context, run_events) + escoria.esc_runner.call_deferred("change_scene", command_params, current_context, run_events) current_context.waiting = true return esctypes.EVENT_LEVEL_STATE.YIELD + """ """ func custom(): @@ -162,30 +236,76 @@ func custom(): """ +cut_scene object name [reverse] [flip_x] [flip_y] +Executes the animation specificed with the "name" parameter on the object, BLOCKING. +The next command in the event will be executed when the animation is finished +playing. +Optional parameters: +- reverse plays the animation in reverse when true +- flip_x flips the x axis of the object's sprites when true + (object's root node needs to be Node2D) +- flip_y flips the y axis of the object's sprites when true + (object's root node needs to be Node2D) """ -func cut_scene(): - pass +func cut_scene(command_params : Array): + if !check_obj(command_params[0], "cut_scene"): + return esctypes.EVENT_LEVEL_STATE.RETURN + private_play_animation(command_params) + return esctypes.EVENT_LEVEL_STATE.YIELD """ +PRIVATE +Play animation using parameters. +Used by commands anim() and cut_scene() """ -func debug(): - pass +func private_play_animation(command_params : Array): + var obj = escoria.esc_runner.get_object(command_params[0]) + var anim_id = command_params[1] + var reverse = false + if command_params.size() > 2: + reverse = command_params[2] + var flip = Vector2(1, 1) + if command_params.size() > 3 && command_params[3]: + flip.x = -1 + if command_params.size() > 4 && command_params[4]: + flip.y = -1 + current_context.waiting = true + obj.play_anim(anim_id, current_context, reverse, flip) """ +debug string [string2 ...] + Takes 1 or more strings, prints them to the console. """ -func dec_global(): - pass +func debug(command_params : Array): + for p in command_params: + printt(p) + return esctypes.EVENT_LEVEL_STATE.RETURN """ +dec_global name value + Subtracts the value from global with given "name". + Value and global must both be integers. """ -func inc_global(): - pass +func dec_global(command_params : Array): + escoria.esc_runner.dec_global(command_params[0], command_params[1]) + return esctypes.EVENT_LEVEL_STATE.RETURN """ +inc_global name value + Adds the value to global with given "name". + Value and global must both be integers. +""" +func inc_global(command_params : Array): + escoria.esc_runner.inc_global(command_params[0], command_params[1]) + return esctypes.EVENT_LEVEL_STATE.RETURN + + +""" +Start a dialog choice. """ func dialog(command_params : Array): current_context.waiting = true @@ -198,13 +318,14 @@ func dialog(command_params : Array): return esctypes.EVENT_LEVEL_STATE.YIELD -""" -""" -func dialog_config(): - pass +#func dialog_config(): +## escoria.esc_runner.dialog_config(params) +## return esctypes.EVENT_LEVEL_STATE.RETURN +# pass """ +enable_terrain node_name Enable the ESCTerrain's NavigationPolygonInstance defined by given node name. Disables previously activated NavigationPolygonInstance. """ @@ -223,18 +344,25 @@ func game_over(command_params : Array): """ +Adds element in inventory. +Usage: inventory_add my_item +equivalent to: set_global i/my_item true """ func inventory_add(command_params : Array): - pass + set_global(["i/"+command_params[0], "true"]) """ +Removes element from inventory. +Usage: inventory_remove my_item +equivalent to: set_global i/my_item false """ func inventory_remove(command_params : Array): - pass + set_global(["i/"+command_params[0], "false"]) """ +TODO: This is dependant to the user UI. It must remain flexible enough. """ func inventory_open(command_params : Array): pass @@ -243,9 +371,10 @@ func inventory_open(command_params : Array): """ """ func jump(command_params : Array): +# escoria.esc_runner.jump(command_params[0]) +# return esctypes.EVENT_LEVEL_STATE.JUMP pass - """ """ func play_snd(command_params : Array): @@ -318,11 +447,11 @@ func set_active(command_params : Array): Set the angle of an object. Usage: set_angle object_id angle_degrees """ -func set_angle(params : Array): - if !check_obj(params[0], "set_angle"): +func set_angle(command_params : Array): + if !check_obj(command_params[0], "set_angle"): return esctypes.EVENT_LEVEL_STATE.RETURN - var obj = escoria.esc_runner.get_object(params[0]) - obj.set_angle(int(params[1])) + var obj = escoria.esc_runner.get_object(command_params[0]) + obj.set_angle(int(command_params[1])) return esctypes.EVENT_LEVEL_STATE.RETURN @@ -355,9 +484,16 @@ func set_global(command_params : Array): """ +set_globals pattern value +Changes the value of multiple globals using a wildcard pattern. +Example: + # clears the inventory + set_globals i/* false """ func set_globals(command_params : Array): - pass + var pattern : String = command_params[0] + var val = command_params[1] + escoria.esc_runner.set_globals(pattern, val) """ @@ -402,17 +538,18 @@ Teleports obj1 at obj2's position. If angle_degrees is set (int), sets obj1's angle to angle_degrees. Usage: teleport obj1 obj2 [angle_degrees] """ -func teleport(params): - if !check_obj(params[0], "teleport"): +func teleport(command_params : Array): + if !check_obj(command_params[0], "teleport"): return esctypes.EVENT_LEVEL_STATE.RETURN - if !check_obj(params[1], "teleport"): + if !check_obj(command_params[1], "teleport"): return esctypes.EVENT_LEVEL_STATE.RETURN var angle - if params.size() > 2: - angle = int(params[2]) + if command_params.size() > 2: + angle = int(command_params[2]) - escoria.esc_runner.get_object(params[0]).teleport(escoria.esc_runner.get_object(params[1]), angle) + escoria.esc_runner.get_object(command_params[0]) \ + .teleport(escoria.esc_runner.get_object(command_params[1]), angle) return esctypes.EVENT_LEVEL_STATE.RETURN diff --git a/addons/escoria-core/game/core-scripts/eschotspot.gd b/addons/escoria-core/game/core-scripts/eschotspot.gd index ce8ffd10..478a7cf5 100644 --- a/addons/escoria-core/game/core-scripts/eschotspot.gd +++ b/addons/escoria-core/game/core-scripts/eschotspot.gd @@ -116,6 +116,8 @@ func update_terrain(on_event_finished_name = null): return if on_event_finished_name != null and on_event_finished_name != "setup": return + if is_exit: + return var pos = position z_index = pos.y if pos.y <= VisualServer.CANVAS_ITEM_Z_MAX else VisualServer.CANVAS_ITEM_Z_MAX diff --git a/addons/escoria-core/game/core-scripts/escplayer.gd b/addons/escoria-core/game/core-scripts/escplayer.gd index ed83a03c..d1878750 100644 --- a/addons/escoria-core/game/core-scripts/escplayer.gd +++ b/addons/escoria-core/game/core-scripts/escplayer.gd @@ -126,10 +126,13 @@ func _ready(): terrain = escoria.room_terrain last_scale = scale + set_process(true) func _process(time): + if Engine.is_editor_hint(): + return $debug.text = str(z_index) if task == PLAYER_TASKS.WALK or task == PLAYER_TASKS.SLIDE: diff --git a/addons/escoria-core/game/inputs_manager.gd b/addons/escoria-core/game/inputs_manager.gd index 91bb984a..22da3a46 100644 --- a/addons/escoria-core/game/inputs_manager.gd +++ b/addons/escoria-core/game/inputs_manager.gd @@ -65,7 +65,7 @@ func _on_mouse_right_click_inventory_item(inventory_item_global_id, event : Inpu func _on_mouse_double_left_click_inventory_item(inventory_item_global_id, event : InputEvent) -> void: printt("Inventory item double left clicked ", inventory_item_global_id) - escoria.main.current_scene.game.double_left_click_on_inventory_item(inventory_item_global_id, event) + escoria.main.current_scene.game.left_double_click_on_inventory_item(inventory_item_global_id, event) func _on_mouse_entered_inventory_item(inventory_item_global_id) -> void: printt("Inventory item focused ", inventory_item_global_id) diff --git a/addons/escoria-core/game/main.gd b/addons/escoria-core/game/main.gd index 0837afc4..2cd9babc 100644 --- a/addons/escoria-core/game/main.gd +++ b/addons/escoria-core/game/main.gd @@ -21,36 +21,43 @@ func set_scene(p_scene, run_events=true): """ if !p_scene: escoria.report_errors("main", ["Trying to set empty scene"]) + + if current_scene != null: + clear_scene() + + get_node("/root").add_child(p_scene) # Ensure we don't have a regular event running when changing scenes if escoria.esc_runner.running_event: assert(escoria.esc_runner.running_event.ev_name == "load") + var events : Dictionary = {} if "esc_script" in p_scene and p_scene.esc_script and run_events: - var events = escoria.esc_compiler.load_esc_file(p_scene.esc_script) + events = escoria.esc_compiler.load_esc_file(p_scene.esc_script) - # :setup is pretty much required in the code, but fortunately - # we can help out with cases where one isn't necessary otherwise - if not "setup" in events: - var fake_setup = escoria.esc_compiler.compile_str(":setup\n") - events["setup"] = fake_setup["setup"] - - escoria.esc_runner.run_event(events["setup"]) +# # :setup is pretty much required in the code, but fortunately +# # we can help out with cases where one isn't necessary otherwise +# if not "setup" in events: +# var fake_setup = escoria.esc_compiler.compile_str(":setup\n") +# events["setup"] = fake_setup["setup"] +# +# escoria.esc_runner.run_event(events["setup"]) +# # We need to ensure that :setup event is finished before adding the next event. +# var setup_done = false +# while !setup_done: +# var event_name = yield(escoria.esc_runner, "event_done") +# if event_name == "setup": +# setup_done = true +# +# # If scene was never visited, run "ready" event +# if !escoria.esc_runner.scenes_cache.has(p_scene.global_id) \ +# and "ready" in events: +# escoria.esc_runner.run_event(events["ready"]) +# - # If scene was never visited, run "ready" event - if !escoria.esc_runner.scenes_cache.has(p_scene.global_id) \ - and "ready" in events: - escoria.esc_runner.run_event(events["ready"]) - - if current_scene != null: - clear_scene() - -# var game_scene = - - get_node("/root").add_child(p_scene) set_current_scene(p_scene, run_events) set_camera_limits() - + return events func set_current_scene(p_scene, run_events=true): current_scene = p_scene @@ -83,6 +90,7 @@ func set_current_scene(p_scene, run_events=true): escoria.esc_runner.register_object("_scene", p_scene, true) # Force overwrite of global + check_game_scene_methods() func clear_scene(): if current_scene == null: @@ -154,5 +162,36 @@ func set_camera_limits(): } printt("setting camera limits from parameter ", scene_camera_limits) - escoria.esc_runner.get_object("camera").set_limits(limits) - escoria.esc_runner.get_object("camera").set_offset(screen_ofs * 2) + current_scene.game.get_node("camera").set_limits(limits) + current_scene.game.get_node("camera").set_offset(screen_ofs * 2) + + +""" +The game.tscn scene's root node script MUST implement the following methods. +If they do not exist, stop immediately. Implement them, even if empty +""" +func check_game_scene_methods(): + assert(current_scene.game.has_method("left_click_on_bg")) + assert(current_scene.game.has_method("right_click_on_bg")) + assert(current_scene.game.has_method("left_double_click_on_bg")) + + assert(current_scene.game.has_method("element_focused")) + assert(current_scene.game.has_method("element_unfocused")) + + assert(current_scene.game.has_method("left_click_on_hotspot")) + assert(current_scene.game.has_method("right_click_on_hotspot")) + assert(current_scene.game.has_method("left_double_click_on_hotspot")) + + assert(current_scene.game.has_method("left_click_on_item")) + assert(current_scene.game.has_method("right_click_on_item")) + assert(current_scene.game.has_method("left_double_click_on_item")) + + assert(current_scene.game.has_method("open_inventory")) + assert(current_scene.game.has_method("close_inventory")) + + assert(current_scene.game.has_method("left_click_on_inventory_item")) + assert(current_scene.game.has_method("right_click_on_inventory_item")) + assert(current_scene.game.has_method("left_double_click_on_inventory_item")) + + assert(current_scene.game.has_method("inventory_item_focused")) + assert(current_scene.game.has_method("inventory_item_unfocused")) diff --git a/addons/escoria-core/game/scenes/camera_player/esccamera.gd b/addons/escoria-core/game/scenes/camera_player/esccamera.gd index 66997046..73157a6d 100644 --- a/addons/escoria-core/game/scenes/camera_player/esccamera.gd +++ b/addons/escoria-core/game/scenes/camera_player/esccamera.gd @@ -68,16 +68,18 @@ func set_target(p_target, p_speed : float = 0.0): if tween.is_active(): var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime()) - escoria.report_warnings("camera.gd:set_target()", ["Tween still active running camera_set_target: " + tweenstat]) + escoria.report_warnings("camera.gd:set_target()", + ["Tween still active running camera_set_target: " + tweenstat]) tween.emit_signal("tween_completed") - tween.interpolate_property(self, "global_position", self.global_position, target_pos, time, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) - + tween.interpolate_property(self, "global_position", self.global_position, + target_pos, time, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) tween.start() func set_camera_zoom(p_zoom_level, p_time): if p_zoom_level <= 0.0: - escoria.report_errors("camera.gd:set_camera_zoom()", ["Tried to set negative or zero zoom level"]) + escoria.report_errors("camera.gd:set_camera_zoom()", + ["Tried to set negative or zero zoom level"]) zoom_time = p_time zoom_target = Vector2(1, 1) * p_zoom_level @@ -87,13 +89,15 @@ func set_camera_zoom(p_zoom_level, p_time): else: if tween.is_active(): var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime()) - escoria.report_warnings("camera", ["Tween still active running camera_set_zoom: " + tweenstat]) + escoria.report_warnings("camera", + ["Tween still active running camera_set_zoom: " + tweenstat]) tween.emit_signal("tween_completed") - tween.interpolate_property(self, "zoom", self.zoom, zoom_target, zoom_time, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) - + tween.interpolate_property(self, "zoom", self.zoom, zoom_target, + zoom_time, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) tween.start() + func push(p_target, p_time, p_type): var time = float(p_time) var type = "TRANS_" + p_type @@ -116,16 +120,19 @@ func push(p_target, p_time, p_type): else: if tween.is_active(): var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime()) - escoria.report_warnings("camera", ["Tween still active running camera_push: " + tweenstat]) + escoria.report_warnings("camera", + ["Tween still active running camera_push: " + tweenstat]) tween.emit_signal("tween_completed") if camera_pos and camera_pos is Camera2D: - tween.interpolate_property(self, "zoom", self.zoom, camera_pos.zoom, time, tween.get(type), Tween.EASE_IN_OUT) - - tween.interpolate_property(self, "global_position", self.global_position, camera_pos_coords, time, tween.get(type), Tween.EASE_IN_OUT) + tween.interpolate_property(self, "zoom", self.zoom, camera_pos.zoom, + time, tween.get(type), Tween.EASE_IN_OUT) + tween.interpolate_property(self, "global_position", self.global_position, + camera_pos_coords, time, tween.get(type), Tween.EASE_IN_OUT) tween.start() + func shift(p_x, p_y, p_time, p_type): var x = int(p_x) var y = int(p_y) @@ -133,21 +140,23 @@ func shift(p_x, p_y, p_time, p_type): var type = "TRANS_" + p_type var new_pos = self.global_position + Vector2(x, y) - target = new_pos if tween.is_active(): var tweenstat = String(tween.tell()) + "/" + String(tween.get_runtime()) - escoria.report_warnings("camera", ["Tween still active running camera_shift: " + tweenstat]) + escoria.report_warnings("camera", + ["Tween still active running camera_shift: " + tweenstat]) tween.emit_signal("tween_completed") - tween.interpolate_property(self, "global_position", self.global_position, new_pos, time, tween.get(type), Tween.EASE_IN_OUT) - + tween.interpolate_property(self, "global_position", self.global_position, + new_pos, time, tween.get(type), Tween.EASE_IN_OUT) tween.start() + func target_reached(_obj=null, _key=null): tween.stop_all() + func _process(_delta): zoom_transform = self.get_canvas_transform() diff --git a/addons/escoria-core/game/scenes/inventory/inventory_ui.gd b/addons/escoria-core/game/scenes/inventory/inventory_ui.gd index 81122e2e..28a926d7 100644 --- a/addons/escoria-core/game/scenes/inventory/inventory_ui.gd +++ b/addons/escoria-core/game/scenes/inventory/inventory_ui.gd @@ -4,17 +4,19 @@ class_name ESCInventory func get_class(): return "ESCInventory" +""" +This script is set on the inventory UI scene's root node. +The scene MUST contain the 2 following nodes: + - one node named "ESCORIA_ALL_ITEMS" containing ALL ESCItems of the game. This is required + to be able to get the ESCInventoryItem for a given ESCItem. + - one Container node (under Control type) that will contain the inventory items. + It must be set in the "items_container" export variable. +""" + + # Define the actual container node to add items as children of. Should be a Container. export(NodePath) var items_container -onready var all_items = $all_items - -# Methods available for selecting an item -enum ITEM_SELECTION_METHODS { - VERB_ACTION, # Use a verb action, such as use or give, on inventory item - ONE_CLICK, # One click on inventory item selects it (eventually put it on cursor) - DRAG_N_DROP # (Useful for mobile) Drag n drop item on another or on background to use/give it -} -export(ITEM_SELECTION_METHODS) var selection_method +onready var all_items = $ESCORIA_ALL_ITEMS var items_ids_in_inventory : Dictionary = {} # { item_id : TextureButton} @@ -52,7 +54,6 @@ func add_new_item_by_id(item_id : String) -> void: escoria.esc_runner.register_object(item_id, item_inventory_button) item_inventory_button.visible = true - # connect this new item TextureButton's signals to our inventory UI item_inventory_button.connect("mouse_left_inventory_item", escoria.inputs_manager, "_on_mouse_left_click_inventory_item") item_inventory_button.connect("mouse_double_left_inventory_item", diff --git a/game/assets_sources/8_way_guy/8_way_stand.png b/game/assets_sources/8_way_guy/8_way_stand.png new file mode 100644 index 00000000..408c7bf1 Binary files /dev/null and b/game/assets_sources/8_way_guy/8_way_stand.png differ diff --git a/game/assets_sources/8_way_guy/8_way_stand.png.import b/game/assets_sources/8_way_guy/8_way_stand.png.import new file mode 100644 index 00000000..e986bf58 --- /dev/null +++ b/game/assets_sources/8_way_guy/8_way_stand.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/8_way_stand.png-bd624ae15a01b85e2dc1bdd162820a10.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://game/assets_sources/8_way_guy/8_way_stand.png" +dest_files=[ "res://.import/8_way_stand.png-bd624ae15a01b85e2dc1bdd162820a10.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/game/assets_sources/8_way_guy/8_way_walk.png b/game/assets_sources/8_way_guy/8_way_walk.png new file mode 100644 index 00000000..12fb0793 Binary files /dev/null and b/game/assets_sources/8_way_guy/8_way_walk.png differ diff --git a/game/assets_sources/8_way_guy/8_way_walk.png.import b/game/assets_sources/8_way_guy/8_way_walk.png.import new file mode 100644 index 00000000..3b21e14a --- /dev/null +++ b/game/assets_sources/8_way_guy/8_way_walk.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/8_way_walk.png-1bdb405563d96a981227d9d82934482d.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://game/assets_sources/8_way_guy/8_way_walk.png" +dest_files=[ "res://.import/8_way_walk.png-1bdb405563d96a981227d9d82934482d.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/game/assets_sources/8_way_guy/not_used/8_way_sprite.png b/game/assets_sources/8_way_guy/not_used/8_way_sprite.png new file mode 100644 index 00000000..6ece6f47 Binary files /dev/null and b/game/assets_sources/8_way_guy/not_used/8_way_sprite.png differ diff --git a/game/assets_sources/8_way_guy/not_used/8_way_sprite.png.import b/game/assets_sources/8_way_guy/not_used/8_way_sprite.png.import new file mode 100644 index 00000000..53947a9f --- /dev/null +++ b/game/assets_sources/8_way_guy/not_used/8_way_sprite.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/8_way_sprite.png-554307c32b89d6eb23c7824829cc57c7.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://game/assets_sources/8_way_guy/not_used/8_way_sprite.png" +dest_files=[ "res://.import/8_way_sprite.png-554307c32b89d6eb23c7824829cc57c7.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/game/characters/character/character.tscn b/game/characters/character/android.tscn similarity index 99% rename from game/characters/character/character.tscn rename to game/characters/character/android.tscn index 6a031661..bb488de9 100644 --- a/game/characters/character/character.tscn +++ b/game/characters/character/android.tscn @@ -94,9 +94,9 @@ animations = [ { "speed": 8.0 } ] -[node name="character" type="Area2D"] +[node name="android" type="Area2D"] script = ExtResource( 1 ) -global_id = "character" +global_id = "android" interaction_direction = 3 tooltip_name = "Character" default_action = "talk" diff --git a/game/characters/character2/8_way_walk.png b/game/characters/character2/8_way_walk.png new file mode 100644 index 00000000..c59fd9ee Binary files /dev/null and b/game/characters/character2/8_way_walk.png differ diff --git a/game/characters/character2/8_way_walk.png.import b/game/characters/character2/8_way_walk.png.import new file mode 100644 index 00000000..20d9ccee --- /dev/null +++ b/game/characters/character2/8_way_walk.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/8_way_walk.png-ecdd71f288ccb9d3bbd77c0a124c4d5c.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://game/characters/character2/8_way_walk.png" +dest_files=[ "res://.import/8_way_walk.png-ecdd71f288ccb9d3bbd77c0a124c4d5c.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/game/characters/character2/character.tscn b/game/characters/character2/character.tscn new file mode 100644 index 00000000..2d76f781 --- /dev/null +++ b/game/characters/character2/character.tscn @@ -0,0 +1,404 @@ +[gd_scene load_steps=78 format=2] + +[ext_resource path="res://addons/escoria-core/game/core-scripts/escplayer.gd" type="Script" id=1] +[ext_resource path="res://game/characters/character2/character_anims.gd" type="Script" id=2] +[ext_resource path="res://game/characters/character2/8_way_walk.png" type="Texture" id=3] + +[sub_resource type="AtlasTexture" id=1] +atlas = ExtResource( 3 ) +region = Rect2( 0, 220, 60, 110 ) + +[sub_resource type="AtlasTexture" id=2] +atlas = ExtResource( 3 ) +region = Rect2( 60, 220, 60, 110 ) + +[sub_resource type="AtlasTexture" id=3] +atlas = ExtResource( 3 ) +region = Rect2( 120, 220, 60, 110 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 3 ) +region = Rect2( 180, 220, 60, 110 ) + +[sub_resource type="AtlasTexture" id=5] +atlas = ExtResource( 3 ) +region = Rect2( 240, 220, 60, 110 ) + +[sub_resource type="AtlasTexture" id=6] +atlas = ExtResource( 3 ) +region = Rect2( 300, 220, 60, 110 ) + +[sub_resource type="AtlasTexture" id=7] +atlas = ExtResource( 3 ) +region = Rect2( 360, 220, 60, 110 ) + +[sub_resource type="AtlasTexture" id=8] +atlas = ExtResource( 3 ) +region = Rect2( 420, 220, 60, 110 ) + +[sub_resource type="AtlasTexture" id=9] +atlas = ExtResource( 3 ) +region = Rect2( 360, 0, 60, 110 ) + +[sub_resource type="AtlasTexture" id=10] +atlas = ExtResource( 3 ) +region = Rect2( 180, 0, 60, 110 ) + +[sub_resource type="AtlasTexture" id=11] +atlas = ExtResource( 3 ) +region = Rect2( 0, 660, 60, 110 ) + +[sub_resource type="AtlasTexture" id=12] +atlas = ExtResource( 3 ) +region = Rect2( 60, 660, 60, 110 ) + +[sub_resource type="AtlasTexture" id=13] +atlas = ExtResource( 3 ) +region = Rect2( 120, 660, 60, 110 ) + +[sub_resource type="AtlasTexture" id=14] +atlas = ExtResource( 3 ) +region = Rect2( 180, 660, 60, 110 ) + +[sub_resource type="AtlasTexture" id=15] +atlas = ExtResource( 3 ) +region = Rect2( 240, 660, 60, 110 ) + +[sub_resource type="AtlasTexture" id=16] +atlas = ExtResource( 3 ) +region = Rect2( 300, 660, 60, 110 ) + +[sub_resource type="AtlasTexture" id=17] +atlas = ExtResource( 3 ) +region = Rect2( 360, 660, 60, 110 ) + +[sub_resource type="AtlasTexture" id=18] +atlas = ExtResource( 3 ) +region = Rect2( 420, 660, 60, 110 ) + +[sub_resource type="AtlasTexture" id=19] +atlas = ExtResource( 3 ) +region = Rect2( 60, 0, 60, 110 ) + +[sub_resource type="AtlasTexture" id=20] +atlas = ExtResource( 3 ) +region = Rect2( 0, 110, 60, 110 ) + +[sub_resource type="AtlasTexture" id=21] +atlas = ExtResource( 3 ) +region = Rect2( 60, 110, 60, 110 ) + +[sub_resource type="AtlasTexture" id=22] +atlas = ExtResource( 3 ) +region = Rect2( 120, 110, 60, 110 ) + +[sub_resource type="AtlasTexture" id=23] +atlas = ExtResource( 3 ) +region = Rect2( 180, 110, 60, 110 ) + +[sub_resource type="AtlasTexture" id=24] +atlas = ExtResource( 3 ) +region = Rect2( 240, 110, 60, 110 ) + +[sub_resource type="AtlasTexture" id=25] +atlas = ExtResource( 3 ) +region = Rect2( 300, 110, 60, 110 ) + +[sub_resource type="AtlasTexture" id=26] +atlas = ExtResource( 3 ) +region = Rect2( 360, 110, 60, 110 ) + +[sub_resource type="AtlasTexture" id=27] +atlas = ExtResource( 3 ) +region = Rect2( 420, 110, 60, 110 ) + +[sub_resource type="AtlasTexture" id=28] +atlas = ExtResource( 3 ) +region = Rect2( 120, 0, 60, 110 ) + +[sub_resource type="AtlasTexture" id=29] +atlas = ExtResource( 3 ) +region = Rect2( 0, 440, 60, 110 ) + +[sub_resource type="AtlasTexture" id=30] +atlas = ExtResource( 3 ) +region = Rect2( 60, 440, 60, 110 ) + +[sub_resource type="AtlasTexture" id=31] +atlas = ExtResource( 3 ) +region = Rect2( 120, 440, 60, 110 ) + +[sub_resource type="AtlasTexture" id=32] +atlas = ExtResource( 3 ) +region = Rect2( 180, 440, 60, 110 ) + +[sub_resource type="AtlasTexture" id=33] +atlas = ExtResource( 3 ) +region = Rect2( 240, 440, 60, 110 ) + +[sub_resource type="AtlasTexture" id=34] +atlas = ExtResource( 3 ) +region = Rect2( 300, 440, 60, 110 ) + +[sub_resource type="AtlasTexture" id=35] +atlas = ExtResource( 3 ) +region = Rect2( 360, 440, 60, 110 ) + +[sub_resource type="AtlasTexture" id=36] +atlas = ExtResource( 3 ) +region = Rect2( 420, 440, 60, 110 ) + +[sub_resource type="AtlasTexture" id=37] +atlas = ExtResource( 3 ) +region = Rect2( 420, 0, 60, 110 ) + +[sub_resource type="AtlasTexture" id=38] +atlas = ExtResource( 3 ) +region = Rect2( 0, 880, 60, 110 ) + +[sub_resource type="AtlasTexture" id=39] +atlas = ExtResource( 3 ) +region = Rect2( 60, 880, 60, 110 ) + +[sub_resource type="AtlasTexture" id=40] +atlas = ExtResource( 3 ) +region = Rect2( 120, 880, 60, 110 ) + +[sub_resource type="AtlasTexture" id=41] +atlas = ExtResource( 3 ) +region = Rect2( 180, 880, 60, 110 ) + +[sub_resource type="AtlasTexture" id=42] +atlas = ExtResource( 3 ) +region = Rect2( 240, 880, 60, 110 ) + +[sub_resource type="AtlasTexture" id=43] +atlas = ExtResource( 3 ) +region = Rect2( 300, 880, 60, 110 ) + +[sub_resource type="AtlasTexture" id=44] +atlas = ExtResource( 3 ) +region = Rect2( 360, 880, 60, 110 ) + +[sub_resource type="AtlasTexture" id=45] +atlas = ExtResource( 3 ) +region = Rect2( 420, 880, 60, 110 ) + +[sub_resource type="AtlasTexture" id=46] +atlas = ExtResource( 3 ) +region = Rect2( 0, 550, 60, 110 ) + +[sub_resource type="AtlasTexture" id=47] +atlas = ExtResource( 3 ) +region = Rect2( 60, 550, 60, 110 ) + +[sub_resource type="AtlasTexture" id=48] +atlas = ExtResource( 3 ) +region = Rect2( 120, 550, 60, 110 ) + +[sub_resource type="AtlasTexture" id=49] +atlas = ExtResource( 3 ) +region = Rect2( 180, 550, 60, 110 ) + +[sub_resource type="AtlasTexture" id=50] +atlas = ExtResource( 3 ) +region = Rect2( 240, 550, 60, 110 ) + +[sub_resource type="AtlasTexture" id=51] +atlas = ExtResource( 3 ) +region = Rect2( 300, 550, 60, 110 ) + +[sub_resource type="AtlasTexture" id=52] +atlas = ExtResource( 3 ) +region = Rect2( 360, 550, 60, 110 ) + +[sub_resource type="AtlasTexture" id=53] +atlas = ExtResource( 3 ) +region = Rect2( 420, 550, 60, 110 ) + +[sub_resource type="AtlasTexture" id=54] +atlas = ExtResource( 3 ) +region = Rect2( 0, 0, 60, 110 ) + +[sub_resource type="AtlasTexture" id=55] +atlas = ExtResource( 3 ) +region = Rect2( 0, 770, 60, 110 ) + +[sub_resource type="AtlasTexture" id=56] +atlas = ExtResource( 3 ) +region = Rect2( 60, 770, 60, 110 ) + +[sub_resource type="AtlasTexture" id=57] +atlas = ExtResource( 3 ) +region = Rect2( 120, 770, 60, 110 ) + +[sub_resource type="AtlasTexture" id=58] +atlas = ExtResource( 3 ) +region = Rect2( 180, 770, 60, 110 ) + +[sub_resource type="AtlasTexture" id=59] +atlas = ExtResource( 3 ) +region = Rect2( 240, 770, 60, 110 ) + +[sub_resource type="AtlasTexture" id=60] +atlas = ExtResource( 3 ) +region = Rect2( 300, 770, 60, 110 ) + +[sub_resource type="AtlasTexture" id=61] +atlas = ExtResource( 3 ) +region = Rect2( 360, 770, 60, 110 ) + +[sub_resource type="AtlasTexture" id=62] +atlas = ExtResource( 3 ) +region = Rect2( 420, 770, 60, 110 ) + +[sub_resource type="AtlasTexture" id=63] +atlas = ExtResource( 3 ) +region = Rect2( 240, 0, 60, 110 ) + +[sub_resource type="AtlasTexture" id=64] +atlas = ExtResource( 3 ) +region = Rect2( 300, 0, 60, 110 ) + +[sub_resource type="AtlasTexture" id=65] +atlas = ExtResource( 3 ) +region = Rect2( 0, 330, 60, 110 ) + +[sub_resource type="AtlasTexture" id=66] +atlas = ExtResource( 3 ) +region = Rect2( 60, 330, 60, 110 ) + +[sub_resource type="AtlasTexture" id=67] +atlas = ExtResource( 3 ) +region = Rect2( 120, 330, 60, 110 ) + +[sub_resource type="AtlasTexture" id=68] +atlas = ExtResource( 3 ) +region = Rect2( 180, 330, 60, 110 ) + +[sub_resource type="AtlasTexture" id=69] +atlas = ExtResource( 3 ) +region = Rect2( 240, 330, 60, 110 ) + +[sub_resource type="AtlasTexture" id=70] +atlas = ExtResource( 3 ) +region = Rect2( 300, 330, 60, 110 ) + +[sub_resource type="AtlasTexture" id=71] +atlas = ExtResource( 3 ) +region = Rect2( 360, 330, 60, 110 ) + +[sub_resource type="AtlasTexture" id=72] +atlas = ExtResource( 3 ) +region = Rect2( 420, 330, 60, 110 ) + +[sub_resource type="SpriteFrames" id=73] +animations = [ { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ) ], +"loop": true, +"name": "walk_down", +"speed": 5.0 +}, { +"frames": [ SubResource( 9 ) ], +"loop": true, +"name": "idle_right", +"speed": 5.0 +}, { +"frames": [ SubResource( 10 ) ], +"loop": true, +"name": "idle_up_left", +"speed": 5.0 +}, { +"frames": [ SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ), SubResource( 17 ), SubResource( 18 ) ], +"loop": true, +"name": "walk_up_left", +"speed": 5.0 +}, { +"frames": [ SubResource( 19 ) ], +"loop": true, +"name": "idle_down_left", +"speed": 5.0 +}, { +"frames": [ SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 23 ), SubResource( 24 ), SubResource( 25 ), SubResource( 26 ), SubResource( 27 ) ], +"loop": true, +"name": "walk_down_left", +"speed": 5.0 +}, { +"frames": [ SubResource( 28 ) ], +"loop": true, +"name": "idle_left", +"speed": 5.0 +}, { +"frames": [ SubResource( 29 ), SubResource( 30 ), SubResource( 31 ), SubResource( 32 ), SubResource( 33 ), SubResource( 34 ), SubResource( 35 ), SubResource( 36 ) ], +"loop": true, +"name": "walk_left", +"speed": 8.0 +}, { +"frames": [ SubResource( 37 ) ], +"loop": true, +"name": "idle_down_right", +"speed": 5.0 +}, { +"frames": [ SubResource( 38 ), SubResource( 39 ), SubResource( 40 ), SubResource( 41 ), SubResource( 42 ), SubResource( 43 ), SubResource( 44 ), SubResource( 45 ) ], +"loop": true, +"name": "walk_up_right", +"speed": 5.0 +}, { +"frames": [ SubResource( 46 ), SubResource( 47 ), SubResource( 48 ), SubResource( 49 ), SubResource( 50 ), SubResource( 51 ), SubResource( 52 ), SubResource( 53 ) ], +"loop": true, +"name": "walk_right", +"speed": 5.0 +}, { +"frames": [ SubResource( 54 ) ], +"loop": true, +"name": "idle_down", +"speed": 5.0 +}, { +"frames": [ SubResource( 55 ), SubResource( 56 ), SubResource( 57 ), SubResource( 58 ), SubResource( 59 ), SubResource( 60 ), SubResource( 61 ), SubResource( 62 ) ], +"loop": true, +"name": "walk_up", +"speed": 5.0 +}, { +"frames": [ SubResource( 63 ) ], +"loop": true, +"name": "idle_up", +"speed": 5.0 +}, { +"frames": [ SubResource( 64 ) ], +"loop": true, +"name": "idle_up_right", +"speed": 5.0 +}, { +"frames": [ SubResource( 65 ), SubResource( 66 ), SubResource( 67 ), SubResource( 68 ), SubResource( 69 ), SubResource( 70 ), SubResource( 71 ), SubResource( 72 ) ], +"loop": true, +"name": "walk_down_right", +"speed": 5.0 +} ] + +[sub_resource type="CapsuleShape2D" id=74] +height = 0.0 + +[node name="character" type="KinematicBody2D"] +script = ExtResource( 1 ) +global_id = "player" +animations = ExtResource( 2 ) +dialog_color = Color( 1, 1, 1, 1 ) + +[node name="sprite" type="AnimatedSprite" parent="."] +position = Vector2( 0, -78.4786 ) +scale = Vector2( 2, 2 ) +frames = SubResource( 73 ) +animation = "idle_down_right" + +[node name="collision" type="CollisionShape2D" parent="."] +shape = SubResource( 74 ) + +[node name="debug" type="Label" parent="."] +margin_right = 40.0 +margin_bottom = 14.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="dialog_position" type="Position2D" parent="."] +position = Vector2( 0, -195.195 ) diff --git a/game/characters/character2/character_anims.gd b/game/characters/character2/character_anims.gd new file mode 100644 index 00000000..39801bcc --- /dev/null +++ b/game/characters/character2/character_anims.gd @@ -0,0 +1,90 @@ +#const dir_angles = [ +# 0, # 0 NORTH FACE CAMERA +# 45, # 1 NORTHEAST +# 90, # 2 EAST +# 135, # 3 SOUTHEAST +# 180, # 4 SOUTH BACK TO CAMERA +# 225, # 5 SOUTHWEST +# 270, # 6 WEST +# 315, # 7 NORTHWEST +#] + +# Angle is [from_angle, area_angle] +# example : on a clock, [180, 45] starts exactly from 6 o'clock (180°) +# and stops between 7 o'clock and 8 o'clock (45° from 6 o'clock) +const dir_angles = [ + [340, 40], # 0 UP + [20, 50], # 1 RIGHT UP + [70, 40], # 2 RIGHT + [110, 50], # 3 RIGHT DOWN + [160, 40], # 4 DOWN + [200, 50], # 5 LEFT DOWN + [250, 40], # 6 LEFT + [290, 50] # 7 LEFT UP +] + +# Array of animations for each direction, from UP to RIGHT_UP clockwise +# [animation_name, scale] : scale parameter can be set to -1 to mirror the animation +const directions = [ + ["walk_up", 1], # 0 UP + ["walk_up_right", 1], # 1 RIGHT UP + ["walk_right", 1], # 2 RIGHT + ["walk_down_right", 1], # 3 RIGHT DOWN + ["walk_down", 1], # 4 DOWN + ["walk_down_left", 1], # 5 LEFT DOWN + ["walk_left", 1], # 6 LEFT + ["walk_up_left", 1] # 7 LEFT UP +] + +const idles = [ + ["idle_up", 1], # 0 UP + ["idle_up_right", 1], # 1 RIGHT UP + ["idle_right", 1], # 2 RIGHT + ["idle_down_right", 1], # 3 RIGHT DOWN + ["idle_down", 1], # 4 DOWN + ["idle_down_left", 1], # 5 LEFT DOWN + ["idle_left", 1], # 6 LEFT + ["idle_up_left", 1] # 7 LEFT UP +] + +const speaks = [ + ["idle_up", 1], # 0 UP + ["idle_up_right", 1], # 1 RIGHT UP + ["idle_right", 1], # 2 RIGHT + ["idle_down_right", 1], # 3 RIGHT DOWN + ["idle_down", 1], # 4 DOWN + ["idle_down_left", 1], # 5 LEFT DOWN + ["idle_left", 1], # 6 LEFT + ["idle_up_left", 1] # 7 LEFT UP +] + + +#const directions = ["walk_left", -1, # 0 +# "walk_left", -1, # 1 +# "walk_back", 1, # 2 +# "walk_back", 1, # 3 +# "walk_left", 1, # 4 +# "walk_left", 1, # 5 +# "walk_front", 1, # 6 +# "walk_front", 1 # 7 +# ] +# +#const idles = [ "idle_front_right", 1, # 0 +# "idle_front_right", 1, # 1 +# "idle_back", 1, # 2 +# "idle_back", 1, # 3 +# "idle_front_left", 1, # 4 +# "idle_front_left", 1, # 5 +# "idle_front", 1, # 6 +# "idle_front", 1 # 7 +# ] +# +#const speaks = ["idle_front_left", 1, # 0 +# "idle_front_left", 1, # 1 +# "idle_back", 1, # 2 +# "idle_back", 1, # 3 +# "idle_front_right", 1, # 4 +# "idle_front_right", 1, # 5 +# "idle_front", 1, # 6 +# "idle_front", 1 # 7 +# ] diff --git a/game/characters/guybrush/guybrush.tscn b/game/characters/guybrush/guybrush.tscn index 2e84307a..2f30ca07 100644 --- a/game/characters/guybrush/guybrush.tscn +++ b/game/characters/guybrush/guybrush.tscn @@ -96,16 +96,26 @@ shader_param/col = Color( 0.611765, 0.215686, 0.0431373, 1 ) [sub_resource type="SpriteFrames" id=4] animations = [ { +"frames": [ ExtResource( 8 ) ], +"loop": true, +"name": "idle_back", +"speed": 5.0 +}, { +"frames": [ ExtResource( 10 ), ExtResource( 11 ), ExtResource( 12 ), ExtResource( 13 ), ExtResource( 14 ), ExtResource( 15 ), ExtResource( 16 ), ExtResource( 17 ), ExtResource( 18 ), ExtResource( 19 ), ExtResource( 20 ) ], +"loop": true, +"name": "walk_front", +"speed": 8.0 +}, { +"frames": [ ExtResource( 6 ) ], +"loop": true, +"name": "idle_front_right", +"speed": 5.0 +}, { "frames": [ ExtResource( 9 ) ], "loop": true, "name": "idle_back_right", "speed": 5.0 }, { -"frames": [ ExtResource( 45 ), ExtResource( 46 ), ExtResource( 47 ), ExtResource( 48 ), ExtResource( 49 ), ExtResource( 50 ), ExtResource( 51 ), ExtResource( 52 ), ExtResource( 53 ), ExtResource( 54 ), ExtResource( 55 ), ExtResource( 56 ) ], -"loop": true, -"name": "walk_back", -"speed": 8.0 -}, { "frames": [ ExtResource( 57 ), ExtResource( 58 ), ExtResource( 59 ), ExtResource( 60 ), ExtResource( 61 ), ExtResource( 62 ), ExtResource( 63 ), ExtResource( 64 ), ExtResource( 65 ), ExtResource( 66 ), ExtResource( 67 ), ExtResource( 68 ) ], "loop": true, "name": "walk_back_left", @@ -116,40 +126,30 @@ animations = [ { "name": "idle_front_left", "speed": 5.0 }, { -"frames": [ ExtResource( 8 ) ], +"frames": [ ExtResource( 33 ), ExtResource( 34 ), ExtResource( 35 ), ExtResource( 36 ), ExtResource( 37 ), ExtResource( 38 ), ExtResource( 39 ), ExtResource( 40 ), ExtResource( 41 ), ExtResource( 42 ), ExtResource( 43 ), ExtResource( 44 ) ], "loop": true, -"name": "idle_back", -"speed": 5.0 +"name": "walk_left", +"speed": 8.0 +}, { +"frames": [ ExtResource( 45 ), ExtResource( 46 ), ExtResource( 47 ), ExtResource( 48 ), ExtResource( 49 ), ExtResource( 50 ), ExtResource( 51 ), ExtResource( 52 ), ExtResource( 53 ), ExtResource( 54 ), ExtResource( 55 ), ExtResource( 56 ) ], +"loop": true, +"name": "walk_back", +"speed": 8.0 }, { "frames": [ ExtResource( 7 ) ], "loop": true, "name": "idle_back_left", "speed": 5.0 }, { -"frames": [ ExtResource( 5 ) ], -"loop": true, -"name": "idle_front", -"speed": 5.0 -}, { -"frames": [ ExtResource( 10 ), ExtResource( 11 ), ExtResource( 12 ), ExtResource( 13 ), ExtResource( 14 ), ExtResource( 15 ), ExtResource( 16 ), ExtResource( 17 ), ExtResource( 18 ), ExtResource( 19 ), ExtResource( 20 ) ], -"loop": true, -"name": "walk_front", -"speed": 8.0 -}, { "frames": [ ExtResource( 21 ), ExtResource( 22 ), ExtResource( 23 ), ExtResource( 24 ), ExtResource( 25 ), ExtResource( 26 ), ExtResource( 27 ), ExtResource( 28 ), ExtResource( 29 ), ExtResource( 30 ), ExtResource( 31 ), ExtResource( 32 ) ], "loop": true, "name": "walk_front_left", "speed": 8.0 }, { -"frames": [ ExtResource( 6 ) ], +"frames": [ ExtResource( 5 ) ], "loop": true, -"name": "idle_front_right", +"name": "idle_front", "speed": 5.0 -}, { -"frames": [ ExtResource( 33 ), ExtResource( 34 ), ExtResource( 35 ), ExtResource( 36 ), ExtResource( 37 ), ExtResource( 38 ), ExtResource( 39 ), ExtResource( 40 ), ExtResource( 41 ), ExtResource( 42 ), ExtResource( 43 ), ExtResource( 44 ) ], -"loop": true, -"name": "walk_left", -"speed": 8.0 } ] [sub_resource type="Animation" id=5] diff --git a/game/items/all_items.tscn b/game/items/ESCORIA_ALL_ITEMS.tscn similarity index 95% rename from game/items/all_items.tscn rename to game/items/ESCORIA_ALL_ITEMS.tscn index 91a018eb..59416988 100644 --- a/game/items/all_items.tscn +++ b/game/items/ESCORIA_ALL_ITEMS.tscn @@ -6,7 +6,7 @@ [ext_resource path="res://game/items/escitems/filled_sheet_escitem.tscn" type="PackedScene" id=4] [ext_resource path="res://addons/escoria-core/game/core-scripts/items_inventory.gd" type="Script" id=5] -[node name="all_items" type="Node2D"] +[node name="ESCORIA_ALL_ITEMS" type="Node2D"] visible = false script = ExtResource( 5 ) diff --git a/game/items/escitems/pen.esc b/game/items/escitems/pen.esc index 223913d4..80430f3f 100755 --- a/game/items/escitems/pen.esc +++ b/game/items/escitems/pen.esc @@ -8,6 +8,9 @@ set_active r5_pen false :use r5_empty_sheet say player "So, let's see..." -set_global i/r5_pen false -set_global i/r5_empty_sheet false -set_global i/r5_filled_sheet true +#set_global i/r5_pen false +inventory_remove r5_pen +#set_global i/r5_empty_sheet false +inventory_remove r5_empty_sheet +#set_global i/r5_filled_sheet true +inventory_add r5_filled_sheet diff --git a/game/rooms/room1/room1.tscn b/game/rooms/room1/room1.tscn index f17ead31..12ec0572 100644 --- a/game/rooms/room1/room1.tscn +++ b/game/rooms/room1/room1.tscn @@ -3,7 +3,7 @@ [ext_resource path="res://game/rooms/room1/walkable_area.tscn" type="PackedScene" id=1] [ext_resource path="res://game/rooms/room1/background.tscn" type="PackedScene" id=2] [ext_resource path="res://addons/escoria-core/game/core-scripts/eschotspot.gd" type="Script" id=3] -[ext_resource path="res://game/characters/guybrush/guybrush.tscn" type="PackedScene" id=4] +[ext_resource path="res://game/characters/character2/character.tscn" type="PackedScene" id=4] [ext_resource path="res://addons/escoria-core/game/core-scripts/escroom.gd" type="Script" id=6] [node name="room1" type="Node2D"] @@ -26,15 +26,6 @@ text = "Move : left click Fast move : double left click" [node name="walkable_area" parent="." instance=ExtResource( 1 )] -scales = null -bitmaps_scale = Vector2( 1, 1 ) -lightmap = null -player_speed_multiplier = 1.0 -player_doubleclick_speed_multiplier = 1.5 -lightmap_modulate = Color( 1, 1, 1, 1 ) -debug_mode = 1 -scale_min = 0.3 -scale_max = 1.0 [node name="Hotspots" type="Node2D" parent="."] @@ -45,6 +36,9 @@ is_exit = true esc_script = "res://game/rooms/room1/esc/right_exit.esc" tooltip_name = "Exit" dialog_color = Color( 1, 1, 1, 1 ) +interact_positions = { +"default": Vector2( 1225.47, 353.99 ) +} [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_door"] polygon = PoolVector2Array( 1177.94, 348.61, 1175.95, 45.3759, 1276.06, 92.0953, 1277.95, 399.407 ) @@ -58,6 +52,9 @@ global_id = "r1_item" esc_script = "res://game/rooms/room1/esc/wall_item.esc" tooltip_name = "Item on the wall" dialog_color = Color( 1, 1, 1, 1 ) +interact_positions = { +"default": Vector2( 671.798, 373.035 ) +} [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/item"] polygon = PoolVector2Array( 635.586, 253.345, 568.928, 60.1716, 709.047, 120.028, 699.524, 247.903 ) diff --git a/game/rooms/room2/room2.tscn b/game/rooms/room2/room2.tscn index 614f7baa..893f6f83 100644 --- a/game/rooms/room2/room2.tscn +++ b/game/rooms/room2/room2.tscn @@ -3,7 +3,7 @@ [ext_resource path="res://game/rooms/room2/walkable_area.tscn" type="PackedScene" id=1] [ext_resource path="res://game/rooms/room2/background.tscn" type="PackedScene" id=2] [ext_resource path="res://addons/escoria-core/game/core-scripts/eschotspot.gd" type="Script" id=3] -[ext_resource path="res://game/characters/guybrush/guybrush.tscn" type="PackedScene" id=4] +[ext_resource path="res://game/characters/character2/character.tscn" type="PackedScene" id=4] [ext_resource path="res://addons/escoria-core/game/core-scripts/escroom.gd" type="Script" id=6] [ext_resource path="res://addons/escoria-core/game/core-scripts/escitem.gd" type="Script" id=7] @@ -17,15 +17,6 @@ esc_script = "res://game/rooms/room2/esc/room2_bridge.esc" player_scene = ExtResource( 4 ) [node name="walkable_area" parent="." instance=ExtResource( 1 )] -scales = null -bitmaps_scale = Vector2( 1, 1 ) -lightmap = null -player_speed_multiplier = 1.0 -player_doubleclick_speed_multiplier = 1.5 -lightmap_modulate = Color( 1, 1, 1, 1 ) -debug_mode = 1 -scale_min = 0.3 -scale_max = 1.0 [node name="background" parent="." instance=ExtResource( 2 )] @@ -38,6 +29,9 @@ esc_script = "res://game/rooms/room2/esc/right_platform.esc" interaction_direction = 3 tooltip_name = "Right platform" dialog_color = Color( 1, 1, 1, 1 ) +interact_positions = { +"default": Vector2( 430.893, 451.052 ) +} [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_platform"] polygon = PoolVector2Array( 870.974, 538.342, 827.536, 353.995, 1181.4, 357.174, 1287.34, 413.325, 1289.46, 545.758 ) @@ -52,6 +46,9 @@ is_exit = true esc_script = "res://game/rooms/room2/esc/right_exit.esc" tooltip_name = "Exit" dialog_color = Color( 1, 1, 1, 1 ) +interact_positions = { +"default": Vector2( 1225.47, 353.99 ) +} [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_door"] polygon = PoolVector2Array( 1177.94, 348.61, 1175.95, 45.3759, 1276.06, 92.0953, 1277.95, 399.407 ) @@ -66,6 +63,9 @@ is_exit = true esc_script = "res://game/rooms/room2/esc/left_exit.esc" tooltip_name = "Exit" dialog_color = Color( 1, 1, 1, 1 ) +interact_positions = { +"default": Vector2( 52.1462, 384.691 ) +} [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/l_door"] polygon = PoolVector2Array( -1.37926, 443.158, 7.96461, 122.796, 84.0504, 77.4118, 88.055, 377.751 ) diff --git a/game/rooms/room3/room3.tscn b/game/rooms/room3/room3.tscn index 5ec40711..6209fadc 100644 --- a/game/rooms/room3/room3.tscn +++ b/game/rooms/room3/room3.tscn @@ -3,7 +3,7 @@ [ext_resource path="res://game/rooms/room3/walkable_area.tscn" type="PackedScene" id=1] [ext_resource path="res://game/rooms/room3/background.tscn" type="PackedScene" id=2] [ext_resource path="res://addons/escoria-core/game/core-scripts/eschotspot.gd" type="Script" id=3] -[ext_resource path="res://game/characters/guybrush/guybrush.tscn" type="PackedScene" id=4] +[ext_resource path="res://game/characters/character2/character.tscn" type="PackedScene" id=4] [ext_resource path="res://addons/escoria-core/game/core-scripts/escroom.gd" type="Script" id=6] [node name="room3" type="Node2D"] @@ -15,15 +15,6 @@ player_scene = ExtResource( 4 ) [node name="background" parent="." instance=ExtResource( 2 )] [node name="walkable_area" parent="." instance=ExtResource( 1 )] -scales = null -bitmaps_scale = Vector2( 1, 1 ) -lightmap = null -player_speed_multiplier = 1.0 -player_doubleclick_speed_multiplier = 1.5 -lightmap_modulate = Color( 1, 1, 1, 1 ) -debug_mode = 1 -scale_min = 0.3 -scale_max = 1.0 [node name="Hotspots" type="Node2D" parent="."] @@ -36,6 +27,9 @@ global_id = "r3_right_platform" esc_script = "res://game/rooms/room3/esc/right_platform.esc" tooltip_name = "Right platform" dialog_color = Color( 1, 1, 1, 1 ) +interact_positions = { +"default": Vector2( 430.893, 451.052 ) +} [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_platform"] polygon = PoolVector2Array( 870.974, 538.342, 827.536, 353.995, 1181.4, 357.174, 1287.34, 413.325, 1289.46, 545.758 ) @@ -56,6 +50,9 @@ is_exit = true esc_script = "res://game/rooms/room3/esc/right_exit.esc" tooltip_name = "Exit" dialog_color = Color( 1, 1, 1, 1 ) +interact_positions = { +"default": Vector2( 1225.47, 353.99 ) +} [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_door"] polygon = PoolVector2Array( 1177.94, 348.61, 1175.95, 45.3759, 1276.06, 92.0953, 1277.95, 399.407 ) @@ -70,6 +67,9 @@ is_exit = true esc_script = "res://game/rooms/room3/esc/left_exit.esc" tooltip_name = "Exit" dialog_color = Color( 1, 1, 1, 1 ) +interact_positions = { +"default": Vector2( 44.1375, 384.691 ) +} [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/l_door"] polygon = PoolVector2Array( -2.71457, 437.818, 6.6293, 121.462, 89.3893, 74.7422, 88.0545, 376.416 ) diff --git a/game/rooms/room4/room4.tscn b/game/rooms/room4/room4.tscn index 315663ea..d8ed600b 100644 --- a/game/rooms/room4/room4.tscn +++ b/game/rooms/room4/room4.tscn @@ -9,9 +9,9 @@ [ext_resource path="res://game/rooms/room4/assets/depth_reduced.png" type="Texture" id=8] [sub_resource type="NavigationPolygon" id=1] -vertices = PoolVector2Array( 1564.36, 574.459, 1576.02, 540.556, 1634.29, 568.102, 1624.42, 800.399, 1536.87, 579.274, 1012.68, 786.929, 1197.79, 675.666, 908.294, 488.354, 996.968, 451.313, 600.739, 456.925, 673.699, 490.599, 371.757, 688.152, 542.371, 788.052, 2.46706, 794.786, 11.4468, 698.255, 189.918, 682.54, 127.06, 573.661, 23.7938, 614.07, 42.8757, 527.64, 125.938, 536.62 ) -polygons = [ PoolIntArray( 0, 1, 2, 3 ), PoolIntArray( 4, 0, 3, 5, 6 ), PoolIntArray( 6, 5, 7, 8 ), PoolIntArray( 9, 8, 7, 10 ), PoolIntArray( 11, 12, 13, 14, 15 ), PoolIntArray( 9, 10, 12, 11 ), PoolIntArray( 16, 15, 14, 17, 18 ), PoolIntArray( 16, 18, 19 ) ] -outlines = [ PoolVector2Array( 11.4468, 698.255, 23.7938, 614.07, 42.8757, 527.64, 125.938, 536.62, 127.06, 573.661, 189.918, 682.54, 371.757, 688.152, 600.739, 456.925, 996.968, 451.313, 1197.79, 675.666, 1536.87, 579.274, 1564.36, 574.459, 1576.02, 540.556, 1634.29, 568.102, 1624.42, 800.399, 1012.68, 786.929, 908.294, 488.354, 673.699, 490.599, 542.371, 788.052, 2.46706, 794.786 ) ] +vertices = PoolVector2Array( 371.757, 688.152, 542.371, 788.052, 2.46706, 794.786, 11.4468, 698.255, 189.918, 682.54, 1564.36, 574.459, 1578.66, 529.011, 1635.23, 551.638, 1624.42, 800.399, 1536.87, 579.274, 1012.68, 786.929, 1197.79, 675.666, 908.294, 488.354, 996.968, 451.313, 600.739, 456.925, 673.699, 490.599, 127.06, 573.661, 23.7938, 614.07, 42.8757, 527.64, 125.717, 528.797 ) +polygons = [ PoolIntArray( 0, 1, 2, 3, 4 ), PoolIntArray( 5, 6, 7, 8 ), PoolIntArray( 9, 5, 8, 10, 11 ), PoolIntArray( 11, 10, 12, 13 ), PoolIntArray( 14, 13, 12, 15 ), PoolIntArray( 14, 15, 1, 0 ), PoolIntArray( 16, 4, 3, 17, 18 ), PoolIntArray( 16, 18, 19 ) ] +outlines = [ PoolVector2Array( 11.4468, 698.255, 23.7938, 614.07, 42.8757, 527.64, 125.717, 528.797, 127.06, 573.661, 189.918, 682.54, 371.757, 688.152, 600.739, 456.925, 996.968, 451.313, 1197.79, 675.666, 1536.87, 579.274, 1564.36, 574.459, 1578.66, 529.011, 1635.23, 551.638, 1624.42, 800.399, 1012.68, 786.929, 908.294, 488.354, 673.699, 490.599, 542.371, 788.052, 2.46706, 794.786 ) ] [node name="room4" type="Node2D"] script = ExtResource( 6 ) @@ -20,15 +20,13 @@ esc_script = "res://game/rooms/room4/esc/room4.esc" player_scene = ExtResource( 4 ) [node name="background" type="TextureRect" parent="."] -margin_left = 0.943848 -margin_right = 2398.94 +margin_right = 1663.0 margin_bottom = 549.0 mouse_filter = 2 script = ExtResource( 2 ) __meta__ = { "_edit_use_anchors_": false } -esc_script = "" [node name="Sprite" type="Sprite" parent="background"] scale = Vector2( 0.692794, 0.692794 ) @@ -52,14 +50,9 @@ points = PoolVector2Array( 6.10242, 307.886, 2.0979, 129.017, 84.858, 129.017, 8 [node name="walkable_area" type="Navigation2D" parent="."] script = ExtResource( 1 ) scales = ExtResource( 8 ) -bitmaps_scale = Vector2( 1, 1 ) -lightmap = null -player_speed_multiplier = 1.0 player_doubleclick_speed_multiplier = 1.8 -lightmap_modulate = Color( 1, 1, 1, 1 ) debug_mode = 0 scale_min = 0.4 -scale_max = 1.0 [node name="platform" type="NavigationPolygonInstance" parent="walkable_area"] visible = false @@ -73,24 +66,6 @@ __meta__ = { position = Vector2( 697.275, 203.998 ) [node name="Hotspots" type="Node2D" parent="."] -position = Vector2( 0.943848, 0 ) - -[node name="r_door" type="Area2D" parent="Hotspots"] -script = ExtResource( 3 ) -global_id = "r_exit" -is_exit = true -esc_script = "res://game/rooms/room4/esc/right_exit.esc" -tooltip_name = "Exit" -dialog_color = Color( 1, 1, 1, 1 ) -interact_positions = { -"default": Vector2( 84.5736, 279.703 ) -} - -[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_door"] -polygon = PoolVector2Array( 1567.92, 294.848, 1573.21, 92.4902, 1651.61, 127.452, 1654.79, 343.583 ) - -[node name="Position2D" type="Position2D" parent="Hotspots/r_door"] -position = Vector2( 1611.46, 301.017 ) [node name="l_door" type="Area2D" parent="Hotspots"] script = ExtResource( 3 ) @@ -104,7 +79,24 @@ interact_positions = { } [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/l_door"] -polygon = PoolVector2Array( 26.3979, 288.491, 27.4573, 70.2414, 147.177, 74.4792, 151.415, 293.788 ) +polygon = PoolVector2Array( 29.1046, 292.156, 31.0151, 76.8949, 147.177, 74.4792, 151.415, 293.788 ) [node name="Position2D" type="Position2D" parent="Hotspots/l_door"] position = Vector2( 83.6298, 279.703 ) + +[node name="r_door" type="Area2D" parent="Hotspots"] +script = ExtResource( 3 ) +global_id = "r_exit" +is_exit = true +esc_script = "res://game/rooms/room4/esc/right_exit.esc" +tooltip_name = "Exit" +dialog_color = Color( 1, 1, 1, 1 ) +interact_positions = { +"default": Vector2( 1612.4, 301.017 ) +} + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_door"] +polygon = PoolVector2Array( 1567.92, 294.848, 1573.21, 92.4902, 1657.34, 129.485, 1654.79, 343.583 ) + +[node name="Position2D" type="Position2D" parent="Hotspots/r_door"] +position = Vector2( 1611.46, 301.017 ) diff --git a/game/rooms/room5/room5.tscn b/game/rooms/room5/room5.tscn index 342af35f..5da8b09b 100644 --- a/game/rooms/room5/room5.tscn +++ b/game/rooms/room5/room5.tscn @@ -3,7 +3,7 @@ [ext_resource path="res://addons/escoria-core/game/core-scripts/escterrain.gd" type="Script" id=1] [ext_resource path="res://game/rooms/room5/background.tscn" type="PackedScene" id=2] [ext_resource path="res://addons/escoria-core/game/core-scripts/eschotspot.gd" type="Script" id=3] -[ext_resource path="res://game/characters/guybrush/guybrush.tscn" type="PackedScene" id=4] +[ext_resource path="res://game/characters/character2/character.tscn" type="PackedScene" id=4] [ext_resource path="res://addons/escoria-core/game/core-scripts/escroom.gd" type="Script" id=6] [ext_resource path="res://addons/escoria-core/game/core-scripts/escitem.gd" type="Script" id=7] [ext_resource path="res://game/items/escitems/wrench_escitem.tscn" type="PackedScene" id=8] diff --git a/game/rooms/room6/esc/character.esc b/game/rooms/room6/esc/android.esc similarity index 54% rename from game/rooms/room6/esc/character.esc rename to game/rooms/room6/esc/android.esc index e101525d..faf0ea4c 100755 --- a/game/rooms/room6/esc/character.esc +++ b/game/rooms/room6/esc/android.esc @@ -7,32 +7,32 @@ say player "I don't think he'd like that." :talk > [!talked_once] say player "Uhm..." - say character "Yeah?" + say android "Yeah?" set_global talked_once true ? option1 1000 option2 true - "What are you doing here?" say player "What are you doing here?" - say character "I'm working! Can't you see that?" - say character "My colleague is supposed to bring me an important report. And he's not coming!" + say android "I'm working! Can't you see that?" + say android "My colleague is supposed to bring me an important report. And he's not coming!" ? - "I'll bring you this report!" say player "I'll bring you this report!" - say character "You will? Great!" - say character "Now please hurry up so I can leave and have lunch." + say android "You will? Great!" + say android "Now please hurry up so I can leave and have lunch." stop - "I've got better things to do." say player "I've got better things to do." - say character "Eh! I'm not asking you anythin'!" + say android "Eh! I'm not asking you anythin'!" stop - "I'm selling these fine leather jackets." say player "I'm selling these fine leather jackets." - say character "Go away, kid." + say android "Go away, kid." stop :give filled_sheet -say character "Hey! That's perfect!" -say character "I can finally got away from here!" -walk character 1200,400 -set_angle character 45 +say android "Hey! That's perfect!" +say android "I can finally got away from here!" +walk android 1200,400 +set_angle android 45 diff --git a/game/rooms/room6/room6.tscn b/game/rooms/room6/room6.tscn index dde36c9f..d886a83f 100644 --- a/game/rooms/room6/room6.tscn +++ b/game/rooms/room6/room6.tscn @@ -6,7 +6,7 @@ [ext_resource path="res://game/characters/guybrush/guybrush.tscn" type="PackedScene" id=4] [ext_resource path="res://addons/escoria-core/game/core-scripts/escitem.gd" type="Script" id=5] [ext_resource path="res://addons/escoria-core/game/core-scripts/escroom.gd" type="Script" id=6] -[ext_resource path="res://game/characters/character/character.tscn" type="PackedScene" id=7] +[ext_resource path="res://game/characters/character/android.tscn" type="PackedScene" id=7] [sub_resource type="NavigationPolygon" id=1] vertices = PoolVector2Array( 1168.92, 640.557, 1182.53, 588.863, 1269.59, 622.872, 1275.03, 799.721, 129.634, 615.792, 1143.08, 613.35, -9.16094, 803.802, 84.5821, 654.06, -6.44019, 711.297, 3.15687, 646.051, 59.2201, 628.698 ) @@ -170,15 +170,15 @@ position = Vector2( 1180.52, 395.193 ) [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_door/Area2D"] polygon = PoolVector2Array( 1169.35, 41.7644, 1168.09, 347.925, 1275.18, 407.141, 1278.96, 88.3814 ) -[node name="character" parent="Hotspots" instance=ExtResource( 7 )] +[node name="android" parent="Hotspots" instance=ExtResource( 7 )] position = Vector2( 373.401, 415.66 ) scale = Vector2( -1, 1 ) -esc_script = "res://game/rooms/room6/esc/character.esc" +esc_script = "res://game/rooms/room6/esc/android.esc" interact_positions = { -"default": Vector2( 595.637, 438.337 ) +"default": Vector2( 151.165, 438.337 ) } -[node name="Position2D" type="Position2D" parent="Hotspots/character"] +[node name="Position2D" type="Position2D" parent="Hotspots/android"] position = Vector2( 222.236, 22.6772 ) [node name="player_start" type="Position2D" parent="."] diff --git a/game/rooms/room7/esc/room7.esc b/game/rooms/room7/esc/room7.esc index 7caa451a..250b5ed8 100755 --- a/game/rooms/room7/esc/room7.esc +++ b/game/rooms/room7/esc/room7.esc @@ -1,6 +1,6 @@ :setup -> [eq ESC_LAST_SCENE room5] - teleport player r6_l_exit +> [eq ESC_LAST_SCENE room6] + teleport player r7_l_exit # Set player look right set_angle player 180 stop @@ -9,8 +9,15 @@ stop :ready -#set_global i/r5_pen true -#set_active r5_pen false -#set_global i/r5_empty_sheet true -#set_active r5_empty_sheet false + +camera_push r7_object2 1 LINEAR +wait 3 +camera_push player 1 LINEAR + +#camera_set_drag_margin_enabled bool bool +#camera_set_pos real int int +#camera_set_target real +#camera_set_zoom real +#camera_set_zoom_height int +#camera_shift int int diff --git a/game/rooms/room7/room7.tscn b/game/rooms/room7/room7.tscn index 813f9b32..be802ddf 100644 --- a/game/rooms/room7/room7.tscn +++ b/game/rooms/room7/room7.tscn @@ -1,10 +1,9 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://addons/escoria-core/game/core-scripts/escterrain.gd" type="Script" id=1] [ext_resource path="res://game/rooms/room7/background.tscn" type="PackedScene" id=2] [ext_resource path="res://addons/escoria-core/game/core-scripts/eschotspot.gd" type="Script" id=3] [ext_resource path="res://game/characters/guybrush/guybrush.tscn" type="PackedScene" id=4] -[ext_resource path="res://addons/escoria-core/game/core-scripts/escitem.gd" type="Script" id=5] [ext_resource path="res://addons/escoria-core/game/core-scripts/escroom.gd" type="Script" id=6] [sub_resource type="NavigationPolygon" id=1] @@ -12,85 +11,6 @@ vertices = PoolVector2Array( 1976.63, 640.557, 1987.95, 588.863, 2070.07, 622.87 polygons = [ PoolIntArray( 0, 1, 2, 3 ), PoolIntArray( 4, 5, 0, 3, 6, 7 ), PoolIntArray( 7, 6, 8, 9, 10 ) ] outlines = [ PoolVector2Array( -6.44019, 711.297, 3.15687, 646.051, 59.2201, 628.698, 84.5821, 654.06, 129.634, 615.792, 1956.81, 616.096, 1976.63, 640.557, 1987.95, 588.863, 2070.07, 622.872, 2066.3, 799.721, -9.16094, 803.802 ) ] -[sub_resource type="Animation" id=2] -resource_name = "r_door_close" -tracks/0/type = "value" -tracks/0/path = NodePath("r_door_closed:visible") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 1, -"values": [ true ] -} -tracks/1/type = "value" -tracks/1/path = NodePath("r_door_opened:visible") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 1, -"values": [ false ] -} -tracks/2/type = "value" -tracks/2/path = NodePath("Position2D:position") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ Vector2( 1180.52, 395.193 ) ] -} - -[sub_resource type="Animation" id=3] -resource_name = "r_door_open" -length = 0.3 -tracks/0/type = "value" -tracks/0/path = NodePath("r_door_closed:visible") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 1, -"values": [ false ] -} -tracks/1/type = "value" -tracks/1/path = NodePath("r_door_opened:visible") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 1, -"values": [ true ] -} -tracks/2/type = "value" -tracks/2/path = NodePath("Position2D:position") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0 ), -"transitions": PoolRealArray( 1 ), -"update": 0, -"values": [ Vector2( 1225.47, 353.99 ) ] -} - [node name="room7" type="Node2D"] script = ExtResource( 6 ) __meta__ = { @@ -101,18 +21,13 @@ esc_script = "res://game/rooms/room7/esc/room7.esc" player_scene = ExtResource( 4 ) [node name="background" parent="." instance=ExtResource( 2 )] +margin_right = 2088.0 + +[node name="Line2D" type="Line2D" parent="background"] +points = PoolVector2Array( 398.738, 142.591, 518.947, 64.809, 516.118, 275.527 ) [node name="walkable_area" type="Navigation2D" parent="."] script = ExtResource( 1 ) -scales = null -bitmaps_scale = Vector2( 1, 1 ) -lightmap = null -player_speed_multiplier = 1.0 -player_doubleclick_speed_multiplier = 1.5 -lightmap_modulate = Color( 1, 1, 1, 1 ) -debug_mode = 1 -scale_min = 0.3 -scale_max = 1.0 [node name="platform" type="NavigationPolygonInstance" parent="walkable_area"] position = Vector2( 7.73163, -264.779 ) @@ -125,7 +40,7 @@ __meta__ = { [node name="l_exit" type="Area2D" parent="Hotspots"] script = ExtResource( 3 ) -global_id = "r6_l_exit" +global_id = "r7_l_exit" is_exit = true esc_script = "res://game/rooms/room7/esc/left_exit.esc" tooltip_name = "Exit" @@ -142,7 +57,7 @@ position = Vector2( 37.4521, 392.045 ) [node name="r_exit" type="Area2D" parent="Hotspots"] script = ExtResource( 3 ) -global_id = "r6_r_exit" +global_id = "r7_r_exit" is_exit = true esc_script = "res://game/rooms/room7/esc/right_exit.esc" is_interactive = false @@ -150,13 +65,13 @@ interaction_direction = 1 tooltip_name = "Exit" dialog_color = Color( 1, 1, 1, 1 ) interact_positions = { -"default": Vector2( 1232.52, 347.193 ), +"default": Vector2( 2038.8, 347.193 ), "r6_r_exit_closed": NodePath("r_door_closed/Position2D"), "r6_r_exit_opened": NodePath("r_door_opened/Position2D") } [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_exit"] -polygon = PoolVector2Array( 1989, 343, 1986, 278.129, 2076, 316.129, 2075, 394 ) +polygon = PoolVector2Array( 1982.34, 349.116, 1980.1, 46.0513, 2081.12, 86.4599, 2075, 394 ) [node name="Position2D" type="Position2D" parent="Hotspots/r_exit"] position = Vector2( 2038.8, 347.193 ) @@ -164,31 +79,20 @@ __meta__ = { "_editor_description_": "" } -[node name="r_door" type="Sprite" parent="Hotspots"] -visible = false -script = ExtResource( 5 ) +[node name="object2" type="Area2D" parent="Hotspots"] +position = Vector2( 1600.63, 13.4695 ) +script = ExtResource( 3 ) +global_id = "r7_object2" dialog_color = Color( 1, 1, 1, 1 ) +interact_positions = { +"default": null +} -[node name="r_door_closed" type="Polygon2D" parent="Hotspots/r_door"] -color = Color( 0.482353, 0.568627, 1, 1 ) -polygon = PoolVector2Array( 1172.3, 44.8186, 1172.3, 348.012, 1273.9, 401.983, 1277.07, 89.2657 ) +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/object2"] +polygon = PoolVector2Array( -112.101, 14.6226, -103.122, 288.503, 130.35, 286.258, 125.861, 16.8675 ) -[node name="Line2D" type="Line2D" parent="Hotspots/r_door/r_door_closed"] -points = PoolVector2Array( 1265.23, 266.8, 1253.65, 276.6, 1252.76, 230.273, 1264.34, 233.837 ) -default_color = Color( 1, 1, 1, 1 ) - -[node name="r_door_opened" type="Polygon2D" parent="Hotspots/r_door"] -visible = false -color = Color( 0.482353, 0.568627, 1, 1 ) -polygon = PoolVector2Array( 1172.3, 44.8186, 1172.3, 348.012, 1029.82, 349.887, 1025.19, 42.1269 ) - -[node name="Line2D" type="Line2D" parent="Hotspots/r_door/r_door_opened"] -points = PoolVector2Array( 1048.98, 230.477, 1048.98, 189.89 ) -default_color = Color( 1, 1, 1, 1 ) - -[node name="AnimationPlayer" type="AnimationPlayer" parent="Hotspots/r_door"] -anims/r_door_close = SubResource( 2 ) -anims/r_door_open = SubResource( 3 ) +[node name="Line2D" type="Line2D" parent="Hotspots/object2"] +points = PoolVector2Array( -74.0056, 70.7457, 2.32182, 28.0921, 89.8739, 77.4804, -82.9853, 268.299, 110.078, 261.564 ) [node name="player_start" type="Position2D" parent="."] position = Vector2( 76.7617, 437.649 ) diff --git a/game/start_game.esc b/game/start_game.esc index 0f74a3c9..0638ce3c 100755 --- a/game/start_game.esc +++ b/game/start_game.esc @@ -13,8 +13,11 @@ #change_scene res://game/rooms/room4/room4.tscn # items rooms -change_scene res://game/rooms/room5/room5.tscn +#change_scene res://game/rooms/room5/room5.tscn # character room #change_scene res://game/rooms/room6/room6.tscn +# long room with camera shift to object 2 if look on object 1 +change_scene res://game/rooms/room7/room7.tscn + diff --git a/game/ui/ui_9verbs/game.gd b/game/ui/ui_9verbs/game.gd new file mode 100644 index 00000000..b73505d2 --- /dev/null +++ b/game/ui/ui_9verbs/game.gd @@ -0,0 +1,114 @@ +extends Node + +""" +Implement methods to react to inputs. + +- left_click_on_bg(position : Vector2) +- right_click_on_bg(position : Vector2) +- left_double_click_on_bg(position : Vector2) + +- element_focused(element_id : String) +- element_unfocused() + +- left_click_on_hotspot(hotspot_global_id : String, event : InputEvent) +- right_click_on_hotspot(hotspot_global_id : String, event : InputEvent) +- left_double_click_on_hotspot(hotspot_global_id : String, event : InputEvent) + +- left_click_on_item(item_global_id : String, event : InputEvent) +- right_click_on_item(item_global_id : String, event : InputEvent) +- left_double_click_on_item(item_global_id : String, event : InputEvent) +""" + +signal element_focused(element_global_id) + + +func _input(event): + if event.is_action_pressed("switch_action_verb"): + if event.button_index == BUTTON_WHEEL_UP: + $ui/verbs_layer/verbs_menu.iterate_actions_cursor(-1) + elif event.button_index == BUTTON_WHEEL_DOWN: + $ui/verbs_layer/verbs_menu.iterate_actions_cursor(1) + +## BACKGROUND ## + +func left_click_on_bg(position : Vector2) -> void: + escoria.do("walk", ["player", position]) + +func right_click_on_bg(position : Vector2) -> void: + escoria.do("walk", ["player", position]) + +func left_double_click_on_bg(position : Vector2) -> void: + escoria.do("walk", ["player", position, true]) + + +## ITEM/HOTSPOT FOCUS ## + +func element_focused(element_id : String) -> void: + #emit_signal("element_focused", element_id) +# var target_obj = escoria.esc_runner.get_object(element_id) +# if escoria.esc_runner.current_action != "use" && escoria.esc_runner.current_tool == null: +# if target_obj is ESCItem or target_obj is ESCHotspot: +# $ui/verbs_layer/verbs_menu.set_by_name(target_obj.default_action) + pass + + +func element_unfocused() -> void: + #emit_signal("element_focused", "") + #$ui/verbs_layer/verbs_menu.set_by_name("walk") + pass + + +## HOTSPOTS ## + +func left_click_on_hotspot(hotspot_global_id : String, event : InputEvent) -> void: + escoria.do("hotspot_left_click", [hotspot_global_id, event]) + +func right_click_on_hotspot(hotspot_global_id : String, event : InputEvent) -> void: + escoria.do("hotspot_right_click", [hotspot_global_id, event]) + +func left_double_click_on_hotspot(hotspot_global_id : String, event : InputEvent) -> void: + escoria.do("hotspot_left_click", [hotspot_global_id, event]) + + +## ITEMS ## + +func left_click_on_item(item_global_id : String, event : InputEvent) -> void: + escoria.do("item_left_click", [item_global_id, event]) + +func right_click_on_item(item_global_id : String, event : InputEvent) -> void: + escoria.do("item_right_click", [item_global_id, event]) + +func left_double_click_on_item(item_global_id : String, event : InputEvent) -> void: + escoria.do("item_left_click", [item_global_id, event]) + + +## INVENTORY ## +func left_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent) -> void: + escoria.do("item_left_click", [inventory_item_global_id, event]) + if escoria.esc_runner.current_action == "use": + var item = escoria.esc_runner.get_object(inventory_item_global_id) + if item.texture: + $ui/verbs_layer/verbs_menu.set_tool_texture(item.texture) + elif item.inventory_item_scene_file.instance().texture_normal: + $ui/verbs_layer/verbs_menu.set_tool_texture(item.inventory_item_scene_file.instance().texture_normal) + + +func right_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent) -> void: + escoria.do("item_right_click", [inventory_item_global_id, event]) + +func left_double_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent) -> void: + pass + +func inventory_item_focused(inventory_item_global_id : String) -> void: + emit_signal("element_focused", inventory_item_global_id) + +func inventory_item_unfocused() -> void: + emit_signal("element_focused", "") + + +func open_inventory(): + $ui/inventory_layer/inventory_ui/inventory_button.show_inventory() + + +func close_inventory(): + $ui/inventory_layer/inventory_ui/inventory_button.close_inventory() diff --git a/game/ui/ui_9verbs/game.tscn b/game/ui/ui_9verbs/game.tscn index ea938f4b..e52b399f 100644 --- a/game/ui/ui_9verbs/game.tscn +++ b/game/ui/ui_9verbs/game.tscn @@ -1,15 +1,17 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://addons/escoria-core/template_scenes/label/action_target_tooltip.tscn" type="PackedScene" id=1] [ext_resource path="res://game/ui/ui_9verbs/inventory_ui.tscn" type="PackedScene" id=2] [ext_resource path="res://game/ui/ui_9verbs/verbs_menu.tscn" type="PackedScene" id=3] [ext_resource path="res://addons/escoria-core/game/scenes/dialogs/dialog_player.tscn" type="PackedScene" id=4] +[ext_resource path="res://game/ui/ui_9verbs/game.gd" type="Script" id=5] [ext_resource path="res://addons/escoria-core/game/scenes/camera_player/camera.tscn" type="PackedScene" id=6] [sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 0.6, 0.6, 0.6, 0.5 ) [node name="game" type="Node"] +script = ExtResource( 5 ) [node name="ui" type="CanvasLayer" parent="."] diff --git a/game/ui/ui_9verbs/inventory_ui.tscn b/game/ui/ui_9verbs/inventory_ui.tscn index 296780c2..f751aacf 100644 --- a/game/ui/ui_9verbs/inventory_ui.tscn +++ b/game/ui/ui_9verbs/inventory_ui.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://addons/escoria-core/game/scenes/inventory/inventory_ui.gd" type="Script" id=1] -[ext_resource path="res://game/items/all_items.tscn" type="PackedScene" id=2] +[ext_resource path="res://game/items/ESCORIA_ALL_ITEMS.tscn" type="PackedScene" id=2] [ext_resource path="res://game/ui/ui_9verbs/inventory_ui_container.gd" type="Script" id=3] diff --git a/game/ui/ui_9verbs/verbs_menu.gd b/game/ui/ui_9verbs/verbs_menu.gd index 04a3b325..d428ec19 100644 --- a/game/ui/ui_9verbs/verbs_menu.gd +++ b/game/ui/ui_9verbs/verbs_menu.gd @@ -1,6 +1,11 @@ tool extends Control +""" +This script is out of Escoria's scope. It controls the UI reaction to an +UI event (eg right click) to change the cursor accordingly. +""" + func _ready(): for but in $actions.get_children(): but.connect("pressed", self, "_on_action_selected", [but.name]) diff --git a/game/ui/ui_mouse_icons/game.gd b/game/ui/ui_mouse_icons/game.gd index 94c2d553..8b9a7a4e 100644 --- a/game/ui/ui_mouse_icons/game.gd +++ b/game/ui/ui_mouse_icons/game.gd @@ -21,6 +21,7 @@ Implement methods to react to inputs. signal element_focused(element_global_id) + func _input(event): if event.is_action_pressed("switch_action_verb"): if event.button_index == BUTTON_WHEEL_UP: @@ -93,7 +94,7 @@ func left_click_on_inventory_item(inventory_item_global_id : String, event : Inp func right_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent) -> void: escoria.do("item_right_click", [inventory_item_global_id, event]) -func double_left_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent) -> void: +func left_double_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent) -> void: pass func inventory_item_focused(inventory_item_global_id : String) -> void: @@ -101,3 +102,11 @@ func inventory_item_focused(inventory_item_global_id : String) -> void: func inventory_item_unfocused() -> void: emit_signal("element_focused", "") + + +func open_inventory(): + $ui/inventory_layer/inventory_ui/inventory_button.show_inventory() + + +func close_inventory(): + $ui/inventory_layer/inventory_ui/inventory_button.close_inventory() diff --git a/game/ui/ui_mouse_icons/inventory/inventory_showhide.gd b/game/ui/ui_mouse_icons/inventory/inventory_showhide.gd index 603bc996..65aeb2ac 100644 --- a/game/ui/ui_mouse_icons/inventory/inventory_showhide.gd +++ b/game/ui/ui_mouse_icons/inventory/inventory_showhide.gd @@ -6,13 +6,20 @@ func _ready(): pass - func _on_inventory_button_pressed(): if !$AnimationPlayer.is_playing() and !showed: - $AnimationPlayer.play("show") - yield($AnimationPlayer, "animation_finished") - showed = true + show_inventory() elif !$AnimationPlayer.is_playing() and showed: - $AnimationPlayer.play("hide") - yield($AnimationPlayer, "animation_finished") - showed = false + close_inventory() + + +func show_inventory(): + $AnimationPlayer.play("show") + yield($AnimationPlayer, "animation_finished") + showed = true + + +func close_inventory(): + $AnimationPlayer.play("hide") + yield($AnimationPlayer, "animation_finished") + showed = false diff --git a/game/ui/ui_mouse_icons/inventory/inventory_ui.tscn b/game/ui/ui_mouse_icons/inventory/inventory_ui.tscn index d4d82c65..360b2a4e 100644 --- a/game/ui/ui_mouse_icons/inventory/inventory_ui.tscn +++ b/game/ui/ui_mouse_icons/inventory/inventory_ui.tscn @@ -6,7 +6,7 @@ [ext_resource path="res://game/ui/ui_mouse_icons/inventory/inventory_showhide.gd" type="Script" id=4] [ext_resource path="res://game/ui/ui_mouse_icons/images/frame.png" type="Texture" id=5] [ext_resource path="res://game/ui/ui_mouse_icons/images/inventory_icon.png" type="Texture" id=6] -[ext_resource path="res://game/items/all_items.tscn" type="PackedScene" id=7] +[ext_resource path="res://game/items/ESCORIA_ALL_ITEMS.tscn" type="PackedScene" id=7] [sub_resource type="Animation" id=1] resource_name = "hide" @@ -100,7 +100,7 @@ __meta__ = { } items_container = NodePath("inventory_button/panel/MarginContainer/ScrollContainer/container") -[node name="all_items" parent="." instance=ExtResource( 7 )] +[node name="ESCORIA_ALL_ITEMS" parent="." instance=ExtResource( 7 )] position = Vector2( 269.391, 275.003 ) [node name="inventory_button" type="TextureButton" parent="."] diff --git a/project.godot b/project.godot index be82b86d..3bcc99f3 100644 --- a/project.godot +++ b/project.godot @@ -117,11 +117,11 @@ debug/terminate_on_warnings=false main/force_quit=true internals/save_data="" debug/development_lang="en" -ui/dialogs_folder="res://game/ui/commons/dialogs" -ui/default_dialog_scene="res://game/ui/commons/dialogs/dialog_label.tscn" ui/tooltip_follows_mouse=true +ui/game_scene="res://game/ui/ui_9verbs/game.tscn" ui/main_menu_scene="res://game/ui/commons/main_menu.tscn" -ui/game_scene="res://game/ui/ui_mouse_icons/game.tscn" +ui/default_dialog_scene="res://game/ui/commons/dialogs/dialog_label.tscn" +ui/dialogs_folder="res://game/ui/commons/dialogs" [input]