Initial commit
This commit is contained in:
34
scenes/misc/DespawnFX.tscn
Normal file
34
scenes/misc/DespawnFX.tscn
Normal file
@@ -0,0 +1,34 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/characters/DespawnFx.gd" type="Script" id=1]
|
||||
[ext_resource path="res://textures/pj/smoke_particle.png" type="Texture2D" id=2]
|
||||
|
||||
[sub_resource type="Curve" id=1]
|
||||
min_value = -360.0
|
||||
max_value = 360.0
|
||||
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 1 ), 0.0, 0.0, 0, 0 ]
|
||||
|
||||
[sub_resource type="Curve" id=2]
|
||||
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.383915, 0.8806 ), -1.68353, -1.68353, 0, 0, Vector2( 1, 0.0885999 ), -0.00244711, 0.0, 0, 0 ]
|
||||
|
||||
[node name="despawn_fx" type="CPUParticles2D"]
|
||||
position = Vector2( 443.999, 413.999 )
|
||||
emitting = false
|
||||
amount = 16
|
||||
lifetime = 0.5
|
||||
one_shot = true
|
||||
explosiveness = 1.0
|
||||
texture = ExtResource( 2 )
|
||||
direction = Vector2( 0, -1 )
|
||||
gravity = Vector2( 0, 0 )
|
||||
initial_velocity = 1500.0
|
||||
initial_velocity_random = 0.5
|
||||
angular_velocity = 360.0
|
||||
angular_velocity_random = 1.0
|
||||
angular_velocity_curve = SubResource( 1 )
|
||||
linear_accel = -5000.0
|
||||
linear_accel_random = 0.2
|
||||
damping = 100.0
|
||||
scale_amount_random = 0.5
|
||||
scale_amount_curve = SubResource( 2 )
|
||||
script = ExtResource( 1 )
|
||||
43
scenes/misc/Dialog_box.gd
Normal file
43
scenes/misc/Dialog_box.gd
Normal file
@@ -0,0 +1,43 @@
|
||||
extends TextureRect
|
||||
class_name DialogBox
|
||||
|
||||
"""
|
||||
Exposes the show_dialog function to the Dialogs singleton.
|
||||
Will show a dialog box with the name of the character and
|
||||
dialog text, two lines at a time.
|
||||
"""
|
||||
|
||||
@onready var dialog_text = $dialog_text
|
||||
|
||||
# warning-ignore:unused_signal
|
||||
signal dialog_started
|
||||
# warning-ignore:unused_signal
|
||||
signal dialog_ended
|
||||
|
||||
var lines_to_skip = 0
|
||||
|
||||
func _ready():
|
||||
Dialogs.dialog_box = self
|
||||
hide()
|
||||
pass # Replace with function body.
|
||||
|
||||
func show_dialog(new_text, speaker):
|
||||
dialog_text.text = new_text
|
||||
$nametag/label.text = speaker
|
||||
lines_to_skip = 0
|
||||
dialog_text.lines_skipped = lines_to_skip
|
||||
$anims.play("appear")
|
||||
pass
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("interact"):
|
||||
match $anims.assigned_animation:
|
||||
"show_text":
|
||||
$anims.play("wait")
|
||||
"wait":
|
||||
lines_to_skip += 2
|
||||
if lines_to_skip < dialog_text.get_line_count():
|
||||
dialog_text.lines_skipped = lines_to_skip
|
||||
$anims.play("show_text")
|
||||
else:
|
||||
$anims.play("disappear")
|
||||
277
scenes/misc/Dialog_box.tscn
Normal file
277
scenes/misc/Dialog_box.tscn
Normal file
@@ -0,0 +1,277 @@
|
||||
[gd_scene load_steps=9 format=2]
|
||||
|
||||
[ext_resource path="res://fonts/dialog.tres" type="FontFile" id=1]
|
||||
[ext_resource path="res://scenes/misc/Dialog_box.gd" type="Script" id=2]
|
||||
[ext_resource path="res://textures/misc/dialog_box.png" type="Texture2D" id=3]
|
||||
[ext_resource path="res://textures/misc/next_dialog_arrow.png" type="Texture2D" id=4]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "appear"
|
||||
length = 0.1
|
||||
step = 0.01
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("dialog_text:visible_characters")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array( 0 ),
|
||||
"transitions": PackedFloat32Array( 1 ),
|
||||
"update": 1,
|
||||
"values": [ 0 ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath(".:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array( 0, 0.1 ),
|
||||
"transitions": PackedFloat32Array( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath(".:visible")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array( 0 ),
|
||||
"transitions": PackedFloat32Array( 1 ),
|
||||
"update": 1,
|
||||
"values": [ true ]
|
||||
}
|
||||
tracks/3/type = "method"
|
||||
tracks/3/path = NodePath(".")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array( 0 ),
|
||||
"transitions": PackedFloat32Array( 1 ),
|
||||
"values": [ {
|
||||
"args": [ "dialog_started" ],
|
||||
"method": "emit_signal"
|
||||
} ]
|
||||
}
|
||||
tracks/4/type = "value"
|
||||
tracks/4/path = NodePath(".:position")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/imported = false
|
||||
tracks/4/enabled = true
|
||||
tracks/4/keys = {
|
||||
"times": PackedFloat32Array( 0.00472333, 0.1 ),
|
||||
"transitions": PackedFloat32Array( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 585 ), Vector2( 0, 427 ) ]
|
||||
}
|
||||
tracks/5/type = "method"
|
||||
tracks/5/path = NodePath("dialog_text")
|
||||
tracks/5/interp = 1
|
||||
tracks/5/loop_wrap = true
|
||||
tracks/5/imported = false
|
||||
tracks/5/enabled = true
|
||||
tracks/5/keys = {
|
||||
"times": PackedFloat32Array( 0.1 ),
|
||||
"transitions": PackedFloat32Array( 1 ),
|
||||
"values": [ {
|
||||
"args": [ "resized" ],
|
||||
"method": "emit_signal"
|
||||
} ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
resource_name = "disappear"
|
||||
length = 0.1
|
||||
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": PackedFloat32Array( 0, 0.1 ),
|
||||
"transitions": PackedFloat32Array( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath(".:visible")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array( 0.1 ),
|
||||
"transitions": PackedFloat32Array( 1 ),
|
||||
"update": 1,
|
||||
"values": [ false ]
|
||||
}
|
||||
tracks/2/type = "method"
|
||||
tracks/2/path = NodePath(".")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array( 0 ),
|
||||
"transitions": PackedFloat32Array( 1 ),
|
||||
"values": [ {
|
||||
"args": [ "dialog_ended" ],
|
||||
"method": "emit_signal"
|
||||
} ]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/path = NodePath(".:position")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array( 0, 0.1 ),
|
||||
"transitions": PackedFloat32Array( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 427 ), Vector2( 0, 582 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
length = 2.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("dialog_text:visible_characters")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array( 0, 2 ),
|
||||
"transitions": PackedFloat32Array( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ 0, 150 ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("next_dialog_arrow:visible")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array( 0 ),
|
||||
"transitions": PackedFloat32Array( 1 ),
|
||||
"update": 1,
|
||||
"values": [ false ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
loop = true
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("next_dialog_arrow:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array( 0, 0.5 ),
|
||||
"transitions": PackedFloat32Array( 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ true, false ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("dialog_text:visible_characters")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array( 0 ),
|
||||
"transitions": PackedFloat32Array( 1 ),
|
||||
"update": 1,
|
||||
"values": [ 150 ]
|
||||
}
|
||||
|
||||
[node name="Dialog_box" type="TextureRect"]
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -173.0
|
||||
offset_bottom = 1.00024
|
||||
texture = ExtResource( 3 )
|
||||
expand = true
|
||||
stretch_mode = 6
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="dialog_text" type="Label" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 54.0
|
||||
offset_top = 45.0
|
||||
offset_right = -58.0
|
||||
offset_bottom = -38.0
|
||||
theme_override_fonts/font = ExtResource( 1 )
|
||||
theme_override_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In semper molestie erat, id aliquam nulla iaculis a. Suspendisse consectetur vehicula consequat. Integer mollis libero sed sem convallis, vitae rutrum metus dapibus. Phasellus purus quam, euismod id diam ut, semper sagittis ipsum. Aenean vel mollis lectus, quis placerat eros. Donec elementum vestibulum augue dignissim vehicula. Mauris ultricies lacus id odio aliquet, eu iaculis urna sodales. "
|
||||
autowrap = true
|
||||
clip_text = true
|
||||
percent_visible = 0.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="next_dialog_arrow" type="TextureRect" parent="."]
|
||||
visible = false
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -121.545
|
||||
offset_top = -52.964
|
||||
offset_right = -66.5452
|
||||
offset_bottom = -6.96399
|
||||
texture = ExtResource( 4 )
|
||||
expand = true
|
||||
stretch_mode = 6
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="nametag" type="TextureRect" parent="."]
|
||||
offset_left = 31.0
|
||||
offset_top = 1.0
|
||||
offset_right = 524.0
|
||||
offset_bottom = 45.0
|
||||
texture = ExtResource( 3 )
|
||||
expand = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="label" type="Label" parent="nametag"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -227.5
|
||||
offset_top = -21.0
|
||||
offset_right = 227.5
|
||||
offset_bottom = 22.0
|
||||
theme_override_fonts/font = ExtResource( 1 )
|
||||
theme_override_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
text = "Character Name"
|
||||
align = 1
|
||||
clip_text = true
|
||||
|
||||
[node name="anims" type="AnimationPlayer" parent="."]
|
||||
anims/appear = SubResource( 1 )
|
||||
anims/disappear = SubResource( 2 )
|
||||
anims/show_text = SubResource( 3 )
|
||||
anims/wait = SubResource( 4 )
|
||||
next/appear = "show_text"
|
||||
next/show_text = "wait"
|
||||
25
scenes/misc/Exit.gd
Normal file
25
scenes/misc/Exit.gd
Normal file
@@ -0,0 +1,25 @@
|
||||
extends Area2D
|
||||
|
||||
class_name Exit
|
||||
|
||||
"""
|
||||
Add this to any area2d and it will send the player to the indicated scene and spawnpoint
|
||||
"""
|
||||
|
||||
@export var to_scene = "" # (String, FILE, "*.tscn")
|
||||
@export var spawnpoint: String = ""
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
body_entered.connect(_on_body_entered, CONNECT_DEFERRED)
|
||||
|
||||
func _on_body_entered(body):
|
||||
if body is Player:
|
||||
if to_scene == "":
|
||||
push_error("Error changing scenes: to_scene has no assigned scene")
|
||||
return false
|
||||
Globals.spawnpoint = spawnpoint
|
||||
Globals.current_level = to_scene
|
||||
if get_tree().change_scene_to_file(to_scene) != OK:
|
||||
push_error("Error changing scene")
|
||||
pass
|
||||
31
scenes/misc/Healthbar.gd
Normal file
31
scenes/misc/Healthbar.gd
Normal file
@@ -0,0 +1,31 @@
|
||||
extends HBoxContainer
|
||||
|
||||
"""
|
||||
Connects to the player node and shows a health bar in the form of hearts
|
||||
"""
|
||||
|
||||
var player : Player = null
|
||||
var heart_scene = preload("res://scenes/misc/Heart.tscn")
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
# Try to get the player node. If null wait till next frame, rinse, repeat.
|
||||
while (player == null):
|
||||
var player_group = get_tree().get_nodes_in_group("player")
|
||||
if not player_group.is_empty():
|
||||
player = player_group.pop_front()
|
||||
else:
|
||||
await get_tree().idle_frame
|
||||
|
||||
player.health_changed.connect(_on_health_changed)
|
||||
_on_health_changed(player.hitpoints)
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# You should probably rewrite this.
|
||||
func _on_health_changed(new_hp):
|
||||
for child in get_children():
|
||||
child.queue_free()
|
||||
for i in new_hp:
|
||||
var heart = heart_scene.instantiate()
|
||||
add_child(heart)
|
||||
|
||||
13
scenes/misc/Healthbar.tscn
Normal file
13
scenes/misc/Healthbar.tscn
Normal file
@@ -0,0 +1,13 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/misc/Healthbar.gd" type="Script" id=1]
|
||||
|
||||
[node name="Healthbar" type="HBoxContainer"]
|
||||
offset_left = 8.0
|
||||
offset_top = 11.0
|
||||
offset_right = 115.0
|
||||
offset_bottom = 39.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
8
scenes/misc/Heart.tscn
Normal file
8
scenes/misc/Heart.tscn
Normal file
@@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dbue8p0cttono"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://d0ixmmo0xq2ua" path="res://textures/misc/heart.png" id="1"]
|
||||
|
||||
[node name="heart" type="TextureRect"]
|
||||
offset_right = 33.0
|
||||
offset_bottom = 28.0
|
||||
texture = ExtResource("1")
|
||||
19
scenes/misc/ItemSpawner.gd
Normal file
19
scenes/misc/ItemSpawner.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
extends Marker2D
|
||||
|
||||
"""
|
||||
Add this to any node. spawn instances an Item.tscn node with the defined values
|
||||
"""
|
||||
|
||||
|
||||
var item_scene = preload("res://scenes/items/Item.tscn")
|
||||
@export var item_type: String = "Generic Item"
|
||||
@export var amount: int = 1
|
||||
|
||||
|
||||
func spawn():
|
||||
var item = item_scene.instantiate()
|
||||
owner.get_parent().add_child(item)
|
||||
item.global_position = global_position
|
||||
item.item_type = item_type
|
||||
item.amount = amount
|
||||
pass
|
||||
6
scenes/misc/ItemSpawner.tscn
Normal file
6
scenes/misc/ItemSpawner.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/misc/ItemSpawner.gd" type="Script" id=1]
|
||||
|
||||
[node name="item_spawner" type="Marker2D"]
|
||||
script = ExtResource( 1 )
|
||||
28
scenes/misc/MusicTrack.tscn
Normal file
28
scenes/misc/MusicTrack.tscn
Normal file
@@ -0,0 +1,28 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="GDScript" id=1]
|
||||
script/source = "extends Node
|
||||
|
||||
\"\"\"
|
||||
Add this to any level and it'll start playing the indicated song
|
||||
as soon as the level loads
|
||||
\"\"\"
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = \"text\"
|
||||
@export var music_track = \"\" # (String, FILE, \"*.ogg\")
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
if music_track != \"\":
|
||||
Music.play(music_track)
|
||||
pass # Replace with function body.
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
"
|
||||
|
||||
[node name="music_track" type="Node"]
|
||||
script = SubResource( 1 )
|
||||
40
scenes/misc/Quest.gd
Normal file
40
scenes/misc/Quest.gd
Normal file
@@ -0,0 +1,40 @@
|
||||
extends Node
|
||||
|
||||
"""
|
||||
Instance this as a child of any Npc.tscn node and it turns into a
|
||||
quest giver.
|
||||
|
||||
The character will also check if the player has a certain amount of a given item and if true
|
||||
Remove said amount from the players inventory and give some amount of another item as a reward
|
||||
This is only useful for fetch quests but you can also ask for '5 demon horns' or something to turn it
|
||||
into a kill quest.
|
||||
Otherwise you'll have to make a quest system a bit more complex.
|
||||
"""
|
||||
|
||||
@export var quest_name: String = "Life as a Rappi Guy"
|
||||
|
||||
@export var required_item: String = "Generic Item"
|
||||
@export var required_amount: int = 10
|
||||
@export var reward_item: String = "Generic Reward"
|
||||
@export var reward_amount: int = 1
|
||||
|
||||
@export var initial_text = "TLDR; bring me 10 thingies" # (String, MULTILINE)
|
||||
@export var pending_text = "You forgot? I want 10 thingies" # (String, MULTILINE)
|
||||
@export var delivered_text = "Thank you! Here's your reward.." # (String, MULTILINE)
|
||||
|
||||
func process() -> String:
|
||||
var quest_status = Quest.get_status(quest_name)
|
||||
match quest_status:
|
||||
Quest.STATUS.NONEXISTENT:
|
||||
Quest.accept_quest(quest_name)
|
||||
return initial_text
|
||||
Quest.STATUS.STARTED:
|
||||
if Inventory.get_item(required_item) >= required_amount:
|
||||
Inventory.remove_item(required_item, required_amount)
|
||||
Quest.change_status(quest_name, Quest.STATUS.COMPLETE)
|
||||
Inventory.add_item(reward_item, reward_amount)
|
||||
return delivered_text
|
||||
else:
|
||||
return pending_text
|
||||
_:
|
||||
return ""
|
||||
6
scenes/misc/Quest.tscn
Normal file
6
scenes/misc/Quest.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dwu2tlrkse1kh"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/misc/Quest.gd" id="1"]
|
||||
|
||||
[node name="Quest" type="Node"]
|
||||
script = ExtResource("1")
|
||||
54
scenes/misc/Stats.gd
Normal file
54
scenes/misc/Stats.gd
Normal file
@@ -0,0 +1,54 @@
|
||||
extends PanelContainer
|
||||
|
||||
var enabled = false
|
||||
|
||||
func _ready():
|
||||
Globals.save_game()
|
||||
get_tree().set_auto_accept_quit(false)
|
||||
hide()
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("pause"):
|
||||
enabled = !enabled
|
||||
visible = enabled
|
||||
get_tree().paused = enabled
|
||||
if enabled:
|
||||
grab_focus()
|
||||
_update_quest_listing()
|
||||
_update_item_listing()
|
||||
|
||||
func _update_quest_listing():
|
||||
var text = ""
|
||||
text += "Started:\n"
|
||||
for quest in Quest.list(Quest.STATUS.STARTED):
|
||||
text += " %s\n" % quest
|
||||
text += "Failed:\n"
|
||||
for quest in Quest.list(Quest.STATUS.FAILED):
|
||||
text += " %s\n" % quest
|
||||
|
||||
$VBoxContainer/HBoxContainer/Quests/Details.text = text
|
||||
pass
|
||||
|
||||
func _update_item_listing():
|
||||
var text = ""
|
||||
var inventory = Inventory.list()
|
||||
if inventory.is_empty():
|
||||
text += "[Empty]"
|
||||
for item in inventory:
|
||||
text += "%s x %s\n" % [item, inventory[item]]
|
||||
$VBoxContainer/HBoxContainer/Inventory/Details.text = text
|
||||
pass
|
||||
|
||||
|
||||
|
||||
func _on_Exit_pressed():
|
||||
quit_game()
|
||||
pass # Replace with function body.
|
||||
|
||||
func _notification(what):
|
||||
if what == NOTIFICATION_WM_CLOSE_REQUEST:
|
||||
quit_game()
|
||||
|
||||
func quit_game():
|
||||
Globals.save_game()
|
||||
get_tree().quit()
|
||||
101
scenes/misc/Stats.tscn
Normal file
101
scenes/misc/Stats.tscn
Normal file
@@ -0,0 +1,101 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/misc/Stats.gd" type="Script" id=1]
|
||||
[ext_resource path="res://fonts/dialog.tres" type="FontFile" id=2]
|
||||
[ext_resource path="res://fonts/stats.tres" type="FontFile" id=3]
|
||||
[ext_resource path="res://scenes/misc/stats.stylebox" type="StyleBox" id=4]
|
||||
|
||||
[node name="Stats" type="PanelContainer"]
|
||||
process_mode = 3
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
focus_neighbor_top = NodePath("VBoxContainer/Exit")
|
||||
focus_neighbor_bottom = NodePath("VBoxContainer/Exit")
|
||||
focus_mode = 2
|
||||
theme_override_styles/panel = ExtResource( 4 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
offset_left = 20.0
|
||||
offset_top = 20.0
|
||||
offset_right = 1004.0
|
||||
offset_bottom = 580.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Paused" type="Label" parent="VBoxContainer"]
|
||||
offset_right = 984.0
|
||||
offset_bottom = 43.0
|
||||
theme_override_fonts/font = ExtResource( 2 )
|
||||
text = "Paused"
|
||||
align = 1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
offset_top = 47.0
|
||||
offset_right = 984.0
|
||||
offset_bottom = 507.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
alignment = 1
|
||||
|
||||
[node name="Quests" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
offset_right = 490.0
|
||||
offset_bottom = 460.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Title" type="Label" parent="VBoxContainer/HBoxContainer/Quests"]
|
||||
offset_right = 490.0
|
||||
offset_bottom = 43.0
|
||||
size_flags_horizontal = 3
|
||||
theme_override_fonts/font = ExtResource( 2 )
|
||||
text = "Quests"
|
||||
align = 1
|
||||
|
||||
[node name="Details" type="Label" parent="VBoxContainer/HBoxContainer/Quests"]
|
||||
offset_top = 47.0
|
||||
offset_right = 490.0
|
||||
offset_bottom = 460.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_fonts/font = ExtResource( 3 )
|
||||
text = "Quest 1
|
||||
Quest 2
|
||||
Quest 3
|
||||
Quest 4"
|
||||
|
||||
[node name="Inventory" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
offset_left = 494.0
|
||||
offset_right = 984.0
|
||||
offset_bottom = 460.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Title" type="Label" parent="VBoxContainer/HBoxContainer/Inventory"]
|
||||
offset_right = 490.0
|
||||
offset_bottom = 43.0
|
||||
theme_override_fonts/font = ExtResource( 2 )
|
||||
text = "Inventory"
|
||||
align = 1
|
||||
|
||||
[node name="Details" type="Label" parent="VBoxContainer/HBoxContainer/Inventory"]
|
||||
offset_top = 47.0
|
||||
offset_right = 490.0
|
||||
offset_bottom = 460.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_fonts/font = ExtResource( 3 )
|
||||
text = "Item 1
|
||||
"
|
||||
|
||||
[node name="Exit" type="Button" parent="VBoxContainer"]
|
||||
offset_top = 511.0
|
||||
offset_right = 984.0
|
||||
offset_bottom = 560.0
|
||||
theme_override_fonts/font = ExtResource( 2 )
|
||||
text = "EXIT"
|
||||
flat = true
|
||||
[connection signal="pressed" from="VBoxContainer/Exit" to="." method="_on_Exit_pressed"]
|
||||
48
scenes/misc/StatusText.gd
Normal file
48
scenes/misc/StatusText.gd
Normal file
@@ -0,0 +1,48 @@
|
||||
extends Label
|
||||
|
||||
"""
|
||||
Connects to the inventory and quest systems and will show a message on screen
|
||||
for every change in either
|
||||
"""
|
||||
|
||||
var messages = []
|
||||
|
||||
|
||||
func _ready():
|
||||
hide()
|
||||
Quest.quest_changed.connect(_questlog_updated)
|
||||
Inventory.item_changed.connect(_inventory_updated)
|
||||
|
||||
|
||||
func _questlog_updated(quest_name, status):
|
||||
var txt
|
||||
match status:
|
||||
Quest.STATUS.STARTED:
|
||||
txt = "Quest aquired: %s." % quest_name
|
||||
Quest.STATUS.COMPLETE:
|
||||
txt = "Quest complete! %s." % quest_name
|
||||
_queue_message(txt)
|
||||
pass
|
||||
|
||||
func _inventory_updated(action, type, amount):
|
||||
var txt
|
||||
match action:
|
||||
"added":
|
||||
txt = "Obtained %s x %s" % [type, amount]
|
||||
"removed":
|
||||
txt = "Lost %s x %s" % [type, amount]
|
||||
_queue_message(txt)
|
||||
pass
|
||||
|
||||
func _queue_message(p_text):
|
||||
messages.push_back(p_text)
|
||||
if not $anims.is_playing():
|
||||
_play_next()
|
||||
pass
|
||||
|
||||
func _play_next():
|
||||
if messages.is_empty():
|
||||
return
|
||||
else:
|
||||
text = messages.pop_front()
|
||||
$anims.queue("update")
|
||||
76
scenes/misc/StatusText.tscn
Normal file
76
scenes/misc/StatusText.tscn
Normal file
@@ -0,0 +1,76 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://iu0aegkhj8po"]
|
||||
|
||||
[ext_resource type="FontFile" path="res://fonts/stats.tres" id="1"]
|
||||
[ext_resource type="Script" path="res://scenes/misc/StatusText.gd" id="2"]
|
||||
|
||||
[sub_resource type="Animation" id="1"]
|
||||
resource_name = "update"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [true, false]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||
}
|
||||
tracks/2/type = "method"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath(".")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(1),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"values": [{
|
||||
"args": [],
|
||||
"method": &"_play_next"
|
||||
}]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_jtjwp"]
|
||||
_data = {
|
||||
"update": SubResource("1")
|
||||
}
|
||||
|
||||
[node name="Status_text" type="Label"]
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
anchors_preset = 14
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_top = 90.609
|
||||
offset_bottom = 121.609
|
||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
theme_override_fonts/font = ExtResource("1")
|
||||
text = "Got x thingie"
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
visible = false
|
||||
show_behind_parent = true
|
||||
layout_mode = 0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
color = Color(0, 0, 0, 0.784314)
|
||||
|
||||
[node name="anims" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_jtjwp")
|
||||
}
|
||||
27
scenes/misc/TouchInterface.gd
Normal file
27
scenes/misc/TouchInterface.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
|
||||
func _ready():
|
||||
Dialogs.dialog_started.connect(_on_dialog_started)
|
||||
Dialogs.dialog_ended.connect(_on_dialog_ended)
|
||||
|
||||
|
||||
func _on_dialog_started():
|
||||
for child in get_children():
|
||||
child.hide()
|
||||
$interact.show()
|
||||
|
||||
func _on_dialog_ended():
|
||||
for child in get_children():
|
||||
child.show()
|
||||
|
||||
|
||||
func _notification(what):
|
||||
if what == NOTIFICATION_PAUSED:
|
||||
for child in get_children():
|
||||
child.hide()
|
||||
$stats.show()
|
||||
elif what == NOTIFICATION_UNPAUSED:
|
||||
for child in get_children():
|
||||
child.show()
|
||||
71
scenes/misc/UI.tscn
Normal file
71
scenes/misc/UI.tscn
Normal file
@@ -0,0 +1,71 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://deqgnj30xx13t"]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://scenes/misc/Dialog_box.tscn" id="1"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/misc/Stats.tscn" id="2"]
|
||||
[ext_resource type="PackedScene" uid="uid://iu0aegkhj8po" path="res://scenes/misc/StatusText.tscn" id="3"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/misc/Healthbar.tscn" id="4"]
|
||||
[ext_resource type="Script" path="res://scenes/misc/TouchInterface.gd" id="7"]
|
||||
[ext_resource type="Texture2D" uid="uid://bf8tm281iqk3u" path="res://textures/misc/arrow.png" id="10"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="1"]
|
||||
size = Vector2(60, 200)
|
||||
|
||||
[node name="UI" type="CanvasLayer"]
|
||||
|
||||
[node name="Dialog_box" parent="." instance=ExtResource("1")]
|
||||
visible = false
|
||||
anchors_preset = 12
|
||||
offset_top = -128.0
|
||||
offset_bottom = 46.0002
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
expand_mode = 1
|
||||
|
||||
[node name="Stats" parent="." instance=ExtResource("2")]
|
||||
anchors_preset = 15
|
||||
|
||||
[node name="Status_text" parent="." instance=ExtResource("3")]
|
||||
visible = false
|
||||
|
||||
[node name="Healthbar" parent="." instance=ExtResource("4")]
|
||||
visible = false
|
||||
offset_right = 14.0
|
||||
|
||||
[node name="TouchInterface" type="Node2D" parent="."]
|
||||
modulate = Color(1, 1, 1, 0.501961)
|
||||
script = ExtResource("7")
|
||||
|
||||
[node name="right" type="TouchScreenButton" parent="TouchInterface"]
|
||||
position = Vector2(176.899, 410.258)
|
||||
texture_normal = ExtResource("10")
|
||||
shape = SubResource("1")
|
||||
passby_press = true
|
||||
action = "move_right"
|
||||
visibility_mode = 1
|
||||
|
||||
[node name="up" type="TouchScreenButton" parent="TouchInterface"]
|
||||
position = Vector2(105.679, 427.331)
|
||||
rotation = -1.5708
|
||||
texture_normal = ExtResource("10")
|
||||
shape = SubResource("1")
|
||||
passby_press = true
|
||||
action = "move_up"
|
||||
visibility_mode = 1
|
||||
|
||||
[node name="left" type="TouchScreenButton" parent="TouchInterface"]
|
||||
position = Vector2(123.46, 497.427)
|
||||
rotation = -3.14159
|
||||
texture_normal = ExtResource("10")
|
||||
shape = SubResource("1")
|
||||
passby_press = true
|
||||
action = "move_left"
|
||||
visibility_mode = 1
|
||||
|
||||
[node name="down" type="TouchScreenButton" parent="TouchInterface"]
|
||||
position = Vector2(193.923, 480.742)
|
||||
rotation = 1.5708
|
||||
texture_normal = ExtResource("10")
|
||||
shape = SubResource("1")
|
||||
passby_press = true
|
||||
action = "move_down"
|
||||
visibility_mode = 1
|
||||
BIN
scenes/misc/stats.stylebox
Normal file
BIN
scenes/misc/stats.stylebox
Normal file
Binary file not shown.
Reference in New Issue
Block a user