diff --git a/src/ServerStorage/Base/Rune.luau b/src/ServerStorage/Base/Rune.luau index 4a029ed..f5922e5 100644 --- a/src/ServerStorage/Base/Rune.luau +++ b/src/ServerStorage/Base/Rune.luau @@ -154,4 +154,9 @@ function Rune:OnDestroy() self = nil end +-- 销毁方法(供外部调用) +function Rune:Destroy() + self:OnDestroy() +end + return Rune \ No newline at end of file diff --git a/src/ServerStorage/Proxy/PlayerFightProxy/LevelLoop.luau b/src/ServerStorage/Proxy/PlayerFightProxy/LevelLoop.luau index 724c128..98b466a 100644 --- a/src/ServerStorage/Proxy/PlayerFightProxy/LevelLoop.luau +++ b/src/ServerStorage/Proxy/PlayerFightProxy/LevelLoop.luau @@ -70,6 +70,7 @@ function LevelLoop:AutoChallenge(ignoreBoss: boolean?) if not self.IsAutoChallenge then return end print("AutoChallenge") + self.PlayerRole:Respawn() LevelProxy:TeleportToLevel(self.Player) -- TODO: 回退有bug,不能一关一关回退 @@ -106,7 +107,6 @@ function LevelLoop:OnChallengeBoss(Player: Player) LevelProxy:ChallengeEnd(self.Player, false) -- 重置玩家状态(先临时调用角色复活,之后复杂的内容再说) task.wait(1) - self.PlayerRole:Respawn() self:AutoChallenge(true) end) end diff --git a/src/StarterPlayerScripts/UI/Windows/RuneStateWindow/init.luau b/src/StarterPlayerScripts/UI/Windows/RuneStateWindow/init.luau index 5909d86..bf62aae 100644 --- a/src/StarterPlayerScripts/UI/Windows/RuneStateWindow/init.luau +++ b/src/StarterPlayerScripts/UI/Windows/RuneStateWindow/init.luau @@ -65,7 +65,6 @@ function RuneStateWindow:RefreshRuneList() -- 暂时使用模拟数据 local runeData = self:GetWearingRuneData() self.Variables["__listRune"]:SetData(runeData) - print("刷新符文列表", runeData) end @@ -87,14 +86,32 @@ function RuneStateWindow:GetWearingRuneData() local PlayerFolder = PlayerDataFolder:FindFirstChild(LocalPlayer.UserId) 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") if not RuneFolder then return runeData end - -- 遍历所有符文,找到穿戴中的 + -- 遍历所有符文,找到镶嵌在当前穿戴装备上的符文 for _, runeInstance in pairs(RuneFolder:GetChildren()) do local wearing = runeInstance:GetAttribute("wearing") - if wearing and tonumber(wearing) > 0 then + if wearing and tonumber(wearing) == wearingEquipmentUniqueId then local runeInfo = { runeName = runeInstance:GetAttribute("runeName"), runeUniqueId = tonumber(runeInstance.Name), @@ -138,7 +155,6 @@ function RuneStateWindow:PlayRuneAnimation() self.isPlayingAnimation = true local record = table.remove(self.runeExecutionQueue, 1) - -- 播放小丑牌动画 self:PlayJokerCardAnimation(record) end @@ -146,7 +162,8 @@ end -- 播放小丑牌动画 function RuneStateWindow:PlayJokerCardAnimation(record: table) -- 找到对应的符文UI元素 - local runeItem = self:FindRuneItem(record.runeName, record.runeUniqueId) + -- 注意:服务端发送的runeUniqueId实际上是TriggerSlot,我们需要通过runeName来查找 + local runeItem = self:FindRuneItemByName(record.runeName) if not runeItem then -- 如果找不到符文,直接播放下一个 task.wait(0.5) -- 短暂延迟 @@ -158,14 +175,35 @@ function RuneStateWindow:PlayJokerCardAnimation(record: table) self:CreateJokerCardEffect(runeItem, record) end --- 查找符文UI元素 +-- 查找符文UI元素(通过名称和唯一ID) function RuneStateWindow:FindRuneItem(runeName: string, runeUniqueId: number) -- 在符文列表中查找对应的符文 local runeList = self.Variables["__listRune"] + if runeList and runeList.Instances then for _, component in pairs(runeList.Instances) do - if component.Data and component.Data.runeName == runeName and component.Data.runeUniqueId == runeUniqueId then - return component + if component.Data then + -- 使用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 @@ -330,8 +368,6 @@ function RuneStateWindow:ConnectRuneExecutionEvent() -- 连接事件 self.runeExecutionConnection = RE_RuneExecutionRecord.OnClientEvent:Connect(function(executionRecords: table) - print("收到符文执行记录:", executionRecords) - -- 发送执行记录到窗口 self:OnRuneExecutionRecord(executionRecords) end)