feat: New streamlined exit item (#455)

Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
Dennis Ploeger
2021-11-22 13:08:10 +01:00
committed by GitHub
parent b9b6b97f07
commit e14373b179
6 changed files with 100 additions and 21 deletions

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>esc_exit</title>
<defs>
<linearGradient x1="32%" y1="0%" x2="68%" y2="100%" id="linearGradient-1">
<stop stop-color="#D4FF2A" offset="0%"></stop>
<stop stop-color="#81D135" offset="100%"></stop>
</linearGradient>
<linearGradient x1="36.7305357%" y1="0%" x2="63.2694643%" y2="100%" id="linearGradient-2">
<stop stop-color="#D4FF2A" offset="0%"></stop>
<stop stop-color="#81D135" offset="100%"></stop>
</linearGradient>
</defs>
<g id="esc_exit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Group" transform="translate(4.000000, 2.000000)" fill-rule="nonzero">
<polygon id="Rectangle-Copy" fill="url(#linearGradient-1)" points="6 10 0 10 0 0 6 0"></polygon>
<path d="M7,0 L7,10 L0,10 L0,0 L7,0 Z M6,1 L1,1 L1,9 L6,9 L6,1 Z" id="Rectangle" fill="#1B2F0D"></path>
</g>
<g id="Group-Copy" transform="translate(4.000000, 2.000000)" fill-rule="nonzero">
<polygon id="Rectangle-Copy" fill="url(#linearGradient-2)" points="6 11.6468788 0 10 0 0 6 1.64687882"></polygon>
<path d="M7,1.92135862 L7,11.9213586 L0,10 L0,0 L7,1.92135862 Z M6,2.64687882 L1,1.2744798 L1,9.2744798 L6,10.6468788 L6,2.64687882 Z" id="Rectangle" fill="#1B2F0D"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,43 @@
# An item that streamlines exiting scenes
extends ESCItem
class_name ESCExit, "res://addons/escoria-core/design/esc_exit.svg"
# Path to the target scene to change to
export(String, FILE, "*.tscn") var target_scene = ""
# Sound effect to play when changing the scene
export(String, FILE, "*.ogg,*.mp3,*.wav") var switch_sound = ""
func _enter_tree():
is_exit = true
player_orients_on_arrival = false
func _ready():
call_deferred("_register_event")
# Registers the exit_scene event based on the properties
func _register_event():
if escoria.object_manager.has(self.global_id) and\
not "exit_scene" in escoria.object_manager.get_object(
self.global_id
).events:
var exit_scene_event_script = [
":exit_scene",
]
if switch_sound != "":
exit_scene_event_script.append(
"play_snd %s" % switch_sound
)
exit_scene_event_script.append("change_scene %s" % target_scene)
var exit_scene_event = escoria.esc_compiler.compile(
exit_scene_event_script
).events["exit_scene"]
escoria.object_manager.get_object(self.global_id)\
.events["exit_scene"] = exit_scene_event

View File

@@ -7,7 +7,7 @@
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=5]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_room.gd" type="Script" id=6]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=7]
[ext_resource path="res://game/rooms/room12/r_door.tscn" type="PackedScene" id=8]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_exit.gd" type="Script" id=8]
[ext_resource path="res://game/items/escitems/button.tscn" type="PackedScene" id=9]
[sub_resource type="NavigationPolygon" id=1]
@@ -68,24 +68,28 @@ position = Vector2( 37.4521, 392.045 )
script = ExtResource( 5 )
global_id = "r12_l_exit"
[node name="r_door" parent="Hotspots" instance=ExtResource( 8 )]
global_id = "r12_r_exit"
esc_script = "res://game/rooms/room12/esc/right_exit.esc"
[node name="ESCLocation" type="Position2D" parent="Hotspots/r_door"]
position = Vector2( 1231.78, 360.624 )
script = ExtResource( 5 )
[node name="button" parent="Hotspots" instance=ExtResource( 9 )]
pause_mode = 1
position = Vector2( 301.706, 73.0751 )
global_id = "r12_button"
esc_script = "res://game/rooms/room12/esc/button.esc"
animations = null
[node name="Position2D" type="Position2D" parent="Hotspots/button"]
position = Vector2( 340.052, 298.812 )
[node name="r_door" type="Area2D" parent="Hotspots"]
script = ExtResource( 8 )
global_id = "r_door"
tooltip_name = "Right exit"
target_scene = "res://game/rooms/room13/room13.tscn"
switch_sound = "res://game/sfx/sounds/doorOpen_2.ogg"
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_door"]
polygon = PoolVector2Array( 1174.44, 47.7028, 1179.5, 355.197, 1277.9, 408.014, 1275.73, 91.8372 )
[node name="ESCLocation" type="Position2D" parent="Hotspots/r_door"]
position = Vector2( 1224.19, 375.505 )
script = ExtResource( 5 )
[node name="player_start" type="Position2D" parent="."]
position = Vector2( 542.824, 468.193 )
script = ExtResource( 5 )

