mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-27 22:41:56 +08:00
feat(角色): 添加猫头鹰角色MTY及其冲刺攻击能力
添加新角色MTY(猫头鹰)及其专属子弹MTYSprint - 实现MTY角色的基本属性和AI行为 - 添加MTYSprint子弹类型及碰撞检测 - 在Wave.gd中添加MTY的生成配置 - 扩展BulletTool工具类添加查找最近子弹功能
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://digr2lvarxtvf"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_pwer0"]
|
||||
[ext_resource type="Script" uid="uid://dqgbohkdj8rbj" path="res://scripts/Contents/Bullets/MTYSprint.gd" id="2_rion0"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_rion0"]
|
||||
radius = 40.0
|
||||
height = 150.0
|
||||
|
||||
[node name="MTYSprint" instance=ExtResource("1_pwer0")]
|
||||
script = ExtResource("2_rion0")
|
||||
displayName = "猛冲"
|
||||
baseDamage = 5.0
|
||||
penerate = 1.0
|
||||
|
||||
[node name="hitbox" parent="." index="1"]
|
||||
shape = SubResource("CapsuleShape2D_rion0")
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://b5ysxff1ujv4l"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://b5ysxff1ujv4l"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cvogxi7mktumf" path="res://components/Abstracts/EntityBase.tscn" id="1_8og84"]
|
||||
[ext_resource type="Script" uid="uid://b80jr04qpitly" path="res://scripts/Contents/Characters/MTY.gd" id="2_hjlm2"]
|
||||
[ext_resource type="Texture2D" uid="uid://cpaafqx7vf443" path="res://resources/characters/bird/mty.png" id="2_i2hh0"]
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_hjlm2"]
|
||||
@@ -24,6 +25,7 @@ radius = 37.0
|
||||
height = 126.0
|
||||
|
||||
[node name="MTY" instance=ExtResource("1_8og84")]
|
||||
script = ExtResource("2_hjlm2")
|
||||
displayName = "猫头鹰"
|
||||
drops = Array[int]([0, 1, 3])
|
||||
dropCounts = Array[Vector2]([Vector2(2, 4), Vector2(2, 4), Vector2(1, 3)])
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
extends BulletBase
|
||||
class_name MTYSprint
|
||||
|
||||
func ai():
|
||||
PresetBulletAI.lockLauncher(self, launcher, true)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dqgbohkdj8rbj
|
||||
@@ -0,0 +1,22 @@
|
||||
extends EntityBase
|
||||
class_name MTY
|
||||
|
||||
func register():
|
||||
fields[FieldStore.Entity.MAX_HEALTH] = 400
|
||||
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.9
|
||||
attackCooldownMap[0] = 1500
|
||||
sprintMultiplier = 5
|
||||
func spawn():
|
||||
BulletBase.generate(ComponentManager.getBullet("MTYSprint"), self, position, 0)
|
||||
func ai():
|
||||
PresetEntityAI.follow(self, currentFocusedBoss)
|
||||
tryAttack(0)
|
||||
func attack(type: int):
|
||||
if type == 0:
|
||||
trySprint()
|
||||
return true
|
||||
func sprint():
|
||||
var target = BulletTool.findClosetBulletCanDamage(position, get_tree(), self)
|
||||
if is_instance_valid(target):
|
||||
var dir = (target.position - position).rotated(MathTool.randc_from([-1, 1]) * deg_to_rad(90))
|
||||
move(dir.normalized() * sprintMultiplier, true)
|
||||
@@ -0,0 +1 @@
|
||||
uid://b80jr04qpitly
|
||||
@@ -27,6 +27,7 @@ static var WAVE_NORMAL = [
|
||||
Wave.create("Hen", 1, 3, false, 0, INF, 1),
|
||||
Wave.create("Cat", 1, 3, false, 0, INF, 1),
|
||||
Wave.create("Dog", 1, 3, false, 0, INF, 1),
|
||||
Wave.create("MTY", 0, 1, false, 0, INF, 4),
|
||||
Wave.create("Chick", 0, 0, true, 9, INF, 20),
|
||||
Wave.create("KukeMC", 0, 0, true, 19, INF, 20),
|
||||
Wave.create("Bear", 0, 0, true, 29, INF, 20),
|
||||
|
||||
@@ -12,3 +12,20 @@ static func canDamage(bullet: BulletBase, target: EntityBase) -> bool:
|
||||
if !GameRule.allowFriendlyFire:
|
||||
if target.isPlayer() == bullet.launcher.isPlayer() and bullet.launcher.currentFocusedBoss != target: return false
|
||||
return true
|
||||
static func findClosetBullet(to: Vector2, fromTree: SceneTree) -> BulletBase:
|
||||
var result: BulletBase = null
|
||||
var lastDistance = INF
|
||||
for bullet in fromTree.get_nodes_in_group("bullets"):
|
||||
if to.distance_to(bullet.position) < lastDistance:
|
||||
lastDistance = to.distance_to(bullet.position)
|
||||
result = bullet
|
||||
return result
|
||||
static func findClosetBulletCanDamage(to: Vector2, fromTree: SceneTree, target: EntityBase) -> BulletBase:
|
||||
var result: BulletBase = null
|
||||
var lastDistance = INF
|
||||
for bullet in fromTree.get_nodes_in_group("bullets"):
|
||||
if canDamage(bullet, target):
|
||||
if to.distance_to(bullet.position) < lastDistance:
|
||||
lastDistance = to.distance_to(bullet.position)
|
||||
result = bullet
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user