1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-06-04 18:57:13 +08:00

feat(召唤系统): 实现彩虹旗召唤物及相关功能

添加SummonBase作为召唤物基类,实现LGBTFlag召唤物
修改LGBTWeapon从发射子弹改为召唤彩虹旗
在ComponentManager中添加召唤物管理功能
更新公鸡角色预设使用彩虹旗武器
This commit is contained in:
2025-11-06 22:26:15 +08:00
parent 5efa92f5df
commit a273f644d2
11 changed files with 81 additions and 33 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ class_name LGBTBullet
var tracer: EntityBase = null
var maxTraceTime: float = 0
var tracePower: float
var tracePower: float = 0
func register():
speed = 1
+22
View File
@@ -0,0 +1,22 @@
extends SummonBase
var atk: float = 0
var maxTraceTime: float = 0
var tracePower: float = 0
func register():
fields[FieldStore.Entity.MAX_HEALTH] = 100
attackCooldownMap[0] = 500
func ai():
tryAttack(0)
func attack(type):
if type == 0:
for bullet in BulletBase.generate(
ComponentManager.getBullet("LGBTBullet"),
self,
findWeaponAnchor("normal"),
position.angle_to_point(EntityTool.findClosetEntity(position, get_tree(), false, true).position)
):
bullet.damage = atk
bullet.maxTraceTime = maxTraceTime
bullet.tracePower = tracePower
+1
View File
@@ -0,0 +1 @@
uid://11fi3jjdm810
+4 -12
View File
@@ -4,20 +4,12 @@ class_name LGBTWeapon
func update(to: int, origin: Dictionary, _entity: EntityBase):
origin["atk"] += 5 * to * soulLevel
origin["count"] += to * soulLevel
origin["power"] += 0.05 * to * soulLevel
origin["trace"] += 0.25 * to * soulLevel
origin["angle"] /= 1 + 0.05 * to * soulLevel
return origin
func attack(entity: EntityBase):
var weaponPos = entity.findWeaponAnchor("normal")
var facingAngle = (get_global_mouse_position() - weaponPos).angle()
var startAngle = facingAngle - deg_to_rad(readStore("angle") * (readStore("count") / 2))
for i in range(int(readStore("count"))):
for j in BulletBase.generate(ComponentManager.getBullet("LGBTBullet"), entity, weaponPos, startAngle + deg_to_rad(readStore("angle") * i)):
var bullet: LGBTBullet = j
bullet.damage = readStore("atk")
bullet.tracer = EntityTool.findClosetEntity(get_global_mouse_position(), get_tree(), !entity.isPlayer(), entity.isPlayer())
bullet.maxTraceTime = readStore("trace") * 1000
bullet.tracePower = readStore("power")
var summon = entity.summon(ComponentManager.getSummon("LGBTFlag"))
summon.atk = readStore("atk")
summon.maxTraceTime = readStore("trace") * 1000
summon.tracePower = readStore("power")
return true
+12
View File
@@ -374,7 +374,19 @@ func useItem(items: Dictionary):
func getItem(items: Dictionary):
for item in items:
inventory[item] = clamp(inventory[item] + items[item], 0, inventoryMax[item])
func summon(who: PackedScene, syncFields: bool = true, lockValue: bool = true) -> SummonBase:
var instance: SummonBase = who.instantiate()
instance.myMaster = self
if isPlayer(): instance.add_to_group("players")
if syncFields:
if lockValue:
instance.fields = fields.duplicate()
else:
instance.fields = fields
get_parent().add_child(instance)
return instance
# 关于追踪
func getTrackingAnchor() -> Vector2:
return hurtbox.get_node("hitbox").global_position
+14
View File
@@ -0,0 +1,14 @@
extends EntityBase
class_name SummonBase
@export var attraction: float = 0.0
var myMaster: EntityBase = null
func _ready():
for entity in get_tree().get_nodes_in_group("mobs"):
var ent = entity as EntityBase
if MathTool.rate(attraction):
ent.currentFocusedBoss = self
if is_instance_valid(myMaster):
myMaster.died.connect(tryDie)
+1
View File
@@ -0,0 +1 @@
uid://bnsl0c5xltsic
@@ -4,6 +4,7 @@ class_name ComponentManager
static var bullets = {}
static var characters = {}
static var summons = {}
static var effects = {}
static var feeds = []
static var uiComponents = {}
@@ -16,6 +17,8 @@ static func init():
bullets[DirTool.getBasenameWithoutExtension(i)] = load(i)
for i in DirTool.listdir("res://components/Characters"):
characters[DirTool.getBasenameWithoutExtension(i)] = load(i)
for i in DirTool.listdir("res://components/Summons"):
summons[DirTool.getBasenameWithoutExtension(i)] = load(i)
for i in DirTool.listdir("res://components/Effects"):
effects[DirTool.getBasenameWithoutExtension(i)] = load(i)
for i in DirTool.listdir("res://components/Feeds"):
@@ -32,6 +35,8 @@ static func getBullet(t: String) -> PackedScene:
return MathTool.priority(bullets.get(t, false), load("res://components/Bullets/%s.tscn" % t))
static func getCharacter(t: String) -> PackedScene:
return MathTool.priority(characters.get(t, false), load("res://components/Characters/%s.tscn" % t))
static func getSummon(t: String) -> PackedScene:
return MathTool.priority(summons.get(t, false), load("res://components/Summons/%s.tscn" % t))
static func getEffect(t: String) -> PackedScene:
return MathTool.priority(effects.get(t, false), load("res://components/Effects/%s.tscn" % t))
static func getFeed(i: int) -> PackedScene: