1
0
mirror of https://gitee.com/freeyz/godot-mota.git synced 2024-12-23 01:39:20 +08:00

增加怪物逻辑和动画

This commit is contained in:
freewu32 2020-07-24 14:18:35 +08:00
parent 382ded0f93
commit c9abebbaf0
12 changed files with 505 additions and 70 deletions

View File

@ -0,0 +1,3 @@
source_md5="8e8d87361090ad2293d29fbc84740e92"
dest_md5="ece39710df6cdb65420858e51d9f920f"

Binary file not shown.

View File

@ -1,13 +1,16 @@
[gd_scene load_steps=5 format=2] [gd_scene load_steps=6 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]
[node name="Main" type="Node2D"] [node name="Main" type="Node2D"]
[node name="BgmAudioPlayer" type="AudioStreamPlayer2D" parent="."] [node name="BgmAudioPlayer" type="AudioStreamPlayer2D" parent="."]
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="."]
@ -15,7 +18,7 @@ tile_set = ExtResource( 4 )
cell_size = Vector2( 32, 32 ) cell_size = Vector2( 32, 32 )
cell_custom_transform = Transform2D( 32, 0, 0, 32, 0, 0 ) cell_custom_transform = Transform2D( 32, 0, 0, 32, 0, 0 )
format = 1 format = 1
tile_data = PoolIntArray( 0, 1, 0, 1, 1, 0, 2, 1, 0, 3, 1, 0, 17, 1, 0, 18, 1, 0, 19, 1, 0, 20, 1, 0, 65536, 1, 0, 65537, 1, 0, 65538, 1, 0, 65539, 1, 0, 65553, 1, 0, 65554, 1, 0, 65555, 1, 0, 65556, 1, 0, 131072, 1, 0, 131073, 1, 0, 131074, 1, 0, 131075, 1, 0, 131089, 1, 0, 131090, 1, 0, 131091, 1, 0, 131092, 1, 0, 196608, 1, 0, 196609, 1, 0, 196610, 1, 0, 196611, 1, 0, 196625, 1, 0, 196626, 1, 0, 196627, 1, 0, 196628, 1, 0, 262144, 1, 0, 262145, 1, 0, 262146, 1, 0, 262147, 1, 0, 262161, 1, 0, 262162, 1, 0, 262163, 1, 0, 262164, 1, 0, 327680, 1, 0, 327681, 1, 0, 327682, 1, 0, 327683, 1, 0, 327697, 1, 0, 327698, 1, 0, 327699, 1, 0, 327700, 1, 0, 393216, 1, 0, 393217, 1, 0, 393218, 1, 0, 393219, 1, 0, 393233, 1, 0, 393234, 1, 0, 393235, 1, 0, 393236, 1, 0, 458752, 1, 0, 458753, 1, 0, 458754, 1, 0, 458755, 1, 0, 458769, 1, 0, 458770, 1, 0, 458771, 1, 0, 458772, 1, 0, 524288, 1, 0, 524289, 1, 0, 524290, 1, 0, 524291, 1, 0, 524305, 1, 0, 524306, 1, 0, 524307, 1, 0, 524308, 1, 0, 589824, 1, 0, 589825, 1, 0, 589826, 1, 0, 589827, 1, 0, 589841, 1, 0, 589842, 1, 0, 589843, 1, 0, 589844, 1, 0, 655360, 1, 0, 655361, 1, 0, 655362, 1, 0, 655363, 1, 0, 655377, 1, 0, 655378, 1, 0, 655379, 1, 0, 655380, 1, 0, 720896, 1, 0, 720897, 1, 0, 720898, 1, 0, 720899, 1, 0, 720913, 1, 0, 720914, 1, 0, 720915, 1, 0, 720916, 1, 0, 786432, 1, 0, 786433, 1, 0, 786434, 1, 0, 786435, 1, 0, 786449, 1, 0, 786450, 1, 0, 786451, 1, 0, 786452, 1, 0 ) tile_data = PoolIntArray( 0, 1, 0, 1, 1, 0, 2, 1, 0, 3, 1, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 0, 10, 0, 0, 11, 0, 0, 12, 0, 0, 13, 0, 0, 14, 0, 0, 15, 0, 0, 16, 0, 0, 17, 1, 0, 18, 1, 0, 19, 1, 0, 20, 1, 0, 65536, 1, 0, 65537, 1, 0, 65538, 1, 0, 65539, 1, 0, 65540, 0, 0, 65541, 0, 0, 65542, 0, 0, 65543, 0, 0, 65544, 0, 0, 65545, 0, 0, 65546, 0, 0, 65547, 0, 0, 65548, 0, 0, 65549, 0, 0, 65550, 0, 0, 65551, 0, 0, 65552, 0, 0, 65553, 1, 0, 65554, 1, 0, 65555, 1, 0, 65556, 1, 0, 131072, 1, 0, 131073, 1, 0, 131074, 1, 0, 131075, 1, 0, 131076, 0, 0, 131077, 0, 0, 131078, 0, 0, 131079, 0, 0, 131080, 0, 0, 131081, 0, 0, 131082, 0, 0, 131083, 0, 0, 131084, 0, 0, 131085, 0, 0, 131086, 0, 0, 131087, 0, 0, 131088, 0, 0, 131089, 1, 0, 131090, 1, 0, 131091, 1, 0, 131092, 1, 0, 196608, 1, 0, 196609, 1, 0, 196610, 1, 0, 196611, 1, 0, 196612, 0, 0, 196613, 0, 0, 196614, 0, 0, 196615, 0, 0, 196616, 0, 0, 196617, 0, 0, 196618, 0, 0, 196619, 0, 0, 196620, 0, 0, 196621, 0, 0, 196622, 0, 0, 196623, 0, 0, 196624, 0, 0, 196625, 1, 0, 196626, 1, 0, 196627, 1, 0, 196628, 1, 0, 262144, 1, 0, 262145, 1, 0, 262146, 1, 0, 262147, 1, 0, 262148, 0, 0, 262149, 0, 0, 262150, 0, 0, 262151, 0, 0, 262152, 0, 0, 262153, 0, 0, 262154, 0, 0, 262155, 0, 0, 262156, 0, 0, 262157, 0, 0, 262158, 0, 0, 262159, 0, 0, 262160, 0, 0, 262161, 1, 0, 262162, 1, 0, 262163, 1, 0, 262164, 1, 0, 327680, 1, 0, 327681, 1, 0, 327682, 1, 0, 327683, 1, 0, 327684, 0, 0, 327685, 0, 0, 327686, 0, 0, 327687, 0, 0, 327688, 0, 0, 327689, 0, 0, 327690, 0, 0, 327691, 0, 0, 327692, 0, 0, 327693, 0, 0, 327694, 0, 0, 327695, 0, 0, 327696, 0, 0, 327697, 1, 0, 327698, 1, 0, 327699, 1, 0, 327700, 1, 0, 393216, 1, 0, 393217, 1, 0, 393218, 1, 0, 393219, 1, 0, 393220, 0, 0, 393221, 0, 0, 393222, 0, 0, 393223, 0, 0, 393224, 0, 0, 393225, 0, 0, 393226, 0, 0, 393227, 0, 0, 393228, 0, 0, 393229, 0, 0, 393230, 0, 0, 393231, 0, 0, 393232, 0, 0, 393233, 1, 0, 393234, 1, 0, 393235, 1, 0, 393236, 1, 0, 458752, 1, 0, 458753, 1, 0, 458754, 1, 0, 458755, 1, 0, 458756, 0, 0, 458757, 0, 0, 458758, 0, 0, 458759, 0, 0, 458760, 0, 0, 458761, 0, 0, 458762, 0, 0, 458763, 0, 0, 458764, 0, 0, 458765, 0, 0, 458766, 0, 0, 458767, 0, 0, 458768, 0, 0, 458769, 1, 0, 458770, 1, 0, 458771, 1, 0, 458772, 1, 0, 524288, 1, 0, 524289, 1, 0, 524290, 1, 0, 524291, 1, 0, 524292, 0, 0, 524293, 0, 0, 524294, 0, 0, 524295, 0, 0, 524296, 0, 0, 524297, 0, 0, 524298, 0, 0, 524299, 0, 0, 524300, 0, 0, 524301, 0, 0, 524302, 0, 0, 524303, 0, 0, 524304, 0, 0, 524305, 1, 0, 524306, 1, 0, 524307, 1, 0, 524308, 1, 0, 589824, 1, 0, 589825, 1, 0, 589826, 1, 0, 589827, 1, 0, 589828, 0, 0, 589829, 0, 0, 589830, 0, 0, 589831, 0, 0, 589832, 0, 0, 589833, 0, 0, 589834, 0, 0, 589835, 0, 0, 589836, 0, 0, 589837, 0, 0, 589838, 0, 0, 589839, 0, 0, 589840, 0, 0, 589841, 1, 0, 589842, 1, 0, 589843, 1, 0, 589844, 1, 0, 655360, 1, 0, 655361, 1, 0, 655362, 1, 0, 655363, 1, 0, 655364, 0, 0, 655365, 0, 0, 655366, 0, 0, 655367, 0, 0, 655368, 0, 0, 655369, 0, 0, 655370, 0, 0, 655371, 0, 0, 655372, 0, 0, 655373, 0, 0, 655374, 0, 0, 655375, 0, 0, 655376, 0, 0, 655377, 1, 0, 655378, 1, 0, 655379, 1, 0, 655380, 1, 0, 720896, 1, 0, 720897, 1, 0, 720898, 1, 0, 720899, 1, 0, 720900, 0, 0, 720901, 0, 0, 720902, 0, 0, 720903, 0, 0, 720904, 0, 0, 720905, 0, 0, 720906, 0, 0, 720907, 0, 0, 720908, 0, 0, 720909, 0, 0, 720910, 0, 0, 720911, 0, 0, 720912, 0, 0, 720913, 1, 0, 720914, 1, 0, 720915, 1, 0, 720916, 1, 0, 786432, 1, 0, 786433, 1, 0, 786434, 1, 0, 786435, 1, 0, 786436, 0, 0, 786437, 0, 0, 786438, 0, 0, 786439, 0, 0, 786440, 0, 0, 786441, 0, 0, 786442, 0, 0, 786443, 0, 0, 786444, 0, 0, 786445, 0, 0, 786446, 0, 0, 786447, 0, 0, 786448, 0, 0, 786449, 1, 0, 786450, 1, 0, 786451, 1, 0, 786452, 1, 0 )
[node name="UI" parent="." instance=ExtResource( 1 )] [node name="UI" parent="." instance=ExtResource( 1 )]

