From a572a77eda9bc1652ca7c1e4dbdf43a053f916c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Thu, 28 Aug 2025 07:45:50 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B8=B8=E6=88=8F=E5=B9=B3=E8=A1=A1):=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=95=8C=E4=BA=BA=E7=94=9F=E6=88=90=E5=92=8C?= =?UTF-8?q?=E5=AD=90=E5=BC=B9=E8=A1=8C=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将敌人数量增长逻辑移至GameRule并调整计算公式 - 修改鸡的攻击行为,子弹现在会朝向玩家发射 - 调整子弹伤害值和旋转动画 - 减少玩家初始苹果数量并增加敌人掉落苹果数量 - 修改BOSS出现波数为第8波 - 移除无用属性和优化代码结构 --- components/Bullets/Star.tscn | 34 +++++++++++++++--------------- components/Characters/Hen.tscn | 1 - components/Scenes/UI.tscn | 3 --- scripts/Contents/Characters/Hen.gd | 4 +++- scripts/Contents/Wave.gd | 5 ++--- scripts/Statemachine/EntityBase.gd | 7 +++--- scripts/Tools/GameRule.gd | 3 ++- 7 files changed, 28 insertions(+), 29 deletions(-) diff --git a/components/Bullets/Star.tscn b/components/Bullets/Star.tscn index 4a40fcd..d1fe70f 100644 --- a/components/Bullets/Star.tscn +++ b/components/Bullets/Star.tscn @@ -15,8 +15,20 @@ animations = [{ "speed": 5.0 }] -[sub_resource type="Animation" id="Animation_kmogx"] -resource_name = "spawn" +[sub_resource type="Animation" id="Animation_cig5u"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [4.38234] +} [sub_resource type="Animation" id="Animation_ynxlt"] resource_name = "loop" @@ -35,20 +47,8 @@ tracks/0/keys = { "values": [0.0, 6.28319] } -[sub_resource type="Animation" id="Animation_cig5u"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:rotation") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [4.38234] -} +[sub_resource type="Animation" id="Animation_kmogx"] +resource_name = "spawn" [sub_resource type="AnimationLibrary" id="AnimationLibrary_ls1ie"] _data = { @@ -64,7 +64,7 @@ radius = 19.2354 script = ExtResource("2_y4b0l") fields = { 0: 10, -1: 5, +1: 1, 2: 0 } lifeTime = 1000.0 diff --git a/components/Characters/Hen.tscn b/components/Characters/Hen.tscn index d765e8d..27e0b3a 100644 --- a/components/Characters/Hen.tscn +++ b/components/Characters/Hen.tscn @@ -36,7 +36,6 @@ script = ExtResource("2_8u5a0") cooldownUnit = 1000.0 drops = Array[int]([0, 1]) dropCounts = Array[Vector2]([Vector2(6, 12), Vector2(3, 8)]) -energy = 1000.0 [node name="hurt" parent="sounds" index="3"] stream = ExtResource("3_ojyt7") diff --git a/components/Scenes/UI.tscn b/components/Scenes/UI.tscn index 1e8178d..451cbcf 100644 --- a/components/Scenes/UI.tscn +++ b/components/Scenes/UI.tscn @@ -48,19 +48,16 @@ alignment = 1 [node name="baseball" parent="root/container/items" instance=ExtResource("3_o2oi4")] unique_name_in_owner = true layout_mode = 2 -autoFree = null [node name="basketball" parent="root/container/items" instance=ExtResource("3_o2oi4")] unique_name_in_owner = true layout_mode = 2 type = 1 -autoFree = null [node name="apple" parent="root/container/items" instance=ExtResource("3_o2oi4")] unique_name_in_owner = true layout_mode = 2 type = 2 -autoFree = null [node name="panels" type="Control" parent="root"] unique_name_in_owner = true diff --git a/scripts/Contents/Characters/Hen.gd b/scripts/Contents/Characters/Hen.gd index ba0d34b..2f72765 100644 --- a/scripts/Contents/Characters/Hen.gd +++ b/scripts/Contents/Characters/Hen.gd @@ -4,14 +4,16 @@ class_name Hen func _ready(): fields[FieldStore.Entity.MAX_HEALTH] = 75 fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.25 + fields[FieldStore.Entity.OFFSET_SHOOT] = 10 super._ready() func ai(): + cooldownUnit = randi_range(1500, 4000) move(currentFocusedBoss.position - position) tryAttack(0) func attack(type): if type == 0: var weaponPos = findWeaponAnchor("normal") for i in randi_range(1, 4): - BulletBase.generate(preload("res://components/Bullets/Star.tscn"), self, weaponPos, randf_range(0, PI * 2)) + BulletBase.generate(preload("res://components/Bullets/Star.tscn"), self, weaponPos, (currentFocusedBoss.position - position).angle()) return true diff --git a/scripts/Contents/Wave.gd b/scripts/Contents/Wave.gd index ef086c2..0893b64 100644 --- a/scripts/Contents/Wave.gd +++ b/scripts/Contents/Wave.gd @@ -9,11 +9,10 @@ var to: float = 0 var per: int = 0 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/Chick.tscn"), 0, 0, true, 1, INF, 4) + create(preload("res://components/Characters/Chick.tscn"), 0, 0, true, 8, INF, 4) ] static func create( @@ -39,7 +38,7 @@ static func entityCountOf(wave: Wave) -> int: if wave.isBoss: return 1 else: - return randi_range(int(wave.minCount), int(wave.maxCount * ((1 + countBoost) ** current))) + return randi_range(ceil(wave.minCount), floor(wave.maxCount * (1 + GameRule.entityCountBoostPerWave * 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 bdcd512..e7b8149 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -32,7 +32,7 @@ var fields = { var inventory = { ItemStore.ItemType.BASEBALL: 100, ItemStore.ItemType.BASKETBALL: 100, - ItemStore.ItemType.APPLE: 10, + ItemStore.ItemType.APPLE: 5, # 初始苹果数量 } var inventoryMax = { ItemStore.ItemType.BASEBALL: INF, # 无限 @@ -46,7 +46,7 @@ var inventoryMax = { @export var sprintMultiplier: float = 4 @export var drops: Array[ItemStore.ItemType] = [] @export var dropCounts: Array[Vector2] = [] -@export var appleCount: Vector2i = Vector2(0, 1) # 死亡后掉落的苹果数量 +@export var appleCount: Vector2i = Vector2(0, 3) # 死亡后掉落的苹果数量 @onready var animatree: AnimationTree = $"%animatree" @onready var texture: AnimatedSprite2D = $"%texture" @@ -57,7 +57,7 @@ var inventoryMax = { var statebar: EntityStateBar var health: float = 0 -@export var energy: float = 0 +var energy: float = 0 var sprinting: bool = false var lastDirection: int = 1 @@ -72,6 +72,7 @@ func _ready(): statebar = selfStatebar statebar.entity = self health = fields.get(FieldStore.Entity.MAX_HEALTH) + energy = fields.get(FieldStore.Entity.MAX_ENERGY) * 0.5 if isPlayer(): UIState.player = self hurtbox.body_entered.connect( diff --git a/scripts/Tools/GameRule.gd b/scripts/Tools/GameRule.gd index a3b487f..8884305 100644 --- a/scripts/Tools/GameRule.gd +++ b/scripts/Tools/GameRule.gd @@ -6,4 +6,5 @@ static var damageOffset: float = 0.2 # 伤害随机浮动比例,默认20%, static var damageLabelSpawnOffset: float = 10 # 伤害标签生成位置的随机偏移 static var itemDroppedSpawnOffset: float = 30 # 掉落物生成位置的随机偏移 static var appleDropRate: float = 0.1 # 苹果掉落概率 -static var refreshCountIncreasePercent: Vector2 = Vector2(0.4, 1.1) # 刷新所需的棒球数量的增加的百分比,随机,默认为40%~110% \ No newline at end of file +static var refreshCountIncreasePercent: Vector2 = Vector2(0.4, 1.1) # 刷新所需的棒球数量的增加的百分比,随机,默认为40%~110% +static var entityCountBoostPerWave: float = 0.1 # 每波敌人数量增加的百分比,倍数级 \ No newline at end of file