diff --git a/components/Bullets/Common/LaserSummoner.tscn b/components/Bullets/Common/LaserSummoner.tscn index 9f2b36e..7e491b9 100644 --- a/components/Bullets/Common/LaserSummoner.tscn +++ b/components/Bullets/Common/LaserSummoner.tscn @@ -208,6 +208,7 @@ height = 2000.0 [node name="LaserSummoner" instance=ExtResource("1_pnxoq")] script = ExtResource("2_nk2p8") autoSpawnAnimation = true +autoDestroyOnHitMap = false freeAfterSpawn = true [node name="texture" parent="." index="0"] diff --git a/components/Scenes/World.tscn b/components/Scenes/World.tscn index a519287..6612ca4 100644 --- a/components/Scenes/World.tscn +++ b/components/Scenes/World.tscn @@ -90,7 +90,7 @@ libraries = { "": SubResource("AnimationLibrary_44ixa") } -[node name="map" type="StaticBody2D" parent="."] +[node name="map" type="StaticBody2D" parent="." groups=["map"]] [node name="background" type="Sprite2D" parent="map"] z_index = -100 diff --git a/scripts/Contents/Bullets/ChickLaser.gd b/scripts/Contents/Bullets/ChickLaser.gd index 48c4c6a..1bf862c 100644 --- a/scripts/Contents/Bullets/ChickLaser.gd +++ b/scripts/Contents/Bullets/ChickLaser.gd @@ -5,4 +5,4 @@ func register(): penerate = 1 func ai(): rotation_degrees += 1 - PresetsAI.lockLauncher(self, launcher, true) + PresetAIs.lockLauncher(self, launcher, true) diff --git a/scripts/Contents/Bullets/ChickSprint.gd b/scripts/Contents/Bullets/ChickSprint.gd index c8449e3..e584f2f 100644 --- a/scripts/Contents/Bullets/ChickSprint.gd +++ b/scripts/Contents/Bullets/ChickSprint.gd @@ -6,6 +6,9 @@ func register(): damage = 20 penerate = 1 func ai(): - PresetsAI.lockLauncher(self, launcher, true) + PresetAIs.lockLauncher(self, launcher, true) if !launcher.sprinting: tryDestroy() +func destroy(beacuseMap: bool): + if beacuseMap: + launcher.takeDamage(self, 0.5) diff --git a/scripts/Contents/Bullets/Diamond.gd b/scripts/Contents/Bullets/Diamond.gd index db311bc..9175a11 100644 --- a/scripts/Contents/Bullets/Diamond.gd +++ b/scripts/Contents/Bullets/Diamond.gd @@ -7,6 +7,6 @@ func register(): damage = 2 func ai(): canDamageSelf = !(timeLived() >= traceTime) - PresetsAI.forward(self, rotation) + PresetAIs.forward(self, rotation) if timeLived() < traceTime: - PresetsAI.trace(self, launcher.currentFocusedBoss.position, 0.05) + PresetAIs.trace(self, launcher.currentFocusedBoss.position, 0.05) diff --git a/scripts/Contents/Bullets/FireScan.gd b/scripts/Contents/Bullets/FireScan.gd index 7fc0f2d..fb094ba 100644 --- a/scripts/Contents/Bullets/FireScan.gd +++ b/scripts/Contents/Bullets/FireScan.gd @@ -6,4 +6,4 @@ func register(): damage = 5 func ai(): - PresetsAI.forward(self, rotation) + PresetAIs.forward(self, rotation) diff --git a/scripts/Contents/Bullets/Presets/Presets.gd b/scripts/Contents/Bullets/Presets/PresetAIs.gd similarity index 95% rename from scripts/Contents/Bullets/Presets/Presets.gd rename to scripts/Contents/Bullets/Presets/PresetAIs.gd index ed5e3ba..10cf42a 100644 --- a/scripts/Contents/Bullets/Presets/Presets.gd +++ b/scripts/Contents/Bullets/Presets/PresetAIs.gd @@ -1,4 +1,4 @@ -class_name PresetsAI +class_name PresetAIs static func lockLauncher(bullet: BulletBase, launcher: EntityBase, onTexture: bool = false): bullet.position = launcher.texture.global_position if onTexture else launcher.position diff --git a/scripts/Contents/Bullets/PurpleCrystal.gd b/scripts/Contents/Bullets/PurpleCrystal.gd index 2f5176c..fc6d0b6 100644 --- a/scripts/Contents/Bullets/PurpleCrystal.gd +++ b/scripts/Contents/Bullets/PurpleCrystal.gd @@ -2,6 +2,6 @@ extends BulletBase class_name PurpleCrystal func ai(): - PresetsAI.forward(self, rotation) -func destroy(): + PresetAIs.forward(self, rotation) +func destroy(_beacuseMap: bool): EffectController.create(preload("res://components/Effects/PurpleCrystalExplosion.tscn"), global_position).shot() diff --git a/scripts/Contents/Bullets/Star.gd b/scripts/Contents/Bullets/Star.gd index 97c87a5..b8ebf62 100644 --- a/scripts/Contents/Bullets/Star.gd +++ b/scripts/Contents/Bullets/Star.gd @@ -4,4 +4,4 @@ class_name Star func register(): damage = 1 func ai(): - PresetsAI.forward(self, rotation) + PresetAIs.forward(self, rotation) diff --git a/scripts/Statemachine/BulletBase.gd b/scripts/Statemachine/BulletBase.gd index f164a35..d088181 100644 --- a/scripts/Statemachine/BulletBase.gd +++ b/scripts/Statemachine/BulletBase.gd @@ -12,6 +12,7 @@ class_name BulletBase @export var autoSpawnAnimation: bool = false @export var autoLoopAnimation: bool = false @export var autoDestroyAnimation: bool = false +@export var autoDestroyOnHitMap: bool = true @export var freeAfterSpawn: bool = false @export var knockback: float = 0 # 击退力,物理引擎单位 @export var recoil: float = 0 # 后坐力,物理引擎单位 @@ -39,6 +40,12 @@ func _ready(): tryDestroy() if autoLoopAnimation: animator.play("loop") + body_entered.connect( + func(body): + if body.is_in_group("map"): + if autoDestroyOnHitMap: + tryDestroy(true) + ) func _process(_delta: float) -> void: if destroying: return if lifeTime > 0: @@ -74,10 +81,10 @@ func timeLived(): func dotLoop(): if await applyDot(): await dotLoop() -func tryDestroy(): +func tryDestroy(becauseMap: bool = false): if destroying: return destroying = true - await destroy() + await destroy(becauseMap) if autoDestroyAnimation: animator.play("destroy") await animator.animation_finished @@ -86,7 +93,7 @@ func tryDestroy(): # 抽象方法 func ai(): pass -func destroy(): +func destroy(_beacuseMap: bool): pass func spawn(): pass