View File

@ -1,10 +1,7 @@
[gd_resource type="TileSet" load_steps=4 format=2] [gd_resource type="TileSet" load_steps=3 format=2]
[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="ConvexPolygonShape2D" id=1]
points = PoolVector2Array( 0, 0, 32, 0, 32, 32, 0, 32 )
[sub_resource type="NavigationPolygon" id=2] [sub_resource type="NavigationPolygon" id=2]
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 ) ]
@ -20,16 +17,9 @@ polygons = [ PoolIntArray( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ) ]
0/navigation_offset = Vector2( 0, 0 ) 0/navigation_offset = Vector2( 0, 0 )
0/shape_offset = Vector2( 0, 0 ) 0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape = SubResource( 1 )
0/shape_one_way = false 0/shape_one_way = false
0/shape_one_way_margin = 1.0 0/shape_one_way_margin = 0.0
0/shapes = [ { 0/shapes = [ ]
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 1 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
0/z_index = 0 0/z_index = 0
1/name = "mota.png 1" 1/name = "mota.png 1"
1/texture = ExtResource( 1 ) 1/texture = ExtResource( 1 )

View File

@ -39,6 +39,11 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://scripts/KeySprite.gd" "path": "res://scripts/KeySprite.gd"
}, { }, {
"base": "AnimatedSprite",
"class": "MonsterSprite",
"language": "GDScript",
"path": "res://scripts/MonsterSprite.gd"
}, {
"base": "TileMap", "base": "TileMap",
"class": "NavigationTileMap", "class": "NavigationTileMap",
"language": "GDScript", "language": "GDScript",
@ -66,6 +71,7 @@ _global_script_class_icons={
"DoorStaticBody2D": "", "DoorStaticBody2D": "",
"ElixirsSprite": "", "ElixirsSprite": "",
"KeySprite": "", "KeySprite": "",
"MonsterSprite": "",
"NavigationTileMap": "", "NavigationTileMap": "",
"PlayerKinematicBody2D": "", "PlayerKinematicBody2D": "",
"PlayerSprite": "", "PlayerSprite": "",
@ -87,6 +93,7 @@ config/icon="res://settings/icon.png"
GameFloorManager="*res://scripts/GameFloorManager.gd" GameFloorManager="*res://scripts/GameFloorManager.gd"
GameArchiveManager="*res://scripts/GameArchiveManager.gd" GameArchiveManager="*res://scripts/GameArchiveManager.gd"
AffectAudioPlayer="*res://scripts/AffectAudioPlayer.gd" AffectAudioPlayer="*res://scripts/AffectAudioPlayer.gd"
MonsterBook="*res://scripts/MonsterBook.gd"
[debug] [debug]
@ -103,7 +110,6 @@ window/stretch/aspect="keep"
[rendering] [rendering]
quality/driver/fallback_to_gles2=true
quality/intended_usage/framebuffer_allocation=0 quality/intended_usage/framebuffer_allocation=0
quality/intended_usage/framebuffer_allocation.mobile=0 quality/intended_usage/framebuffer_allocation.mobile=0
quality/2d/use_pixel_snap=true quality/2d/use_pixel_snap=true

403
scenes/Monster.tscn Normal file
View File

@ -0,0 +1,403 @@
[gd_scene load_steps=63 format=2]
[ext_resource path="res://images/mota.png" type="Texture" id=1]
[ext_resource path="res://scripts/MonsterSprite.gd" type="Script" id=2]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 0, 32, 32, 32 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 32, 32, 32, 32 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 1 )
region = Rect2( 32, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 1 )
region = Rect2( 0, 64, 32, 32 )
[sub_resource type="AtlasTexture" id=6]
atlas = ExtResource( 1 )
region = Rect2( 32, 64, 32, 32 )
[sub_resource type="AtlasTexture" id=7]
atlas = ExtResource( 1 )
region = Rect2( 192, 96, 32, 32 )
[sub_resource type="AtlasTexture" id=8]
atlas = ExtResource( 1 )
region = Rect2( 224, 96, 32, 32 )
[sub_resource type="AtlasTexture" id=9]
atlas = ExtResource( 1 )
region = Rect2( 64, 160, 32, 32 )
[sub_resource type="AtlasTexture" id=10]
atlas = ExtResource( 1 )
region = Rect2( 96, 160, 32, 32 )
[sub_resource type="AtlasTexture" id=11]
atlas = ExtResource( 1 )
region = Rect2( 192, 64, 32, 32 )
[sub_resource type="AtlasTexture" id=12]
atlas = ExtResource( 1 )
region = Rect2( 224, 64, 32, 32 )
[sub_resource type="AtlasTexture" id=13]
atlas = ExtResource( 1 )
region = Rect2( 256, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=14]
atlas = ExtResource( 1 )
region = Rect2( 288, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=15]
atlas = ExtResource( 1 )
region = Rect2( 256, 64, 32, 32 )
[sub_resource type="AtlasTexture" id=16]
atlas = ExtResource( 1 )
region = Rect2( 288, 64, 32, 32 )
[sub_resource type="AtlasTexture" id=17]
atlas = ExtResource( 1 )
region = Rect2( 64, 128, 32, 32 )
[sub_resource type="AtlasTexture" id=18]
atlas = ExtResource( 1 )
region = Rect2( 96, 128, 32, 32 )
[sub_resource type="AtlasTexture" id=19]
atlas = ExtResource( 1 )
region = Rect2( 128, 96, 32, 32 )
[sub_resource type="AtlasTexture" id=20]
atlas = ExtResource( 1 )
region = Rect2( 160, 96, 32, 32 )
[sub_resource type="AtlasTexture" id=21]
atlas = ExtResource( 1 )
region = Rect2( 64, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=22]
atlas = ExtResource( 1 )
region = Rect2( 96, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=23]
atlas = ExtResource( 1 )
region = Rect2( 256, 96, 32, 32 )
[sub_resource type="AtlasTexture" id=24]
atlas = ExtResource( 1 )
region = Rect2( 288, 96, 32, 32 )
[sub_resource type="AtlasTexture" id=25]
atlas = ExtResource( 1 )
region = Rect2( 192, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=26]
atlas = ExtResource( 1 )
region = Rect2( 224, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=27]
atlas = ExtResource( 1 )
region = Rect2( 256, 32, 32, 32 )
[sub_resource type="AtlasTexture" id=28]
atlas = ExtResource( 1 )
region = Rect2( 288, 32, 32, 32 )
[sub_resource type="AtlasTexture" id=29]
atlas = ExtResource( 1 )
region = Rect2( 64, 64, 32, 32 )
[sub_resource type="AtlasTexture" id=30]
atlas = ExtResource( 1 )
region = Rect2( 96, 64, 32, 32 )
[sub_resource type="AtlasTexture" id=31]
atlas = ExtResource( 1 )
region = Rect2( 128, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=32]
atlas = ExtResource( 1 )
region = Rect2( 160, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=33]
atlas = ExtResource( 1 )
region = Rect2( 0, 160, 32, 32 )
[sub_resource type="AtlasTexture" id=34]
atlas = ExtResource( 1 )
region = Rect2( 32, 160, 32, 32 )
[sub_resource type="AtlasTexture" id=35]
atlas = ExtResource( 1 )
region = Rect2( 0, 96, 32, 32 )
[sub_resource type="AtlasTexture" id=36]
atlas = ExtResource( 1 )
region = Rect2( 32, 96, 32, 32 )
[sub_resource type="AtlasTexture" id=37]
atlas = ExtResource( 1 )
region = Rect2( 64, 32, 32, 32 )
[sub_resource type="AtlasTexture" id=38]
atlas = ExtResource( 1 )
region = Rect2( 96, 32, 32, 32 )
[sub_resource type="AtlasTexture" id=39]
atlas = ExtResource( 1 )
region = Rect2( 192, 32, 32, 32 )
[sub_resource type="AtlasTexture" id=40]
atlas = ExtResource( 1 )
region = Rect2( 224, 32, 32, 32 )
[sub_resource type="AtlasTexture" id=41]
atlas = ExtResource( 1 )
region = Rect2( 128, 128, 32, 32 )
[sub_resource type="AtlasTexture" id=42]
atlas = ExtResource( 1 )
region = Rect2( 160, 128, 32, 32 )
[sub_resource type="AtlasTexture" id=43]
atlas = ExtResource( 1 )
region = Rect2( 128, 32, 32, 32 )
[sub_resource type="AtlasTexture" id=44]
atlas = ExtResource( 1 )
region = Rect2( 160, 32, 32, 32 )
[sub_resource type="AtlasTexture" id=45]
atlas = ExtResource( 1 )
region = Rect2( 128, 64, 32, 32 )
[sub_resource type="AtlasTexture" id=46]
atlas = ExtResource( 1 )
region = Rect2( 160, 64, 32, 32 )
[sub_resource type="AtlasTexture" id=47]
atlas = ExtResource( 1 )
region = Rect2( 0, 128, 32, 32 )
[sub_resource type="AtlasTexture" id=48]
atlas = ExtResource( 1 )
region = Rect2( 32, 128, 32, 32 )
[sub_resource type="AtlasTexture" id=49]
atlas = ExtResource( 1 )
region = Rect2( 256, 128, 32, 32 )
[sub_resource type="AtlasTexture" id=50]
atlas = ExtResource( 1 )
region = Rect2( 288, 128, 32, 32 )
[sub_resource type="AtlasTexture" id=51]
atlas = ExtResource( 1 )
region = Rect2( 256, 32, 32, 32 )
[sub_resource type="AtlasTexture" id=52]
atlas = ExtResource( 1 )
region = Rect2( 288, 32, 32, 32 )
[sub_resource type="AtlasTexture" id=53]
atlas = ExtResource( 1 )
region = Rect2( 64, 96, 32, 32 )
[sub_resource type="AtlasTexture" id=54]
atlas = ExtResource( 1 )
region = Rect2( 96, 96, 32, 32 )
[sub_resource type="AtlasTexture" id=55]
atlas = ExtResource( 1 )
region = Rect2( 192, 128, 32, 32 )
[sub_resource type="AtlasTexture" id=56]
atlas = ExtResource( 1 )
region = Rect2( 224, 128, 32, 32 )
[sub_resource type="SpriteFrames" id=57]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ) ],
"loop": true,
"name": "skeleton",
"speed": 5.0
}, {
"frames": [ SubResource( 3 ), SubResource( 4 ) ],
"loop": true,
"name": "greenSlime",
"speed": 5.0
}, {
"frames": [ SubResource( 5 ), SubResource( 6 ) ],
"loop": true,
"name": "zombie",
"speed": 5.0
}, {
"frames": [ SubResource( 7 ), SubResource( 8 ) ],
"loop": true,
"name": "blueGuard",
"speed": 5.0
}, {
"frames": [ SubResource( 9 ), SubResource( 10 ) ],
"loop": true,
"name": "darkKnight",
"speed": 5.0
}, {
"frames": [ SubResource( 11 ), SubResource( 12 ) ],
"loop": true,
"name": "slimeMan",
"speed": 5.0
}, {
"frames": [ SubResource( 13 ), SubResource( 14 ) ],
"loop": true,
"name": "bigBat",
"speed": 5.0
}, {
"frames": [ SubResource( 15 ), SubResource( 16 ) ],
"loop": true,
"name": "slimelord",
"speed": 5.0
}, {
"frames": [ SubResource( 17 ), SubResource( 18 ) ],
"loop": true,
"name": "yellowKnight",
"speed": 5.0
}, {
"frames": [ SubResource( 19 ), SubResource( 20 ) ],
"loop": true,
"name": "yellowGuard",
"speed": 5.0
}, {
"frames": [ SubResource( 21 ), SubResource( 22 ) ],
"loop": true,
"name": "redSlime",
"speed": 5.0
}, {
"frames": [ SubResource( 23 ), SubResource( 24 ) ],
"loop": true,
"name": "redGuard",
"speed": 5.0
}, {
"frames": [ SubResource( 25 ), SubResource( 26 ) ],
"loop": true,
"name": "bat",
"speed": 5.0
}, {
"frames": [ SubResource( 27 ), SubResource( 28 ) ],
"loop": true,
"name": "vampire",
"speed": 5.0
}, {
"frames": [ SubResource( 29 ), SubResource( 30 ) ],
"loop": true,
"name": "zombieKnight",
"speed": 5.0
}, {
"frames": [ SubResource( 31 ), SubResource( 32 ) ],
"loop": true,
"name": "blackSlime",
"speed": 5.0
}, {
"frames": [ SubResource( 33 ), SubResource( 34 ) ],
"loop": true,
"name": "ghostSkeleton",
"speed": 5.0
}, {
"frames": [ SubResource( 35 ), SubResource( 36 ) ],
"loop": true,
"name": "brownWizard",
"speed": 5.0
}, {
"frames": [ SubResource( 37 ), SubResource( 38 ) ],
"loop": true,
"name": "skeletonSoilder",
"speed": 5.0
}, {
"frames": [ SubResource( 39 ), SubResource( 40 ) ],
"loop": true,
"name": "bluePriest",
"speed": 5.0
}, {
"frames": [ SubResource( 41 ), SubResource( 42 ) ],
"loop": true,
"name": "redKnight",
"speed": 5.0
}, {
"frames": [ SubResource( 43 ), SubResource( 44 ) ],
"loop": true,
"name": "skeletonCaptain",
"speed": 5.0
}, {
"frames": [ SubResource( 45 ), SubResource( 46 ) ],
"loop": true,
"name": "rock",
"speed": 5.0
}, {
"frames": [ SubResource( 47 ), SubResource( 48 ) ],
"loop": true,
"name": "redBat",
"speed": 5.0
}, {
"frames": [ SubResource( 49 ), SubResource( 50 ) ],
"loop": true,
"name": "soldier",
"speed": 5.0
}, {
"frames": [ SubResource( 51 ), SubResource( 52 ) ],
"loop": true,
"name": "redPriest",
"speed": 5.0
}, {
"frames": [ SubResource( 53 ), SubResource( 54 ) ],
"loop": true,
"name": "redWizard",
"speed": 5.0
}, {
"frames": [ SubResource( 55 ), SubResource( 56 ) ],
"loop": true,
"name": "swordsman",
"speed": 5.0
} ]
[sub_resource type="AtlasTexture" id=58]
atlas = ExtResource( 1 )
region = Rect2( 288, 448, 32, 32 )
[sub_resource type="SpriteFrames" id=59]
animations = [ {
"frames": [ null, SubResource( 58 ) ],
"loop": true,
"name": "default",
"speed": 20.0
} ]
[sub_resource type="RectangleShape2D" id=60]
[node name="MonsterSprite" type="AnimatedSprite"]
position = Vector2( 304, 144 )
z_index = 1
frames = SubResource( 57 )
animation = "bat"
playing = true
script = ExtResource( 2 )
[node name="AtkSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 59 )
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 60 )
[connection signal="animation_finished" from="AtkSprite" to="." method="_on_AtkSprite_animation_finished"]
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

View File

@ -1,11 +1,8 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=4 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/Doore.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/Elixirs.tscn" type="PackedScene" id=4]
[ext_resource path="res://scenes/Player.tscn" type="PackedScene" id=5] [ext_resource path="res://scenes/Player.tscn" type="PackedScene" id=5]
[ext_resource path="res://scenes/Key.tscn" type="PackedScene" id=6]
[node name="Floor1" type="Node2D"] [node name="Floor1" type="Node2D"]
@ -14,52 +11,10 @@ tile_set = ExtResource( 1 )
cell_size = Vector2( 32, 32 ) cell_size = Vector2( 32, 32 )
collision_mask = 2147483649 collision_mask = 2147483649
format = 1 format = 1
tile_data = PoolIntArray( 196618, 2, 0, 262151, 2, 0, 262152, 2, 0, 262153, 2, 0, 262154, 2, 0, 262155, 2, 0, 262156, 2, 0, 262157, 2, 0, 327687, 2, 0, 327690, 2, 0, 327693, 2, 0, 393222, 2, 0, 393223, 2, 0, 393224, 2, 0, 393225, 2, 0, 393226, 2, 0, 393227, 2, 0, 393228, 2, 0, 393229, 2, 0, 393230, 2, 0, 393231, 2, 0, 458759, 2, 0, 458760, 2, 0, 458762, 2, 0, 458765, 2, 0, 524296, 2, 0, 524297, 2, 0, 524298, 2, 0, 524299, 2, 0, 524300, 2, 0, 524301, 2, 0, 589834, 2, 0 ) 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, 131087, 2, 0, 196613, 2, 0, 196614, 2, 0, 196615, 2, 0, 196616, 2, 0, 196617, 2, 0, 196619, 2, 0, 196620, 2, 0, 196621, 2, 0, 196623, 2, 0, 262149, 2, 0, 262150, 2, 0, 262151, 2, 0, 262153, 2, 0, 262155, 2, 0, 262156, 2, 0, 262157, 2, 0, 262159, 2, 0, 327686, 2, 0, 327689, 2, 0, 327693, 2, 0, 327695, 2, 0, 393221, 2, 0, 393222, 2, 0, 393223, 2, 0, 393225, 2, 0, 393226, 2, 0, 393227, 2, 0, 393228, 2, 0, 393229, 2, 0, 393231, 2, 0, 458757, 2, 0, 458758, 2, 0, 458759, 2, 0, 458761, 2, 0, 458767, 2, 0, 524294, 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, 589830, 2, 0, 589831, 2, 0, 589834, 2, 0, 589838, 2, 0, 655365, 2, 0, 655366, 2, 0, 655367, 2, 0, 655369, 2, 0, 655370, 2, 0, 655371, 2, 0, 655373, 2, 0, 655374, 2, 0, 655375, 2, 0, 720901, 2, 0, 720902, 2, 0, 720903, 2, 0, 720905, 2, 0, 720906, 2, 0, 720907, 2, 0, 720909, 2, 0, 720910, 2, 0, 720911, 2, 0 )
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="Item" type="Node2D" parent="."] [node name="Item" type="Node2D" parent="."]
[node name="KeySprite" parent="Item" instance=ExtResource( 6 )]
[node name="KeySprite2" parent="Item" instance=ExtResource( 6 )]
position = Vector2( 336, 144 )
region_rect = Rect2( 160, 448, 32, 32 )
key_type = 2
[node name="KeySprite3" parent="Item" instance=ExtResource( 6 )]
position = Vector2( 336, 272 )
region_rect = Rect2( 192, 448, 32, 32 )
key_type = 3
[node name="KeySprite4" parent="Item" instance=ExtResource( 6 )]
position = Vector2( 240, 208 )
region_rect = Rect2( 128, 448, 32, 32 )
key_type = 1
[node name="DoorSprite" parent="Item" instance=ExtResource( 2 )]
[node name="DoorSprite2" parent="Item" instance=ExtResource( 2 )]
position = Vector2( 368, 208 )
region_rect = Rect2( 256, 480, 32, 32 )
door_type = 2
[node name="DoorSprite3" parent="Item" instance=ExtResource( 2 )]
position = Vector2( 336, 176 )
region_rect = Rect2( 288, 480, 32, 32 )
door_type = 3
[node name="DoorSprite4" parent="Item" instance=ExtResource( 2 )]
position = Vector2( 336, 240 )
region_rect = Rect2( 288, 480, 32, 32 )
door_type = 3
[node name="ElixirsSprite" parent="Item" instance=ExtResource( 4 )]
[node name="ElixirsSprite2" parent="Item" instance=ExtResource( 4 )]
position = Vector2( 240, 144 )
region_rect = Rect2( 128, 416, 32, 32 )
elixirs_color = 1
elixirs_value = 200
[node name="PlayerKinematicBody2D" parent="." instance=ExtResource( 5 )] [node name="PlayerKinematicBody2D" parent="." instance=ExtResource( 5 )]
navigation_tile_map_path = NodePath("../../Floor1/NavigationTileMap") position = Vector2( 336, 368 )

