提交新版魔塔代码

This commit is contained in:
freewu32 2020-08-21 10:16:32 +08:00
parent 72fcd09ce9
commit 00c1714afd
97 changed files with 2924 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/.import

56
Main.gd Normal file
View File

@ -0,0 +1,56 @@
extends Node2D
class_name Main
func _ready():
connect_player_properties_update()
connect_level_update()
init_bgm()
func connect_player_properties_update():
var player = get_level_manager().get_current_level_instance().get_player()
player.connect("hp_changed",self,"on_hp_changed")
player.connect("atk_changed",self,"on_atk_changed")
player.connect("def_changed",self,"on_def_changed")
player.connect("money_changed",self,"on_money_changed")
player.connect("yellow_key_changed",self,"on_yellow_key_changed")
player.connect("blue_key_changed",self,"on_blue_key_changed")
player.connect("red_key_changed",self,"on_red_key_changed")
func connect_level_update():
get_level_manager().connect("level_changed",self,"on_level_changed")
func init_bgm():
var audio_player = $BgmSound as AudioStreamPlayer2D
audio_player.playing = true
func on_hp_changed(hp):
get_hud().get_hp_view().text = hp as String
func on_atk_changed(atk):
get_hud().get_atk_view().text = atk as String
func on_def_changed(def):
get_hud().get_def_view().text = def as String
func on_money_changed(money):
get_hud().get_money_view().text = money as String
func on_yellow_key_changed(yellow_key):
get_hud().get_yellow_key_view().text = "%0*d" % [2,yellow_key]
func on_blue_key_changed(blue_key):
get_hud().get_blue_key_view().text = "%0*d" % [2,blue_key]
func on_red_key_changed(red_key):
get_hud().get_red_key_view().text = "%0*d" % [2,red_key]
func on_level_changed(level):
connect_player_properties_update()
get_hud().get_level_view().text = "%s" % level
func get_hud() -> Hud:
return $HUD as Hud
func get_level_manager() -> LevelsManager:
return $Level as LevelsManager

413
Main.tscn Normal file
View File

