mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 23:11:54 +08:00
feat: 重构World工具,添加WorldManager类,更新波次生成逻辑,增强敌人管理功能
This commit is contained in:
@@ -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")]
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ extends EntityBase
|
||||
class_name Rooster
|
||||
|
||||
func _ready():
|
||||
fields[FieldStore.Entity.MAX_HEALTH] = 500
|
||||
super._ready()
|
||||
|
||||
func ai():
|
||||
|
||||
@@ -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)):
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user