Added bg_sound manager and according ESC command.
Started transitions scene.
This commit is contained in:
@@ -6,30 +6,56 @@ const autoloads = {
|
||||
"esctypes": "res://addons/escoria-core/game/core-scripts/escoria_types.gd"
|
||||
}
|
||||
|
||||
const custom_types = [
|
||||
{
|
||||
"type_name": "ESCBackground",
|
||||
"parent_type": "Sprite",
|
||||
"script_res": "res://addons/escoria-core/game/core-scripts/escbackground.gd"
|
||||
},
|
||||
{
|
||||
"type_name": "ESCItem",
|
||||
"parent_type": "Area2D",
|
||||
"script_res": "res://addons/escoria-core/game/core-scripts/escitem.gd"
|
||||
},
|
||||
{
|
||||
"type_name": "ESCItemsInventory",
|
||||
"parent_type": "GridContainer",
|
||||
"script_res": "res://addons/escoria-core/game/core-scripts/items_inventory.gd"
|
||||
},
|
||||
{
|
||||
"type_name": "ESCInventoryItem",
|
||||
"parent_type": "TextureButton",
|
||||
"script_res": "res://addons/escoria-core/game/core-scripts/escinventoryitem.gd"
|
||||
},
|
||||
{
|
||||
"type_name": "ESCPlayer",
|
||||
"parent_type": "KinematicBody2D",
|
||||
"script_res": "res://addons/escoria-core/game/core-scripts/escplayer.gd"
|
||||
},
|
||||
{
|
||||
"type_name": "ESCRoom",
|
||||
"parent_type": "Node2D",
|
||||
"script_res": "res://addons/escoria-core/game/core-scripts/escroom.gd"
|
||||
},
|
||||
{
|
||||
"type_name": "ESCTerrain",
|
||||
"parent_type": "Navigation2D",
|
||||
"script_res": "res://addons/escoria-core/game/core-scripts/escterrain.gd"
|
||||
}
|
||||
]
|
||||
|
||||
func _enter_tree():
|
||||
add_autoloads()
|
||||
|
||||
add_custom_type("ESCBackground", "Sprite",
|
||||
load("res://addons/escoria-core/game/core-scripts/escbackground.gd"), null)
|
||||
add_custom_type("ESCCharacter", "KinematicBody2D",
|
||||
load("res://addons/escoria-core/game/core-scripts/esccharacter.gd"), null)
|
||||
add_custom_type("ESCItem", "Area2D",
|
||||
load("res://addons/escoria-core/game/core-scripts/escitem.gd"), null)
|
||||
add_custom_type("ESCItemsInventory", "GridContainer",
|
||||
load("res://addons/escoria-core/game/core-scripts/items_inventory.gd"), null)
|
||||
add_custom_type("ESCInventoryItem", "TextureButton",
|
||||
load("res://addons/escoria-core/game/core-scripts/inventory_item.gd"), null)
|
||||
add_custom_type("ESCPlayer", "KinematicBody2D",
|
||||
load("res://addons/escoria-core/game/core-scripts/escplayer.gd"), null)
|
||||
add_custom_type("ESCRoom", "Node2D",
|
||||
load("res://addons/escoria-core/game/core-scripts/escroom.gd"), null)
|
||||
add_custom_type("ESCTerrain", "Navigation2D",
|
||||
load("res://addons/escoria-core/game/core-scripts/escterrain.gd"), null)
|
||||
for custom_type in custom_types:
|
||||
add_custom_type(custom_type.type_name, custom_type.parent_type,
|
||||
load(custom_type.script_res), null)
|
||||
|
||||
set_escoria_main_settings()
|
||||
set_escoria_debug_settings()
|
||||
set_escoria_ui_settings()
|
||||
set_escoria_internal_settings()
|
||||
set_escoria_sound_settings()
|
||||
|
||||
|
||||
func set_escoria_ui_settings():
|
||||
@@ -65,6 +91,16 @@ func set_escoria_ui_settings():
|
||||
}
|
||||
ProjectSettings.add_property_info(main_menu_scene_property_info)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/ui/pause_menu_scene"):
|
||||
ProjectSettings.set_setting("escoria/ui/pause_menu_scene", "")
|
||||
var pause_menu_scene_property_info = {
|
||||
"name": "escoria/ui/pause_menu_scene",
|
||||
"type": TYPE_STRING,
|
||||
"hint": PROPERTY_HINT_FILE,
|
||||
"hint_string": "*.tscn, *.scn"
|
||||
}
|
||||
ProjectSettings.add_property_info(pause_menu_scene_property_info)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/ui/game_scene"):
|
||||
ProjectSettings.set_setting("escoria/ui/game_scene", "")
|
||||
var game_scene_property_info = {
|
||||
@@ -122,6 +158,30 @@ func set_escoria_internal_settings():
|
||||
}
|
||||
ProjectSettings.add_property_info(save_data_property_info)
|
||||
|
||||
|
||||
func set_escoria_sound_settings():
|
||||
if !ProjectSettings.has_setting("escoria/sound/music_volume"):
|
||||
ProjectSettings.set_setting("escoria/sound/music_volume", 5)
|
||||
var music_data_property_info = {
|
||||
"name": "escoria/sound/music_volume",
|
||||
"type": TYPE_INT,
|
||||
"hint": PROPERTY_HINT_RANGE,
|
||||
"hint_string": "0,15"
|
||||
}
|
||||
ProjectSettings.add_property_info(music_data_property_info)
|
||||
|
||||
if !ProjectSettings.has_setting("escoria/sound/sound_volume"):
|
||||
ProjectSettings.set_setting("escoria/sound/sound_volume", 8)
|
||||
var sound_data_property_info = {
|
||||
"name": "escoria/sound/sound_volume",
|
||||
"type": TYPE_INT,
|
||||
"hint": PROPERTY_HINT_RANGE,
|
||||
"hint_string": "0,15"
|
||||
}
|
||||
ProjectSettings.add_property_info(sound_data_property_info)
|
||||
|
||||
|
||||
|
||||
# Defines platform-specific parameters. Those are the ones that must be re-set for each platform export.
|
||||
func set_escoria_platform_settings():
|
||||
# Skip cache - certain platforms (esp. mobile) lack memory for caching scenes
|
||||
@@ -143,7 +203,6 @@ func remove_autoloads():
|
||||
|
||||
func _exit_tree():
|
||||
remove_custom_type("ESCBackground")
|
||||
remove_custom_type("ESCCharacter")
|
||||
remove_custom_type("ESCItem")
|
||||
remove_custom_type("ESCInventoryItem")
|
||||
remove_custom_type("ESCItemsInventory")
|
||||
|
||||
@@ -52,7 +52,7 @@ var commands = {
|
||||
"inventory_display": { "min_args": 1, "types": [TYPE_BOOL] },
|
||||
"jump": { "min_args": 1 },
|
||||
"label": { "min_args": 1 },
|
||||
"play_snd": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL] },
|
||||
"set_sound_state": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL] },
|
||||
"queue_animation": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL] },
|
||||
"queue_resource": { "min_args": 1, "types": [TYPE_STRING, TYPE_BOOL] },
|
||||
"repeat": true,
|
||||
|
||||
@@ -349,7 +349,10 @@ func change_scene(params, context, run_events=true):
|
||||
# main.clear_scene()
|
||||
# camera = null
|
||||
event_queue = []
|
||||
|
||||
|
||||
escoria.main.scene_transition.fade_out()
|
||||
yield(escoria.main.scene_transition, "transition_done")
|
||||
|
||||
# Regular events need to be reset immediately, so we don't
|
||||
# accidentally `yield()` on them, for performance reasons.
|
||||
# This does not affect `stack` so execution is fine anyway.
|
||||
@@ -381,6 +384,9 @@ func change_scene(params, context, run_events=true):
|
||||
room_scene.move_child(game_scene, 0)
|
||||
var events = escoria.main.set_scene(room_scene, run_events)
|
||||
|
||||
escoria.main.scene_transition.fade_in()
|
||||
yield(escoria.main.scene_transition, "transition_done")
|
||||
|
||||
# If scene was never visited, add "ready" event to the events stack
|
||||
if !scenes_cache.has(room_scene.global_id) \
|
||||
and "ready" in events:
|
||||
@@ -526,7 +532,7 @@ func register_object(name : String, val : Object, force : bool = false):
|
||||
|
||||
# Most objects have states/animations, but don't count on it
|
||||
# if val.has_method("set_state"):
|
||||
if val is ESCItem or val is ESCPlayer or val is ESCCharacter:
|
||||
if val is ESCItem or val is ESCPlayer:
|
||||
if name in states:
|
||||
set_state(name, [states[name], true])
|
||||
else:
|
||||
@@ -722,23 +728,9 @@ func object_exit_scene(name : String):
|
||||
if inventory_has(name):
|
||||
objects[name] = objects[name].duplicate()
|
||||
else:
|
||||
escoria.logger.info("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:
|
||||
# escoria.logger.report_errors("", ["Label not found: "+p_label+", can't jump"])
|
||||
# stack.remove(stack.size()-1)
|
||||
# break
|
||||
# else:
|
||||
# stack.remove(stack.size()-1)
|
||||
if name != "bg_music":
|
||||
escoria.logger.info("Object " + name + " removed from scene.")
|
||||
objects.erase(name)
|
||||
|
||||
|
||||
func check_obj(name, cmd):
|
||||
@@ -747,3 +739,4 @@ func check_obj(name, cmd):
|
||||
escoria.logger.report_errors("", ["Global id "+name+" not found for " + cmd])
|
||||
return false
|
||||
return true
|
||||
|
||||
|
||||
@@ -399,9 +399,16 @@ func jump(command_params : Array):
|
||||
|
||||
|
||||
"""
|
||||
set_sound_state bg_music|bg_sound off|default|<path/to/music.file> true|false
|
||||
"""
|
||||
func play_snd(command_params : Array):
|
||||
pass
|
||||
func set_sound_state(command_params : Array):
|
||||
var snd_player = command_params[0]
|
||||
var snd_id = command_params[1]
|
||||
var loop = false
|
||||
if command_params.size() == 3 and command_params[2]:
|
||||
loop = true
|
||||
escoria.main.get_node(snd_player).set_state(snd_id, loop)
|
||||
return esctypes.EVENT_LEVEL_STATE.RETURN
|
||||
|
||||
|
||||
"""
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
tool
|
||||
extends Node
|
||||
class_name ESCCharacter
|
||||
|
||||
export(String) var character_id
|
||||
export(String, FILE, ".esc") var esc_script = ""
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
@@ -4,7 +4,6 @@ const OBJ_DEFAULT_STATE = "default"
|
||||
|
||||
## Custom nodes:
|
||||
#var ESCBackground = preload("res://addons/escoria-core/game/core-scripts/escbackground.gd")
|
||||
#var ESCCharacter = preload("res://addons/escoria-core/game/core-scripts/esccharacter.gd")
|
||||
#var ESCItem = preload("res://addons/escoria-core/game/core-scripts/escitem.gd")
|
||||
#var ESCItemsInventory = preload("res://addons/escoria-core/game/core-scripts/items_inventory.gd")
|
||||
#var ESCInventoryItem = preload("res://addons/escoria-core/game/core-scripts/inventory_item.gd")
|
||||
|
||||
@@ -57,7 +57,8 @@ func set_debug_mode(p_debug_mode : bool):
|
||||
debug_texturerect_node.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
move_child(debug_texturerect_node, 2)
|
||||
else:
|
||||
remove_child(debug_texturerect_node)
|
||||
if debug_texturerect_node:
|
||||
remove_child(debug_texturerect_node)
|
||||
|
||||
|
||||
func on_action_selected() -> void:
|
||||
|
||||
@@ -11,6 +11,7 @@ onready var utils = load("res://addons/escoria-core/game/core-scripts/utils/util
|
||||
|
||||
# INSTANCES
|
||||
var main_menu_instance
|
||||
|
||||
## Dialog player instantiator. This instance is called directly for dialogs.
|
||||
var dialog_player
|
||||
## Inventory scene
|
||||
@@ -30,18 +31,14 @@ onready var game_size = get_viewport().size
|
||||
|
||||
|
||||
##################################################################################
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
|
||||
# Called by Main menu "start new game"
|
||||
func new_game():
|
||||
var actions = esc_compiler.load_esc_file(ProjectSettings.get_setting("escoria/main/game_start_script"))
|
||||
$esc_runner.run_game(actions)
|
||||
|
||||
|
||||
func set_main_menu(scene):
|
||||
main_menu_instance = scene
|
||||
|
||||
escoria.main.scene_transition.fade_in()
|
||||
yield(escoria.main.scene_transition, "transition_done")
|
||||
|
||||
|
||||
|
||||
@@ -83,6 +80,13 @@ func register_object(object : Object):
|
||||
if main.current_scene:
|
||||
main.current_scene.game.tooltip_node = object
|
||||
|
||||
if object is ESCBackgroundMusic:
|
||||
$esc_runner.register_object(object_id, object, true)
|
||||
|
||||
if object is ESCBackgroundSound:
|
||||
$esc_runner.register_object(object_id, object, true)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
|
||||
@@ -24,7 +24,4 @@ script = ExtResource( 4 )
|
||||
|
||||
[node name="main" parent="." instance=ExtResource( 2 )]
|
||||
|
||||
[node name="Viewport" type="Viewport" parent="."]
|
||||
usage = 0
|
||||
|
||||
[editable path="main"]
|
||||
|
||||
@@ -13,6 +13,9 @@ func _input(event):
|
||||
if event.is_action_pressed("esc_show_debug_prompt"):
|
||||
escoria.main.get_node("layers/debug_layer/esc_prompt_popup").popup()
|
||||
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
_on_pause_menu_requested()
|
||||
|
||||
if ProjectSettings.get_setting("escoria/ui/tooltip_follows_mouse"):
|
||||
if escoria.main.current_scene and escoria.main.current_scene.game:
|
||||
if event is InputEventMouseMotion:
|
||||
@@ -124,3 +127,8 @@ func clean_hover_stack():
|
||||
|
||||
func hover_stack_pop(item):
|
||||
hover_stack.erase(item)
|
||||
|
||||
################################################################################
|
||||
|
||||
func _on_pause_menu_requested():
|
||||
escoria.main.current_scene.game.pause_game()
|
||||
|
||||
@@ -11,6 +11,10 @@ var wait_level
|
||||
|
||||
var screen_ofs = Vector2(0, 0)
|
||||
|
||||
# ESCBackgroundMusic node
|
||||
onready var bg_music = $bg_music
|
||||
onready var scene_transition = $layers/curtain/scene_transition
|
||||
|
||||
func _ready():
|
||||
$layers/wait_timer.connect("timeout", self, "_on_wait_finished")
|
||||
|
||||
@@ -25,7 +29,8 @@ func set_scene(p_scene, run_events=true):
|
||||
if current_scene != null:
|
||||
clear_scene()
|
||||
|
||||
get_node("/root").add_child(p_scene)
|
||||
# get_node("/root").add_child(p_scene)
|
||||
add_child(p_scene)
|
||||
|
||||
# Ensure we don't have a regular event running when changing scenes
|
||||
if escoria.esc_runner.running_event:
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/main.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/esc_prompt/esc_prompt_popup.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/sound/bg_music.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/transitions/transition.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/sound/bg_sound.tscn" type="PackedScene" id=5]
|
||||
|
||||
[node name="main" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
@@ -9,6 +12,9 @@ script = ExtResource( 1 )
|
||||
[node name="layers" type="Node" parent="."]
|
||||
|
||||
[node name="curtain" type="CanvasLayer" parent="layers"]
|
||||
layer = 20
|
||||
|
||||
[node name="scene_transition" parent="layers/curtain" instance=ExtResource( 4 )]
|
||||
|
||||
[node name="menu" type="CanvasLayer" parent="layers"]
|
||||
|
||||
@@ -17,3 +23,7 @@ script = ExtResource( 1 )
|
||||
[node name="debug_layer" type="CanvasLayer" parent="layers"]
|
||||
|
||||
[node name="esc_prompt_popup" parent="layers/debug_layer" instance=ExtResource( 2 )]
|
||||
|
||||
[node name="bg_music" parent="." instance=ExtResource( 3 )]
|
||||
|
||||
[node name="bg_sound" parent="." instance=ExtResource( 5 )]
|
||||
|
||||
@@ -6,7 +6,8 @@ extends Node
|
||||
func _ready():
|
||||
var main_menu_path = ProjectSettings.get_setting("escoria/ui/main_menu_scene")
|
||||
var main_menu_scene = load(main_menu_path).instance()
|
||||
get_tree().get_root().call_deferred("add_child", main_menu_scene)
|
||||
escoria.set_main_menu(main_menu_scene)
|
||||
# get_tree().get_root().call_deferred("add_child", main_menu_scene)
|
||||
escoria.call_deferred("add_child", main_menu_scene)
|
||||
escoria.main_menu_instance = main_menu_scene
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ The scene MUST contain the 2 following nodes:
|
||||
|
||||
|
||||
# Define the actual container node to add items as children of. Should be a Container.
|
||||
export(NodePath) var items_container
|
||||
export(NodePath) var inventory_ui_container
|
||||
onready var all_items = $ESCORIA_ALL_ITEMS
|
||||
|
||||
var items_ids_in_inventory : Dictionary = {} # { item_id : TextureButton}
|
||||
@@ -30,10 +30,10 @@ func _ready():
|
||||
|
||||
escoria.register_object(self)
|
||||
|
||||
if items_container == null or items_container.is_empty():
|
||||
if inventory_ui_container == null or inventory_ui_container.is_empty():
|
||||
escoria.logger.report_errors(self.get_path(), ["Items container is empty."])
|
||||
return
|
||||
for c in get_node(items_container).get_items():
|
||||
for c in get_node(inventory_ui_container).get_items():
|
||||
items_ids_in_inventory[c.item_id] = c
|
||||
# c.connect("pressed", escoria.inputs_manager, "_on_inventory_item_pressed", [c.item_id])
|
||||
|
||||
@@ -55,7 +55,7 @@ func add_new_item_by_id(item_id : String) -> void:
|
||||
"Check item's id in ESCORIA_ALL_ITEMS scene."])
|
||||
var item_inventory_button = all_items.get_inventory_item(item_id).duplicate()
|
||||
items_ids_in_inventory[item_id] = item_inventory_button
|
||||
get_node(items_container).add_item(item_inventory_button)
|
||||
get_node(inventory_ui_container).add_item(item_inventory_button)
|
||||
|
||||
# Add the item to inventory
|
||||
if !escoria.esc_runner.objects.has(item_id):
|
||||
@@ -90,7 +90,7 @@ func remove_item_by_id(item_id : String) -> void:
|
||||
item_inventory_button.disconnect("inventory_item_unfocused",
|
||||
escoria.inputs_manager, "_on_mouse_exited_inventory_item")
|
||||
|
||||
get_node(items_container).remove_item(item_inventory_button)
|
||||
get_node(inventory_ui_container).remove_item(item_inventory_button)
|
||||
item_inventory_button.queue_free()
|
||||
items_ids_in_inventory.erase(item_id)
|
||||
|
||||
|
||||
42
addons/escoria-core/game/scenes/sound/bg_music.gd
Normal file
42
addons/escoria-core/game/scenes/sound/bg_music.gd
Normal file
@@ -0,0 +1,42 @@
|
||||
extends Control
|
||||
class_name ESCBackgroundMusic
|
||||
|
||||
func get_class():
|
||||
return "ESCBackgroundMusic"
|
||||
|
||||
onready var stream = $AudioStreamPlayer
|
||||
var state = "default"
|
||||
export var global_id = "bg_music"
|
||||
|
||||
|
||||
func game_cleared():
|
||||
set_state("off", true)
|
||||
self.disconnect("tree_exited", escoria.esc_runner, "object_exit_scene")
|
||||
escoria.register_object(self)
|
||||
|
||||
|
||||
func set_state(p_state, p_force = false):
|
||||
# If already playing this stream, keep playing, unless p_force
|
||||
if p_state == state and not p_force and stream.is_playing():
|
||||
return
|
||||
|
||||
state = p_state
|
||||
|
||||
# If state is "off"/"default", turn off music
|
||||
if state == "off" or state == "default":
|
||||
stream.stream = null
|
||||
return
|
||||
|
||||
var resource = load(p_state)
|
||||
|
||||
stream.stream = resource
|
||||
|
||||
if stream.stream:
|
||||
resource.set_loop(true)
|
||||
if ProjectSettings.has_setting("escoria/sound/music_volume"):
|
||||
stream.volume_db = ProjectSettings.get_setting("escoria/sound/music_volume")
|
||||
stream.play()
|
||||
|
||||
func _ready():
|
||||
escoria.register_object(self)
|
||||
|
||||
16
addons/escoria-core/game/scenes/sound/bg_music.tscn
Normal file
16
addons/escoria-core/game/scenes/sound/bg_music.tscn
Normal file
@@ -0,0 +1,16 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/sound/bg_music.gd" type="Script" id=1]
|
||||
|
||||
[node name="bg_music" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_right = -1680.0
|
||||
margin_bottom = -1050.0
|
||||
mouse_filter = 2
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
41
addons/escoria-core/game/scenes/sound/bg_sound.gd
Normal file
41
addons/escoria-core/game/scenes/sound/bg_sound.gd
Normal file
@@ -0,0 +1,41 @@
|
||||
extends Control
|
||||
class_name ESCBackgroundSound
|
||||
|
||||
func get_class():
|
||||
return "ESCBackgroundSound"
|
||||
|
||||
onready var stream = $AudioStreamPlayer
|
||||
var state = "default"
|
||||
export var global_id = "bg_sound"
|
||||
|
||||
|
||||
func game_cleared():
|
||||
stream.stream = null
|
||||
escoria.register_object(self)
|
||||
|
||||
|
||||
func set_state(p_state, p_force = false):
|
||||
# If already playing this stream, keep playing, unless p_force
|
||||
if p_state == state and not p_force and stream.is_playing():
|
||||
return
|
||||
|
||||
state = p_state
|
||||
|
||||
# If state is "off"/"default", turn off music
|
||||
if state == "off" or state == "default":
|
||||
stream.stream = null
|
||||
return
|
||||
|
||||
var resource = load(p_state)
|
||||
|
||||
stream.stream = resource
|
||||
|
||||
if stream.stream:
|
||||
resource.set_loop(false)
|
||||
if ProjectSettings.has_setting("escoria/sound/sound_volume"):
|
||||
stream.volume_db = ProjectSettings.get_setting("escoria/sound/sound_volume")
|
||||
stream.play()
|
||||
|
||||
|
||||
func _ready():
|
||||
escoria.register_object(self)
|
||||
16
addons/escoria-core/game/scenes/sound/bg_sound.tscn
Normal file
16
addons/escoria-core/game/scenes/sound/bg_sound.tscn
Normal file
@@ -0,0 +1,16 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/sound/bg_sound.gd" type="Script" id=1]
|
||||
|
||||
[node name="bg_sound" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_right = -1680.0
|
||||
margin_bottom = -1050.0
|
||||
mouse_filter = 2
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
BIN
addons/escoria-core/game/scenes/transitions/masks/curtain.png
Normal file
BIN
addons/escoria-core/game/scenes/transitions/masks/curtain.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 146 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 137 KiB |
BIN
addons/escoria-core/game/scenes/transitions/masks/shards.png
Normal file
BIN
addons/escoria-core/game/scenes/transitions/masks/shards.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
Binary file not shown.
28
addons/escoria-core/game/scenes/transitions/transition.gd
Normal file
28
addons/escoria-core/game/scenes/transitions/transition.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
extends ColorRect
|
||||
|
||||
export(String, "fade_black", "fade_white", "transition_in", "transition_out") var transition_name
|
||||
# Reference to the _AnimationPlayer_ node
|
||||
onready var _anim_player := $AnimationPlayer
|
||||
|
||||
|
||||
|
||||
signal transition_done
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# Plays the animation backward to fade in
|
||||
_anim_player.play_backwards(transition_name)
|
||||
|
||||
|
||||
func fade_out() -> void:
|
||||
# Plays the Fade animation and wait until it finishes
|
||||
_anim_player.play(transition_name)
|
||||
yield(_anim_player, "animation_finished")
|
||||
emit_signal("transition_done")
|
||||
|
||||
func fade_in() -> void:
|
||||
# Plays the Fade animation and wait until it finishes
|
||||
_anim_player.play_backwards(transition_name)
|
||||
yield(_anim_player, "animation_finished")
|
||||
emit_signal("transition_done")
|
||||
|
||||
83
addons/escoria-core/game/scenes/transitions/transition.tscn
Normal file
83
addons/escoria-core/game/scenes/transitions/transition.tscn
Normal file
@@ -0,0 +1,83 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/transitions/transition.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/escoria-core/game/scenes/transitions/shaders/transition.material" type="Material" id=2]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "fade_black"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.5 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Color( 0, 0, 0, 0 ), Color( 0, 0, 0, 1 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
resource_name = "fade_white"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.5 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
resource_name = "transition_in"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath(".:material:shader_param/cutoff")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 1 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ 0.0, 1.0 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
resource_name = "transition_out"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath(".:material:shader_param/cutoff")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 1 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ 1.0, 0.0 ]
|
||||
}
|
||||
|
||||
[node name="scene_transition" type="ColorRect"]
|
||||
material = ExtResource( 2 )
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
transition_name = "transition_out"
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/fade_black = SubResource( 1 )
|
||||
anims/fade_white = SubResource( 2 )
|
||||
anims/transition_in = SubResource( 3 )
|
||||
anims/transition_out = SubResource( 4 )
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/inventory_item.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/escoria-core/game/core-scripts/escinventoryitem.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/escoria-core/game/assets/images/no_image.png" type="Texture" id=2]
|
||||
|
||||
[node name="inventory_item" type="TextureButton"]
|
||||
|
||||
Reference in New Issue
Block a user