Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ba1ba3bafc
16
Dialog-System-Example/Body_Label.gd
Normal file
16
Dialog-System-Example/Body_Label.gd
Normal file
|
@ -0,0 +1,16 @@
|
|||
extends Label
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
149
Dialog-System-Example/Dialog_Player.tscn
Normal file
149
Dialog-System-Example/Dialog_Player.tscn
Normal file
|
@ -0,0 +1,149 @@
|
|||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://Dialog-System-Example/scripts/dialog_player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Dialog-System-Example/textures/menu_section_9patch.png" type="Texture" id=2]
|
||||
[ext_resource path="res://Dialog-System-Example/fonts/speaker_font.tres" type="DynamicFont" id=3]
|
||||
[ext_resource path="res://Dialog-System-Example/fonts/body_font.tres" type="DynamicFont" id=4]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "TextDisplay"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath(".:percent_visible")
|
||||
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=2]
|
||||
loop = true
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath(".:rect_scale")
|
||||
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, 1 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 1, 1 ), Vector2( 1.1, 1.1 ), Vector2( 1, 1 ) ]
|
||||
}
|
||||
|
||||
[node name="Dialog_Player" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Dialog_Box" type="Control" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Body_NinePatchRect" type="NinePatchRect" parent="Dialog_Box"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -360.0
|
||||
margin_top = -128.0
|
||||
margin_right = 360.0
|
||||
margin_bottom = 128.0
|
||||
rect_min_size = Vector2( 720, 256 )
|
||||
texture = ExtResource( 2 )
|
||||
patch_margin_left = 3
|
||||
patch_margin_top = 3
|
||||
patch_margin_right = 3
|
||||
patch_margin_bottom = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Dialog_Box/Body_NinePatchRect"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 16.0
|
||||
margin_top = 48.0
|
||||
margin_right = -16.0
|
||||
margin_bottom = -48.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Body_Label" type="Label" parent="Dialog_Box/Body_NinePatchRect/MarginContainer"]
|
||||
margin_right = 688.0
|
||||
margin_bottom = 160.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
custom_fonts/font = ExtResource( 4 )
|
||||
text = "This is where the dialog text is displayed.
|
||||
Press F6 to run this example. ^_^"
|
||||
|
||||
[node name="Body_AnimationPlayer" type="AnimationPlayer" parent="Dialog_Box/Body_NinePatchRect/MarginContainer/Body_Label"]
|
||||
anims/TextDisplay = SubResource( 1 )
|
||||
|
||||
[node name="Speaker_NinePatchRect" type="NinePatchRect" parent="Dialog_Box/Body_NinePatchRect"]
|
||||
margin_left = -24.3768
|
||||
margin_top = -13.2964
|
||||
margin_right = 155.623
|
||||
margin_bottom = 34.7036
|
||||
rect_min_size = Vector2( 180, 48 )
|
||||
texture = ExtResource( 2 )
|
||||
patch_margin_left = 3
|
||||
patch_margin_top = 3
|
||||
patch_margin_right = 3
|
||||
patch_margin_bottom = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Speaker_Label" type="Label" parent="Dialog_Box/Body_NinePatchRect/Speaker_NinePatchRect"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
custom_fonts/font = ExtResource( 3 )
|
||||
text = "Speaker"
|
||||
align = 1
|
||||
valign = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="SpaceBar_NinePatchRect" type="NinePatchRect" parent="Dialog_Box/Body_NinePatchRect"]
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -231.69
|
||||
margin_top = -40.0
|
||||
margin_right = 24.3102
|
||||
margin_bottom = 8.0
|
||||
rect_min_size = Vector2( 180, 48 )
|
||||
texture = ExtResource( 2 )
|
||||
patch_margin_left = 3
|
||||
patch_margin_top = 3
|
||||
patch_margin_right = 3
|
||||
patch_margin_bottom = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="SpaceBar_Label" type="Label" parent="Dialog_Box/Body_NinePatchRect/SpaceBar_NinePatchRect"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
custom_fonts/font = ExtResource( 3 )
|
||||
text = "Press SpaceBar"
|
||||
align = 1
|
||||
valign = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="SpaceBar_AnimationPlayer" type="AnimationPlayer" parent="Dialog_Box/Body_NinePatchRect/SpaceBar_NinePatchRect"]
|
||||
autoplay = "Blink"
|
||||
anims/Blink = SubResource( 2 )
|
||||
[connection signal="animation_finished" from="Dialog_Box/Body_NinePatchRect/MarginContainer/Body_Label/Body_AnimationPlayer" to="." method="_on_Body_AnimationPlayer_animation_finished"]
|
BIN
Dialog-System-Example/fonts/Cave-Story.ttf
Normal file
BIN
Dialog-System-Example/fonts/Cave-Story.ttf
Normal file
Binary file not shown.
7
Dialog-System-Example/fonts/body_font.tres
Normal file
7
Dialog-System-Example/fonts/body_font.tres
Normal file
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="DynamicFont" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Dialog-System-Example/fonts/Cave-Story.ttf" type="DynamicFontData" id=1]
|
||||
|
||||
[resource]
|
||||
size = 35
|
||||
font_data = ExtResource( 1 )
|
7
Dialog-System-Example/fonts/speaker_font.tres
Normal file
7
Dialog-System-Example/fonts/speaker_font.tres
Normal file
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="DynamicFont" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Dialog-System-Example/fonts/Cave-Story.ttf" type="DynamicFontData" id=1]
|
||||
|
||||
[resource]
|
||||
size = 39
|
||||
font_data = ExtResource( 1 )
|
90
Dialog-System-Example/scripts/dialog_player.gd
Normal file
90
Dialog-System-Example/scripts/dialog_player.gd
Normal file
|
@ -0,0 +1,90 @@
|
|||
extends Node
|
||||
|
||||
onready var _Body_AnimationPlayer = self.find_node("Body_AnimationPlayer")
|
||||
onready var _Body_LBL = self.find_node("Body_Label")
|
||||
onready var _Dialog_Box = self.find_node("Dialog_Box")
|
||||
onready var _Speaker_LBL = self.find_node("Speaker_Label")
|
||||
onready var _SpaceBar_Icon = self.find_node("SpaceBar_NinePatchRect")
|
||||
|
||||
var _did = 0
|
||||
var _nid = 0
|
||||
var _final_nid = 0
|
||||
var _Story_Reader
|
||||
|
||||
# Virtual Methods
|
||||
|
||||
func _ready():
|
||||
var Story_Reader_Class = load("res://addons/EXP-System-Dialog/Reference_StoryReader/EXP_StoryReader.gd")
|
||||
_Story_Reader = Story_Reader_Class.new()
|
||||
|
||||
var story = load("res://Dialog-System-Example/stories/Example_Story_Baked.tres")
|
||||
_Story_Reader.read(story)
|
||||
|
||||
_Dialog_Box.visible = false
|
||||
_SpaceBar_Icon.visible = false
|
||||
|
||||
play_dialog("Plains/Battle/Slime")
|
||||
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventKey:
|
||||
if event.pressed == true and event.scancode == KEY_SPACE:
|
||||
_on_Dialog_Player_pressed_spacebar()
|
||||
|
||||
# Callback Methods
|
||||
|
||||
func _on_Body_AnimationPlayer_animation_finished(anim_name):
|
||||
_SpaceBar_Icon.visible = true
|
||||
|
||||
|
||||
func _on_Dialog_Player_pressed_spacebar():
|
||||
if _is_waiting():
|
||||
_SpaceBar_Icon.visible = false
|
||||
_get_next_node()
|
||||
if _is_playing():
|
||||
_play_node()
|
||||
|
||||
# Public Methods
|
||||
|
||||
func play_dialog(record_name : String):
|
||||
_did = _Story_Reader.get_did_via_record_name(record_name)
|
||||
_nid = self._Story_Reader.get_nid_via_exact_text(_did, "<start>")
|
||||
_final_nid = _Story_Reader.get_nid_via_exact_text(_did, "<end>")
|
||||
_get_next_node()
|
||||
_play_node()
|
||||
_Dialog_Box.visible = true
|
||||
|
||||
# Private Methods
|
||||
|
||||
func _is_playing():
|
||||
return _Dialog_Box.visible
|
||||
|
||||
|
||||
func _is_waiting():
|
||||
return _SpaceBar_Icon.visible
|
||||
|
||||
|
||||
func _get_next_node():
|
||||
_nid = _Story_Reader.get_nid_from_slot(_did, _nid, 0)
|
||||
|
||||
if _nid == _final_nid:
|
||||
_Dialog_Box.visible = false
|
||||
|
||||
|
||||
func _get_tagged_text(tag : String, text : String):
|
||||
var start_tag = "<" + tag + ">"
|
||||
var end_tag = "</" + tag + ">"
|
||||
var start_index = text.find(start_tag) + start_tag.length()
|
||||
var end_index = text.find(end_tag)
|
||||
var substr_length = end_index - start_index
|
||||
return text.substr(start_index, substr_length)
|
||||
|
||||
|
||||
func _play_node():
|
||||
var text = _Story_Reader.get_text(_did, _nid)
|
||||
var speaker = _get_tagged_text("speaker", text)
|
||||
var dialog = _get_tagged_text("dialog", text)
|
||||
|
||||
_Speaker_LBL.text = speaker
|
||||
_Body_LBL.text = dialog
|
||||
_Body_AnimationPlayer.play("TextDisplay")
|
149
Dialog-System-Example/stories/Example_Story.tres
Normal file
149
Dialog-System-Example/stories/Example_Story.tres
Normal file
|
@ -0,0 +1,149 @@
|
|||
[gd_resource type="Resource" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/EXP-System-Dialog/Resource_EditorStory/EXP_EditorStory.gd" type="Script" id=1]
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
TYPE = "EXP_Story_editor"
|
||||
names = {
|
||||
"Plains/Battle/Bandit": 6,
|
||||
"Plains/Battle/Slime": 3,
|
||||
"Sign/Village/West/Exit": 4,
|
||||
"Village/Battle/Elder": 2,
|
||||
"Village/Pot": 5,
|
||||
"Village/Start": 1
|
||||
}
|
||||
story = {
|
||||
1: {
|
||||
"available_nid": [ 1, 2, 3 ],
|
||||
"groups": [ ],
|
||||
"human_readable_description": "Waking up in the sleepy starting village.",
|
||||
"name": "Village/Start",
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
},
|
||||
2: {
|
||||
"available_nid": [ ],
|
||||
"groups": [ ],
|
||||
"human_readable_description": "Village Elder - Battle Tutorial",
|
||||
"name": "Village/Battle/Elder",
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
},
|
||||
3: {
|
||||
"available_nid": [ ],
|
||||
"groups": [ ],
|
||||
"human_readable_description": "Slime Enemy - Trash Talk",
|
||||
"name": "Plains/Battle/Slime",
|
||||
"nodes": {
|
||||
1: {
|
||||
"graph_offset": Vector2( 200, 0 ),
|
||||
"links": {
|
||||
0: 2
|
||||
},
|
||||
"rect_size": Vector2( 324, 137 ),
|
||||
"slot_amount": 1,
|
||||
"text": "<start>",
|
||||
"type": "line"
|
||||
},
|
||||
2: {
|
||||
"graph_offset": Vector2( 400, 160 ),
|
||||
"links": {
|
||||
0: 3
|
||||
},
|
||||
"rect_size": Vector2( 324, 137 ),
|
||||
"slot_amount": 1,
|
||||
"text": "<speaker>Player</speaker>
|
||||
<dialog>You don't look so tough!</dialog>",
|
||||
"type": "line"
|
||||
},
|
||||
3: {
|
||||
"graph_offset": Vector2( 600, 320 ),
|
||||
"links": {
|
||||
0: 4
|
||||
},
|
||||
"rect_size": Vector2( 324, 137 ),
|
||||
"slot_amount": 1,
|
||||
"text": "<speaker>Player</speaker>
|
||||
<dialog>I'll turn you into breakfast jelly!!</dialog>",
|
||||
"type": "line"
|
||||
},
|
||||
4: {
|
||||
"graph_offset": Vector2( 800, 480 ),
|
||||
"links": {
|
||||
0: 5
|
||||
},
|
||||
"rect_size": Vector2( 324, 137 ),
|
||||
"slot_amount": 1,
|
||||
"text": "<speaker>Slime</speaker>
|
||||
<dialog>Eating newbs like you is my jam!</dialog>",
|
||||
"type": "line"
|
||||
},
|
||||
5: {
|
||||
"graph_offset": Vector2( 1000, 640 ),
|
||||
"links": {
|
||||
|
||||
},
|
||||
"rect_size": Vector2( 324, 137 ),
|
||||
"slot_amount": 1,
|
||||
"text": "<end>",
|
||||
"type": "line"
|
||||
}
|
||||
}
|
||||
},
|
||||
4: {
|
||||
"available_nid": [ ],
|
||||
"groups": [ ],
|
||||
"human_readable_description": "Broken Signpost - Nemu Village - West Exit",
|
||||
"name": "Sign/Village/West/Exit",
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
},
|
||||
5: {
|
||||
"available_nid": [ ],
|
||||
"groups": [ ],
|
||||
"human_readable_description": "Suspicious looking pot - disembodied voice.",
|
||||
"name": "Village/Pot",
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
},
|
||||
6: {
|
||||
"available_nid": [ ],
|
||||
"groups": [ ],
|
||||
"human_readable_description": "Getting robbed by the bandit who sucks at being a bandit.",
|
||||
"name": "Plains/Battle/Bandit",
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
},
|
||||
7: {
|
||||
"available_nid": [ ],
|
||||
"groups": [ ],
|
||||
"human_readable_description": "New Dialog - Enter Human Readable Description.",
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
},
|
||||
8: {
|
||||
"available_nid": [ ],
|
||||
"groups": [ ],
|
||||
"human_readable_description": "New Dialog - Enter Human Readable Description.",
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
},
|
||||
9: {
|
||||
"available_nid": [ ],
|
||||
"groups": [ ],
|
||||
"human_readable_description": "New Dialog - Enter Human Readable Description.",
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
available_dids = [ ]
|
||||
groups = [ "Enemies", "Grasslands", "NPCs", "Nemu Village", "Signposts", "Spellbooks", "Tutorials" ]
|
94
Dialog-System-Example/stories/Example_Story_Baked.tres
Normal file
94
Dialog-System-Example/stories/Example_Story_Baked.tres
Normal file
|
@ -0,0 +1,94 @@
|
|||
[gd_resource type="Resource" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/EXP-System-Dialog/Resource_BakedStory/EXP_BakedStory.gd" type="Script" id=1]
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
TYPE = "EXP_Baked_Story"
|
||||
story = {
|
||||
1: {
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
},
|
||||
2: {
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
},
|
||||
3: {
|
||||
"nodes": {
|
||||
1: {
|
||||
"links": {
|
||||
0: 2
|
||||
},
|
||||
"text": "<start>"
|
||||
},
|
||||
2: {
|
||||
"links": {
|
||||
0: 3
|
||||
},
|
||||
"text": "<speaker>Player</speaker>
|
||||
<dialog>You don't look so tough!</dialog>"
|
||||
},
|
||||
3: {
|
||||
"links": {
|
||||
0: 4
|
||||
},
|
||||
"text": "<speaker>Player</speaker>
|
||||
<dialog>I'll turn you into breakfast jelly!!</dialog>"
|
||||
},
|
||||
4: {
|
||||
"links": {
|
||||
0: 5
|
||||
},
|
||||
"text": "<speaker>Slime</speaker>
|
||||
<dialog>Eating newbs like you is my jam!</dialog>"
|
||||
},
|
||||
5: {
|
||||
"links": {
|
||||
|
||||
},
|
||||
"text": "<end>"
|
||||
}
|
||||
}
|
||||
},
|
||||
4: {
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
},
|
||||
5: {
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
},
|
||||
6: {
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
},
|
||||
7: {
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
},
|
||||
8: {
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
},
|
||||
9: {
|
||||
"nodes": {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
names = {
|
||||
"Plains/Battle/Bandit": 6,
|
||||
"Plains/Battle/Slime": 3,
|
||||
"Sign/Village/West/Exit": 4,
|
||||
"Village/Battle/Elder": 2,
|
||||
"Village/Pot": 5,
|
||||
"Village/Start": 1
|
||||
}
|
BIN
Dialog-System-Example/textures/menu_section_9patch.png
Normal file
BIN
Dialog-System-Example/textures/menu_section_9patch.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 296 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/menu_section_9patch.png-beceadcf40f205d430547faaab724953.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Dialog-System-Example/textures/menu_section_9patch.png"
|
||||
dest_files=[ "res://.import/menu_section_9patch.png-beceadcf40f205d430547faaab724953.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=false
|
||||
svg/scale=1.0
|
|
@ -1,7 +1,7 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://art/Wand.png" type="Texture" id=1]
|
||||
[ext_resource path="res://script/ItemPickup.gd" type="Script" id=2]
|
||||
[ext_resource path="res://script/basic_wand_collectable.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "Bounce"
|
||||
|
@ -29,7 +29,7 @@ collision_layer = 0
|
|||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Wand Pickup" type="Sprite" parent="."]
|
||||
position = Vector2( 0, 0.853822 )
|
||||
position = Vector2( 0, -1.83113 )
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
|
|
21
LICENSE.txt
Normal file
21
LICENSE.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 David E Lipps
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
BIN
art/Wand.png
BIN
art/Wand.png
Binary file not shown.
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 170 B |
|
@ -1,10 +1,12 @@
|
|||
[gd_scene load_steps=11 format=2]
|
||||
[gd_scene load_steps=13 format=2]
|
||||
|
||||
[ext_resource path="res://script/player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://ui/PlayerStats.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://meta/BoundedCamera.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://script/PlayerStateMachine.gd" type="Script" id=4]
|
||||
[ext_resource path="res://ui/Inventory.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://art/WizardM.png" type="Texture" id=6]
|
||||
[ext_resource path="res://script/WandManager.gd" type="Script" id=7]
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=1]
|
||||
polygon = PoolVector2Array( -7, 0, -7, -2, -6, -2, -6, -3, -5, -3, -5, -5, -6, -5, -6, -10, -7, -10, -7, -12, -6, -12, -6, -19, -4, -19, -4, -18, -3, -18, -3, -17, 1, -17, 1, -16, 3, -16, 3, -15, 4, -15, 4, -14, 5, -14, 5, -13, 6, -13, 6, -12, 7, -12, 7, -10, 6, -10, 6, -9, 5, -9, 5, -8, 6, -8, 6, -4, 5, -4, 5, 0, -7, 0 )
|
||||
|
@ -66,6 +68,8 @@ height = 4.0
|
|||
collision_mask = 2
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Inventory" parent="." instance=ExtResource( 5 )]
|
||||
|
||||
[node name="Stats" parent="." instance=ExtResource( 2 )]
|
||||
|
||||
[node name="Camera" parent="." instance=ExtResource( 3 )]
|
||||
|
@ -80,8 +84,9 @@ drag_margin_bottom = 0.0
|
|||
[node name="PlayerStateMachine" type="Node" parent="."]
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="HoldPosition" type="Position2D" parent="."]
|
||||
[node name="WandManager" type="Position2D" parent="."]
|
||||
position = Vector2( 0, -7 )
|
||||
script = ExtResource( 7 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0, -12 )
|
||||
|
|
|
@ -1,19 +1,10 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://characters/Player.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://meta/DungeonTilemap.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Items/Basic Wand Pickup.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://art/Pedestal.png" type="Texture" id=4]
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
||||
|
||||
[node name="Pedestal" type="Sprite" parent="."]
|
||||
position = Vector2( 98, 168 )
|
||||
texture = ExtResource( 4 )
|
||||
|
||||
[node name="Wand Pickup" parent="Pedestal" instance=ExtResource( 3 )]
|
||||
position = Vector2( 0, -12 )
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource( 1 )]
|
||||
position = Vector2( 60, 176 )
|
||||
|
||||
|
|
17
magic/Wands/Conduit1.tscn
Normal file
17
magic/Wands/Conduit1.tscn
Normal file
|
@ -0,0 +1,17 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://art/Wand.png" type="Texture" id=1]
|
||||
[ext_resource path="res://script/BasicWand.gd" type="Script" id=2]
|
||||
|
||||
[node name="Conduit1" type="Sprite"]
|
||||
position = Vector2( 7, 0 )
|
||||
rotation = 1.5708
|
||||
texture = ExtResource( 1 )
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="ProjectileSpawn" type="Position2D" parent="."]
|
||||
position = Vector2( -6.11959e-07, -7 )
|
||||
|
||||
[node name="ShootDelay" type="Timer" parent="."]
|
||||
wait_time = 0.3
|
||||
one_shot = true
|
30
magic/projectiles/Projectile1.tscn
Normal file
30
magic/projectiles/Projectile1.tscn
Normal file
|
@ -0,0 +1,30 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://script/Projectile.gd" type="Script" id=1]
|
||||
[ext_resource path="res://art/WhiteProjectile.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 4.0
|
||||
|
||||
[sub_resource type="Environment" id=2]
|
||||
background_mode = 4
|
||||
glow_enabled = true
|
||||
glow_intensity = 0.25
|
||||
glow_bloom = 0.15
|
||||
glow_blend_mode = 0
|
||||
glow_hdr_threshold = 3.29
|
||||
glow_bicubic_upscale = true
|
||||
|
||||
[node name="WhiteProjectile" type="KinematicBody2D"]
|
||||
collision_layer = 8
|
||||
collision_mask = 2
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="WhiteProjectile" type="Sprite" parent="."]
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource( 2 )
|
|
@ -9,6 +9,11 @@
|
|||
config_version=4
|
||||
|
||||
_global_script_classes=[ {
|
||||
"base": "Area2D",
|
||||
"class": "Collectable",
|
||||
"language": "GDScript",
|
||||
"path": "res://script/ItemPickup.gd"
|
||||
}, {
|
||||
"base": "KinematicBody2D",
|
||||
"class": "Projectile",
|
||||
"language": "GDScript",
|
||||
|
@ -20,6 +25,7 @@ _global_script_classes=[ {
|
|||
"path": "res://script/StateMachine.gd"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"Collectable": "",
|
||||
"Projectile": "",
|
||||
"StateMachine": ""
|
||||
}
|
||||
|
|
80
script/Inventory.gd
Normal file
80
script/Inventory.gd
Normal file
|
@ -0,0 +1,80 @@
|
|||
extends CanvasLayer
|
||||
|
||||
var open = false setget set_open
|
||||
|
||||
onready var parent = get_parent()
|
||||
|
||||
var active_conduit = null
|
||||
var active_projectile = null
|
||||
var active_effect = null
|
||||
|
||||
onready var Anim = $AnimationPlayer
|
||||
|
||||
###
|
||||
onready var Conduits = $Conduits
|
||||
onready var Conduit1 = $Inventory/Conduits/Conduit1
|
||||
onready var Conduit2 = $Inventory/Conduits/Conduit2
|
||||
onready var Conduit3 = $Inventory/Conduits/Conduit3
|
||||
onready var Conduit4 = $Inventory/Conduits/Conduit4
|
||||
|
||||
onready var Projectiles = $Inventory/Projectiles
|
||||
onready var Projectile1 = $Inventory/Projectiles/Projectile1
|
||||
onready var Projectile2 = $Inventory/Projectiles/Projectile2
|
||||
onready var Projectile3 = $Inventory/Projectiles/Projectile3
|
||||
onready var Projectile4 = $Inventory/Projectiles/Projectile4
|
||||
|
||||
onready var Effects = $Inventory/Effects
|
||||
onready var Effect1 = $Inventory/Effects/Effect1
|
||||
onready var Effect2 = $Inventory/Effects/Effect2
|
||||
onready var Effect3 = $Inventory/Effects/Effect3
|
||||
onready var Effect4 = $Inventory/Effects/Effect4
|
||||
###
|
||||
|
||||
func _process(delta):
|
||||
if Input.is_action_just_pressed("inventory"):
|
||||
set_open(!open)
|
||||
|
||||
func set_open(new):
|
||||
if open != new:
|
||||
if new == true:
|
||||
Anim.play("SlideIn")
|
||||
if new == false:
|
||||
Anim.play("SlideOut")
|
||||
open = new
|
||||
|
||||
func add_item(index):
|
||||
match index:
|
||||
Globals.Conduit1:
|
||||
Conduit1.visible = true
|
||||
Globals.Conduit2:
|
||||
Conduit2.visible = true
|
||||
Globals.Conduit3:
|
||||
Conduit3.visible = true
|
||||
Globals.Conduit4:
|
||||
Conduit4.visible = true
|
||||
|
||||
Globals.Projectile1:
|
||||
Projectile1.visible = true
|
||||
Globals.Projectile2:
|
||||
Projectile2.visible = true
|
||||
Globals.Projectile3:
|
||||
Projectile3.visible = true
|
||||
Globals.Projectile4:
|
||||
Projectile4.visible = true
|
||||
|
||||
Globals.Effect1:
|
||||
Effect1.visible = true
|
||||
Globals.Effect2:
|
||||
Effect2.visible = true
|
||||
Globals.Conduit3:
|
||||
Effect3.visible = true
|
||||
Globals.Conduit4:
|
||||
Effect4.visible = true
|
||||
|
||||
func _on_Conduit1_toggled(button_pressed):
|
||||
if button_pressed and Conduit1.is_visible():
|
||||
active_conduit = Globals.Magic[Globals.Conduit1]
|
||||
print(active_conduit)
|
||||
parent.WandManager.set_current_conduit(active_conduit)
|
||||
else:
|
||||
parent.WandManager.clear_conduit()
|
|
@ -1,6 +1,7 @@
|
|||
extends Area2D
|
||||
class_name Collectable
|
||||
|
||||
export var Item: PackedScene
|
||||
|
||||
func _on_Area2D_body_entered(body):
|
||||
print(body)
|
||||
queue_free()
|
||||
|
|
12
script/WandManager.gd
Normal file
12
script/WandManager.gd
Normal file
|
@ -0,0 +1,12 @@
|
|||
extends Position2D
|
||||
|
||||
onready var parent = get_parent()
|
||||
onready var inv = parent.Inventory
|
||||
|
||||
func clear_conduit():
|
||||
for c in get_children():
|
||||
c.queue_free()
|
||||
|
||||
func set_current_conduit(conduit):
|
||||
clear_conduit()
|
||||
add_child(conduit.instance())
|
7
script/basic_wand_collectable.gd
Normal file
7
script/basic_wand_collectable.gd
Normal file
|
@ -0,0 +1,7 @@
|
|||
extends Collectable
|
||||
|
||||
|
||||
func _on_Area2D_body_entered(body):
|
||||
if body.get("Inventory") != null:
|
||||
body.Inventory.add_item(Globals.Conduit1)
|
||||
queue_free()
|
|
@ -1,5 +1,43 @@
|
|||
extends Node
|
||||
|
||||
enum {Conduit1, Conduit2, Conduit3, Conduit4, }
|
||||
enum {Projectile1, Projectile2, Projectile3, Projectile4}
|
||||
enum {Effect1, Effect2, Effect3, Effect4}
|
||||
|
||||
const TILE_SIZE = 16
|
||||
|
||||
###
|
||||
var conduit1_ps = preload("res://magic/Wands/Conduit1.tscn")
|
||||
var conduit2_ps
|
||||
var conduit3_ps
|
||||
var conduit4_ps
|
||||
|
||||
var projectile1_ps = preload("res://magic/projectiles/Projectile1.tscn")
|
||||
var projectile2_ps
|
||||
var projectile3_ps
|
||||
var projectile4_ps
|
||||
|
||||
var effect1_ps
|
||||
var effect2_ps
|
||||
var effect3_ps
|
||||
var effect4_ps
|
||||
|
||||
var Magic: Array = [
|
||||
conduit1_ps,
|
||||
conduit2_ps,
|
||||
conduit3_ps,
|
||||
conduit4_ps,
|
||||
projectile1_ps,
|
||||
projectile2_ps,
|
||||
projectile3_ps,
|
||||
projectile4_ps,
|
||||
effect1_ps,
|
||||
effect2_ps,
|
||||
effect3_ps,
|
||||
effect4_ps,
|
||||
]
|
||||
###
|
||||
|
||||
var WHITE_PROJECTILE_PS = preload("res://magic/projectiles/WhiteProjectile.tscn")
|
||||
var basic_wand_ps = preload("res://magic/Wands/BasicWand.tscn")
|
||||
var player = Vector2()
|
||||
|
|
|
@ -24,8 +24,9 @@ onready var Anim: AnimationPlayer = $AnimationPlayer
|
|||
onready var CoyoteTimer: Timer = $CoyoteTimer
|
||||
onready var ShootDelay: Timer = $ShootDelay
|
||||
onready var StateMachine: Node = $PlayerStateMachine
|
||||
onready var HoldPosition: Node2D = $HoldPosition
|
||||
onready var WandManager: Node2D = $WandManager
|
||||
onready var ProjectileSpawn: Node2D = $HoldPosition/ProjectileSpawn
|
||||
onready var Inventory: CanvasLayer = $Inventory
|
||||
onready var Wand
|
||||
onready var Stats = $Stats
|
||||
|
||||
|
@ -62,10 +63,10 @@ func _physics_process(delta):
|
|||
func handle_move_input():
|
||||
input_direction = int(Input.is_action_pressed("right")) - int(Input.is_action_pressed("left"))
|
||||
velocity.x = lerp(velocity.x, speed * input_direction, get_movement_weight())
|
||||
HoldPosition.look_at(get_global_mouse_position())
|
||||
WandManager.look_at(get_global_mouse_position())
|
||||
|
||||
if Input.is_action_pressed("shoot") and Wand != null:
|
||||
Wand.fire_projectile(HoldPosition.rotation_degrees)
|
||||
Wand.fire_projectile(WandManager.rotation_degrees)
|
||||
|
||||
if input_direction > 0:
|
||||
Spr.flip_h = false
|
||||
|
|
70
ui/Inventory.tscn
Normal file
70
ui/Inventory.tscn
Normal file
|
@ -0,0 +1,70 @@
|
|||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://ui/Inventory.png" type="Texture" id=1]
|
||||
[ext_resource path="res://script/Inventory.gd" type="Script" id=2]
|
||||
[ext_resource path="res://art/Wand.png" type="Texture" id=3]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "SlideIn"
|
||||
length = 0.2
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Inventory:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.2 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 160, -43 ), Vector2( 160, 50 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
resource_name = "SlideOut"
|
||||
length = 0.2
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Inventory:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.2 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 160, 50 ), Vector2( 160, -43 ) ]
|
||||
}
|
||||
|
||||
[node name="Inventory" type="CanvasLayer"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/SlideIn = SubResource( 1 )
|
||||
anims/SlideOut = SubResource( 2 )
|
||||
|
||||
[node name="Inventory" type="Sprite" parent="."]
|
||||
position = Vector2( 160, -43 )
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="Conduits" type="Node2D" parent="Inventory"]
|
||||
|
||||
[node name="Conduit1" type="TextureButton" parent="Inventory/Conduits"]
|
||||
light_mask = -2147483647
|
||||
margin_left = -74.0
|
||||
margin_top = -18.0
|
||||
margin_right = -70.0
|
||||
margin_bottom = -4.0
|
||||
toggle_mode = true
|
||||
action_mode = 0
|
||||
texture_normal = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Projectiles" type="Node2D" parent="Inventory"]
|
||||
visible = false
|
||||
|
||||
[node name="Effects" type="Node2D" parent="Inventory"]
|
||||
visible = false
|
||||
[connection signal="toggled" from="Inventory/Conduits/Conduit1" to="." method="_on_Conduit1_toggled"]
|
Loading…
Reference in a new issue