1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-30 16:01:53 +08:00

feat: 添加新的子弹类型和相关逻辑,更新角色攻击方式,增加无差别伤害选项

This commit is contained in:
2025-08-27 08:58:14 +08:00
parent c5da8d7b5e
commit 5b2c2f5cf7
10 changed files with 58 additions and 17 deletions
+6
View File
@@ -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")
+5
View File
@@ -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"]
+6 -4
View File
@@ -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
+1 -1
View File
@@ -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)])
+16
View File
@@ -0,0 +1,16 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="apple1" x="0px" y="0px" width="63.215999603271484" height="64.36821365356445" viewBox="-0.5 -0.49321448802948 63.215999603271484 64.36821365356445" enable-background="new 0 0 62.218 63.375" xml:space="preserve">
<g>
<g id="Apple">
<path id="Fill_1_" fill="#EC1C2C" d="M59.083,34.402c0,14.527-12.525,26.307-27.978,26.307c-15.453,0-27.977-11.775-27.977-26.307&#13;&#10;&#9;&#9;c0-14.527,12.523-21.275,27.977-21.275C46.557,13.126,59.083,19.876,59.083,34.402z" stroke-width="1"/>
<g id="Outline_1_">
<path id="Outline_2_" fill="#231F20" d="M34.285,11.96c-4.608-0.391-9.136,0.189-9.136,0.189C10.821,13.473,0,19.883,0,34.121&#13;&#10;&#9;&#9;&#9;c0,16.156,13.928,29.254,31.107,29.254c17.182,0,31.109-13.098,31.109-29.254C62.216,18.977,49.969,12.69,34.285,11.96z&#13;&#10;&#9;&#9;&#9; M31.108,59.333c-14.559,0-26.357-11.099-26.357-24.785c0-12.064,9.169-18.433,21.314-19.774c0.249-0.029,8.456-0.144,8.456-0.144&#13;&#10;&#9;&#9;&#9;c12.942,0.936,22.949,7.318,22.949,19.92C57.464,48.236,45.666,59.333,31.108,59.333z" stroke-width="1"/>
<path id="Line" fill="#231F20" d="M40.332,19.062c-2.303-0.761-4.617-0.241-6.929,0.389c-1.916,0.608-6.112,1.162-6.19,1.098&#13;&#10;&#9;&#9;&#9;c-1.198-0.058-2.389-0.358-3.571-1.099c-0.48-0.303-0.982,0.378-0.598,0.773c1.768,1.803,4.068,1.782,6.455,1.514&#13;&#10;&#9;&#9;&#9;c3.575-0.401,6.993-0.491,10.561-0.672C41.22,21.004,41.433,19.426,40.332,19.062z" stroke-width="1"/>
</g>
<path id="Shine" fill="#FFFFFF" d="M12.555,34.261c0,3.431,1.85,6.212-0.084,6.212c-1.934,0-3.5-2.781-3.5-6.212&#13;&#10;&#9;&#9;c0-3.43,1.566-6.211,3.5-6.211C14.405,28.05,12.555,30.832,12.555,34.261z" stroke-width="1"/>
</g>
<g id="Stem">
<path id="Fill" fill="#99661D" d="M29.515,20.766c0.371-0.066,0.973-0.13,1.348-0.219c0.062-4.827,0.538-9.648-1.624-14.212&#13;&#10;&#9;&#9;c-0.592-1.253-1.33-2.354-2.064-3.482c-1.02,0.611-2.038,1.223-3.059,1.833C28.31,8.982,29.773,14.618,29.515,20.766z" stroke-width="1"/>
<path id="Outline" fill="#231F20" d="M28.602,0.6c-0.393-0.523-1.078-0.782-1.658-0.435c-1.805,1.084-3.607,2.168-5.414,3.252&#13;&#10;&#9;&#9;c-0.637,0.383-0.838,1.371-0.242,1.898c3.477,3.091,4.617,6.041,4.9,6.557c0.592,1.081,1.592,4.534,1.562,7.749l0.046,1.609&#13;&#10;&#9;&#9;c1.479,0.562,5.25-0.562,5.25-0.562c0.021-0.354,0.251-2.23,0.251-2.23C33.466,17.677,34.13,7.958,28.602,0.6z M30.755,20.38&#13;&#10;&#9;&#9;l-1.109,0.141v-1.152c0.05-5.714-1.568-10.625-5.53-14.683c1.021-0.61,2.039-1.222,3.059-1.833&#13;&#10;&#9;&#9;c0.734,1.128,1.472,2.229,2.064,3.482c2.012,4.247,1.634,8.375,1.522,12.817L30.755,20.38z" stroke-width="1"/>
</g>
</g>
</svg><!--rotationCenter:31:31-->

After

Width:  |  Height:  |  Size: 2.7 KiB

+3 -1
View File
@@ -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))
+6
View File
@@ -0,0 +1,6 @@
extends BulletBase
class_name Laser
func ai():
rotation_degrees += 2
position = launcher.texture.global_position
+10 -8
View File
@@ -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)
+4 -2
View File
@@ -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()):
+1 -1
View File
@@ -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: