diff --git a/components/Scenes/World.tscn b/components/Scenes/World.tscn index 5581788..63b7e64 100644 --- a/components/Scenes/World.tscn +++ b/components/Scenes/World.tscn @@ -1,13 +1,13 @@ [gd_scene load_steps=5 format=3 uid="uid://dmxi1ikn6avig"] -[ext_resource type="Script" path="res://scripts/Tools/WorldTool.gd" id="1_t2xvy"] +[ext_resource type="Script" path="res://scripts/Tools/WorldManager.gd" id="1_lxsxj"] [ext_resource type="PackedScene" uid="uid://dfwg750a47ggx" path="res://components/Scenes/UI.tscn" id="2_04cdd"] [ext_resource type="PackedScene" uid="uid://bm7ymrri6pykb" path="res://components/Characters/Rooster.tscn" id="3_5ui6q"] [ext_resource type="Texture2D" uid="uid://ckk8kahhof06u" path="res://resources/maps/Castle 2.png" id="6_p0nkj"] [node name="world" type="Node2D"] y_sort_enabled = true -script = ExtResource("1_t2xvy") +script = ExtResource("1_lxsxj") [node name="UI" parent="." instance=ExtResource("2_04cdd")] diff --git a/scripts/Contents/Characters/Rooster.gd b/scripts/Contents/Characters/Rooster.gd index a9b0bde..1c811ef 100644 --- a/scripts/Contents/Characters/Rooster.gd +++ b/scripts/Contents/Characters/Rooster.gd @@ -2,7 +2,6 @@ extends EntityBase class_name Rooster func _ready(): - fields[FieldStore.Entity.MAX_HEALTH] = 500 super._ready() func ai(): diff --git a/scripts/Contents/Wave.gd b/scripts/Contents/Wave.gd index 8bcb195..90c30eb 100644 --- a/scripts/Contents/Wave.gd +++ b/scripts/Contents/Wave.gd @@ -12,7 +12,8 @@ static var current: int = 0 static var countBoost: float = 0.1 # 每波增加的敌人数量百分比,指数级 static var data: Array[Wave] = [ # entity, minCount, maxCount, isBoss, from, to, per - create(preload("res://components/Characters/Hen.tscn"), 1, 5, false, 0, INF, 1) + create(preload("res://components/Characters/Hen.tscn"), 1, 5, false, 0, INF, 1), + create(preload("res://components/Characters/Chick.tscn"), 0, 0, true, 1, INF, 2) ] static func create( @@ -35,8 +36,10 @@ static func create( return wave static func entityCountOf(wave: Wave) -> int: if wave.from <= current and wave.to >= current and int(current - wave.from) % wave.per == 0: - print("abc") - return randi_range(int(wave.minCount), int(wave.maxCount * ((1 + countBoost) ** current))) + if wave.isBoss: + return 1 + else: + return randi_range(int(wave.minCount), int(wave.maxCount * ((1 + countBoost) ** current))) return 0 static func spawn(): for i in range(len(data)): diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index 61851e5..fc2683f 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -139,3 +139,5 @@ static func generate( if addToWorld: WorldManager.rootNode.add_child(instance) return instance +static func mobCount(): + return len(WorldManager.tree.get_nodes_in_group("mobs")) diff --git a/scripts/Tools/WorldTool.gd b/scripts/Tools/WorldManager.gd similarity index 65% rename from scripts/Tools/WorldTool.gd rename to scripts/Tools/WorldManager.gd index 42ae300..5c9d81e 100644 --- a/scripts/Tools/WorldTool.gd +++ b/scripts/Tools/WorldManager.gd @@ -7,4 +7,6 @@ static var tree: SceneTree func _ready(): tree = get_tree() rootNode = self - Wave.next() +func _physics_process(_delta): + if EntityBase.mobCount() == 0: + Wave.next()