This commit is contained in:
Ggafrik 2025-08-20 23:35:37 +08:00
parent 3661704fb4
commit f440012952
3 changed files with 52 additions and 11 deletions

View File

@ -154,4 +154,9 @@ function Rune:OnDestroy()
self = nil self = nil
end end
-- 销毁方法(供外部调用)
function Rune:Destroy()
self:OnDestroy()
end
return Rune return Rune

View File

@ -70,6 +70,7 @@ function LevelLoop:AutoChallenge(ignoreBoss: boolean?)
if not self.IsAutoChallenge then return end if not self.IsAutoChallenge then return end
print("AutoChallenge") print("AutoChallenge")
self.PlayerRole:Respawn()
LevelProxy:TeleportToLevel(self.Player) LevelProxy:TeleportToLevel(self.Player)
-- TODO: 回退有bug不能一关一关回退 -- TODO: 回退有bug不能一关一关回退
@ -106,7 +107,6 @@ function LevelLoop:OnChallengeBoss(Player: Player)
LevelProxy:ChallengeEnd(self.Player, false) LevelProxy:ChallengeEnd(self.Player, false)
-- 重置玩家状态(先临时调用角色复活,之后复杂的内容再说) -- 重置玩家状态(先临时调用角色复活,之后复杂的内容再说)
task.wait(1) task.wait(1)
self.PlayerRole:Respawn()
self:AutoChallenge(true) self:AutoChallenge(true)
end) end)
end end

View File

@ -65,7 +65,6 @@ function RuneStateWindow:RefreshRuneList()
-- 暂时使用模拟数据 -- 暂时使用模拟数据
local runeData = self:GetWearingRuneData() local runeData = self:GetWearingRuneData()
self.Variables["__listRune"]:SetData(runeData) self.Variables["__listRune"]:SetData(runeData)
print("刷新符文列表", runeData)
end end
@ -87,14 +86,32 @@ function RuneStateWindow:GetWearingRuneData()
local PlayerFolder = PlayerDataFolder:FindFirstChild(LocalPlayer.UserId) local PlayerFolder = PlayerDataFolder:FindFirstChild(LocalPlayer.UserId)
if not PlayerFolder then return runeData end if not PlayerFolder then return runeData end
-- 获取装备文件夹,找到当前穿戴的装备
local EquipmentFolder = PlayerFolder:FindFirstChild("Equipment")
if not EquipmentFolder then return runeData end
local wearingEquipmentUniqueId = nil
for _, equipmentInstance in pairs(EquipmentFolder:GetChildren()) do
local wearing = equipmentInstance:GetAttribute("wearing")
if wearing and tonumber(wearing) > 0 then
wearingEquipmentUniqueId = tonumber(equipmentInstance.Name)
break
end
end
-- 如果没有穿戴装备,返回空数据
if not wearingEquipmentUniqueId then
return runeData
end
-- 获取符文文件夹 -- 获取符文文件夹
local RuneFolder = PlayerFolder:FindFirstChild("Rune") local RuneFolder = PlayerFolder:FindFirstChild("Rune")
if not RuneFolder then return runeData end if not RuneFolder then return runeData end
-- 遍历所有符文,找到穿戴中的 -- 遍历所有符文,找到镶嵌在当前穿戴装备上的符文
for _, runeInstance in pairs(RuneFolder:GetChildren()) do for _, runeInstance in pairs(RuneFolder:GetChildren()) do
local wearing = runeInstance:GetAttribute("wearing") local wearing = runeInstance:GetAttribute("wearing")
if wearing and tonumber(wearing) > 0 then if wearing and tonumber(wearing) == wearingEquipmentUniqueId then
local runeInfo = { local runeInfo = {
runeName = runeInstance:GetAttribute("runeName"), runeName = runeInstance:GetAttribute("runeName"),
runeUniqueId = tonumber(runeInstance.Name), runeUniqueId = tonumber(runeInstance.Name),
@ -138,7 +155,6 @@ function RuneStateWindow:PlayRuneAnimation()
self.isPlayingAnimation = true self.isPlayingAnimation = true
local record = table.remove(self.runeExecutionQueue, 1) local record = table.remove(self.runeExecutionQueue, 1)
-- 播放小丑牌动画 -- 播放小丑牌动画
self:PlayJokerCardAnimation(record) self:PlayJokerCardAnimation(record)
end end
@ -146,7 +162,8 @@ end
-- 播放小丑牌动画 -- 播放小丑牌动画
function RuneStateWindow:PlayJokerCardAnimation(record: table) function RuneStateWindow:PlayJokerCardAnimation(record: table)
-- 找到对应的符文UI元素 -- 找到对应的符文UI元素
local runeItem = self:FindRuneItem(record.runeName, record.runeUniqueId) -- 注意服务端发送的runeUniqueId实际上是TriggerSlot我们需要通过runeName来查找
local runeItem = self:FindRuneItemByName(record.runeName)
if not runeItem then if not runeItem then
-- 如果找不到符文,直接播放下一个 -- 如果找不到符文,直接播放下一个
task.wait(0.5) -- 短暂延迟 task.wait(0.5) -- 短暂延迟
@ -158,14 +175,35 @@ function RuneStateWindow:PlayJokerCardAnimation(record: table)
self:CreateJokerCardEffect(runeItem, record) self:CreateJokerCardEffect(runeItem, record)
end end
-- 查找符文UI元素 -- 查找符文UI元素通过名称和唯一ID
function RuneStateWindow:FindRuneItem(runeName: string, runeUniqueId: number) function RuneStateWindow:FindRuneItem(runeName: string, runeUniqueId: number)
-- 在符文列表中查找对应的符文 -- 在符文列表中查找对应的符文
local runeList = self.Variables["__listRune"] local runeList = self.Variables["__listRune"]
if runeList and runeList.Instances then if runeList and runeList.Instances then
for _, component in pairs(runeList.Instances) do for _, component in pairs(runeList.Instances) do
if component.Data and component.Data.runeName == runeName and component.Data.runeUniqueId == runeUniqueId then if component.Data then
return component -- 使用runeName和wearingSlot来匹配因为runeUniqueId在服务端和客户端可能不匹配
if component.Data.runeName == runeName and component.Data.wearingSlot == runeUniqueId then
return component
end
end
end
end
return nil
end
-- 查找符文UI元素仅通过名称
function RuneStateWindow:FindRuneItemByName(runeName: string)
-- 在符文列表中查找对应的符文
local runeList = self.Variables["__listRune"]
if runeList and runeList.Instances then
for _, component in pairs(runeList.Instances) do
if component.Data then
if component.Data.runeName == runeName then
return component
end
end end
end end
end end
@ -330,8 +368,6 @@ function RuneStateWindow:ConnectRuneExecutionEvent()
-- 连接事件 -- 连接事件
self.runeExecutionConnection = RE_RuneExecutionRecord.OnClientEvent:Connect(function(executionRecords: table) self.runeExecutionConnection = RE_RuneExecutionRecord.OnClientEvent:Connect(function(executionRecords: table)
print("收到符文执行记录:", executionRecords)
-- 发送执行记录到窗口 -- 发送执行记录到窗口
self:OnRuneExecutionRecord(executionRecords) self:OnRuneExecutionRecord(executionRecords)
end) end)