mirror of
https://gitee.com/freeyz/godot-mota.git
synced 2024-12-22 14:49:21 +08:00
增加封印门处理,添加2F和8F封印门
This commit is contained in:
parent
1b038e0115
commit
016fe39434
31
src/door/SealDoor.gd
Normal file
31
src/door/SealDoor.gd
Normal file
@ -0,0 +1,31 @@
|
||||
tool
|
||||
extends StaticBody2D
|
||||
|
||||
export var left_monster_path : NodePath setget set_left_monster
|
||||
|
||||
export var right_monster_path : NodePath setget set_right_monster
|
||||
|
||||
export var count : int = 0
|
||||
|
||||
func _ready():
|
||||
var left_monster = get_node(left_monster_path)
|
||||
var right_monster = get_node(right_monster_path)
|
||||
left_monster.get_child(0).connect("monster_dead",self,"on_monster_dead")
|
||||
right_monster.get_child(0).connect("monster_dead",self,"on_monster_dead")
|
||||
|
||||
func set_left_monster(value):
|
||||
print(value)
|
||||
left_monster_path = value
|
||||
count += 1
|
||||
|
||||
func set_right_monster(value):
|
||||
right_monster_path = value
|
||||
count += 1
|
||||
|
||||
func on_monster_dead():
|
||||
count -= 1
|
||||
if count == 0:
|
||||
$AnimatedSprite.playing = true
|
||||
|
||||
func _on_AnimatedSprite_animation_finished():
|
||||
queue_free()
|
18
src/door/SealDoor.tscn
Normal file
18
src/door/SealDoor.tscn
Normal file
@ -0,0 +1,18 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://src/door/SealDoor.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="SealDoor" type="StaticBody2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
frames = ExtResource( 2 )
|
||||
animation = "seal_door"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
[connection signal="animation_finished" from="AnimatedSprite" to="." method="_on_AnimatedSprite_animation_finished"]
|
@ -87,6 +87,7 @@ position = Vector2( 114.1, 432 )
|
||||
|
||||
[node name="Monster" parent="Items" instance=ExtResource( 6 )]
|
||||
position = Vector2( 112, 144 )
|
||||
frame = 0
|
||||
|
||||
[node name="Monster2" parent="Items" instance=ExtResource( 6 )]
|
||||
position = Vector2( 144, 144 )
|
||||
@ -118,12 +119,15 @@ animation = "skeletonSoilder"
|
||||
|
||||
[node name="Monster5" parent="Items" instance=ExtResource( 6 )]
|
||||
position = Vector2( 304, 464 )
|
||||
frame = 0
|
||||
|
||||
[node name="Monster6" parent="Items" instance=ExtResource( 6 )]
|
||||
position = Vector2( 368, 464 )
|
||||
frame = 0
|
||||
|
||||
[node name="Monster3" parent="Items" instance=ExtResource( 6 )]
|
||||
position = Vector2( 176, 144 )
|
||||
frame = 0
|
||||
|
||||
[node name="Stairs" parent="Items" instance=ExtResource( 3 )]
|
||||
position = Vector2( 48, 144 )
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=14 format=2]
|
||||
[gd_scene load_steps=15 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]
|
||||
@ -12,6 +12,7 @@
|
||||
[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://src/npc/ThiefNpc.tscn" type="PackedScene" id=12]
|
||||
[ext_resource path="res://src/door/SealDoor.tscn" type="PackedScene" id=13]
|
||||
[ext_resource path="res://src/monster/Monster.tscn" type="PackedScene" id=14]
|
||||
|
||||
[node name="Level2" type="Node2D"]
|
||||
@ -35,21 +36,26 @@ 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 )
|
||||
|
||||
[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 )
|
||||
@ -82,12 +88,16 @@ position = Vector2( 48, 464 )
|
||||
[node name="MonsterSprite" parent="Items" instance=ExtResource( 14 )]
|
||||
position = Vector2( 208, 176 )
|
||||
animation = "blueGuard"
|
||||
frame = 0
|
||||
|
||||
[node name="MonsterSprite2" parent="Items" instance=ExtResource( 14 )]
|
||||
position = Vector2( 272, 176 )
|
||||
animation = "blueGuard"
|
||||
frame = 0
|
||||
|
||||
[node name="SealDoor" parent="Items" instance=ExtResource( 13 )]
|
||||
position = Vector2( 240, 208 )
|
||||
left_monster_path = NodePath("../MonsterSprite")
|
||||
right_monster_path = NodePath("../MonsterSprite2")
|
||||
count = 2
|
||||
|
||||
[node name="Thief" parent="." instance=ExtResource( 12 )]
|
||||
|
||||
|
@ -69,78 +69,62 @@ position = Vector2( 176, 272 )
|
||||
[node name="MonsterSprite" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 304, 272 )
|
||||
animation = "skeleton"
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite3" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 176, 208 )
|
||||
animation = "redSlime"
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite10" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 80, 464 )
|
||||
animation = "redSlime"
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite15" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 368, 176 )
|
||||
animation = "redSlime"
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite11" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 112, 432 )
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite14" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 368, 144 )
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite16" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 368, 208 )
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite12" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 48, 432 )
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite5" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 176, 405.1 )
|
||||
position = Vector2( 176, 400 )
|
||||
animation = "bat"
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite13" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 112, 208 )
|
||||
animation = "bat"
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite6" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 240, 400 )
|
||||
animation = "redSlime"
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite7" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 240, 432 )
|
||||
animation = "bluePriest"
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite8" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 144, 304 )
|
||||
animation = "bluePriest"
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite2" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 304, 336 )
|
||||
animation = "skeletonSoilder"
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite9" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 80, 304 )
|
||||
animation = "skeletonSoilder"
|
||||
frame = 1
|
||||
|
||||
[node name="MonsterSprite4" parent="Items" instance=ExtResource( 9 )]
|
||||
position = Vector2( 240, 208 )
|
||||
animation = "skeletonSoilder"
|
||||
frame = 1
|
||||
|
||||
[node name="YellowKey" parent="Items" instance=ExtResource( 10 )]
|
||||
position = Vector2( 176, 464 )
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=17 format=2]
|
||||
[gd_scene load_steps=18 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]
|
||||
@ -16,6 +16,7 @@
|
||||
[ext_resource path="res://src/props/RedGemstone.tscn" type="PackedScene" id=14]
|
||||
[ext_resource path="res://src/props/BlueDrug.tscn" type="PackedScene" id=15]
|
||||
[ext_resource path="res://src/monster/Monster.tscn" type="PackedScene" id=16]
|
||||
[ext_resource path="res://src/door/SealDoor.tscn" type="PackedScene" id=17]
|
||||
|
||||
[node name="Level8" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
@ -124,6 +125,7 @@ position = Vector2( 368, 208 )
|
||||
|
||||
[node name="MonsterSprite" parent="Items" instance=ExtResource( 16 )]
|
||||
position = Vector2( 240, 176 )
|
||||
frame = 0
|
||||
|
||||
[node name="MonsterSprite2" parent="Items" instance=ExtResource( 16 )]
|
||||
position = Vector2( 304, 272 )
|
||||
@ -159,9 +161,11 @@ animation = "redSlime"
|
||||
|
||||
[node name="MonsterSprite9" parent="Items" instance=ExtResource( 16 )]
|
||||
position = Vector2( 112, 304 )
|
||||
frame = 0
|
||||
|
||||
[node name="MonsterSprite11" parent="Items" instance=ExtResource( 16 )]
|
||||
position = Vector2( 48, 432 )
|
||||
frame = 0
|
||||
|
||||
[node name="MonsterSprite6" parent="Items" instance=ExtResource( 16 )]
|
||||
position = Vector2( 208, 368 )
|
||||
@ -179,5 +183,11 @@ animation = "skeletonSoilder"
|
||||
position = Vector2( 368, 272 )
|
||||
animation = "yellowGuard"
|
||||
|
||||
[node name="SealDoor" parent="Items" instance=ExtResource( 17 )]
|
||||
position = Vector2( 336, 240 )
|
||||
left_monster_path = NodePath("../MonsterSprite2")
|
||||
right_monster_path = NodePath("../MonsterSprite3")
|
||||
count = 2
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource( 4 )]
|
||||
position = Vector2( 48, 176 )
|
||||
|
@ -6,6 +6,8 @@ var monster_info : Dictionary
|
||||
|
||||
var monster_sprite : AnimatedSprite
|
||||
|
||||
signal monster_dead
|
||||
|
||||
func _ready():
|
||||
monster_sprite = get_parent()
|
||||
monster_info = MonsterBook.get_info_by_name(monster_sprite.animation)
|
||||
@ -31,8 +33,14 @@ func on_player_touched(player):
|
||||
#删除怪物
|
||||
monster_sprite.queue_free()
|
||||
player.resume()
|
||||
#通知
|
||||
emit_signal("monster_dead")
|
||||
|
||||
# 计算伤害
|
||||
func get_hurt(player) -> int:
|
||||
var count = (self.monster_info.hp / (player.atk - monster_info.def)) as int
|
||||
return count * (monster_info.atk - player.def)
|
||||
var hurt = count * (monster_info.atk - player.def)
|
||||
if hurt < 0:
|
||||
return 0
|
||||
else:
|
||||
return hurt
|
||||
|
@ -25,6 +25,7 @@ animations = [ {
|
||||
]]
|
||||
frames = ExtResource( 8 )
|
||||
animation = "greenSlime"
|
||||
frame = 1
|
||||
playing = true
|
||||
|
||||
[node name="Monster" type="StaticBody2D" parent="."]
|
||||
|
Loading…
Reference in New Issue
Block a user