View File

@ -4,7 +4,7 @@ class_name DoorStaticBody2D
onready var door_sprite : DoorSprite = get_parent() onready var door_sprite : DoorSprite = get_parent()
func on_player_touched(): func on_player_touched(player):
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:

View File

@ -13,9 +13,9 @@ var player_info = {
#英雄血量 #英雄血量
"hp" : 1000, "hp" : 1000,
# 英雄攻击力 # 英雄攻击力
"atk" : 1, "atk" : 10,
# 英雄防御力 # 英雄防御力
"def" : 1, "def" : 10,
#默认金钱 #默认金钱
"money" : 0, "money" : 0,
# 英雄等级 # 英雄等级
@ -98,10 +98,20 @@ func load_by_index(index:int) -> void:
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_hp_view()
update_key_view()
# 更新楼层UI显示
func update_floor_view():
$"/root/Main/UI/LevelBackground/LevelLabel".text = "魔塔 第%s" % player_info.now_floor $"/root/Main/UI/LevelBackground/LevelLabel".text = "魔塔 第%s" % player_info.now_floor
#更新人物血量
# 更新人物血量
func update_hp_view():
$"/root/Main/UI/HpSprite/HpBackground/HpLabel".text = player_info.hp as String $"/root/Main/UI/HpSprite/HpBackground/HpLabel".text = player_info.hp as String
#更新钥匙数量显示
# 更新钥匙数量显示
func update_key_view():
$"/root/Main/UI/KeyBackground/YellowKeyCountLabel".text = player_info.yellow_key as String $"/root/Main/UI/KeyBackground/YellowKeyCountLabel".text = player_info.yellow_key as String
$"/root/Main/UI/KeyBackground/BlueKeyCountLabel".text = player_info.blue_key as String $"/root/Main/UI/KeyBackground/BlueKeyCountLabel".text = player_info.blue_key as String
$"/root/Main/UI/KeyBackground/RedKeyCountLabel".text = player_info.red_key as String $"/root/Main/UI/KeyBackground/RedKeyCountLabel".text = player_info.red_key as String

24
scripts/MonsterBook.gd Normal file
View File

@ -0,0 +1,24 @@
extends Node
var monster_data : Dictionary
# 根据json文件初始化怪物数据
func _ready():
var file = File.new()
file.open("res://monster.json",File.READ)
var json_result = JSON.parse(file.get_as_text())
if json_result.error != OK:
print(json_result.error_string)
else:
monster_data = json_result.result
file.close()
# 获取所有怪物名称
func get_monsters_name() -> Array:
if monster_data == null:
return []
return monster_data.keys()
# 根据怪物名称获取怪物信息
func get_info_by_name(name:String) -> Dictionary:
return monster_data[name]

41
scripts/MonsterSprite.gd Normal file
View File

@ -0,0 +1,41 @@
extends AnimatedSprite
class_name MonsterSprite
var monster_info : Dictionary
func _on_Area2D_body_entered(body):
# 查询怪物信息
monster_info = MonsterBook.get_info_by_name(animation)
if monster_info == null:
print("未找到怪物",animation)
return
# 开始播放打斗动画
$AtkSprite.playing = true
# 打斗动画播放完成回调
func _on_AtkSprite_animation_finished():
var atk_sprite =$AtkSprite
atk_sprite.playing = false
var player_info = GameArchiveManager.player_info
monster_info.hp -= get_hurt(player_info.atk - monster_info.def)
if monster_info.hp <= 0:
dead()
return
player_info.hp -= get_hurt(monster_info.atk - player_info.def)
GameArchiveManager.update_hp_view()
if player_info.hp <=0:
print("game over")
else:
atk_sprite.playing = true
func dead():
GameArchiveManager.add_used_item(get_path())
queue_free()
# 计算伤害
func get_hurt(hurt:int) -> int:
if hurt > 0:
return hurt
else:
return 0

View File

@ -50,4 +50,4 @@ func call_collider(collision:KinematicCollision2D):
if collider is TileMap: if collider is TileMap:
return return
if collider.has_method("on_player_touched"): if collider.has_method("on_player_touched"):
collider.on_player_touched() collider.call("on_player_touched",self)