From 287f29695d415251b8d315881ebfa13ee67ab590 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, 6 Nov 2025 22:42:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=AD=A6=E5=99=A8=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96LGBT=E6=AD=A6=E5=99=A8=E5=92=8C=E5=8F=AC?= =?UTF-8?q?=E5=94=A4=E7=89=A9=E8=A1=8C=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 增加LGBT武器的冷却时间从0.1到1000 - 召唤物现在会继承召唤者位置 - 优化子弹追踪逻辑和生命周期 - 修复召唤物AI行为和玩家状态检测 - 调整召唤物属性和攻击冷却时间 --- components/Bullets/LGBTBullet.tscn | 8 ++++---- components/Summons/LGBTFlag.tscn | 2 ++ components/Weapons/LGBT.tscn | 2 +- scripts/Contents/Summons/LGBTFlag.gd | 8 +++++--- scripts/Contents/Weapons/LGBTWeapon.gd | 2 +- scripts/Statemachine/EntityBase.gd | 18 ++++++++++++------ scripts/Statemachine/SummonBase.gd | 3 +-- 7 files changed, 26 insertions(+), 17 deletions(-) diff --git a/components/Bullets/LGBTBullet.tscn b/components/Bullets/LGBTBullet.tscn index c0a5ef3..c1c824d 100644 --- a/components/Bullets/LGBTBullet.tscn +++ b/components/Bullets/LGBTBullet.tscn @@ -2,8 +2,8 @@ [ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_bnhy4"] [ext_resource type="Texture2D" uid="uid://d2pndtow16635" path="res://resources/bullets/lgbt-bullet/造型2.svg" id="2_cnsbx"] -[ext_resource type="Script" path="res://scripts/Contents/Bullets/LGBTBullet.gd" id="2_iakgr"] -[ext_resource type="Script" path="res://scripts/Statemachine/LeadingMark.gd" id="3_rirwy"] +[ext_resource type="Script" uid="uid://b1y68fg5fwdnj" path="res://scripts/Contents/Bullets/LGBTBullet.gd" id="2_iakgr"] +[ext_resource type="Script" uid="uid://clyli5ui8nysk" path="res://scripts/Statemachine/LeadingMark.gd" id="3_rirwy"] [sub_resource type="CircleShape2D" id="CircleShape2D_1e8f0"] radius = 12.3693 @@ -80,7 +80,7 @@ alpha_curve = SubResource("CurveTexture_tnhr3") [node name="LGBTBullet" instance=ExtResource("1_bnhy4")] script = ExtResource("2_iakgr") -lifeTime = 2000.0 +lifeTime = 5000.0 [node name="texture" parent="." index="0"] rotation = 1.5708 @@ -99,5 +99,5 @@ process_material = SubResource("ParticleProcessMaterial_4q0mc") [node name="particles2" type="GPUParticles2D" parent="." index="3"] z_index = -1 amount = 30 -process_material = SubResource("ParticleProcessMaterial_xktft") texture = ExtResource("2_cnsbx") +process_material = SubResource("ParticleProcessMaterial_xktft") diff --git a/components/Summons/LGBTFlag.tscn b/components/Summons/LGBTFlag.tscn index 4266b8a..fc36783 100644 --- a/components/Summons/LGBTFlag.tscn +++ b/components/Summons/LGBTFlag.tscn @@ -6,3 +6,5 @@ [node name="LGBTFlag" instance=ExtResource("1_fktqv")] script = ExtResource("2_6d456") attraction = 0.5 + +[node name="normal" type="Node2D" parent="texture/weapons" index="0"] diff --git a/components/Weapons/LGBT.tscn b/components/Weapons/LGBT.tscn index 3c4655e..fdc8923 100644 --- a/components/Weapons/LGBT.tscn +++ b/components/Weapons/LGBT.tscn @@ -29,7 +29,7 @@ storeType = { } descriptionTemplate = "每$angle发射1/$count条以$power效率追踪$trace秒的[b]七彩光标[/b],每条造成$atk点伤害。" needEnergy = 25.0 -cooldown = 0.1 +cooldown = 1000.0 [node name="attack" parent="sounds" index="0"] stream = ExtResource("4_c5xse") diff --git a/scripts/Contents/Summons/LGBTFlag.gd b/scripts/Contents/Summons/LGBTFlag.gd index e567c51..f4fe288 100644 --- a/scripts/Contents/Summons/LGBTFlag.gd +++ b/scripts/Contents/Summons/LGBTFlag.gd @@ -5,18 +5,20 @@ var maxTraceTime: float = 0 var tracePower: float = 0 func register(): - fields[FieldStore.Entity.MAX_HEALTH] = 100 - attackCooldownMap[0] = 500 + fields[FieldStore.Entity.MAX_HEALTH] = 500 + attackCooldownMap[0] = 250 func ai(): tryAttack(0) func attack(type): if type == 0: + var tracer = EntityTool.findClosetEntity(position, get_tree(), false, true) for bullet in BulletBase.generate( ComponentManager.getBullet("LGBTBullet"), self, findWeaponAnchor("normal"), - position.angle_to_point(EntityTool.findClosetEntity(position, get_tree(), false, true).position) + position.angle_to_point(tracer.position) ): + bullet.tracer = tracer bullet.damage = atk bullet.maxTraceTime = maxTraceTime bullet.tracePower = tracePower diff --git a/scripts/Contents/Weapons/LGBTWeapon.gd b/scripts/Contents/Weapons/LGBTWeapon.gd index 5d6c9c9..315909a 100644 --- a/scripts/Contents/Weapons/LGBTWeapon.gd +++ b/scripts/Contents/Weapons/LGBTWeapon.gd @@ -8,7 +8,7 @@ func update(to: int, origin: Dictionary, _entity: EntityBase): origin["trace"] += 0.25 * to * soulLevel return origin func attack(entity: EntityBase): - var summon = entity.summon(ComponentManager.getSummon("LGBTFlag")) + var summon = entity.summon(ComponentManager.getSummon("LGBTFlag"), true) summon.atk = readStore("atk") summon.maxTraceTime = readStore("trace") * 1000 summon.tracePower = readStore("power") diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index c328e87..8bfc692 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -118,9 +118,10 @@ func _ready(): weapons.append(i) weaponBag.append(i.displayName) statebar.levelLabels.hide() - UIState.player = self + if !is_instance_valid(UIState.player): UIState.player = self energyChanged.connect( func(newEnergy, dontChangeDirection): + if !UIState.player == self: return UIState.energyPercent.maxValue = fields.get(FieldStore.Entity.MAX_ENERGY) if dontChangeDirection: UIState.energyPercent.currentValue = newEnergy @@ -129,8 +130,6 @@ func _ready(): ) rebuildWeaponIcons() else: - if !currentFocusedBoss: - currentFocusedBoss = get_tree().get_nodes_in_group("players")[0] applyLevel() health = fields.get(FieldStore.Entity.MAX_HEALTH) energy = fields.get(FieldStore.Entity.MAX_ENERGY) @@ -158,6 +157,8 @@ func _process(_delta): if is_instance_valid(statebar): statebar.levelLabel.text = str(level) func _physics_process(_delta: float) -> void: + if !isPlayer() && !currentFocusedBoss: + currentFocusedBoss = MathTool.randc_from(get_tree().get_nodes_in_group("players")) animatree.set("parameters/blend_position", lerpf(animatree.get("parameters/blend_position"), lastDirection, 0.2)) if sprinting: if sprintAi(): @@ -166,6 +167,8 @@ func _physics_process(_delta: float) -> void: velocity = Vector2.ZERO if (isPlayer() or is_instance_valid(currentFocusedBoss)) and not charginup and canRunAi: ai() + elif isSummon(): + ai() move_and_slide() storeEnergy(randf_range(0.01, 0.05 + fields.get(FieldStore.Entity.ENERGY_REGENERATION) - 1), true) trailParticle.emitting = trailing @@ -255,13 +258,13 @@ func useEnergy(value: float): return state func tryAttack(type: int, needChargeUp: bool = false): var weapon: Weapon - if isPlayer(): + if isPlayer() and !isSummon(): if len(weapons) > type: weapon = weapons[type] else: return var state - if isPlayer(): + if isPlayer() and !isSummon(): state = true else: var cooldownTimer: CooldownTimer @@ -275,7 +278,7 @@ func tryAttack(type: int, needChargeUp: bool = false): charginup = true await EffectController.create(ComponentManager.getEffect("AttackStar"), damageAnchor.global_position).shot() charginup = false - if isPlayer(): + if isPlayer() and !isSummon(): if await weapon.tryAttack(self): weapon.playSound("attack") else: @@ -376,6 +379,7 @@ func getItem(items: Dictionary): inventory[item] = clamp(inventory[item] + items[item], 0, inventoryMax[item]) func summon(who: PackedScene, syncFields: bool = true, lockValue: bool = true) -> SummonBase: var instance: SummonBase = who.instantiate() + instance.position = position instance.myMaster = self if isPlayer(): instance.add_to_group("players") if syncFields: @@ -393,6 +397,8 @@ func getTrackingAnchor() -> Vector2: # 关于分组 func isPlayer(): return is_in_group("players") +func isSummon(): + return self is SummonBase # 抽象方法,实际上是一些钩子,不需要全部实现 func ai(): diff --git a/scripts/Statemachine/SummonBase.gd b/scripts/Statemachine/SummonBase.gd index 635295c..215543a 100644 --- a/scripts/Statemachine/SummonBase.gd +++ b/scripts/Statemachine/SummonBase.gd @@ -6,9 +6,8 @@ class_name SummonBase var myMaster: EntityBase = null func _ready(): + super._ready() for entity in get_tree().get_nodes_in_group("mobs"): var ent = entity as EntityBase if MathTool.rate(attraction): ent.currentFocusedBoss = self - if is_instance_valid(myMaster): - myMaster.died.connect(tryDie)