diff --git a/components/Bullets/Diamond.tscn b/components/Bullets/Diamond.tscn index efe1c99..68b8daf 100644 --- a/components/Bullets/Diamond.tscn +++ b/components/Bullets/Diamond.tscn @@ -17,7 +17,13 @@ animations = [{ [node name="Diamond" instance=ExtResource("1_8udva")] script = ExtResource("2_yxtyj") +fields = { +0: 10, +1: 2, +2: 0 +} lifeTime = 5000.0 +indisDamage = true [node name="texture" parent="." index="0"] sprite_frames = SubResource("SpriteFrames_oj6iy") diff --git a/components/Bullets/FireScan.tscn b/components/Bullets/FireScan.tscn index 4f0e5b6..0e7dfcf 100644 --- a/components/Bullets/FireScan.tscn +++ b/components/Bullets/FireScan.tscn @@ -8,6 +8,11 @@ a = Vector2(0, -10) [node name="FireScan" instance=ExtResource("1_cqre5")] script = ExtResource("2_qprdp") +fields = { +0: 10, +1: 30, +2: 0 +} lifeDistance = 200.0 [node name="hitbox" parent="." index="1"] diff --git a/components/Bullets/Laser.tscn b/components/Bullets/Laser.tscn index 65b2cdf..2e1f801 100644 --- a/components/Bullets/Laser.tscn +++ b/components/Bullets/Laser.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=6 format=3 uid="uid://bvri0nv1jrigf"] +[gd_scene load_steps=7 format=3 uid="uid://bvri0nv1jrigf"] [ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_3u4op"] [ext_resource type="Shader" path="res://shaders/Laser.gdshader" id="2_h6cxi"] +[ext_resource type="Script" path="res://scripts/Contents/Bullets/Laser.gd" id="2_yy5sr"] [sub_resource type="SpriteFrames" id="SpriteFrames_yip5k"] @@ -15,12 +16,13 @@ shader_parameter/soft_edge = 0.5 height = 300.0 [node name="Laser" instance=ExtResource("1_3u4op")] +script = ExtResource("2_yy5sr") fields = { 0: 10, -1: 5, -2: 0 +1: 15, +2: 1 } -lifeTime = 100.0 +lifeTime = 1000.0 [node name="texture" parent="." index="0"] rotation = 1.5708 diff --git a/components/Characters/Chick.tscn b/components/Characters/Chick.tscn index 22bcabe..9eb8eaa 100644 --- a/components/Characters/Chick.tscn +++ b/components/Characters/Chick.tscn @@ -32,7 +32,7 @@ animations = [{ [node name="Chick" instance=ExtResource("1_goqmy")] script = ExtResource("2_r6bub") -cooldownUnit = 200.0 +cooldownUnit = 2000.0 displayName = "小鸡" drops = Array[int]([0, 1]) dropCounts = Array[Vector2]([Vector2(10, 20), Vector2(7, 14)]) diff --git a/resources/items/apple.svg b/resources/items/apple.svg new file mode 100644 index 0000000..0a6efaa --- /dev/null +++ b/resources/items/apple.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/scripts/Contents/Bullets/Diamond.gd b/scripts/Contents/Bullets/Diamond.gd index e4e26da..ae9e429 100644 --- a/scripts/Contents/Bullets/Diamond.gd +++ b/scripts/Contents/Bullets/Diamond.gd @@ -2,6 +2,8 @@ extends BulletBase class_name Diamond func ai(): - if Time.get_ticks_msec() - spawnInWhen < 500: # 生成的前0.5秒可以追踪 + var tracing = Time.get_ticks_msec() - spawnInWhen < 1000 + if tracing: rotation = lerp_angle(rotation, position.angle_to_point(launcher.currentFocusedBoss.position), 0.1) + canDamageSelf = !tracing forward(Vector2.from_angle(rotation)) diff --git a/scripts/Contents/Bullets/Laser.gd b/scripts/Contents/Bullets/Laser.gd new file mode 100644 index 0000000..ee46b66 --- /dev/null +++ b/scripts/Contents/Bullets/Laser.gd @@ -0,0 +1,6 @@ +extends BulletBase +class_name Laser + +func ai(): + rotation_degrees += 2 + position = launcher.texture.global_position diff --git a/scripts/Contents/Characters/Chick.gd b/scripts/Contents/Characters/Chick.gd index 55407fe..57d93a1 100644 --- a/scripts/Contents/Characters/Chick.gd +++ b/scripts/Contents/Characters/Chick.gd @@ -3,6 +3,8 @@ class_name Chick @onready var firepot = $"%firepot" +const laserCount = 4 + func _ready(): fields[FieldStore.Entity.MAX_HEALTH] = 1000 fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.1 @@ -10,23 +12,23 @@ func _ready(): func ai(): move(currentFocusedBoss.position - position) - if currentFocusedBoss.position.distance_to(position) < 300: + if currentFocusedBoss.position.distance_to(position) < 200: + tryAttack(2) + elif currentFocusedBoss.position.distance_to(position) < 400: tryAttack(1) else: tryAttack(0) func attack(type): if type == 0: var weaponPos = findWeaponAnchor("normal") - BulletBase.generate(preload("res://components/Bullets/Diamond.tscn"), self, weaponPos, rotation + deg_to_rad(MathTool.randc_from([-90, 90]))) + for i in randi_range(10, 20): + BulletBase.generate(preload("res://components/Bullets/Diamond.tscn"), self, weaponPos + MathTool.randv2_range(20), rotation + deg_to_rad(randf_range(-90, 90))) elif type == 1: + for i in range(laserCount): + BulletBase.generate(preload("res://components/Bullets/Laser.tscn"), self, texture.global_position, deg_to_rad(90 * i)) + elif type == 2: var weaponPos = findWeaponAnchor("normal") var target = weaponPos.angle_to_point(currentFocusedBoss.position) firepot.global_rotation = target firepot.shot() BulletBase.generate(preload("res://components/Bullets/FireScan.tscn"), self, weaponPos, target) - # elif type == 2: - # var weaponPos = findWeaponAnchor("normal") - # var target = weaponPos.angle_to_point(currentFocusedBoss.position) - # firepot.global_rotation = target - # firepot.shot() - BulletBase.generate(preload("res://components/Bullets/Laser.tscn"), self, weaponPos, target) diff --git a/scripts/Statemachine/BulletBase.gd b/scripts/Statemachine/BulletBase.gd index e35efe5..e65a0fe 100644 --- a/scripts/Statemachine/BulletBase.gd +++ b/scripts/Statemachine/BulletBase.gd @@ -8,6 +8,8 @@ class_name BulletBase } @export var lifeDistance: float = -1 # -1表示无限距离 @export var lifeTime: float = -1 # -1表示无限时间 +@export var indisDamage: bool = false # 是否无差别伤害(不区分敌我) +@export var canDamageSelf: bool = false # 是否可以伤害发射者 var launcher: EntityBase = null var spawnInWhen: float = 0 @@ -31,8 +33,8 @@ func _physics_process(_delta: float) -> void: func hit(target: Node): var entity: EntityBase = EntityTool.fromHurtbox(target) if !entity || !launcher: return - if entity == launcher: return - if !GameRule.allowFriendlyFire: + if !canDamageSelf && entity == launcher: return + if !indisDamage && !GameRule.allowFriendlyFire: if entity.isPlayer() == launcher.isPlayer(): return entity.takeDamage(self, MathTool.rate(launcher.fields.get(FieldStore.Entity.CRIT_RATE))) if !MathTool.rate(fullPenerate()): diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index 75f87d3..d9e9dd8 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -83,7 +83,7 @@ func takeDamage(bullet: BulletBase, crit: bool): playSound("hurt") health -= damage DamageLabel.create(damage, crit, $"%damageAnchor".global_position + MathTool.randv2_range(GameRule.damageLabelSpawnOffset)) - if isBoss: + if isBoss and bullet.launcher.isPlayer(): bullet.launcher.setBoss(self) if health <= 0: if isBoss: