1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 15:01:53 +08:00
Files
Dog-Lynx-And-HCN/scripts/Contents/Wave.gd
T
fallingshrimp 01ab16ed9f feat(武器): 新增道教石像武器及无为子弹
添加道教石像武器资源文件、脚本和场景配置
实现无为子弹的碰撞检测和动画效果
调整树武器的伤害计算方式,现在基于格挡率
优化游戏波次配置,调整敌人数量和出现时机
修复初始选择面板在发布模式下的逻辑问题
2026-04-02 22:39:29 +08:00

129 lines
3.7 KiB
GDScript

class_name Wave
# 元数据
var entity: String
var minCount: int = 1
var maxCount: int = 1
var isBoss: bool = false
var from: float = 0
var to: float = 0
var per: int = 0
# 实例数据
var entityPosition: Vector2
func duplicate() -> Wave:
var wave = Wave.new()
wave.entity = entity
wave.minCount = minCount
wave.maxCount = maxCount
wave.isBoss = isBoss
wave.from = from
wave.to = to
wave.per = per
return wave
static var WAVE_NORMAL = [
Wave.create("Hen", 1, 3, false, 0, INF, 3),
Wave.create("Cat", 1, 5, false, 0, INF, 1),
Wave.create("Dog", 1, 2, false, 0, INF, 5),
Wave.create("MTY", 0, 1, false, 4, INF, 7),
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, 23),
]
static var WAVE_TESTBOSS_ALL = [
Wave.create("Chick", 0, 0, true, 0, INF, 3),
Wave.create("KukeMC", 0, 0, true, 1, INF, 3),
Wave.create("Bear", 0, 0, true, 2, INF, 3),
]
static var WAVE_TESTBOSS_KUKE = [
Wave.create("KukeMC", 0, 0, true, 0, INF, 1),
]
static var WAVE_TESTBOSS_BEAR = [
Wave.create("Bear", 0, 0, true, 0, INF, 1),
]
static var WAVE_TESTBOSS_CHICK = [
Wave.create("Chick", 0, 0, true, 0, INF, 1),
]
static var WAVE_JUSTJOKE = [
Wave.create("Kernyr", 0, 0, true, 0, INF, 1),
]
static var WAVE_EMPTY = []
static var waveConfig = [WAVE_NORMAL, 1]
static var current: int = startWith(1) if WorldManager.isRelease() else startWith(waveConfig[1])
static var data = WAVE_NORMAL if WorldManager.isRelease() else waveConfig[0]
static func create(
entity_: String,
minCount_: int = 1,
maxCount_: int = 1,
isBoss_: bool = false,
from_: float = 0,
to_: float = 0,
per_: int = 0
) -> Wave:
var wave = Wave.new()
wave.entity = entity_
wave.minCount = minCount_
wave.maxCount = maxCount_
wave.isBoss = isBoss_
wave.from = from_
wave.to = to_
wave.per = per_
return wave
static func hasBoss() -> bool:
for wave in data:
if canSpawn(wave):
if wave.isBoss:
return true
return false
static func canSpawn(wave: Wave) -> bool:
return wave.from <= current and wave.to >= current and int(current - wave.from) % wave.per == 0
static func entityCountOf(wave: Wave) -> int:
if canSpawn(wave):
if wave.isBoss:
return 1
elif !hasBoss():
return randi_range(ceil(wave.minCount), floor(wave.maxCount * (1 + GameRule.entityCountBoostPerWave * current)))
return 0
static func getNextBossInfo() -> Array:
var nextBossName = ""
var minWavesLeft = INF
for wave in data:
if wave.isBoss:
var wavesLeft = wave.from - current
if wavesLeft > 0 and wavesLeft < minWavesLeft:
minWavesLeft = wavesLeft
nextBossName = ComponentManager.getCharacter(wave.entity).instantiate().displayName
if minWavesLeft < INF:
return [nextBossName, minWavesLeft]
return []
static func spawn(center: Vector2) -> Array:
var result: Array = []
for i in range(len(data)):
var wave: Wave = data[i]
for j in range(entityCountOf(wave)):
var currentWave = wave.duplicate()
currentWave.entityPosition = MathTool.sampleInRing(200, 1000) + center
result.append(currentWave)
return result
static func next(waves: Array):
for wave in waves:
if wave is EncodedObjectAsID:
wave = instance_from_id(wave.get_instance_id())
EntityBase.generate(ComponentManager.getCharacter(wave.entity), wave.entityPosition, true, wave.isBoss)
current += 1
UIState.showTip("%d波开始!" % current, TipBox.MessageType.INFO)
showNextBossReminder()
static func showNextBossReminder():
var nextBossInfo = getNextBossInfo()
if nextBossInfo:
var bossName = nextBossInfo[0]
var wavesLeft = nextBossInfo[1]
if wavesLeft > 0:
UIState.showTip("Boss [b]%s[/b] 将在[b]%d[/b]波后到来!" % [bossName, wavesLeft], TipBox.MessageType.WARNING)
static func startWith(wave: int):
return wave - 1