@ -0,0 +1,413 @@
[gd_scene load_steps=23 format=2]
[ext_resource path="res://src/levels/Level1.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/sounds/bgm.ogg" type="AudioStream" id=5]
[ext_resource path="res://assets/images/ground.png" type="Texture" id=6]
[ext_resource path="res://assets/images/icons_old.png" type="Texture" id=7]
[ext_resource path="res://assets/fonts/Droid Sans Fallback.tres" type="DynamicFont" id=8]
[ext_resource path="res://src/level/LevelsManager.gd" type="Script" id=10]
[ext_resource path="res://src/hud/HUD.gd" type="Script" id=11]
[ext_resource path="res://Main.gd" type="Script" id=12]
[sub_resource type="AtlasTexture" id=1]
flags = 4
atlas = ExtResource( 7 )
region = Rect2( 0, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=2]
flags = 4
atlas = ExtResource( 7 )
region = Rect2( 0, 96, 32, 32 )
[sub_resource type="AtlasTexture" id=3]
flags = 4
atlas = ExtResource( 7 )
region = Rect2( 0, 128, 32, 32 )
[sub_resource type="AtlasTexture" id=4]
flags = 4
atlas = ExtResource( 7 )
region = Rect2( 0, 160, 32, 32 )
[sub_resource type="AtlasTexture" id=5]
flags = 4
atlas = ExtResource( 7 )
region = Rect2( 0, 192, 32, 32 )
[sub_resource type="StreamTexture" id=6]
flags = 4
load_path = "res://.import/icons_old.png-15488db7964fa7b4e69cdc7d96c7bd7f.stex"
[sub_resource type="AtlasTexture" id=7]
flags = 4
atlas = SubResource( 6 )
region = Rect2( 0, 320, 32, 32 )
[sub_resource type="AtlasTexture" id=8]
flags = 4
atlas = SubResource( 6 )
region = Rect2( 0, 352, 32, 32 )
[sub_resource type="AtlasTexture" id=9]
flags = 4
atlas = SubResource( 6 )
region = Rect2( 0, 384, 32, 32 )
[sub_resource type="AtlasTexture" id=10]
flags = 4
atlas = SubResource( 6 )
region = Rect2( 0, 544, 32, 32 )
[sub_resource type="AtlasTexture" id=11]
flags = 4
atlas = SubResource( 6 )
region = Rect2( 0, 448, 32, 32 )
[sub_resource type="AtlasTexture" id=12]
flags = 4
atlas = SubResource( 6 )
region = Rect2( 0, 480, 32, 32 )
[sub_resource type="AtlasTexture" id=13]
flags = 4
atlas = SubResource( 6 )
region = Rect2( 0, 512, 32, 32 )
[sub_resource type="AtlasTexture" id=14]
flags = 4
atlas = SubResource( 6 )
region = Rect2( 0, 544, 32, 32 )
[node name="Main" type="Node2D"]
script = ExtResource( 12 )
[node name="HUD" type="CanvasLayer" parent="."]
script = ExtResource( 11 )
[node name="HeaderBackground" type="TextureRect" parent="HUD"]
margin_right = 414.0
margin_bottom = 96.0
texture = ExtResource( 6 )
stretch_mode = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="GridContainer" type="GridContainer" parent="HUD/HeaderBackground"]
margin_left = 16.0
margin_top = 1.0
margin_right = 398.0
margin_bottom = 33.0
columns = 6
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Location" type="TextureRect" parent="HUD/HeaderBackground/GridContainer"]
margin_right = 32.0
margin_bottom = 32.0
texture = SubResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="LevelLabel" type="Label" parent="HUD/HeaderBackground/GridContainer"]
margin_left = 36.0
margin_top = 5.0
margin_right = 124.0
margin_bottom = 27.0
size_flags_horizontal = 3
custom_fonts/font = ExtResource( 8 )
text = "1层"
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Location2" type="TextureRect" parent="HUD/HeaderBackground/GridContainer"]
margin_left = 128.0
margin_right = 160.0
margin_bottom = 32.0
texture = SubResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HpLabel" type="Label" parent="HUD/HeaderBackground/GridContainer"]
margin_left = 164.0
margin_top = 5.0
margin_right = 252.0
margin_bottom = 27.0
size_flags_horizontal = 3
custom_fonts/font = ExtResource( 8 )
text = "1000"
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Location3" type="TextureRect" parent="HUD/HeaderBackground/GridContainer"]
margin_left = 256.0
margin_right = 288.0
margin_bottom = 32.0
texture = SubResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="AtkLabel" type="Label" parent="HUD/HeaderBackground/GridContainer"]
margin_left = 292.0
margin_top = 5.0
margin_right = 380.0
margin_bottom = 27.0
size_flags_horizontal = 3
custom_fonts/font = ExtResource( 8 )
text = "10"
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="GridContainer2" type="GridContainer" parent="HUD/HeaderBackground"]
margin_left = 16.0
margin_top = 33.0
margin_right = 268.0
margin_bottom = 65.0
columns = 4
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Location" type="TextureRect" parent="HUD/HeaderBackground/GridContainer2"]
margin_right = 32.0
margin_bottom = 32.0
texture = SubResource( 4 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="DefLabel" type="Label" parent="HUD/HeaderBackground/GridContainer2"]
margin_left = 36.0
margin_top = 5.0
margin_right = 124.0
margin_bottom = 27.0
size_flags_horizontal = 3
custom_fonts/font = ExtResource( 8 )
text = "10"
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Location2" type="TextureRect" parent="HUD/HeaderBackground/GridContainer2"]
margin_left = 128.0
margin_right = 160.0
margin_bottom = 32.0
texture = SubResource( 5 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ExpLabel" type="Label" parent="HUD/HeaderBackground/GridContainer2"]
margin_left = 164.0
margin_top = 5.0
margin_right = 252.0
margin_bottom = 27.0
size_flags_horizontal = 3
custom_fonts/font = ExtResource( 8 )
text = "0"
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="GridContainer3" type="GridContainer" parent="HUD/HeaderBackground"]
margin_left = 268.0
margin_top = 33.0
margin_right = 360.0
margin_bottom = 65.0
columns = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="YellowKeyCount" type="Label" parent="HUD/HeaderBackground/GridContainer3"]
margin_right = 28.0
margin_bottom = 32.0
size_flags_horizontal = 3
size_flags_vertical = 7
custom_fonts/font = ExtResource( 8 )
text = "00"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="BlueKeyCount" type="Label" parent="HUD/HeaderBackground/GridContainer3"]
margin_left = 32.0
margin_right = 60.0
margin_bottom = 32.0
size_flags_horizontal = 3
size_flags_vertical = 7
custom_fonts/font = ExtResource( 8 )
text = "00"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="RedKeyCount" type="Label" parent="HUD/HeaderBackground/GridContainer3"]
margin_left = 64.0
margin_right = 92.0
margin_bottom = 32.0
size_flags_horizontal = 3
size_flags_vertical = 7
custom_fonts/font = ExtResource( 8 )
text = "00"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="BottomBackground" type="TextureRect" parent="HUD"]
margin_top = 512.0
margin_right = 414.0
margin_bottom = 544.0
texture = ExtResource( 6 )
stretch_mode = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="GridContainer" parent="HUD/BottomBackground"]
anchor_left = 0.231
anchor_top = 0.238
anchor_right = 0.329
anchor_bottom = 0.238
margin_left = -87.634
margin_top = -4.616
margin_right = 221.598
margin_bottom = 27.384
rect_scale = Vector2( 0.8, 0.8 )
columns = 8
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TextureButton" type="TextureButton" parent="HUD/BottomBackground/VBoxContainer"]
margin_right = 40.0
margin_bottom = 32.0
size_flags_horizontal = 3
texture_normal = SubResource( 7 )
[node name="TextureButton2" type="TextureButton" parent="HUD/BottomBackground/VBoxContainer"]
margin_left = 44.0
margin_right = 84.0
margin_bottom = 32.0
size_flags_horizontal = 3
texture_normal = SubResource( 8 )
[node name="TextureButton3" type="TextureButton" parent="HUD/BottomBackground/VBoxContainer"]
margin_left = 88.0
margin_right = 128.0
margin_bottom = 32.0
size_flags_horizontal = 3
texture_normal = SubResource( 9 )
[node name="TextureButton4" type="TextureButton" parent="HUD/BottomBackground/VBoxContainer"]
margin_left = 132.0
margin_right = 172.0
margin_bottom = 32.0
size_flags_horizontal = 3
texture_normal = SubResource( 10 )
[node name="TextureButton5" type="TextureButton" parent="HUD/BottomBackground/VBoxContainer"]
margin_left = 176.0
margin_right = 216.0
margin_bottom = 32.0
size_flags_horizontal = 3
texture_normal = SubResource( 11 )
[node name="SaveButton" type="TextureButton" parent="HUD/BottomBackground/VBoxContainer"]
margin_left = 220.0
margin_right = 260.0
margin_bottom = 32.0
size_flags_horizontal = 3
texture_normal = SubResource( 12 )
[node name="LoadButton" type="TextureButton" parent="HUD/BottomBackground/VBoxContainer"]
margin_left = 264.0
margin_right = 304.0
margin_bottom = 32.0
size_flags_horizontal = 3
texture_normal = SubResource( 13 )
[node name="TextureButton8" type="TextureButton" parent="HUD/BottomBackground/VBoxContainer"]
margin_left = 308.0
margin_right = 348.0
margin_bottom = 32.0
size_flags_horizontal = 3
texture_normal = SubResource( 14 )
[node name="Label" type="Label" parent="HUD/BottomBackground"]
margin_left = 288.0
margin_right = 414.0
margin_bottom = 32.0
size_flags_horizontal = 3
custom_fonts/font = ExtResource( 8 )
custom_colors/font_color = Color( 1, 0.0313726, 0.0313726, 1 )
custom_colors/font_outline_modulate = Color( 0, 0, 0, 1 )
text = "Normal"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MessageDialog" type="PopupDialog" parent="HUD"]
margin_top = 96.0
margin_right = 414.0
margin_bottom = 224.0
__meta__ = {
"_edit_group_": true,
"_edit_use_anchors_": false
}
[node name="ContentLabel" type="Label" parent="HUD/MessageDialog"]
anchor_left = 0.022
anchor_top = 0.02
anchor_right = 0.044
anchor_bottom = 0.02
margin_left = -1.108
margin_top = 5.44
margin_right = 386.784
margin_bottom = 93.44
custom_fonts/font = ExtResource( 8 )
text = "测试"
autowrap = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ClickLabel" type="Label" parent="HUD/MessageDialog"]
margin_left = 328.0
margin_top = 96.0
margin_right = 404.0
margin_bottom = 118.0
custom_fonts/font = ExtResource( 8 )
text = "点击继续..."
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Level" type="Node2D" parent="."]
script = ExtResource( 10 )
[node name="Level1" parent="Level" instance=ExtResource( 1 )]
[node name="BgmSound" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource( 5 )
volume_db = -10.0

View File

@ -0,0 +1,6 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://assets/fonts/Droid Sans Fallback.ttf" type="DynamicFontData" id=1]
[resource]
font_data = ExtResource( 1 )

Binary file not shown.

BIN
assets/images/airwall.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/airwall.png-4e50710bad9d32d0e9241a41c05f5b66.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/airwall.png"
dest_files=[ "res://.import/airwall.png-4e50710bad9d32d0e9241a41c05f5b66.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
assets/images/animates.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/animates.png-c4cc1e3aa63596e2506166b7dbfe1d0e.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/animates.png"
dest_files=[ "res://.import/animates.png-c4cc1e3aa63596e2506166b7dbfe1d0e.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
assets/images/brave.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/brave.png-f231128af6d2f6f5f51b0c8f58f6ae81.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/brave.png"
dest_files=[ "res://.import/brave.png-f231128af6d2f6f5f51b0c8f58f6ae81.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

BIN
assets/images/cloud.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/cloud.png-146b185731b4d423da840e465a283aef.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/cloud.png"
dest_files=[ "res://.import/cloud.png-146b185731b4d423da840e465a283aef.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
assets/images/enemy48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/enemy48.png-f82b9046530986dab82bb8ea38951bf2.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/enemy48.png"
dest_files=[ "res://.import/enemy48.png-f82b9046530986dab82bb8ea38951bf2.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
assets/images/enemys.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/enemys.png-a6f94a87f989d30addc7b764fabf062a.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/enemys.png"
dest_files=[ "res://.import/enemys.png-a6f94a87f989d30addc7b764fabf062a.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
assets/images/fog.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/fog.png-17b90af73551b22c82800396bd465452.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/fog.png"
dest_files=[ "res://.import/fog.png-17b90af73551b22c82800396bd465452.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
assets/images/ground.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/ground.png-a10a452afa2dab242aacf15617dc4109.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/ground.png"
dest_files=[ "res://.import/ground.png-a10a452afa2dab242aacf15617dc4109.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
assets/images/icons.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icons.png-c94cfcbcfb14d55ce62faf7c1b93c35f.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/icons.png"
dest_files=[ "res://.import/icons.png-c94cfcbcfb14d55ce62faf7c1b93c35f.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=1
flags/anisotropic=false
flags/srgb=0
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
assets/images/icons_old.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icons_old.png-15488db7964fa7b4e69cdc7d96c7bd7f.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/icons_old.png"
dest_files=[ "res://.import/icons_old.png-15488db7964fa7b4e69cdc7d96c7bd7f.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
assets/images/items.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/items.png-4b6e1e121326a6fdd441b53d99ff45dd.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/items.png"
dest_files=[ "res://.import/items.png-4b6e1e121326a6fdd441b53d99ff45dd.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
assets/images/keyboard.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/keyboard.png-26c333563bfa661a0dd64d702396d55a.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/keyboard.png"
dest_files=[ "res://.import/keyboard.png-26c333563bfa661a0dd64d702396d55a.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
assets/images/npc48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/npc48.png-4049254b2a727e49b803bc9fa2060e34.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/npc48.png"
dest_files=[ "res://.import/npc48.png-4049254b2a727e49b803bc9fa2060e34.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
assets/images/npcs.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/npcs.png-459d8433e25c2ee1212d2ec00b6c919e.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/npcs.png"
dest_files=[ "res://.import/npcs.png-459d8433e25c2ee1212d2ec00b6c919e.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
assets/images/terrains.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/terrains.png-14f083ec1ac3884eb67f9f57f70e1428.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/images/terrains.png"
dest_files=[ "res://.import/terrains.png-14f083ec1ac3884eb67f9f57f70e1428.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

BIN
assets/sounds/attack.ogg Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/attack.ogg-da9a01799924066967d855df94d38170.oggstr"
[deps]
source_file="res://assets/sounds/attack.ogg"
dest_files=[ "res://.import/attack.ogg-da9a01799924066967d855df94d38170.oggstr" ]
[params]
loop=false
loop_offset=0

BIN
assets/sounds/bgm.ogg Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/bgm.ogg-e8f5f96c6d648d158f9dc999735d182f.oggstr"
[deps]
source_file="res://assets/sounds/bgm.ogg"
dest_files=[ "res://.import/bgm.ogg-e8f5f96c6d648d158f9dc999735d182f.oggstr" ]
[params]
loop=true
loop_offset=0

BIN
assets/sounds/bomb.ogg Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/bomb.ogg-ddd259583b8ecae457de3bb348a95122.oggstr"
[deps]
source_file="res://assets/sounds/bomb.ogg"
dest_files=[ "res://.import/bomb.ogg-ddd259583b8ecae457de3bb348a95122.oggstr" ]
[params]
loop=false
loop_offset=0

BIN
assets/sounds/centerFly.ogg Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/centerFly.ogg-6b99410184f8f0298cd359109acf2032.oggstr"
[deps]
source_file="res://assets/sounds/centerFly.ogg"
dest_files=[ "res://.import/centerFly.ogg-6b99410184f8f0298cd359109acf2032.oggstr" ]
[params]
loop=false
loop_offset=0

BIN
assets/sounds/door.ogg Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/door.ogg-0793837bc0fdd7d80499fff150245388.oggstr"
[deps]
source_file="res://assets/sounds/door.ogg"
dest_files=[ "res://.import/door.ogg-0793837bc0fdd7d80499fff150245388.oggstr" ]
[params]
loop=false
loop_offset=0

BIN
assets/sounds/equip.ogg Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/equip.ogg-0d078867bea64169859e25d1059df065.oggstr"
[deps]
source_file="res://assets/sounds/equip.ogg"
dest_files=[ "res://.import/equip.ogg-0d078867bea64169859e25d1059df065.oggstr" ]
[params]
loop=false
loop_offset=0

BIN
assets/sounds/floor.ogg Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/floor.ogg-b2b0ed92b163bcc4ff89aef251743970.oggstr"
[deps]
source_file="res://assets/sounds/floor.ogg"
dest_files=[ "res://.import/floor.ogg-b2b0ed92b163bcc4ff89aef251743970.oggstr" ]
[params]
loop=false
loop_offset=0

BIN
assets/sounds/item.ogg Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/item.ogg-11014114c6f1f3a93b4a78f6e8acbd28.oggstr"
[deps]
source_file="res://assets/sounds/item.ogg"
dest_files=[ "res://.import/item.ogg-11014114c6f1f3a93b4a78f6e8acbd28.oggstr" ]
[params]
loop=false
loop_offset=0

BIN
assets/sounds/jump.ogg Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/jump.ogg-0e3b092722e416b10416565166ca88d7.oggstr"
[deps]
source_file="res://assets/sounds/jump.ogg"
dest_files=[ "res://.import/jump.ogg-0e3b092722e416b10416565166ca88d7.oggstr" ]
[params]
loop=false
loop_offset=0

BIN
assets/sounds/pickaxe.ogg Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/pickaxe.ogg-685ecf42aac26a05a5adb6ef6bf3457d.oggstr"
[deps]
source_file="res://assets/sounds/pickaxe.ogg"
dest_files=[ "res://.import/pickaxe.ogg-685ecf42aac26a05a5adb6ef6bf3457d.oggstr" ]
[params]
loop=false
loop_offset=0

BIN
assets/sounds/zone.ogg Normal file

Binary file not shown.

View File

@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/zone.ogg-cb092dff02265d0afbda41645fa54064.oggstr"
[deps]
source_file="res://assets/sounds/zone.ogg"
dest_files=[ "res://.import/zone.ogg-cb092dff02265d0afbda41645fa54064.oggstr" ]
[params]
loop=false
loop_offset=0

22
export_presets.cfg Normal file
View File

@ -0,0 +1,22 @@
[preset.0]
name="HTML5"
platform="HTML5"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
patch_list=PoolStringArray( )
script_export_mode=1
script_encryption_key=""
[preset.0.options]
vram_texture_compression/for_desktop=true
vram_texture_compression/for_mobile=false
html/custom_html_shell=""
html/head_include=""
custom_template/release=""
custom_template/debug=""

112
project.godot Normal file
View File

@ -0,0 +1,112 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
_global_script_classes=[ {
"base": "Tween",
"class": "ArrayTween",
"language": "GDScript",
"path": "res://src/player/ArrayTween.gd"
}, {
"base": "StaticBody2D",
"class": "Door",
"language": "GDScript",
"path": "res://src/door/Door.gd"
}, {
"base": "Area2D",
"class": "HitPlot",
"language": "GDScript",
"path": "res://src/plot/HitPlot.gd"
}, {
"base": "CanvasLayer",
"class": "Hud",
"language": "GDScript",
"path": "res://src/hud/HUD.gd"
}, {
"base": "Node2D",
"class": "LevelInstance",
"language": "GDScript",
"path": "res://src/level/LevelInstance.gd"
}, {
"base": "Node2D",
"class": "LevelsManager",
"language": "GDScript",
"path": "res://src/level/LevelsManager.gd"
}, {
"base": "Node2D",
"class": "Main",
"language": "GDScript",
"path": "res://Main.gd"
}, {
"base": "TileMap",
"class": "NavigationTileMap",
"language": "GDScript",
"path": "res://src/navigation/NavigationTileMap.gd"
}, {
"base": "KinematicBody2D",
"class": "Player",
"language": "GDScript",
"path": "res://src/player/Player.gd"
}, {
"base": "Position2D",
"class": "PlayerProps",
"language": "GDScript",
"path": "res://src/props/PlayerProps.gd"
}, {
"base": "Position2D",
"class": "Stairs",
"language": "GDScript",
"path": "res://src/stairs/Stairs.gd"
} ]
_global_script_class_icons={
"ArrayTween": "",
"Door": "",
"HitPlot": "",
"Hud": "",
"LevelInstance": "",
"LevelsManager": "",
"Main": "",
"NavigationTileMap": "",
"Player": "",
"PlayerProps": "",
"Stairs": ""
}
[application]
config/name="Mobile-mota"
run/main_scene="res://Main.tscn"
config/icon="res://settings/icon.png"
[autoload]
FileUtils="*res://src/utils/FileUtils.gd"
Messages="*res://src/hud/Messages.gd"
[debug]
settings/fps/force_fps=60
gdscript/warnings/unused_variable=false
gdscript/warnings/unused_argument=false
gdscript/warnings/unreachable_code=false
[display]
window/size/width=416
window/size/height=544
window/size/always_on_top=true
window/dpi/allow_hidpi=true
window/stretch/mode="viewport"
window/stretch/aspect="keep"
[rendering]
quality/driver/driver_name="GLES2"
quality/2d/use_pixel_snap=true
environment/default_environment="res://settings/default_env.tres"

View File

@ -0,0 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[resource]
background_mode = 2
background_sky = SubResource( 1 )

BIN
settings/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

34
settings/icon.png.import Normal file
View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-63d61f13bea2972fb98d2318c1e93e56.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://settings/icon.png"
dest_files=[ "res://.import/icon.png-63d61f13bea2972fb98d2318c1e93e56.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

18
src/door/BlueDoor.tscn Normal file
View File

@ -0,0 +1,18 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://src/door/Door.gd" type="Script" id=1]
[ext_resource path="res://src/door/door_spriteframes.tres" type="SpriteFrames" id=2]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 16, 16 )
[node name="BlueDoor" type="StaticBody2D"]
script = ExtResource( 1 )
need_key_type = "blue_key"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
[node name="Sprite" type="AnimatedSprite" parent="."]
frames = ExtResource( 2 )
animation = "blue_door"

34
src/door/Door.gd Normal file
View File

@ -0,0 +1,34 @@
tool
extends StaticBody2D
class_name Door
# 钥匙类型
export(String,"yellow_key,blue_key","red_key","none") var need_key_type : String = "yellow_key"
# 是否启用
export var enabled : bool = true
onready var anim_sprite : AnimatedSprite = $Sprite
func _ready():
anim_sprite.connect("animation_finished",self,"on_animation_finished")
# 玩家触碰回调
func on_player_touched(player):
if not enabled:
return
if need_key_type != "none":
if player[need_key_type] <= 0:
return
player[need_key_type] -= 1
anim_sprite.playing = true
# 动画结束回调
func on_animation_finished():
queue_free()
# 强制开启
func open():
if need_key_type == "none":
anim_sprite.playing = true

8
src/door/HiddenDoor.tscn Normal file
View File

@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://src/door/IronDoor.tscn" type="PackedScene" id=1]
[node name="HiddenDoor" instance=ExtResource( 1 )]
[node name="Sprite" parent="." index="1"]
animation = "hidden_door"

10
src/door/IronDoor.tscn Normal file
View File

@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://src/door/RedDoor.tscn" type="PackedScene" id=1]
[node name="IronDoor" instance=ExtResource( 1 )]
need_key_type = "none"
enabled = false
[node name="Sprite" parent="." index="1"]
animation = "iron_door"

19
src/door/RedDoor.tscn Normal file
View File

@ -0,0 +1,19 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://src/door/door_spriteframes.tres" type="SpriteFrames" id=1]
[ext_resource path="res://src/door/Door.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 16, 16 )
[node name="RedDoor" type="StaticBody2D"]
position = Vector2( 207, 400 )
script = ExtResource( 2 )
need_key_type = "red_key"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
[node name="Sprite" type="AnimatedSprite" parent="."]
frames = ExtResource( 1 )
animation = "red_door"

18
src/door/YellowDoor.tscn Normal file
View File

@ -0,0 +1,18 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://src/door/door_spriteframes.tres" type="SpriteFrames" id=1]
[ext_resource path="res://src/door/Door.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 16, 16 )
[node name="YellowDoor" type="StaticBody2D"]
position = Vector2( 207, 400 )
script = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
[node name="Sprite" type="AnimatedSprite" parent="."]
frames = ExtResource( 1 )
animation = "yellow_door"

View File

@ -0,0 +1,181 @@
[gd_resource type="SpriteFrames" load_steps=30 format=2]
[ext_resource path="res://assets/images/animates.png" type="Texture" id=1]
[sub_resource type="AtlasTexture" id=1]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 0, 128, 32, 32 )
[sub_resource type="AtlasTexture" id=2]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 32, 128, 32, 32 )
[sub_resource type="AtlasTexture" id=3]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 64, 128, 32, 32 )
[sub_resource type="AtlasTexture" id=4]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 96, 128, 32, 32 )
[sub_resource type="AtlasTexture" id=5]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 0, 192, 32, 32 )
[sub_resource type="AtlasTexture" id=6]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 32, 192, 32, 32 )
[sub_resource type="AtlasTexture" id=7]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 64, 192, 32, 32 )
[sub_resource type="AtlasTexture" id=8]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 96, 192, 32, 32 )
[sub_resource type="AtlasTexture" id=9]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 0, 224, 32, 32 )
[sub_resource type="AtlasTexture" id=10]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 32, 224, 32, 32 )
[sub_resource type="AtlasTexture" id=11]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 64, 224, 32, 32 )
[sub_resource type="AtlasTexture" id=12]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 96, 224, 32, 32 )
[sub_resource type="AtlasTexture" id=13]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 0, 256, 32, 32 )
[sub_resource type="AtlasTexture" id=14]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 32, 256, 32, 32 )
[sub_resource type="AtlasTexture" id=15]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 64, 256, 32, 32 )
[sub_resource type="AtlasTexture" id=16]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 96, 256, 32, 32 )
[sub_resource type="AtlasTexture" id=17]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 0, 288, 32, 32 )
[sub_resource type="AtlasTexture" id=18]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 32, 288, 32, 32 )
[sub_resource type="AtlasTexture" id=19]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 64, 288, 32, 32 )
[sub_resource type="AtlasTexture" id=20]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 96, 288, 32, 32 )
[sub_resource type="AtlasTexture" id=21]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 0, 320, 32, 32 )
[sub_resource type="AtlasTexture" id=22]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 32, 320, 32, 32 )
[sub_resource type="AtlasTexture" id=23]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 64, 320, 32, 32 )
[sub_resource type="AtlasTexture" id=24]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 96, 320, 32, 32 )
[sub_resource type="AtlasTexture" id=25]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 0, 160, 32, 32 )
[sub_resource type="AtlasTexture" id=26]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 32, 160, 32, 32 )
[sub_resource type="AtlasTexture" id=27]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 64, 160, 32, 32 )
[sub_resource type="AtlasTexture" id=28]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 96, 160, 32, 32 )
[resource]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ) ],
"loop": false,
"name": "yellow_door",
"speed": 30.0
}, {
"frames": [ SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ) ],
"loop": false,
"name": "red_door",
"speed": 30.0
}, {
"frames": [ SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ) ],
"loop": false,
"name": "green_door",
"speed": 30.0
}, {
"frames": [ SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ) ],
"loop": false,
"name": "seal_door",
"speed": 30.0
}, {
"frames": [ SubResource( 17 ), SubResource( 18 ), SubResource( 19 ), SubResource( 20 ) ],
"loop": false,
"name": "iron_door",
"speed": 30.0
}, {
"frames": [ SubResource( 21 ), SubResource( 22 ), SubResource( 23 ), SubResource( 24 ) ],
"loop": false,
"name": "hidden_door",
"speed": 30.0
}, {
"frames": [ SubResource( 25 ), SubResource( 26 ), SubResource( 27 ), SubResource( 28 ) ],
"loop": false,
"name": "blue_door",
"speed": 30.0
} ]

