mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-06-06 19:57:12 +08:00
feat(ShaderStage): 将基类从CanvasItem改为Node2D并添加类名
feat(LightGun): 添加长度属性和粒子发射控制 refactor(TickTool): 修改millseconds参数类型并添加动画关键帧修改功能 feat(Bear): 添加新攻击类型6并优化攻击5的子弹生成逻辑
This commit is contained in:
@@ -154,6 +154,7 @@ height = 118.0
|
||||
[node name="LightGun" instance=ExtResource("1_kwotu")]
|
||||
script = ExtResource("2_jid6s")
|
||||
allColor = SubResource("GradientTexture1D_aqmnp")
|
||||
length = 1000.0
|
||||
displayName = "空灵长枪"
|
||||
autoSpawnAnimation = true
|
||||
freeAfterSpawn = true
|
||||
@@ -178,6 +179,7 @@ texture = ExtResource("5_bepne")
|
||||
unique_name_in_owner = true
|
||||
z_index = -1
|
||||
position = Vector2(-55, 0)
|
||||
emitting = false
|
||||
amount = 50
|
||||
process_material = SubResource("ParticleProcessMaterial_ppc2o")
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
extends BulletBase
|
||||
|
||||
@export var allColor: GradientTexture1D = null
|
||||
@export var length: float = 1000
|
||||
|
||||
@onready var track: Node2D = $"%track"
|
||||
@onready var track: ShaderStage = $"%track"
|
||||
@onready var sword: Sprite2D = $"%sword"
|
||||
@onready var points: GPUParticles2D = $"%points"
|
||||
|
||||
@@ -16,7 +17,14 @@ func spawn():
|
||||
track.material = track.material.duplicate()
|
||||
points.process_material = points.process_material.duplicate()
|
||||
setColor(myColor)
|
||||
track.size.x = length
|
||||
TickTool.modifyAnimationKey(animator, "spawn", "sword:position:x", Animation.TrackType.TYPE_BEZIER, 2.5, length / -2)
|
||||
TickTool.modifyAnimationKey(animator, "spawn", "sword:position:x", Animation.TrackType.TYPE_BEZIER, 3, length / 2)
|
||||
TickTool.modifyAnimationKey(animator, "spawn", "%hitbox:position:x", Animation.TrackType.TYPE_BEZIER, 2.5, length / -2)
|
||||
TickTool.modifyAnimationKey(animator, "spawn", "%hitbox:position:x", Animation.TrackType.TYPE_BEZIER, 3, length / 2)
|
||||
await TickTool.millseconds(2500)
|
||||
points.emitting = true
|
||||
func setColor(color: Color):
|
||||
track.material.set_shader_parameter("color", color)
|
||||
sword.modulate = color
|
||||
points.process_material.color = color
|
||||
points.process_material.color = color
|
||||
@@ -12,6 +12,7 @@ func register():
|
||||
attackCooldownMap[3] = 13000
|
||||
attackCooldownMap[4] = 4500
|
||||
attackCooldownMap[5] = 5500
|
||||
attackCooldownMap[6] = 10000
|
||||
sprintMultiplier = 60
|
||||
func spawn():
|
||||
texture.play("walk")
|
||||
@@ -19,7 +20,6 @@ func ai():
|
||||
PresetEntityAI.follow(self, currentFocusedBoss, 200)
|
||||
for i in len(attackCooldownMap.keys()):
|
||||
tryAttack(i)
|
||||
# tryAttack(5)
|
||||
func attack(type):
|
||||
var weaponPos = findWeaponAnchor("normal")
|
||||
if type == 0:
|
||||
@@ -60,14 +60,22 @@ func attack(type):
|
||||
await TickTool.millseconds(830.0 / count)
|
||||
return false
|
||||
elif type == 5:
|
||||
playSound("attack5")
|
||||
var target = currentFocusedBoss.position
|
||||
var count = randi_range(10, 15)
|
||||
for i in range(count):
|
||||
for bullet in BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/LightGun.tscn"), self, target, 0):
|
||||
bullet.position += Vector2.from_angle(deg_to_rad(360.0 / count * i)) * 1000
|
||||
bullet.rotation = bullet.position.angle_to_point(target)
|
||||
bullet.rotation = deg_to_rad(360.0 / count * i)
|
||||
await TickTool.millseconds(1670.0 / count)
|
||||
return false
|
||||
elif type == 6:
|
||||
playSound("attack6")
|
||||
for i in 16:
|
||||
for bullet in BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/LightGun.tscn"), self, currentFocusedBoss.position, 0):
|
||||
bullet.position += MathTool.randv2_range(300)
|
||||
bullet.look_at(currentFocusedBoss.position)
|
||||
await TickTool.millseconds(100)
|
||||
return false
|
||||
return true
|
||||
func sprint():
|
||||
move(Vector2(sign((currentFocusedBoss.position - position).x * sprintMultiplier), 0), true)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@tool
|
||||
extends CanvasItem
|
||||
extends Node2D
|
||||
class_name ShaderStage
|
||||
|
||||
@export var size: Vector2 = Vector2.ONE * 100
|
||||
@export var color: Color = Color.WHITE
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class_name TickTool
|
||||
|
||||
static func millseconds(ms: int):
|
||||
static func millseconds(ms: float):
|
||||
return await WorldManager.tree.create_timer(ms / 1000.0).timeout
|
||||
static func frame(count: int = 1):
|
||||
for i in range(count):
|
||||
@@ -8,3 +8,15 @@ static func frame(count: int = 1):
|
||||
static func until(predicate: Callable):
|
||||
while not predicate.call():
|
||||
await frame()
|
||||
static func modifyAnimationKey(animator: AnimationPlayer, name: String, track: NodePath, trackType: Animation.TrackType, time: float, value: Variant):
|
||||
var animation = animator.get_animation(name)
|
||||
var trackIdx = animation.find_track(track, trackType)
|
||||
var keyIdx = animation.track_find_key(trackIdx, time)
|
||||
var inHandle
|
||||
var outHandle
|
||||
if trackType == Animation.TrackType.TYPE_BEZIER:
|
||||
inHandle = animation.bezier_track_get_key_in_handle(trackIdx, keyIdx)
|
||||
outHandle = animation.bezier_track_get_key_out_handle(trackIdx, keyIdx)
|
||||
animation.track_set_key_value(trackIdx, keyIdx, [value, inHandle.x, inHandle.y, outHandle.x, outHandle.y])
|
||||
else:
|
||||
animation.track_set_key_value(trackIdx, keyIdx, [value])
|
||||
|
||||
Reference in New Issue
Block a user