mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat(武器): 添加齿轮回旋镖武器及其子弹效果
添加新的武器"齿轮回旋镖"及其配套子弹资源: 1. 实现齿轮武器的基本逻辑,包括攻击和属性计算 2. 添加齿轮子弹的旋转、减速和回旋行为 3. 包含相关资源文件(图片、场景、脚本) 4. 将新武器添加到公鸡角色的武器库中
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
extends BulletBase
|
||||
class_name CogwheelBullet
|
||||
|
||||
var initialRotate: float = 0
|
||||
var rotateSpeed: float = 0
|
||||
var dotTime: float = 0
|
||||
var slow: float = 0.2
|
||||
|
||||
func ai():
|
||||
PresetBulletAI.forward(self, rotation)
|
||||
texture.rotation_degrees += rotateSpeed
|
||||
if rotateSpeed < 0:
|
||||
speed += slow
|
||||
PresetBulletAI.trace(self, launcher.position, 0.1)
|
||||
if position.distance_to(launcher.position) < 100:
|
||||
tryDestroy()
|
||||
else:
|
||||
speed = initialSpeed * (rotateSpeed / initialRotate)
|
||||
dotTime = 1000 / (rotateSpeed)
|
||||
rotateSpeed -= slow
|
||||
func applyDot():
|
||||
hitbox.disabled = true
|
||||
await TickTool.frame()
|
||||
hitbox.disabled = false
|
||||
await TickTool.millseconds(dotTime / launcher.fields[FieldStore.Entity.ATTACK_SPEED])
|
||||
await TickTool.frame() # 等至少一帧,防止跳帧导致没检测到伤害
|
||||
return true
|
||||
|
||||
func refract(newBullet: BulletBase, _entity: EntityBase, _index: int, _total: int, _lastBullet: float):
|
||||
if newBullet is CogwheelBullet:
|
||||
newBullet.rotateSpeed = initialRotate
|
||||
return newBullet
|
||||
@@ -0,0 +1 @@
|
||||
uid://cfe4nv832olhp
|
||||
@@ -0,0 +1,20 @@
|
||||
@tool
|
||||
extends Weapon
|
||||
|
||||
func update(to: int, origin: Dictionary, _entity: EntityBase):
|
||||
origin["atk"] += 2 * to * soulLevel
|
||||
origin["rotate"] += 1 * to * soulLevel
|
||||
return origin
|
||||
func attack(entity: EntityBase):
|
||||
var weaponPos = entity.findWeaponAnchor("normal")
|
||||
for bullet in BulletBase.generate(
|
||||
ComponentManager.getBullet("Cogwheel"),
|
||||
entity,
|
||||
weaponPos,
|
||||
weaponPos.angle_to_point(get_global_mouse_position()),
|
||||
):
|
||||
if bullet is CogwheelBullet:
|
||||
bullet.initialRotate = readStore("rotate")
|
||||
bullet.rotateSpeed = readStore("rotate")
|
||||
bullet.baseDamage = readStore("atk")
|
||||
return true
|
||||
@@ -0,0 +1 @@
|
||||
uid://nm2xleunwf4r
|
||||
Reference in New Issue
Block a user