33
src/hud/HUD.gd Normal file
View File

@ -0,0 +1,33 @@
extends CanvasLayer
class_name Hud
func get_level_view() -> Label:
return $"HeaderBackground/GridContainer/LevelLabel" as Label
func get_hp_view() -> Label:
return $"HeaderBackground/GridContainer/HpLabel" as Label
func get_atk_view() -> Label:
return $"HeaderBackground/GridContainer/AtkLabel" as Label
func get_def_view() -> Label:
return $"HeaderBackground/GridContainer2/DefLabel" as Label
func get_exp_view() -> Label:
return $"HeaderBackground/GridContainer2/ExpLabel" as Label
func get_yellow_key_view() -> Label:
return $"HeaderBackground/GridContainer3/YellowKeyCount" as Label
func get_blue_key_view() -> Label:
return $"HeaderBackground/GridContainer3/BlueKeyCount" as Label
func get_red_key_view() -> Label:
return $"HeaderBackground/GridContainer3/RedKeyCount" as Label
func get_save_button_view() -> TextureButton:
return $"BottomBackground/VBoxContainer/SaveButton" as TextureButton
func get_load_button_view() -> TextureButton:
return $"BottomBackground/VBoxContainer/Loadutton" as TextureButton

18
src/hud/Messages.gd Normal file
View File

@ -0,0 +1,18 @@
extends Node
onready var content_label : Label = $"/root/Main/HUD/MessageDialog/ContentLabel"
onready var message_dlalog : PopupDialog = $"/root/Main/HUD/MessageDialog"
func _ready():
message_dlalog.connect("gui_input",self,"on_message_dialog_input")
pass
func showDialog(message:String) -> PopupDialog:
content_label.text = message
message_dlalog.popup()
return message_dlalog
func on_message_dialog_input(event: InputEvent):
if event is InputEventMouseButton and event.pressed:
message_dlalog.visible = false

View File

@ -0,0 +1,7 @@
extends Node2D
class_name LevelInstance
# 获取当前玩家
func get_player() -> Player:
return $Player as Player

View File

@ -0,0 +1,92 @@
extends Node2D
class_name LevelsManager
const tmp_level_scene_path = "user://tmp/"
const init_level_scene_path = "res://src/levels/"
const group_name = "serializable"
# 当前楼层
export var level : int = 1 setget set_level
# 全局数据
var global : Dictionary = {}
signal level_changed(level)
func _ready():
var dir = Directory.new()
FileUtils.remove_dir(tmp_level_scene_path)
dir.make_dir(tmp_level_scene_path)
# 获取当前楼层实例
func get_current_level_instance() -> LevelInstance:
return get_child(0) as LevelInstance
# 设置楼层
func set_level(next_level:int):
#保存数据
save_instance_to_local()
save_data_to_local()
#加载数据
var next_scene = load_scene_from_local(next_level)
add_child(next_scene)
get_current_level_instance().free()
load_data_from_local(next_level)
#设置数据
level = next_level
emit_signal("level_changed",next_level)
# 设置楼层和位置
func set_level_and_position(next_level:int,position:Vector2):
set_level(next_level)
var player = get_current_level_instance().get_player()
player.position = position
# 保存当前场景到本地文件
func save_instance_to_local():
var scene = PackedScene.new()
var result = scene.pack(get_current_level_instance())
if result == OK:
var error = ResourceSaver.save("%s%s.tscn" % [tmp_level_scene_path,level], scene)
if error != OK:
push_error("保存场景失败")
# 从本地加载场景文件
func load_scene_from_local(next_level:int) -> LevelInstance:
var path = "%s%s.tscn" % [tmp_level_scene_path,next_level]
var scene = null
if FileUtils.file_exist(path):
scene = load(path).instance()
else:
var init_path = "%sLevel%s.tscn" % [init_level_scene_path,next_level]
print("init_path ",init_path)
scene = load(init_path).instance()
scene.name = "Level%s" % next_level
return scene as LevelInstance
# 保存游戏数据
func save_data_to_local():
var data = {}
for node in get_tree().get_nodes_in_group(group_name):
node.save_data(data,global)
var file = File.new()
var file_error = file.open("%s%s.data" % [tmp_level_scene_path,level],File.WRITE)
if file_error != OK:
print("保存游戏数据失败:",file_error)
return
file.store_var(data,true)
file.close()
# 还原游戏数据
func load_data_from_local(next_level:int):
var file = File.new()
var file_error = file.open("%s%s.data" % [tmp_level_scene_path,next_level],File.READ)
var data = null
if file_error == OK:
data = file.get_var(true)
else:
data = {}
for node in get_tree().get_nodes_in_group(group_name):
node.load_data(data,global)

27
src/levels/Level1.tscn Normal file
View File

@ -0,0 +1,27 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://src/player/Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/level/LevelInstance.gd" type="Script" id=2]
[ext_resource path="res://src/navigation/NavigationTileMap.gd" type="Script" id=4]
[ext_resource path="res://src/navigation/NavigationTileset.tres" type="TileSet" id=5]
[node name="Level1" type="Node2D"]
script = ExtResource( 2 )
[node name="NavigationTileMap" type="TileMap" parent="."]
light_mask = -2147483647
tile_set = ExtResource( 5 )
cell_size = Vector2( 32, 32 )
cell_quadrant_size = 1
occluder_light_mask = 0
format = 1
tile_data = PoolIntArray( 196608, 1, 0, 196609, 1, 0, 196610, 1, 0, 196611, 1, 0, 196612, 1, 0, 196613, 1, 0, 196614, 1, 0, 196615, 1, 0, 196616, 1, 0, 196617, 1, 0, 196618, 1, 0, 196619, 1, 0, 196620, 1, 0, 262144, 1, 0, 262145, 2, 0, 262146, 2, 0, 262147, 2, 0, 262148, 2, 0, 262149, 2, 0, 262150, 2, 0, 262151, 2, 0, 262152, 2, 0, 262153, 2, 0, 262154, 2, 0, 262155, 2, 0, 262156, 1, 0, 327680, 1, 0, 327681, 1, 0, 327682, 1, 0, 327683, 1, 0, 327684, 1, 0, 327685, 1, 0, 327686, 1, 0, 327687, 1, 0, 327688, 1, 0, 327689, 1, 0, 327690, 1, 0, 327691, 2, 0, 327692, 1, 0, 393216, 1, 0, 393217, 2, 0, 393218, 2, 0, 393219, 2, 0, 393220, 2, 0, 393221, 2, 0, 393222, 1, 0, 393223, 2, 0, 393224, 2, 0, 393225, 2, 0, 393226, 1, 0, 393227, 2, 0, 393228, 1, 0, 458752, 1, 0, 458753, 2, 0, 458754, 2, 0, 458755, 2, 0, 458756, 1, 0, 458757, 2, 0, 458758, 1, 0, 458759, 2, 0, 458760, 2, 0, 458761, 2, 0, 458762, 1, 0, 458763, 2, 0, 458764, 1, 0, 524288, 1, 0, 524289, 1, 0, 524290, 2, 0, 524291, 1, 0, 524292, 1, 0, 524293, 2, 0, 524294, 1, 0, 524295, 1, 0, 524296, 1, 0, 524297, 2, 0, 524298, 1, 0, 524299, 2, 0, 524300, 1, 0, 589824, 1, 0, 589825, 2, 0, 589826, 2, 0, 589827, 2, 0, 589828, 1, 0, 589829, 2, 0, 589830, 2, 0, 589831, 2, 0, 589832, 2, 0, 589833, 2, 0, 589834, 1, 0, 589835, 2, 0, 589836, 1, 0, 655360, 1, 0, 655361, 2, 0, 655362, 2, 0, 655363, 2, 0, 655364, 1, 0, 655365, 2, 0, 655366, 1, 0, 655367, 1, 0, 655368, 1, 0, 655369, 1, 0, 655370, 1, 0, 655371, 2, 0, 655372, 1, 0, 720896, 1, 0, 720897, 1, 0, 720898, 2, 0, 720899, 1, 0, 720900, 1, 0, 720901, 2, 0, 720902, 2, 0, 720903, 2, 0, 720904, 2, 0, 720905, 2, 0, 720906, 2, 0, 720907, 2, 0, 720908, 1, 0, 786432, 1, 0, 786433, 2, 0, 786434, 2, 0, 786435, 2, 0, 786436, 1, 0, 786437, 1, 0, 786438, 2, 0, 786439, 1, 0, 786440, 1, 0, 786441, 1, 0, 786442, 2, 0, 786443, 1, 0, 786444, 1, 0, 851968, 1, 0, 851969, 2, 0, 851970, 2, 0, 851971, 2, 0, 851972, 1, 0, 851973, 2, 0, 851974, 2, 0, 851975, 2, 0, 851976, 1, 0, 851977, 2, 0, 851978, 2, 0, 851979, 2, 0, 851980, 1, 0, 917504, 1, 0, 917505, 2, 0, 917506, 2, 0, 917507, 2, 0, 917508, 1, 0, 917509, 2, 0, 917510, 2, 0, 917511, 2, 0, 917512, 1, 0, 917513, 2, 0, 917514, 2, 0, 917515, 2, 0, 917516, 1, 0, 983040, 1, 0, 983041, 1, 0, 983042, 1, 0, 983043, 1, 0, 983044, 1, 0, 983045, 1, 0, 983046, 1, 0, 983047, 1, 0, 983048, 1, 0, 983049, 1, 0, 983050, 1, 0, 983051, 1, 0, 983052, 1, 0 )
script = ExtResource( 4 )
changed_cells = {
}
[node name="Items" type="Node2D" parent="."]
[node name="Player" parent="." instance=ExtResource( 1 )]
position = Vector2( 207, 464 )

172
src/levels/Level2.tscn Normal file
View File

@ -0,0 +1,172 @@
[gd_scene load_steps=20 format=2]
[ext_resource path="res://src/player/Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/level/LevelInstance.gd" type="Script" id=2]
[ext_resource path="res://src/stairs/StairsDown.tscn" type="PackedScene" id=3]
[ext_resource path="res://src/navigation/NavigationTileMap.gd" type="Script" id=4]
[ext_resource path="res://src/navigation/NavigationTileset.tres" type="TileSet" id=5]
[ext_resource path="res://src/door/BlueDoor.tscn" type="PackedScene" id=6]
[ext_resource path="res://src/door/IronDoor.tscn" type="PackedScene" id=7]
[ext_resource path="res://src/door/HiddenDoor.tscn" type="PackedScene" id=8]
[ext_resource path="res://src/props/YellowKey.tscn" type="PackedScene" id=9]
[ext_resource path="res://src/stairs/StairsUp.tscn" type="PackedScene" id=10]
[ext_resource path="res://src/props/BlueDrug.tscn" type="PackedScene" id=11]
[ext_resource path="res://assets/images/npcs.png" type="Texture" id=12]
[ext_resource path="res://src/npc/HelpEscape.gd" type="Script" id=13]
[sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 16, 16 )
[sub_resource type="AtlasTexture" id=1]
flags = 4
atlas = ExtResource( 12 )
region = Rect2( 0, 64, 32, 32 )
[sub_resource type="AtlasTexture" id=2]
flags = 4
atlas = ExtResource( 12 )
region = Rect2( 32, 64, 32, 32 )
[sub_resource type="SpriteFrames" id=3]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ) ],
"loop": true,
"name": "thief",
"speed": 5.0
} ]
[sub_resource type="Animation" id=6]
resource_name = "leave"
tracks/0/type = "value"
tracks/0/path = NodePath(".: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.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 48, 400 ), Vector2( 48, 464 ) ]
}
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": PoolRealArray( 0.5, 1 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
}
[sub_resource type="Animation" id=5]
resource_name = "open_door"
tracks/0/type = "value"
tracks/0/path = NodePath(".: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.5, 1 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 0,
"values": [ Vector2( 112, 336 ), Vector2( 48, 336 ), Vector2( 48, 400 ) ]
}
[node name="Level2" type="Node2D"]
script = ExtResource( 2 )
[node name="NavigationTileMap" type="TileMap" parent="."]
tile_set = ExtResource( 5 )
cell_size = Vector2( 32, 32 )
cell_quadrant_size = 1
format = 1
tile_data = PoolIntArray( 196608, 1, 0, 196609, 1, 0, 196610, 1, 0, 196611, 1, 0, 196612, 1, 0, 196613, 1, 0, 196614, 1, 0, 196615, 1, 0, 196616, 1, 0, 196617, 1, 0, 196618, 1, 0, 196619, 1, 0, 196620, 1, 0, 262144, 1, 0, 262145, 2, 0, 262146, 2, 0, 262147, 2, 0, 262148, 2, 0, 262149, 2, 0, 262150, 2, 0, 262151, 2, 0, 262152, 2, 0, 262153, 2, 0, 262154, 2, 0, 262155, 2, 0, 262156, 1, 0, 327680, 1, 0, 327681, 2, 0, 327682, 2, 0, 327683, 1, 0, 327684, 1, 0, 327685, 2, 0, 327686, 2, 0, 327687, 2, 0, 327688, 2, 0, 327689, 2, 0, 327690, 1, 0, 327691, 1, 0, 327692, 1, 0, 393216, 1, 0, 393217, 2, 0, 393218, 1, 0, 393219, 1, 0, 393220, 1, 0, 393221, 1, 0, 393222, 1, 0, 393223, 2, 0, 393224, 1, 0, 393225, 1, 0, 393226, 1, 0, 393227, 1, 0, 393228, 1, 0, 458752, 1, 0, 458753, 2, 0, 458754, 1, 0, 458755, 2, 0, 458756, 2, 0, 458757, 1, 0, 458758, 2, 0, 458759, 2, 0, 458760, 2, 0, 458761, 1, 0, 458762, 2, 0, 458763, 2, 0, 458764, 1, 0, 524288, 1, 0, 524289, 2, 0, 524290, 1, 0, 524291, 2, 0, 524292, 2, 0, 524293, 2, 0, 524294, 2, 0, 524295, 2, 0, 524296, 2, 0, 524297, 2, 0, 524298, 2, 0, 524299, 2, 0, 524300, 1, 0, 589824, 1, 0, 589825, 2, 0, 589826, 1, 0, 589827, 1, 0, 589828, 1, 0, 589829, 1, 0, 589830, 2, 0, 589831, 2, 0, 589832, 2, 0, 589833, 1, 0, 589834, 1, 0, 589835, 1, 0, 589836, 1, 0, 655360, 1, 0, 655361, 2, 0, 655363, 2, 0, 655364, 2, 0, 655365, 1, 0, 655366, 2, 0, 655367, 2, 0, 655368, 2, 0, 655369, 1, 0, 655370, 2, 0, 655371, 2, 0, 655372, 1, 0, 720896, 1, 0, 720897, 2, 0, 720898, 1, 0, 720899, 2, 0, 720900, 2, 0, 720901, 2, 0, 720902, 2, 0, 720903, 2, 0, 720904, 2, 0, 720905, 2, 0, 720906, 2, 0, 720907, 2, 0, 720908, 1, 0, 786432, 1, 0, 786433, 2, 0, 786434, 1, 0, 786435, 1, 0, 786436, 1, 0, 786437, 1, 0, 786438, 2, 0, 786439, 2, 0, 786440, 2, 0, 786441, 1, 0, 786442, 1, 0, 786443, 1, 0, 786444, 1, 0, 851968, 1, 0, 851969, 2, 0, 851970, 1, 0, 851971, 2, 0, 851972, 2, 0, 851973, 1, 0, 851974, 2, 0, 851975, 2, 0, 851976, 2, 0, 851977, 1, 0, 851978, 2, 0, 851979, 2, 0, 851980, 1, 0, 917504, 1, 0, 917505, 2, 0, 917506, 1, 0, 917507, 2, 0, 917508, 2, 0, 917509, 2, 0, 917510, 2, 0, 917511, 2, 0, 917512, 2, 0, 917513, 2, 0, 917514, 2, 0, 917515, 2, 0, 917516, 1, 0, 983040, 1, 0, 983041, 1, 0, 983042, 1, 0, 983043, 1, 0, 983044, 1, 0, 983045, 1, 0, 983046, 1, 0, 983047, 1, 0, 983048, 1, 0, 983049, 1, 0, 983050, 1, 0, 983051, 1, 0, 983052, 1, 0 )
script = ExtResource( 4 )
changed_cells = {
}
[node name="Items" type="Node2D" parent="."]
[node name="BlueDoor" parent="Items" instance=ExtResource( 6 )]
position = Vector2( 112, 144 )
[node name="IronDoor" parent="Items" instance=ExtResource( 7 )]
position = Vector2( 176, 272 )
enabled = true
[node name="IronDoor2" parent="Items" instance=ExtResource( 7 )]
position = Vector2( 176, 368 )
enabled = true
[node name="IronDoor3" parent="Items" instance=ExtResource( 7 )]
position = Vector2( 176, 464 )
enabled = true
[node name="IronDoor4" parent="Items" instance=ExtResource( 7 )]
position = Vector2( 304, 464 )
enabled = true
[node name="IronDoor5" parent="Items" instance=ExtResource( 7 )]
position = Vector2( 304, 368 )
enabled = true
[node name="IronDoor6" parent="Items" instance=ExtResource( 7 )]
position = Vector2( 304, 272 )
enabled = true
[node name="HiddenDoor" parent="Items" instance=ExtResource( 8 )]
position = Vector2( 80, 336 )
enabled = true
[node name="Stairs" parent="Items" instance=ExtResource( 3 )]
position = Vector2( 48, 144 )
[node name="YellowKey" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 112, 240 )
[node name="YellowKey2" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 112, 272 )
[node name="YellowKey3" parent="Items" instance=ExtResource( 9 )]
position = Vector2( 144, 240 )
[node name="PlayerProps5" parent="Items" instance=ExtResource( 11 )]
position = Vector2( 112, 464 )
[node name="PlayerProps6" parent="Items" instance=ExtResource( 11 )]
position = Vector2( 112, 432 )
[node name="PlayerProps7" parent="Items" instance=ExtResource( 11 )]
position = Vector2( 144, 432 )
[node name="Stairs2" parent="Items" instance=ExtResource( 10 )]
position = Vector2( 48, 464 )
[node name="StaticBody2D" type="StaticBody2D" parent="."]
position = Vector2( 112, 336 )
script = ExtResource( 13 )
__meta__ = {
"_edit_group_": true
}
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
shape = SubResource( 4 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="StaticBody2D"]
frames = SubResource( 3 )
animation = "thief"
playing = true
[node name="AnimationPlayer" type="AnimationPlayer" parent="StaticBody2D"]
anims/leave = SubResource( 6 )
anims/open_door = SubResource( 5 )
[node name="Player" parent="." instance=ExtResource( 1 )]
position = Vector2( 112, 368 )
navigation_tile_map_path = NodePath("../../Level2/NavigationTileMap")

