mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-06-29 15:02:29 +08:00
feat: 添加新的角色Hen,更新Chick角色的攻击逻辑,增强Boss状态条和子弹功能
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
[gd_scene load_steps=5 format=3 uid="uid://dbqrmirh6qi7s"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_8udva"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dfptmc7clhtx7" path="res://resources/bullets/diamond/frames/0.svg" id="2_txmup"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/Contents/Bullets/Diamond.gd" id="2_yxtyj"]
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_oj6iy"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("2_txmup")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 5.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[node name="Diamond" instance=ExtResource("1_8udva")]
|
||||||
|
script = ExtResource("2_yxtyj")
|
||||||
|
lifeDistance = 500.0
|
||||||
|
|
||||||
|
[node name="texture" parent="." index="0"]
|
||||||
|
sprite_frames = SubResource("SpriteFrames_oj6iy")
|
||||||
@@ -39,6 +39,9 @@ position = Vector2(0, -37)
|
|||||||
sprite_frames = SubResource("SpriteFrames_xji3d")
|
sprite_frames = SubResource("SpriteFrames_xji3d")
|
||||||
animation = &"walk"
|
animation = &"walk"
|
||||||
|
|
||||||
|
[node name="normal" type="Node2D" parent="texture/weapons" index="0"]
|
||||||
|
position = Vector2(30, -12)
|
||||||
|
|
||||||
[node name="movebox" parent="." index="1"]
|
[node name="movebox" parent="." index="1"]
|
||||||
shape = SubResource("RectangleShape2D_rn84j")
|
shape = SubResource("RectangleShape2D_rn84j")
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://c8h1abpbe6cww"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cvogxi7mktumf" path="res://components/Abstracts/EntityBase.tscn" id="1_twxai"]
|
||||||
|
|
||||||
|
[node name="EntityBase" instance=ExtResource("1_twxai")]
|
||||||
@@ -16,12 +16,3 @@ position = Vector2(394, 274)
|
|||||||
[node name="chick" parent="." groups=["mobs"] instance=ExtResource("4_tnil0")]
|
[node name="chick" parent="." groups=["mobs"] instance=ExtResource("4_tnil0")]
|
||||||
position = Vector2(644, 391)
|
position = Vector2(644, 391)
|
||||||
isBoss = true
|
isBoss = true
|
||||||
|
|
||||||
[node name="Chick" parent="." instance=ExtResource("4_tnil0")]
|
|
||||||
position = Vector2(261, 468)
|
|
||||||
|
|
||||||
[node name="Chick2" parent="." instance=ExtResource("4_tnil0")]
|
|
||||||
position = Vector2(837, 492)
|
|
||||||
|
|
||||||
[node name="Chick3" parent="." instance=ExtResource("4_tnil0")]
|
|
||||||
position = Vector2(897, 185)
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
extends BulletBase
|
||||||
|
class_name Diamond
|
||||||
|
|
||||||
|
func ai():
|
||||||
|
rotation_degrees += 1
|
||||||
|
forward(Vector2.from_angle(rotation))
|
||||||
@@ -1,6 +1,17 @@
|
|||||||
extends EntityBase
|
extends EntityBase
|
||||||
class_name Chick
|
class_name Chick
|
||||||
|
|
||||||
|
var angle = 0
|
||||||
func _ready():
|
func _ready():
|
||||||
fields[FieldStore.Entity.MAX_HEALTH] = 1000
|
fields[FieldStore.Entity.MAX_HEALTH] = 1000
|
||||||
|
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.25
|
||||||
super._ready()
|
super._ready()
|
||||||
|
|
||||||
|
func ai():
|
||||||
|
move(currentFocusedBoss.position - position)
|
||||||
|
if tryAttack(0):
|
||||||
|
angle += 20
|
||||||
|
func attack(type):
|
||||||
|
if type == 0:
|
||||||
|
var weaponPos = findWeaponAnchor("normal")
|
||||||
|
BulletBase.generate(preload("res://components/Bullets/Diamond.tscn"), self, weaponPos, deg_to_rad(angle))
|
||||||
|
|||||||
@@ -22,4 +22,4 @@ func sprint():
|
|||||||
move(Vector2(
|
move(Vector2(
|
||||||
Input.get_axis("m_left", "m_right"),
|
Input.get_axis("m_left", "m_right"),
|
||||||
Input.get_axis("m_up", "m_down")
|
Input.get_axis("m_up", "m_down")
|
||||||
) * 6, true)
|
) * 8, true)
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ class_name BossBar
|
|||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
super._process(delta)
|
super._process(delta)
|
||||||
if entity:
|
if is_instance_valid(entity):
|
||||||
nameLabel.text = entity.displayName
|
nameLabel.text = entity.displayName
|
||||||
valueLabel.text = "%.2f" % (entity.health / entity.fields[FieldStore.Entity.MAX_HEALTH] * 100)
|
valueLabel.text = "%.2f" % (entity.health / entity.fields[FieldStore.Entity.MAX_HEALTH] * 100)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func hit(target: Node):
|
|||||||
var entity: EntityBase = EntityTool.fromHurtbox(target)
|
var entity: EntityBase = EntityTool.fromHurtbox(target)
|
||||||
if !entity || !launcher: return
|
if !entity || !launcher: return
|
||||||
if entity == launcher: return
|
if entity == launcher: return
|
||||||
if GameRule.allowFriendlyFire:
|
if !GameRule.allowFriendlyFire:
|
||||||
if entity.isPlayer() == launcher.isPlayer(): return
|
if entity.isPlayer() == launcher.isPlayer(): return
|
||||||
entity.takeDamage(self, MathTool.rate(launcher.fields.get(FieldStore.Entity.CRIT_RATE)))
|
entity.takeDamage(self, MathTool.rate(launcher.fields.get(FieldStore.Entity.CRIT_RATE)))
|
||||||
if !MathTool.rate(fullPenerate()):
|
if !MathTool.rate(fullPenerate()):
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ var sprinting: bool = false
|
|||||||
func _ready():
|
func _ready():
|
||||||
health = fields.get(FieldStore.Entity.MAX_HEALTH)
|
health = fields.get(FieldStore.Entity.MAX_HEALTH)
|
||||||
statebar.visible = !isBoss
|
statebar.visible = !isBoss
|
||||||
|
if !isPlayer():
|
||||||
|
currentFocusedBoss = get_tree().get_nodes_in_group("players")[0]
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
health = clamp(health, 0, fields.get(FieldStore.Entity.MAX_HEALTH))
|
health = clamp(health, 0, fields.get(FieldStore.Entity.MAX_HEALTH))
|
||||||
animatree.set("parameters/blend_position", lerpf(animatree.get("parameters/blend_position"), lastDirection, 0.1))
|
animatree.set("parameters/blend_position", lerpf(animatree.get("parameters/blend_position"), lastDirection, 0.1))
|
||||||
@@ -40,7 +42,8 @@ func _physics_process(_delta: float) -> void:
|
|||||||
sprinting = false
|
sprinting = false
|
||||||
else:
|
else:
|
||||||
velocity = Vector2.ZERO
|
velocity = Vector2.ZERO
|
||||||
ai()
|
if isPlayer() or is_instance_valid(currentFocusedBoss):
|
||||||
|
ai()
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
# 通用方法
|
# 通用方法
|
||||||
@@ -70,8 +73,10 @@ func startCooldown():
|
|||||||
lastAttack = Time.get_ticks_msec()
|
lastAttack = Time.get_ticks_msec()
|
||||||
return state
|
return state
|
||||||
func tryAttack(type: int):
|
func tryAttack(type: int):
|
||||||
if startCooldown():
|
var state = startCooldown()
|
||||||
|
if state:
|
||||||
attack(type)
|
attack(type)
|
||||||
|
return state
|
||||||
func trySprint():
|
func trySprint():
|
||||||
sprint()
|
sprint()
|
||||||
sprinting = true
|
sprinting = true
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ class_name EntityStateBar
|
|||||||
@onready var healthBar: ColorBar = $"%health"
|
@onready var healthBar: ColorBar = $"%health"
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
if entity:
|
if is_instance_valid(entity):
|
||||||
healthBar.maxValue = entity.fields.get(FieldStore.Entity.MAX_HEALTH)
|
healthBar.maxValue = entity.fields.get(FieldStore.Entity.MAX_HEALTH)
|
||||||
healthBar.setCurrent(entity.health)
|
healthBar.setCurrent(entity.health)
|
||||||
|
|||||||
Reference in New Issue
Block a user