mirror of
https://gitee.com/freeyz/godot-mota.git
synced 2025-01-24 11:31:30 +08:00
增加楼层切换功能和读档bug修复
This commit is contained in:
parent
c9abebbaf0
commit
895a7e0d0e
@ -1,16 +1,17 @@
|
|||||||
[gd_scene load_steps=6 format=2]
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://scenes/UI.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://scenes/UI.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://scenes/floors/Floor1.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://scenes/floors/Floor1.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://scripts/BgmAudioPlayer.gd" type="Script" id=3]
|
[ext_resource path="res://scripts/BgmAudioPlayer.gd" type="Script" id=3]
|
||||||
[ext_resource path="res://images/mota_tileset.tres" type="TileSet" id=4]
|
[ext_resource path="res://images/mota_tileset.tres" type="TileSet" id=4]
|
||||||
[ext_resource path="res://sounds/bgm.ogg" type="AudioStream" id=5]
|
[ext_resource path="res://sounds/bgm.ogg" type="AudioStream" id=5]
|
||||||
|
[ext_resource path="res://scripts/GameInit.gd" type="Script" id=6]
|
||||||
|
|
||||||
[node name="Main" type="Node2D"]
|
[node name="Main" type="Node2D"]
|
||||||
|
script = ExtResource( 6 )
|
||||||
|
|
||||||
[node name="BgmAudioPlayer" type="AudioStreamPlayer2D" parent="."]
|
[node name="BgmAudioPlayer" type="AudioStreamPlayer2D" parent="."]
|
||||||
stream = ExtResource( 5 )
|
stream = ExtResource( 5 )
|
||||||
volume_db = -20.0
|
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
[node name="BackgroundTileMap" type="TileMap" parent="."]
|
[node name="BackgroundTileMap" type="TileMap" parent="."]
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[ext_resource path="res://images/mota.png" type="Texture" id=1]
|
[ext_resource path="res://images/mota.png" type="Texture" id=1]
|
||||||
|
|
||||||
[sub_resource type="NavigationPolygon" id=2]
|
[sub_resource type="NavigationPolygon" id=1]
|
||||||
vertices = PoolVector2Array( 12.8379, -3.70605, 12.9995, 7.7608, 11.8689, 13.575, -5.4122, 14.7056, -5.4122, 18.5817, 11.7074, 18.2587, 12.3534, 36.5088, 18.4906, 36.5088, 17.1986, 19.0662, 39.8093, 18.7432, 38.1943, 11.7985, 18.4906, 12.606, 18.4906, -4.02911 )
|
vertices = PoolVector2Array( 12.8379, -3.70605, 12.9995, 7.7608, 11.8689, 13.575, -5.4122, 14.7056, -5.4122, 18.5817, 11.7074, 18.2587, 12.3534, 36.5088, 18.4906, 36.5088, 17.1986, 19.0662, 39.8093, 18.7432, 38.1943, 11.7985, 18.4906, 12.606, 18.4906, -4.02911 )
|
||||||
polygons = [ PoolIntArray( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ) ]
|
polygons = [ PoolIntArray( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ) ]
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ polygons = [ PoolIntArray( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ) ]
|
|||||||
2/tile_mode = 0
|
2/tile_mode = 0
|
||||||
2/occluder_offset = Vector2( 0, 0 )
|
2/occluder_offset = Vector2( 0, 0 )
|
||||||
2/navigation_offset = Vector2( 0, 0 )
|
2/navigation_offset = Vector2( 0, 0 )
|
||||||
2/navigation = SubResource( 2 )
|
2/navigation = SubResource( 1 )
|
||||||
2/shape_offset = Vector2( 0, 0 )
|
2/shape_offset = Vector2( 0, 0 )
|
||||||
2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||||
2/shape_one_way = false
|
2/shape_one_way = false
|
||||||
|
@ -35,6 +35,11 @@ _global_script_classes=[ {
|
|||||||
"path": "res://scripts/ElixirsSprite.gd"
|
"path": "res://scripts/ElixirsSprite.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "Sprite",
|
"base": "Sprite",
|
||||||
|
"class": "GemSprite",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://scripts/GemSprite.gd"
|
||||||
|
}, {
|
||||||
|
"base": "Sprite",
|
||||||
"class": "KeySprite",
|
"class": "KeySprite",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://scripts/KeySprite.gd"
|
"path": "res://scripts/KeySprite.gd"
|
||||||
@ -63,6 +68,11 @@ _global_script_classes=[ {
|
|||||||
"class": "SaveGameButton",
|
"class": "SaveGameButton",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://scripts/SaveGameButton.gd"
|
"path": "res://scripts/SaveGameButton.gd"
|
||||||
|
}, {
|
||||||
|
"base": "Sprite",
|
||||||
|
"class": "StairsSprite",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://scripts/StairsSprite.gd"
|
||||||
} ]
|
} ]
|
||||||
_global_script_class_icons={
|
_global_script_class_icons={
|
||||||
"ArrayTween": "",
|
"ArrayTween": "",
|
||||||
@ -70,12 +80,14 @@ _global_script_class_icons={
|
|||||||
"DoorSprite": "",
|
"DoorSprite": "",
|
||||||
"DoorStaticBody2D": "",
|
"DoorStaticBody2D": "",
|
||||||
"ElixirsSprite": "",
|
"ElixirsSprite": "",
|
||||||
|
"GemSprite": "",
|
||||||
"KeySprite": "",
|
"KeySprite": "",
|
||||||
"MonsterSprite": "",
|
"MonsterSprite": "",
|
||||||
"NavigationTileMap": "",
|
"NavigationTileMap": "",
|
||||||
"PlayerKinematicBody2D": "",
|
"PlayerKinematicBody2D": "",
|
||||||
"PlayerSprite": "",
|
"PlayerSprite": "",
|
||||||
"SaveGameButton": ""
|
"SaveGameButton": "",
|
||||||
|
"StairsSprite": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
[application]
|
[application]
|
||||||
@ -88,6 +100,10 @@ config/custom_user_dir_name="mota"
|
|||||||
boot_splash/image="res://images/logo.png"
|
boot_splash/image="res://images/logo.png"
|
||||||
config/icon="res://settings/icon.png"
|
config/icon="res://settings/icon.png"
|
||||||
|
|
||||||
|
[audio]
|
||||||
|
|
||||||
|
default_bus_layout=""
|
||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
GameFloorManager="*res://scripts/GameFloorManager.gd"
|
GameFloorManager="*res://scripts/GameFloorManager.gd"
|
||||||
|
19
scenes/Gem.tscn
Normal file
19
scenes/Gem.tscn
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://images/mota.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://scripts/GemSprite.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
|
||||||
|
[node name="GemSprite" type="Sprite"]
|
||||||
|
position = Vector2( 368, 336 )
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
region_enabled = true
|
||||||
|
region_rect = Rect2( 128, 384, 32, 32 )
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[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"]
|
21
scenes/Stairs.tscn
Normal file
21
scenes/Stairs.tscn
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://images/mota.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://scripts/StairsSprite.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
|
||||||
|
[node name="StairsSprite" type="Sprite" groups=[
|
||||||
|
"stairs",
|
||||||
|
]]
|
||||||
|
position = Vector2( 176, 48 )
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
region_enabled = true
|
||||||
|
region_rect = Rect2( 96, 512, 32, 32 )
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[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"]
|
@ -1,8 +1,13 @@
|
|||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=9 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://images/mota_tileset.tres" type="TileSet" id=1]
|
[ext_resource path="res://images/mota_tileset.tres" type="TileSet" id=1]
|
||||||
|
[ext_resource path="res://scenes/Door.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://scripts/NavigationTileMap.gd" type="Script" id=3]
|
[ext_resource path="res://scripts/NavigationTileMap.gd" type="Script" id=3]
|
||||||
[ext_resource path="res://scenes/Player.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://scenes/Key.tscn" type="PackedScene" id=4]
|
||||||
|
[ext_resource path="res://scenes/Elixirs.tscn" type="PackedScene" id=6]
|
||||||
|
[ext_resource path="res://scenes/Monster.tscn" type="PackedScene" id=7]
|
||||||
|
[ext_resource path="res://scenes/Gem.tscn" type="PackedScene" id=8]
|
||||||
|
[ext_resource path="res://scenes/Stairs.tscn" type="PackedScene" id=9]
|
||||||
|
|
||||||
[node name="Floor1" type="Node2D"]
|
[node name="Floor1" type="Node2D"]
|
||||||
|
|
||||||
@ -16,5 +21,119 @@ script = ExtResource( 3 )
|
|||||||
|
|
||||||
[node name="Item" type="Node2D" parent="."]
|
[node name="Item" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="PlayerKinematicBody2D" parent="." instance=ExtResource( 5 )]
|
[node name="ElixirsSprite" parent="Item" instance=ExtResource( 6 )]
|
||||||
position = Vector2( 336, 368 )
|
position = Vector2( 176, 368 )
|
||||||
|
elixirs_value = 50
|
||||||
|
|
||||||
|
[node name="ElixirsSprite2" parent="Item" instance=ExtResource( 6 )]
|
||||||
|
position = Vector2( 176, 336 )
|
||||||
|
elixirs_value = 50
|
||||||
|
|
||||||
|
[node name="ElixirsSprite5" parent="Item" instance=ExtResource( 6 )]
|
||||||
|
position = Vector2( 176, 112 )
|
||||||
|
elixirs_value = 50
|
||||||
|
|
||||||
|
[node name="ElixirsSprite3" parent="Item" instance=ExtResource( 6 )]
|
||||||
|
position = Vector2( 400, 144 )
|
||||||
|
elixirs_value = 50
|
||||||
|
|
||||||
|
[node name="ElixirsSprite4" parent="Item" instance=ExtResource( 6 )]
|
||||||
|
position = Vector2( 464, 368 )
|
||||||
|
region_rect = Rect2( 128, 416, 32, 32 )
|
||||||
|
elixirs_color = 1
|
||||||
|
elixirs_value = 200
|
||||||
|
|
||||||
|
[node name="DoorSprite" parent="Item" instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 336, 304 )
|
||||||
|
|
||||||
|
[node name="DoorSprite2" parent="Item" instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 208, 272 )
|
||||||
|
|
||||||
|
[node name="DoorSprite3" parent="Item" instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 208, 176 )
|
||||||
|
|
||||||
|
[node name="DoorSprite4" parent="Item" instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 272, 112 )
|
||||||
|
|
||||||
|
[node name="DoorSprite5" parent="Item" instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 336, 208 )
|
||||||
|
|
||||||
|
[node name="DoorSprite6" parent="Item" instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 432, 176 )
|
||||||
|
|
||||||
|
[node name="DoorSprite7" parent="Item" instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 464, 304 )
|
||||||
|
|
||||||
|
[node name="KeySprite" parent="Item" instance=ExtResource( 4 )]
|
||||||
|
position = Vector2( 240, 368 )
|
||||||
|
|
||||||
|
[node name="KeySprite2" parent="Item" instance=ExtResource( 4 )]
|
||||||
|
position = Vector2( 240, 336 )
|
||||||
|
|
||||||
|
[node name="KeySprite5" parent="Item" instance=ExtResource( 4 )]
|
||||||
|
position = Vector2( 304, 336 )
|
||||||
|
|
||||||
|
[node name="KeySprite3" parent="Item" instance=ExtResource( 4 )]
|
||||||
|
position = Vector2( 176, 240 )
|
||||||
|
|
||||||
|
[node name="KeySprite4" parent="Item" instance=ExtResource( 4 )]
|
||||||
|
position = Vector2( 400, 112 )
|
||||||
|
|
||||||
|
[node name="MonsterSprite" parent="Item" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 208, 144 )
|
||||||
|
animation = "skeleton"
|
||||||
|
frame = 1
|
||||||
|
|
||||||
|
[node name="MonsterSprite9" parent="Item" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 272, 48 )
|
||||||
|
animation = "redSlime"
|
||||||
|
frame = 1
|
||||||
|
|
||||||
|
[node name="MonsterSprite10" parent="Item" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 240, 48 )
|
||||||
|
animation = "greenSlime"
|
||||||
|
|
||||||
|
[node name="MonsterSprite11" parent="Item" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 304, 48 )
|
||||||
|
animation = "greenSlime"
|
||||||
|
frame = 1
|
||||||
|
|
||||||
|
[node name="MonsterSprite2" parent="Item" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 208, 240 )
|
||||||
|
animation = "skeletonSoilder"
|
||||||
|
frame = 1
|
||||||
|
|
||||||
|
[node name="MonsterSprite3" parent="Item" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 464, 336 )
|
||||||
|
frame = 1
|
||||||
|
|
||||||
|
[node name="MonsterSprite6" parent="Item" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 368, 208 )
|
||||||
|
|
||||||
|
[node name="MonsterSprite7" parent="Item" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 432, 208 )
|
||||||
|
|
||||||
|
[node name="MonsterSprite8" parent="Item" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 400, 208 )
|
||||||
|
animation = "bluePriest"
|
||||||
|
|
||||||
|
[node name="MonsterSprite4" parent="Item" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 432, 368 )
|
||||||
|
animation = "greenSlime"
|
||||||
|
frame = 1
|
||||||
|
|
||||||
|
[node name="MonsterSprite5" parent="Item" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 496, 368 )
|
||||||
|
animation = "greenSlime"
|
||||||
|
frame = 1
|
||||||
|
|
||||||
|
[node name="GemSprite" parent="Item" instance=ExtResource( 8 )]
|
||||||
|
position = Vector2( 368, 112 )
|
||||||
|
region_rect = Rect2( 96, 384, 32, 32 )
|
||||||
|
gem_color = 1
|
||||||
|
|
||||||
|
[node name="GemSprite2" parent="Item" instance=ExtResource( 8 )]
|
||||||
|
position = Vector2( 368, 144 )
|
||||||
|
|
||||||
|
[node name="StairsSprite" parent="Item" instance=ExtResource( 9 )]
|
||||||
|
player_init_position = Vector2( 208, 48 )
|
||||||
|
103
scenes/floors/Floor2.tscn
Normal file
103
scenes/floors/Floor2.tscn
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
[gd_scene load_steps=8 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://scripts/NavigationTileMap.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://images/mota_tileset.tres" type="TileSet" id=2]
|
||||||
|
[ext_resource path="res://scenes/Stairs.tscn" type="PackedScene" id=3]
|
||||||
|
[ext_resource path="res://scenes/Monster.tscn" type="PackedScene" id=4]
|
||||||
|
[ext_resource path="res://scenes/Door.tscn" type="PackedScene" id=5]
|
||||||
|
[ext_resource path="res://scenes/Elixirs.tscn" type="PackedScene" id=6]
|
||||||
|
[ext_resource path="res://scenes/Key.tscn" type="PackedScene" id=7]
|
||||||
|
|
||||||
|
[node name="Floor2" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="NavigationTileMap" type="TileMap" parent="."]
|
||||||
|
tile_set = ExtResource( 2 )
|
||||||
|
cell_size = Vector2( 32, 32 )
|
||||||
|
format = 1
|
||||||
|
tile_data = PoolIntArray( 65541, 2, 0, 65542, 2, 0, 65543, 2, 0, 65544, 2, 0, 65545, 2, 0, 65546, 2, 0, 65547, 2, 0, 65548, 2, 0, 65549, 2, 0, 65550, 2, 0, 65551, 2, 0, 131077, 2, 0, 131078, 2, 0, 131081, 2, 0, 131082, 2, 0, 131083, 2, 0, 131084, 2, 0, 131085, 2, 0, 196613, 2, 0, 196619, 2, 0, 262149, 2, 0, 262151, 2, 0, 262152, 2, 0, 262154, 2, 0, 262155, 2, 0, 262156, 2, 0, 262158, 2, 0, 262159, 2, 0, 327685, 2, 0, 327687, 2, 0, 327688, 2, 0, 327689, 2, 0, 327690, 2, 0, 327691, 2, 0, 327692, 2, 0, 327693, 2, 0, 327694, 2, 0, 327695, 2, 0, 393221, 2, 0, 393226, 2, 0, 393227, 2, 0, 393228, 2, 0, 458757, 2, 0, 458758, 2, 0, 458759, 2, 0, 458760, 2, 0, 458762, 2, 0, 458763, 2, 0, 458764, 2, 0, 458766, 2, 0, 458767, 2, 0, 524293, 2, 0, 524295, 2, 0, 524296, 2, 0, 524297, 2, 0, 524298, 2, 0, 524299, 2, 0, 524300, 2, 0, 524301, 2, 0, 524302, 2, 0, 524303, 2, 0, 589829, 2, 0, 589834, 2, 0, 589835, 2, 0, 589836, 2, 0, 655365, 2, 0, 655367, 2, 0, 655368, 2, 0, 655370, 2, 0, 655371, 2, 0, 655372, 2, 0, 655374, 2, 0, 655375, 2, 0, 720901, 2, 0, 720903, 2, 0, 720904, 2, 0, 720905, 2, 0, 720906, 2, 0, 720907, 2, 0, 720908, 2, 0, 720909, 2, 0, 720910, 2, 0, 720911, 2, 0 )
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Item" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="MonsterSprite" parent="Item" instance=ExtResource( 4 )]
|
||||||
|
position = Vector2( 336, 80 )
|
||||||
|
animation = "blueGuard"
|
||||||
|
|
||||||
|
[node name="MonsterSprite2" parent="Item" instance=ExtResource( 4 )]
|
||||||
|
position = Vector2( 400, 80 )
|
||||||
|
animation = "blueGuard"
|
||||||
|
|
||||||
|
[node name="KeySprite" parent="Item" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 240, 176 )
|
||||||
|
|
||||||
|
[node name="KeySprite3" parent="Item" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 272, 176 )
|
||||||
|
|
||||||
|
[node name="KeySprite2" parent="Item" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 240, 144 )
|
||||||
|
|
||||||
|
[node name="DoorSprite" parent="Item" instance=ExtResource( 5 )]
|
||||||
|
position = Vector2( 304, 176 )
|
||||||
|
region_rect = Rect2( 288, 480, 32, 32 )
|
||||||
|
door_type = 3
|
||||||
|
|
||||||
|
[node name="ElixirsSprite" parent="Item" instance=ExtResource( 6 )]
|
||||||
|
position = Vector2( 240, 368 )
|
||||||
|
region_rect = Rect2( 128, 416, 32, 32 )
|
||||||
|
elixirs_color = 1
|
||||||
|
|
||||||
|
[node name="ElixirsSprite3" parent="Item" instance=ExtResource( 6 )]
|
||||||
|
position = Vector2( 240, 336 )
|
||||||
|
region_rect = Rect2( 128, 416, 32, 32 )
|
||||||
|
elixirs_color = 1
|
||||||
|
|
||||||
|
[node name="ElixirsSprite2" parent="Item" instance=ExtResource( 6 )]
|
||||||
|
position = Vector2( 272, 368 )
|
||||||
|
region_rect = Rect2( 128, 416, 32, 32 )
|
||||||
|
elixirs_color = 1
|
||||||
|
|
||||||
|
[node name="DoorSprite2" parent="Item" instance=ExtResource( 5 )]
|
||||||
|
position = Vector2( 304, 272 )
|
||||||
|
region_rect = Rect2( 288, 480, 32, 32 )
|
||||||
|
door_type = 3
|
||||||
|
enabled = false
|
||||||
|
|
||||||
|
[node name="DoorSprite8" parent="Item" instance=ExtResource( 5 )]
|
||||||
|
position = Vector2( 240, 48 )
|
||||||
|
region_rect = Rect2( 224, 480, 32, 32 )
|
||||||
|
door_type = 1
|
||||||
|
|
||||||
|
[node name="DoorSprite7" parent="Item" instance=ExtResource( 5 )]
|
||||||
|
position = Vector2( 208, 240 )
|
||||||
|
region_rect = Rect2( 0, 512, 32, 32 )
|
||||||
|
door_type = 4
|
||||||
|
enabled = false
|
||||||
|
|
||||||
|
[node name="DoorSprite3" parent="Item" instance=ExtResource( 5 )]
|
||||||
|
position = Vector2( 304, 368 )
|
||||||
|
region_rect = Rect2( 288, 480, 32, 32 )
|
||||||
|
door_type = 3
|
||||||
|
|
||||||
|
[node name="DoorSprite4" parent="Item" instance=ExtResource( 5 )]
|
||||||
|
position = Vector2( 432, 368 )
|
||||||
|
region_rect = Rect2( 288, 480, 32, 32 )
|
||||||
|
door_type = 3
|
||||||
|
|
||||||
|
[node name="DoorSprite5" parent="Item" instance=ExtResource( 5 )]
|
||||||
|
position = Vector2( 432, 272 )
|
||||||
|
region_rect = Rect2( 288, 480, 32, 32 )
|
||||||
|
door_type = 3
|
||||||
|
|
||||||
|
[node name="DoorSprite6" parent="Item" instance=ExtResource( 5 )]
|
||||||
|
position = Vector2( 432, 176 )
|
||||||
|
region_rect = Rect2( 288, 480, 32, 32 )
|
||||||
|
door_type = 3
|
||||||
|
|
||||||
|
[node name="StairsSprite" parent="Item" instance=ExtResource( 3 )]
|
||||||
|
region_rect = Rect2( 64, 512, 32, 32 )
|
||||||
|
stairs_type = 1
|
||||||
|
player_init_position = Vector2( 176, 80 )
|
||||||
|
|
||||||
|
[node name="StairsSprite2" parent="Item" instance=ExtResource( 3 )]
|
||||||
|
position = Vector2( 176, 368 )
|
||||||
|
player_init_position = Vector2( 176, 336 )
|
@ -27,3 +27,10 @@ func play_door():
|
|||||||
func play_item():
|
func play_item():
|
||||||
stream = item
|
stream = item
|
||||||
play()
|
play()
|
||||||
|
|
||||||
|
func play_attack():
|
||||||
|
if playing:
|
||||||
|
return
|
||||||
|
pitch_scale = 1.5
|
||||||
|
stream = attack
|
||||||
|
play()
|
||||||
|
@ -4,10 +4,13 @@ extends Sprite
|
|||||||
class_name DoorSprite
|
class_name DoorSprite
|
||||||
|
|
||||||
# 门类型
|
# 门类型
|
||||||
enum DoorType { Yellow,Blue,Red,Iron }
|
enum DoorType { Yellow,Blue,Red,Iron,Wall }
|
||||||
|
|
||||||
export(DoorType) var door_type setget set_door_type
|
export(DoorType) var door_type setget set_door_type
|
||||||
|
|
||||||
|
# 是否被禁用
|
||||||
|
export var enabled : bool = true
|
||||||
|
|
||||||
# 默认数据初始化
|
# 默认数据初始化
|
||||||
func _init():
|
func _init():
|
||||||
self.texture = load("res://images/mota.png")
|
self.texture = load("res://images/mota.png")
|
||||||
@ -24,3 +27,5 @@ func set_door_type(value):
|
|||||||
region_rect = Rect2(256,480,32,32)
|
region_rect = Rect2(256,480,32,32)
|
||||||
DoorType.Iron:
|
DoorType.Iron:
|
||||||
region_rect = Rect2(288,480,32,32)
|
region_rect = Rect2(288,480,32,32)
|
||||||
|
DoorType.Wall:
|
||||||
|
region_rect = Rect2(0,512,32,32)
|
||||||
|
@ -5,6 +5,8 @@ class_name DoorStaticBody2D
|
|||||||
onready var door_sprite : DoorSprite = get_parent()
|
onready var door_sprite : DoorSprite = get_parent()
|
||||||
|
|
||||||
func on_player_touched(player):
|
func on_player_touched(player):
|
||||||
|
if not door_sprite.enabled:
|
||||||
|
return
|
||||||
match door_sprite.door_type:
|
match door_sprite.door_type:
|
||||||
DoorSprite.DoorType.Yellow:
|
DoorSprite.DoorType.Yellow:
|
||||||
if GameArchiveManager.player_info.yellow_key <= 0:
|
if GameArchiveManager.player_info.yellow_key <= 0:
|
||||||
|
@ -18,10 +18,6 @@ var player_info = {
|
|||||||
"def" : 10,
|
"def" : 10,
|
||||||
#默认金钱
|
#默认金钱
|
||||||
"money" : 0,
|
"money" : 0,
|
||||||
# 英雄等级
|
|
||||||
"level" : 1,
|
|
||||||
# 英雄经验
|
|
||||||
"experience" : 0,
|
|
||||||
# 当前楼层
|
# 当前楼层
|
||||||
"now_floor" : 1,
|
"now_floor" : 1,
|
||||||
# 去过的最大楼层
|
# 去过的最大楼层
|
||||||
@ -91,16 +87,30 @@ func update_player_position() -> void:
|
|||||||
# 根据索引加载存档
|
# 根据索引加载存档
|
||||||
func load_by_index(index:int) -> void:
|
func load_by_index(index:int) -> void:
|
||||||
var archive = get_archives()[index]
|
var archive = get_archives()[index]
|
||||||
self.player_info = archive.player_info
|
|
||||||
#加载楼层
|
#加载楼层
|
||||||
GameFloorManager.load_by_floor(self.player_info.now_floor)
|
var next_floor = GameFloorManager.load_by_floor(archive.player_info.now_floor)
|
||||||
#设置人物位置
|
#设置人物位置
|
||||||
|
self.player_info = archive.player_info
|
||||||
|
GameFloorManager.instance_player(self.player_info.position,next_floor)
|
||||||
var player = get_player()
|
var player = get_player()
|
||||||
player.position = self.player_info.position
|
player.position = self.player_info.position
|
||||||
#更新楼层UI显示
|
#更新UI显示
|
||||||
update_floor_view()
|
update_floor_view()
|
||||||
update_hp_view()
|
update_hp_view()
|
||||||
update_key_view()
|
update_key_view()
|
||||||
|
update_atk_view()
|
||||||
|
update_def_view()
|
||||||
|
update_money_view()
|
||||||
|
|
||||||
|
func update_money_view():
|
||||||
|
$"/root/Main/UI/MoneySprite/MoneyBackground/MoneyLabel".text = player_info.money as String
|
||||||
|
|
||||||
|
func update_def_view():
|
||||||
|
$"/root/Main/UI/DefSprite/DefBackground/DefLabel".text = player_info.def as String
|
||||||
|
|
||||||
|
# 更新共计界面视图
|
||||||
|
func update_atk_view():
|
||||||
|
$"/root/Main/UI/AtkSprite/AtkBackground/AtkLabel".text = player_info.atk as String
|
||||||
|
|
||||||
# 更新楼层UI显示
|
# 更新楼层UI显示
|
||||||
func update_floor_view():
|
func update_floor_view():
|
||||||
|
@ -3,13 +3,48 @@ extends Node
|
|||||||
const floor_file_path = "res://scenes/floors/Floor"
|
const floor_file_path = "res://scenes/floors/Floor"
|
||||||
|
|
||||||
# 加载指定楼层
|
# 加载指定楼层
|
||||||
func load_by_floor(f:int) -> void:
|
func load_by_floor(f:int) -> Node2D:
|
||||||
var root = get_tree().get_root().get_node("Main")
|
var root = get_tree().get_root().get_node("Main")
|
||||||
var next_floor = load("%s%s%s" % [floor_file_path,f,".tscn"]).instance() as Node2D
|
var next_floor = load("%s%s%s" % [floor_file_path,f,".tscn"]).instance() as Node2D
|
||||||
var used_items = GameArchiveManager.get_used_item(f)
|
var used_items = GameArchiveManager.get_used_item(f)
|
||||||
root.get_node("Floor%s" % f).free()
|
root.get_node("Floor%s" % GameArchiveManager.player_info.now_floor).free()
|
||||||
root.add_child(next_floor)
|
root.add_child(next_floor)
|
||||||
for used_item in used_items:
|
for used_item in used_items:
|
||||||
var node = next_floor.get_node(used_item)
|
var node = next_floor.get_node(used_item)
|
||||||
if node != null:
|
if node != null:
|
||||||
node.free()
|
node.free()
|
||||||
|
GameArchiveManager.player_info.now_floor = f
|
||||||
|
return next_floor
|
||||||
|
|
||||||
|
# 加载上一层楼层
|
||||||
|
func load_added_floor():
|
||||||
|
var f = GameArchiveManager.player_info.now_floor
|
||||||
|
if f + 1 > 50:
|
||||||
|
return
|
||||||
|
var next_floor = load_by_floor(f + 1)
|
||||||
|
var stairs = get_tree().get_nodes_in_group("stairs")
|
||||||
|
if stairs.empty():
|
||||||
|
return
|
||||||
|
for s in stairs:
|
||||||
|
if s.stairs_type == StairsSprite.StairsType.Down:
|
||||||
|
instance_player(s.player_init_position,next_floor)
|
||||||
|
return
|
||||||
|
|
||||||
|
# 加载下一次楼层
|
||||||
|
func load_reduced_floor():
|
||||||
|
var f = GameArchiveManager.player_info.now_floor
|
||||||
|
if f - 1 < 0:
|
||||||
|
return
|
||||||
|
var next_floor = load_by_floor(f - 1)
|
||||||
|
var stairs = get_tree().get_nodes_in_group("stairs")
|
||||||
|
if stairs.empty():
|
||||||
|
return
|
||||||
|
for s in stairs:
|
||||||
|
if s.stairs_type == StairsSprite.StairsType.Up:
|
||||||
|
instance_player(s.player_init_position,next_floor)
|
||||||
|
return
|
||||||
|
|
||||||
|
func instance_player(position:Vector2,next_floor:Node2D) -> void:
|
||||||
|
var player = load("res://scenes/Player.tscn").instance()
|
||||||
|
player.position = position
|
||||||
|
next_floor.add_child(player)
|
||||||
|
5
scripts/GameInit.gd
Normal file
5
scripts/GameInit.gd
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
extends Node2D
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
GameFloorManager.instance_player(Vector2(336,368),$"/root/Main/Floor1")
|
||||||
|
pass
|
36
scripts/GemSprite.gd
Normal file
36
scripts/GemSprite.gd
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
tool
|
||||||
|
extends Sprite
|
||||||
|
|
||||||
|
class_name GemSprite
|
||||||
|
|
||||||
|
# 宝石颜色
|
||||||
|
enum GemColor { Blue,Red }
|
||||||
|
|
||||||
|
export(GemColor) var gem_color setget set_gem_color
|
||||||
|
|
||||||
|
# 上升属性值
|
||||||
|
export var up_value : int = 1
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
self.texture = load("res://images/mota.png")
|
||||||
|
self.region_enabled = true
|
||||||
|
|
||||||
|
func set_gem_color(value):
|
||||||
|
gem_color = value
|
||||||
|
match value:
|
||||||
|
GemColor.Blue:
|
||||||
|
region_rect = Rect2(128,384,32,32)
|
||||||
|
GemColor.Red:
|
||||||
|
region_rect = Rect2(96,384,32,32)
|
||||||
|
|
||||||
|
func _on_Area2D_body_entered(body):
|
||||||
|
match gem_color:
|
||||||
|
GemColor.Blue:
|
||||||
|
GameArchiveManager.player_info.def += up_value
|
||||||
|
GameArchiveManager.update_def_view()
|
||||||
|
GemColor.Red:
|
||||||
|
GameArchiveManager.player_info.atk += up_value
|
||||||
|
GameArchiveManager.update_atk_view()
|
||||||
|
AffectAudioPlayer.play_item()
|
||||||
|
queue_free()
|
||||||
|
GameArchiveManager.add_used_item(get_path())
|
@ -31,16 +31,13 @@ func _on_Area2D_body_entered(body):
|
|||||||
match key_type:
|
match key_type:
|
||||||
KeyType.Yellow:
|
KeyType.Yellow:
|
||||||
GameArchiveManager.player_info.yellow_key += 1
|
GameArchiveManager.player_info.yellow_key += 1
|
||||||
$"/root/Main/UI/KeyBackground/YellowKeyCountLabel".text = GameArchiveManager.player_info.yellow_key as String
|
|
||||||
KeyType.Blue:
|
KeyType.Blue:
|
||||||
GameArchiveManager.player_info.blue_key += 1
|
GameArchiveManager.player_info.blue_key += 1
|
||||||
$"/root/Main/UI/KeyBackground/BlueKeyCountLabel".text = GameArchiveManager.player_info.blue_key as String
|
|
||||||
KeyType.Red:
|
KeyType.Red:
|
||||||
GameArchiveManager.player_info.red_key += 1
|
GameArchiveManager.player_info.red_key += 1
|
||||||
$"/root/Main/UI/KeyBackground/RedKeyCountLabel".text = GameArchiveManager.player_info.red_key as String
|
|
||||||
KeyType.Green:
|
KeyType.Green:
|
||||||
GameArchiveManager.player_info.green_key += 1
|
GameArchiveManager.player_info.green_key += 1
|
||||||
$"/root/Main/UI/KeyBackground/GreenKeyCountLabel".text = GameArchiveManager.player_info.green_key as String
|
GameArchiveManager.update_key_view()
|
||||||
queue_free()
|
queue_free()
|
||||||
GameArchiveManager.add_used_item(get_path())
|
GameArchiveManager.add_used_item(get_path())
|
||||||
AffectAudioPlayer.play_item()
|
AffectAudioPlayer.play_item()
|
||||||
|
@ -15,12 +15,17 @@ func _on_Area2D_body_entered(body):
|
|||||||
|
|
||||||
# 打斗动画播放完成回调
|
# 打斗动画播放完成回调
|
||||||
func _on_AtkSprite_animation_finished():
|
func _on_AtkSprite_animation_finished():
|
||||||
|
AffectAudioPlayer.play_attack()
|
||||||
var atk_sprite =$AtkSprite
|
var atk_sprite =$AtkSprite
|
||||||
atk_sprite.playing = false
|
atk_sprite.playing = false
|
||||||
var player_info = GameArchiveManager.player_info
|
var player_info = GameArchiveManager.player_info
|
||||||
monster_info.hp -= get_hurt(player_info.atk - monster_info.def)
|
monster_info.hp -= get_hurt(player_info.atk - monster_info.def)
|
||||||
if monster_info.hp <= 0:
|
if monster_info.hp <= 0:
|
||||||
dead()
|
#怪物死亡计算
|
||||||
|
GameArchiveManager.add_used_item(get_path())
|
||||||
|
player_info.money += monster_info.money
|
||||||
|
GameArchiveManager.update_money_view()
|
||||||
|
queue_free()
|
||||||
return
|
return
|
||||||
player_info.hp -= get_hurt(monster_info.atk - player_info.def)
|
player_info.hp -= get_hurt(monster_info.atk - player_info.def)
|
||||||
GameArchiveManager.update_hp_view()
|
GameArchiveManager.update_hp_view()
|
||||||
@ -29,10 +34,6 @@ func _on_AtkSprite_animation_finished():
|
|||||||
else:
|
else:
|
||||||
atk_sprite.playing = true
|
atk_sprite.playing = true
|
||||||
|
|
||||||
func dead():
|
|
||||||
GameArchiveManager.add_used_item(get_path())
|
|
||||||
queue_free()
|
|
||||||
|
|
||||||
# 计算伤害
|
# 计算伤害
|
||||||
func get_hurt(hurt:int) -> int:
|
func get_hurt(hurt:int) -> int:
|
||||||
if hurt > 0:
|
if hurt > 0:
|
||||||
|
30
scripts/StairsSprite.gd
Normal file
30
scripts/StairsSprite.gd
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
tool
|
||||||
|
extends Sprite
|
||||||
|
|
||||||
|
# 楼梯
|
||||||
|
class_name StairsSprite
|
||||||
|
|
||||||
|
enum StairsType { Up,Down }
|
||||||
|
|
||||||
|
export(StairsType) var stairs_type = StairsType.Up setget set_stairs_type
|
||||||
|
|
||||||
|
export var player_init_position : Vector2
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
self.texture = load("res://images/mota.png")
|
||||||
|
self.region_enabled = true
|
||||||
|
|
||||||
|
func set_stairs_type(value):
|
||||||
|
stairs_type = value
|
||||||
|
match value:
|
||||||
|
StairsType.Up:
|
||||||
|
region_rect = Rect2(96,512,32,32)
|
||||||
|
StairsType.Down:
|
||||||
|
region_rect = Rect2(64,512,32,32)
|
||||||
|
|
||||||
|
func _on_Area2D_body_entered(body):
|
||||||
|
if stairs_type == StairsType.Up:
|
||||||
|
GameFloorManager.call_deferred("load_added_floor")
|
||||||
|
if stairs_type == StairsType.Down:
|
||||||
|
GameFloorManager.call_deferred("load_reduced_floor")
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user