75
src/levels/Level3.tscn Normal file
View File

@ -0,0 +1,75 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://src/level/LevelInstance.gd" type="Script" id=1]
[ext_resource path="res://src/navigation/NavigationTileMap.gd" type="Script" id=2]
[ext_resource path="res://src/navigation/NavigationTileset.tres" type="TileSet" id=3]
[ext_resource path="res://src/player/Player.tscn" type="PackedScene" id=4]
[ext_resource path="res://src/stairs/StairsDown.tscn" type="PackedScene" id=5]
[ext_resource path="res://assets/images/enemys.png" type="Texture" id=6]
[ext_resource path="res://src/plot/HitPlot.gd" type="Script" id=7]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 0, 0.1 )
[node name="Level3" type="Node2D"]
script = ExtResource( 1 )
[node name="NavigationTileMap" type="TileMap" parent="."]
tile_set = ExtResource( 3 )
cell_size = Vector2( 32, 32 )
cell_quadrant_size = 1
format = 1
tile_data = PoolIntArray( 196608, 1, 0, 196609, 1, 0, 196610, 1, 0, 196611, 1, 0, 196612, 1, 0, 196613, 1, 0, 196614, 1, 0, 196615, 1, 0, 196616, 1, 0, 196617, 1, 0, 196618, 1, 0, 196619, 1, 0, 196620, 1, 0, 262144, 1, 0, 262145, 2, 0, 262146, 2, 0, 262147, 1, 0, 262148, 2, 0, 262149, 2, 0, 262150, 2, 0, 262151, 1, 0, 262152, 2, 0, 262153, 1, 0, 262154, 2, 0, 262155, 2, 0, 262156, 1, 0, 327680, 1, 0, 327681, 2, 0, 327682, 2, 0, 327683, 1, 0, 327684, 2, 0, 327685, 2, 0, 327686, 2, 0, 327687, 1, 0, 327688, 2, 0, 327689, 2, 0, 327690, 2, 0, 327691, 2, 0, 327692, 1, 0, 393216, 1, 0, 393217, 2, 0, 393218, 2, 0, 393219, 1, 0, 393220, 2, 0, 393221, 2, 0, 393222, 2, 0, 393223, 1, 0, 393224, 2, 0, 393225, 1, 0, 393226, 1, 0, 393227, 1, 0, 393228, 1, 0, 458752, 1, 0, 458753, 2, 0, 458754, 1, 0, 458755, 1, 0, 458756, 1, 0, 458757, 2, 0, 458758, 1, 0, 458759, 1, 0, 458760, 2, 0, 458761, 1, 0, 458762, 2, 0, 458763, 2, 0, 458764, 1, 0, 524288, 1, 0, 524289, 2, 0, 524290, 2, 0, 524291, 2, 0, 524292, 2, 0, 524293, 2, 0, 524294, 2, 0, 524295, 2, 0, 524296, 2, 0, 524297, 2, 0, 524298, 2, 0, 524299, 2, 0, 524300, 1, 0, 589824, 1, 0, 589825, 2, 0, 589826, 1, 0, 589827, 1, 0, 589828, 2, 0, 589829, 2, 0, 589830, 2, 0, 589831, 1, 0, 589832, 2, 0, 589833, 1, 0, 589834, 1, 0, 589835, 1, 0, 589836, 1, 0, 655360, 1, 0, 655361, 2, 0, 655362, 2, 0, 655363, 1, 0, 655364, 1, 0, 655365, 2, 0, 655366, 1, 0, 655367, 1, 0, 655368, 2, 0, 655369, 1, 0, 655370, 2, 0, 655371, 2, 0, 655372, 1, 0, 720896, 1, 0, 720897, 2, 0, 720898, 2, 0, 720899, 1, 0, 720900, 2, 0, 720901, 2, 0, 720902, 2, 0, 720903, 1, 0, 720904, 2, 0, 720905, 2, 0, 720906, 2, 0, 720907, 2, 0, 720908, 1, 0, 786432, 1, 0, 786433, 2, 0, 786434, 2, 0, 786435, 1, 0, 786436, 2, 0, 786437, 2, 0, 786438, 2, 0, 786439, 1, 0, 786440, 2, 0, 786441, 1, 0, 786442, 1, 0, 786443, 1, 0, 786444, 1, 0, 851968, 1, 0, 851969, 1, 0, 851970, 1, 0, 851971, 1, 0, 851972, 1, 0, 851973, 2, 0, 851974, 1, 0, 851975, 1, 0, 851976, 2, 0, 851977, 1, 0, 851978, 2, 0, 851979, 2, 0, 851980, 1, 0, 917504, 1, 0, 917505, 2, 0, 917506, 2, 0, 917507, 2, 0, 917508, 2, 0, 917509, 2, 0, 917510, 2, 0, 917511, 1, 0, 917512, 2, 0, 917513, 2, 0, 917514, 2, 0, 917515, 2, 0, 917516, 1, 0, 983040, 1, 0, 983041, 1, 0, 983042, 1, 0, 983043, 1, 0, 983044, 1, 0, 983045, 1, 0, 983046, 1, 0, 983047, 1, 0, 983048, 1, 0, 983049, 1, 0, 983050, 1, 0, 983051, 1, 0, 983052, 1, 0 )
script = ExtResource( 2 )
changed_cells = {
}
[node name="Stairs" parent="NavigationTileMap" instance=ExtResource( 5 )]
position = Vector2( 48, 464 )
[node name="Player" parent="." instance=ExtResource( 4 )]
position = Vector2( 80, 464 )
[node name="HitPlot" type="Area2D" parent="."]
position = Vector2( 176, 368 )
script = ExtResource( 7 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="HitPlot"]
position = Vector2( 0, 32 )
shape = SubResource( 1 )
[node name="Devil" type="Sprite" parent="HitPlot"]
visible = false
position = Vector2( 0, -32 )
texture = ExtResource( 6 )
region_enabled = true
region_rect = Rect2( 0, 1408, 32, 32 )
[node name="Devils" type="Node2D" parent="HitPlot/Devil"]
visible = false
[node name="Devil1" type="Sprite" parent="HitPlot/Devil/Devils"]
position = Vector2( 0, 32 )
texture = ExtResource( 6 )
region_enabled = true
region_rect = Rect2( 0, 1440, 32, 32 )
[node name="Devil2" type="Sprite" parent="HitPlot/Devil/Devils"]
position = Vector2( -32, 64 )
texture = ExtResource( 6 )
region_enabled = true
region_rect = Rect2( 0, 1440, 32, 32 )
[node name="Devil3" type="Sprite" parent="HitPlot/Devil/Devils"]
position = Vector2( 32, 64 )
texture = ExtResource( 6 )
region_enabled = true
region_rect = Rect2( 0, 1440, 32, 32 )
[node name="Devil4" type="Sprite" parent="HitPlot/Devil/Devils"]
position = Vector2( 0, 96 )
texture = ExtResource( 6 )
region_enabled = true
region_rect = Rect2( 0, 1440, 32, 32 )
[connection signal="body_entered" from="HitPlot" to="HitPlot" method="_on_HitPlot_body_entered"]

View File

@ -0,0 +1,93 @@
tool
extends TileMap
# 支持导航的瓦片地图
class_name NavigationTileMap
# 路径规划的cell_index
export var navigation_cell_index = 2
# 墙cell
export var wall_cell_index = 1
# 路径规划算法
var astar : AStar2D = AStar2D.new()
# 被修改的cell集合
export var changed_cells : Dictionary = {}
# 初始化tilemap配置
func _init():
self.tile_set = load("res://src/navigation/NavigationTileset.tres")
self.cell_size = Vector2(32,32)
self.cell_quadrant_size = 1
# 初始化node和edge
func _ready():
self.add_to_group("serializable")
refresh_astar()
# 刷新路径规划
func refresh_astar():
astar.clear()
var cells = get_used_cells_by_id(navigation_cell_index)
init_nodes(cells)
init_edges(cells)
# 初始化nodes
func init_nodes(cells:Array):
for index in range(cells.size()):
var cell_position = cells[index] * cell_size
cell_position.x += 16
cell_position.y += 16
astar.add_point(index, cell_position)
# 初始化edge
func init_edges(cells:Array):
for index in range(cells.size()):
var cell = cells[index]
#left
var left_cell_index = cells.find(Vector2(cell.x - 1,cell.y))
if left_cell_index != -1:
astar.connect_points(index,left_cell_index)
#right
var right_cell_index = cells.find(Vector2(cell.x + 1,cell.y))
if right_cell_index != -1:
astar.connect_points(index,right_cell_index)
#up
var up_cell_index = cells.find(Vector2(cell.x,cell.y - 1))
if up_cell_index != -1:
astar.connect_points(index,up_cell_index)
#down
var down_cell_index = cells.find(Vector2(cell.x,cell.y + 1))
if down_cell_index != -1:
astar.connect_points(index,down_cell_index)
# 拦截记录运行时修改的cell
func set_cell(x: int, y: int, tile: int, flip_x: bool = false,
flip_y: bool = false, transpose: bool = false, autotile_coord: Vector2 = Vector2( 0, 0 )):
if not Engine.editor_hint:
self.changed_cells[Vector2(x,y)] = tile
print(x,",",y,"-",tile)
return .set_cell(x,y,tile,flip_x,flip_y,transpose,autotile_coord)
# 拦截记录运行时修改的cell
func set_cellv(position: Vector2, tile: int, flip_x: bool = false, flip_y: bool = false, transpose: bool = false):
if not Engine.editor_hint:
self.changed_cells[position] = tile
return .set_cellv(position,tile,flip_x,flip_y,transpose)
# 增加导航图库
func add_navigation_cell(position:Vector2):
self.set_cellv(world_to_map(position),navigation_cell_index)
refresh_astar()
# 保存游戏数据
func save_data(data:Dictionary,global:Dictionary):
data.navigation_changed_cells = changed_cells
# 还原游戏数据
func load_data(data:Dictionary,global:Dictionary):
if not data.has("navigation_changed_cells"):
return
changed_cells = data.navigation_changed_cells
for key in changed_cells.keys():
.set_cellv(key,changed_cells[key])
refresh_astar()

View File

@ -0,0 +1,16 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://src/navigation/NavigationTileMap.gd" type="Script" id=1]
[ext_resource path="res://src/navigation/NavigationTileset.tres" type="TileSet" id=2]
[node name="NavigationTileMap" type="TileMap" groups=[
"serializable",
]]
tile_set = ExtResource( 2 )
cell_size = Vector2( 32, 32 )
cell_quadrant_size = 1
format = 1
script = ExtResource( 1 )
changed_cells = {
}

View File

@ -0,0 +1,34 @@
[gd_resource type="TileSet" load_steps=3 format=2]
[ext_resource path="res://assets/images/terrains.png" type="Texture" id=1]
[ext_resource path="res://assets/images/animates.png" type="Texture" id=2]
[resource]
1/name = "animates.png 1"
1/texture = ExtResource( 2 )
1/tex_offset = Vector2( 0, 0 )
1/modulate = Color( 1, 1, 1, 1 )
1/region = Rect2( 0, 320, 32, 32 )
1/tile_mode = 0
1/occluder_offset = Vector2( 0, 0 )
1/navigation_offset = Vector2( 0, 0 )
1/shape_offset = Vector2( 0, 0 )
1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
1/shape_one_way = false
1/shape_one_way_margin = 0.0
1/shapes = [ ]
1/z_index = 0
2/name = "terrains.png 2"
2/texture = ExtResource( 1 )
2/tex_offset = Vector2( 0, 0 )
2/modulate = Color( 1, 1, 1, 1 )
2/region = Rect2( 0, 0, 32, 32 )
2/tile_mode = 0
2/occluder_offset = Vector2( 0, 0 )
2/navigation_offset = Vector2( 0, 0 )
2/shape_offset = Vector2( 0, 0 )
2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
2/shape_one_way = false
2/shape_one_way_margin = 0.0
2/shapes = [ ]
2/z_index = 0

30
src/npc/HelpEscape.gd Normal file
View File

@ -0,0 +1,30 @@
extends StaticBody2D
# 第一次对话
export var once_talked : bool = false
# 第二次对话
export var second_talked : bool = false
func _ready():
if once_talked and second_talked:
queue_free()
func on_player_touched(player):
print("touched")
var anim_player = $AnimationPlayer as AnimationPlayer
if not once_talked:
yield(Messages.showDialog("你清醒了吗 你到监狱时还处在昏迷中 魔法警卫把你扔到我这个房间 但你很幸运 我刚完成逃跑的暗道你就醒了 我们一起越狱吧"),"popup_hide")
var hidden_door = $"../Items/HiddenDoor" as Door
var navigation_tile_map = $"../NavigationTileMap" as NavigationTileMap
navigation_tile_map.add_navigation_cell(hidden_door.position)
hidden_door.open()
anim_player.play("open_door")
once_talked = true
return
if not second_talked:
yield(Messages.showDialog("我们终于逃出来了 你的剑盾被警卫拿走了 你必须先找到武器 我知道铁建在5楼 铁盾在9楼 你最好先取得它们 我现在还有事没发帮你 再见"),"popup_hide")
anim_player.play("leave")
yield(anim_player,"animation_finished")
second_talked = true
queue_free()
return

69
src/npc/ThiefNpc.tscn Normal file
View File

@ -0,0 +1,69 @@
[gd_scene load_steps=10 format=2]
[ext_resource path="res://assets/images/npcs.png" type="Texture" id=1]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 16, 16 )
[sub_resource type="AtlasTexture" id=2]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=3]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 32, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=4]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 0, 64, 32, 32 )
[sub_resource type="AtlasTexture" id=5]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 32, 64, 32, 32 )
[sub_resource type="AtlasTexture" id=6]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 0, 32, 32, 32 )
[sub_resource type="AtlasTexture" id=7]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 32, 32, 32, 32 )
[sub_resource type="SpriteFrames" id=8]
animations = [ {
"frames": [ SubResource( 2 ), SubResource( 3 ) ],
"loop": true,
"name": "old_man",
"speed": 5.0
}, {
"frames": [ SubResource( 4 ), SubResource( 5 ) ],
"loop": true,
"name": "thief",
"speed": 5.0
}, {
"frames": [ SubResource( 6 ), SubResource( 7 ) ],
"loop": true,
"name": "business_man",
"speed": 5.0
} ]
[node name="ThiefNpc" type="StaticBody2D"]
position = Vector2( 112, 336 )
__meta__ = {
"_edit_group_": true
}
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 8 )
animation = "thief"
frame = 1
playing = true

48
src/player/ArrayTween.gd Normal file
View File

@ -0,0 +1,48 @@
extends Tween
class_name ArrayTween
var index = 0
var values : Array
# 单个节点动画时间
export var duration: float = 1.0
# 动画步进回调
signal array_value_step(step)
# 所有节点动画播放完成
signal array_completed
func _ready():
connect("tween_completed",self,"on_tween_completed")
pass
# 使用节点进行动画
func interpolate_array(values:Array) -> void:
if values.size() < 2:
return
if is_active():
stop_all()
self.index = 0
self.values = values
play_step()
# 播放其中一节
func play_step():
var start_value = values[index]
var end_value = values[index + 1]
self.interpolate_method(self,"on_step",start_value,end_value,duration)
self.start()
# 程序内步进回调
func on_step(step):
emit_signal("array_value_step",step)
pass
# 动画完成回调
func on_tween_completed(object: Object, key: NodePath):
if index + 2 < values.size():
index += 1
play_step()
else:
emit_signal("array_completed")

142
src/player/Player.gd Normal file
View File

@ -0,0 +1,142 @@
extends KinematicBody2D
class_name Player
export(NodePath) var navigation_tile_map_path : NodePath
export var hp : int = 1000 setget set_hp
export var atk : int = 10 setget set_atk
export var def : int = 10 setget set_def
export var money : int = 0 setget set_money
export var yellow_key : int = 0 setget set_yellow_key
export var blue_key : int = 0 setget set_blue_key
export var red_key : int = 0 setget set_red_key
var navigation_tile_map : NavigationTileMap
var navigation_rect : Rect2
onready var array_tween : ArrayTween = $ArrayTween
onready var animation_tree : AnimationTree = $AnimationTree
signal hp_changed(hp)
signal atk_changed(atk)
signal def_changed(def)
signal money_changed(money)
signal yellow_key_changed(yellow_key)
signal blue_key_changed(blue_key)
signal red_key_changed(red_key)
func _ready():
self.add_to_group("serializable")
#初始化导航相关数据
if not navigation_tile_map_path.is_empty():
navigation_tile_map = get_node(navigation_tile_map_path)
navigation_rect = navigation_tile_map.get_used_rect()
navigation_rect.position *= navigation_tile_map.cell_size
navigation_rect.size *= navigation_tile_map.cell_size
# 监听屏幕点击事件
func _unhandled_input(event):
if event is InputEventMouseButton and event.is_pressed() and navigation_tile_map != null:
if not navigation_rect.has_point(event.position):
return
var astar = navigation_tile_map.astar
var start_id = astar.get_closest_point(position)
var end_id = astar.get_closest_point(event.position)
var paths = astar.get_point_path(start_id,end_id)
animation_tree.active = true
array_tween.interpolate_array(paths)
func _on_ArrayTween_array_completed():
animation_tree.active = false
func _on_ArrayTween_array_value_step(step):
var diff = step - position
animation_tree["parameters/player/blend_position"] = diff
var result = move_and_collide(diff)
call_collider(result)
# 停止角色运动
func stop():
set_process_unhandled_input(false)
array_tween.stop_all()
animation_tree.active = false
# 恢复角色运动
func resume():
set_process_unhandled_input(true)
animation_tree.active = true
# 调用被碰撞对象的方法
func call_collider(collision:KinematicCollision2D):
if collision == null or collision.collider == null:
return
var collider = collision.collider
if collider is TileMap:
return
if collider.has_method("on_player_touched"):
array_tween.stop_all()
animation_tree.active = false
collider.call("on_player_touched",self)
# 保存游戏数据
func save_data(data:Dictionary,global:Dictionary):
if not global.has("player"):
global.player = {}
global.player.hp = hp
global.player.atk = atk
global.player.def = def
global.player.money = money
global.player.yellow_key = yellow_key
global.player.blue_key = blue_key
global.player.red_key = red_key
data.player_position = position
# 还原游戏数据
func load_data(data:Dictionary,global:Dictionary):
if data.has("player_position"):
self.position = data.player_position
self.hp = global.player.hp
self.atk = global.player.atk
self.def = global.player.def
self.money = global.player.money
self.yellow_key = global.player.yellow_key
self.blue_key = global.player.blue_key
self.red_key = global.player.red_key
func set_hp(value):
hp = value
emit_signal("hp_changed",value)
func set_atk(value):
atk = value
emit_signal("atk_changed",value)
func set_def(value):
def = value
emit_signal("def_changed",value)
func set_money(value):
money = value
emit_signal("money_changed",value)
func set_yellow_key(value):
yellow_key = value
emit_signal("yellow_key_changed",value)
func set_blue_key(value):
blue_key = value
emit_signal("blue_key_changed",value)
func set_red_key(value):
red_key = value
emit_signal("red_key_changed",value)

143
src/player/Player.tscn Normal file
View File