View File

@@ -3,10 +3,10 @@
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_terrain.gd" type="Script" id=1]
[ext_resource path="res://game/rooms/room13/background.tscn" type="PackedScene" id=2]
[ext_resource path="res://game/fonts/caslonantique.tres" type="DynamicFont" id=3]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_exit.gd" type="Script" id=4]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=5]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_room.gd" type="Script" id=6]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=7]
[ext_resource path="res://game/rooms/room13/r_door.tscn" type="PackedScene" id=8]
[sub_resource type="NavigationPolygon" id=1]
vertices = PoolVector2Array( 1168.92, 640.557, 1182.53, 588.863, 1269.59, 622.872, 1275.03, 799.721, 864.626, 613.518, 1143.08, 613.35, -9.16094, 803.802, 386.666, 618.012, 129.634, 615.792, 84.5821, 654.06, -6.44019, 711.297, 3.15687, 646.051, 59.2201, 628.698 )
@@ -67,15 +67,6 @@ position = Vector2( 37.4521, 392.045 )
script = ExtResource( 5 )
global_id = "r12_l_exit"
[node name="r_door" parent="Hotspots" instance=ExtResource( 8 )]
global_id = "r13_r_exit"
esc_script = "res://game/rooms/room13/esc/right_exit.esc"
default_action = "use"
[node name="ESCLocation" type="Position2D" parent="Hotspots/r_door"]
position = Vector2( 1231.78, 360.624 )
script = ExtResource( 5 )
[node name="Hint" type="Area2D" parent="Hotspots"]
pause_mode = 1
script = ExtResource( 7 )
@@ -101,3 +92,14 @@ __meta__ = {
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hotspots/Hint"]
position = Vector2( 651.176, 177.775 )
shape = SubResource( 2 )
[node name="r_door" type="Area2D" parent="Hotspots"]
position = Vector2( 1161.53, -2.99619 )
script = ExtResource( 4 )
target_scene = "res://game/rooms/room14/room14.tscn"
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/r_door"]
polygon = PoolVector2Array( 11.9329, 46.7699, 15.928, 354.381, 118.798, 416.303, 117.799, 90.7143 )
[node name="Position2D" type="Position2D" parent="Hotspots/r_door"]
position = Vector2( 60.9229, 371.53 )

View File

@@ -199,6 +199,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/types/esc_execution.gd"
}, {
"base": "ESCItem",
"class": "ESCExit",
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc_exit.gd"
}, {
"base": "Node2D",
"class": "ESCGame",
"language": "GDScript",
@@ -578,6 +583,7 @@ _global_script_class_icons={
"ESCEvent": "",
"ESCEventManager": "",
"ESCExecution": "",
"ESCExit": "res://addons/escoria-core/design/esc_exit.svg",
"ESCGame": "",
"ESCGlobalsManager": "",
"ESCGroup": "",