@ -0,0 +1,143 @@
[gd_scene load_steps=16 format=2]
[ext_resource path="res://src/player/ArrayTween.gd" type="Script" id=1]
[ext_resource path="res://src/player/Player.gd" type="Script" id=2]
[ext_resource path="res://assets/images/brave.png" type="Texture" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 15.9, 15.9 )
[sub_resource type="Animation" id=2]
resource_name = "down"
length = 1.6
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.4, 0.8, 1.2 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"update": 1,
"values": [ 0, 1, 2, 3 ]
}
[sub_resource type="Animation" id=3]
resource_name = "left"
length = 1.6
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.4, 0.8, 1.2 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"update": 1,
"values": [ 4, 5, 6, 7 ]
}
[sub_resource type="Animation" id=4]
resource_name = "right"
length = 1.6
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.4, 0.8, 1.2 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"update": 1,
"values": [ 8, 9, 10, 11 ]
}
[sub_resource type="Animation" id=5]
resource_name = "up"
length = 1.6
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.4, 0.8, 1.2 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"update": 1,
"values": [ 12, 13, 14, 15 ]
}
[sub_resource type="AnimationNodeTimeScale" id=12]
[sub_resource type="AnimationNodeAnimation" id=6]
animation = "left"
[sub_resource type="AnimationNodeAnimation" id=7]
animation = "up"
[sub_resource type="AnimationNodeAnimation" id=8]
animation = "down"
[sub_resource type="AnimationNodeAnimation" id=9]
animation = "right"
[sub_resource type="AnimationNodeBlendSpace2D" id=10]
blend_point_0/node = SubResource( 6 )
blend_point_0/pos = Vector2( -1, 0 )
blend_point_1/node = SubResource( 7 )
blend_point_1/pos = Vector2( 0, -1 )
blend_point_2/node = SubResource( 8 )
blend_point_2/pos = Vector2( 0, 1 )
blend_point_3/node = SubResource( 9 )
blend_point_3/pos = Vector2( 1, 0 )
blend_mode = 1
[sub_resource type="AnimationNodeBlendTree" id=11]
graph_offset = Vector2( -55, 58 )
nodes/TimeScale/node = SubResource( 12 )
nodes/TimeScale/position = Vector2( 220, 100 )
nodes/output/position = Vector2( 420, 100 )
nodes/player/node = SubResource( 10 )
nodes/player/position = Vector2( 0, 100 )
node_connections = [ "output", 0, "TimeScale", "TimeScale", 0, "player" ]
[node name="Player" type="KinematicBody2D"]
script = ExtResource( 2 )
__meta__ = {
"_edit_group_": true
}
navigation_tile_map_path = NodePath("../NavigationTileMap")
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 3 )
vframes = 4
hframes = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/down = SubResource( 2 )
anims/left = SubResource( 3 )
anims/right = SubResource( 4 )
anims/up = SubResource( 5 )
[node name="ArrayTween" type="Tween" parent="."]
script = ExtResource( 1 )
duration = 0.1
[node name="AnimationTree" type="AnimationTree" parent="."]
tree_root = SubResource( 11 )
anim_player = NodePath("../AnimationPlayer")
parameters/TimeScale/scale = 10.0
parameters/player/blend_position = Vector2( 0, 0 )
[connection signal="array_completed" from="ArrayTween" to="." method="_on_ArrayTween_array_completed"]
[connection signal="array_value_step" from="ArrayTween" to="." method="_on_ArrayTween_array_value_step"]

27
src/plot/HitPlot.gd Normal file
View File

@ -0,0 +1,27 @@
extends Area2D
class_name HitPlot
export var used : bool = false
func _ready():
if used:
queue_free()
func _on_HitPlot_body_entered(body):
if used:
return
# 魔王剧情
body.stop()
$Devil.visible = true
yield(Messages.showDialog("欢迎来到魔塔 你是第100位挑战者 你若能打败我所有的手下 我就与你一对一的对决斗 现在你必须接受我的安排"),"popup_hide")
$Devil/Devils.visible = true
yield(Messages.showDialog("什么"),"popup_hide")
to_second_level()
# 移动角色到二楼监狱
func to_second_level():
var levels_manager = $"/root/Main/Level" as LevelsManager
used = true
levels_manager.connect("level_changed",self,"on_level_changed")
levels_manager.call_deferred("set_level_and_position",2,Vector2(112,368))

26
src/props/BlueDrug.tscn Normal file
View File

@ -0,0 +1,26 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://assets/images/items.png" type="Texture" id=1]
[ext_resource path="res://src/props/PlayerProps.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
[node name="PlayerProps5" type="Position2D"]
position = Vector2( 336, 432 )
script = ExtResource( 2 )
__meta__ = {
"_edit_group_": true
}
update_property = "hp"
update_value = 200
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 672, 32, 32 )
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 1 )
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

View File

@ -0,0 +1,25 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://assets/images/items.png" type="Texture" id=1]
[ext_resource path="res://src/props/PlayerProps.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
[node name="BlueGemstone" type="Position2D"]
position = Vector2( 272, 368 )
script = ExtResource( 2 )
__meta__ = {
"_edit_group_": true
}
update_property = "def"
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 544, 32, 32 )
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 1 )
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

25
src/props/BlueKey.tscn Normal file
View File

@ -0,0 +1,25 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://assets/images/items.png" type="Texture" id=1]
[ext_resource path="res://src/props/PlayerProps.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
[node name="PlayerProps2" type="Position2D"]
position = Vector2( 207, 432 )
script = ExtResource( 2 )
__meta__ = {
"_edit_group_": true
}
update_property = "blue_key"
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 32, 32, 32 )
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 1 )
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

15
src/props/PlayerProps.gd Normal file
View File

@ -0,0 +1,15 @@
extends Position2D
# 玩家可以捡取的游戏道具
class_name PlayerProps
# 变更的属性
export(String,"yellow_key","blue_key","red_key","hp","atk","def") var update_property : String = "yellow_key"
# 变更的内容
export var update_value : int = 1
func _on_Area2D_body_entered(body):
var levels_manager = $"/root/Main/Level" as LevelsManager
var player = levels_manager.get_current_level_instance().get_player()
player[update_property] += update_value
queue_free()

26
src/props/RedDrug.tscn Normal file
View File

@ -0,0 +1,26 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://assets/images/items.png" type="Texture" id=1]
[ext_resource path="res://src/props/PlayerProps.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
[node name="PlayerProps4" type="Position2D"]
position = Vector2( 304, 432 )
script = ExtResource( 2 )
__meta__ = {
"_edit_group_": true
}
update_property = "hp"
update_value = 50
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 640, 32, 32 )
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 1 )
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

View File

@ -0,0 +1,25 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://assets/images/items.png" type="Texture" id=1]
[ext_resource path="res://src/props/PlayerProps.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
[node name="RedGemstone" type="Position2D"]
position = Vector2( 240, 368 )
script = ExtResource( 2 )
__meta__ = {
"_edit_group_": true
}
update_property = "atk"
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 512, 32, 32 )
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 1 )
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

25
src/props/RedKey.tscn Normal file
View File

@ -0,0 +1,25 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://assets/images/items.png" type="Texture" id=1]
[ext_resource path="res://src/props/PlayerProps.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
[node name="PlayerProps3" type="Position2D"]
position = Vector2( 240, 432 )
script = ExtResource( 2 )
__meta__ = {
"_edit_group_": true
}
update_property = "red_key"
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 64, 32, 32 )
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 1 )
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

24
src/props/YellowKey.tscn Normal file
View File

@ -0,0 +1,24 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://assets/images/items.png" type="Texture" id=1]
[ext_resource path="res://src/props/PlayerProps.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
[node name="YellowKey" type="Position2D"]
position = Vector2( 176, 432 )
script = ExtResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 0, 32, 32 )
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 1 )
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

29
src/stairs/Stairs.gd Normal file
View File

@ -0,0 +1,29 @@
extends Position2D
class_name Stairs
# 楼梯类型
enum StairsType { Up,Down }
export(StairsType) var stairs_type = StairsType.Up
export var disabled : bool = false
onready var sprite : Sprite = $Sprite
onready var collision_shape : CollisionShape2D = $Area2D/CollisionShape2D
func _on_Area2D_body_entered(body):
if disabled:
return
print("entered")
disabled = true
body.position = position
var levels_manager = $"/root/Main/Level" as LevelsManager
if stairs_type == StairsType.Up:
levels_manager.set_deferred("level",levels_manager.level + 1)
else:
levels_manager.set_deferred("level",levels_manager.level - 1)
func _on_Area2D_body_exited(body):
disabled = false

View File

@ -0,0 +1,22 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://assets/images/terrains.png" type="Texture" id=1]
[ext_resource path="res://src/stairs/Stairs.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
[node name="Stairs" type="Position2D"]
script = ExtResource( 2 )
stairs_type = 1
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 640, 32, 32 )
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 1 )
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
[connection signal="body_exited" from="Area2D" to="." method="_on_Area2D_body_exited"]

21
src/stairs/StairsUp.tscn Normal file
View File

@ -0,0 +1,21 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://assets/images/terrains.png" type="Texture" id=1]
[ext_resource path="res://src/stairs/Stairs.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
[node name="Stairs" type="Position2D"]
script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 672, 32, 32 )
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 1 )
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
[connection signal="body_exited" from="Area2D" to="." method="_on_Area2D_body_exited"]

21
src/utils/FileUtils.gd Normal file
View File

@ -0,0 +1,21 @@
extends Node
func file_exist(path:String) -> bool:
var file = File.new()
var result = file.file_exists(path)
file.close()
return result
func remove_dir(path:String) -> void:
var dir = Directory.new()
if dir.open(path) == OK:
dir.list_dir_begin()
var file_name = dir.get_next()
while file_name != "":
if dir.current_is_dir():
print("Found directory: " + file_name)
else:
dir.remove(file_name)
file_name = dir.get_next()
else:
print("An error occurred when trying to access the path.")