diff --git a/Assets/Lua/Core/LuaMain.lua b/Assets/Lua/Core/LuaMain.lua index 42e2a20e9..5402cf421 100644 --- a/Assets/Lua/Core/LuaMain.lua +++ b/Assets/Lua/Core/LuaMain.lua @@ -84,6 +84,7 @@ local LuaMain = class("LuaMain") -- 这里是异步初始化, 初始化的耗时操作可放这里面 function LuaMain:Init() + AW = InternalRequire("async-await") Constant = InternalRequire("Constant") PlatformPack = InternalRequire("PlatformPack") Inspect = InternalRequire("inspect") diff --git a/Assets/Lua/Core/async-await.lua b/Assets/Lua/Core/async-await.lua new file mode 100644 index 000000000..6f08cb6b5 --- /dev/null +++ b/Assets/Lua/Core/async-await.lua @@ -0,0 +1,45 @@ +local co = coroutine +local unp = table.unpack ~= nil and table.unpack or unpack +local M = {} + +local function next_step (thread, success, ...) + local res = {co.resume(thread, ...)} + assert(res[1], unp(res, 2)) + if co.status(thread) ~= 'dead' then + res[2](function (...) + next_step(thread, success, ...) + end) + else + success(unp(res, 2)) + end +end + +M.async = function (func) + assert(type(func) == 'function', 'async params must be function') + local res = { + is_done = false, + data = nil, + cb = nil + } + next_step(co.create(func), function (...) + res.is_done = true + res.data = {...} + if res.cb ~= nil then + res.cb(unp(res.data)) + end + end) + return function (cb) + if cb ~= nil and res.is_done then + cb(unp(res.data)) + else + res.cb = cb + end + end +end + +M.await = function (async_cb) + assert(type(async_cb) == 'function', 'await params must be function') + return co.yield(async_cb) +end + +return M diff --git a/Assets/Lua/Core/async-await.lua.meta b/Assets/Lua/Core/async-await.lua.meta new file mode 100644 index 000000000..71c202d7d --- /dev/null +++ b/Assets/Lua/Core/async-await.lua.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 355d2e9fe69c94e48a86eadc3a0433eb +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Lua/Entities/MinePlayerEntityView.lua b/Assets/Lua/Entities/MinePlayerEntityView.lua index 8f647b125..b819fcedd 100644 --- a/Assets/Lua/Entities/MinePlayerEntityView.lua +++ b/Assets/Lua/Entities/MinePlayerEntityView.lua @@ -19,14 +19,16 @@ function MinePlayerEntityView:ExitWorld() end function MinePlayerEntityView:InitGenerateView() - MinePlayerEntityView.super.InitGenerateView(self) - -- 添加主角光环 - local guanghuanGo = ManagerContainer.ResMgr:LuaGetGoFromPool(Constants.EffectPath, 'Hero/Common/FX_Hero_guanghuan') - local guanghuanTrans = guanghuanGo.transform - guanghuanTrans:SetParent(self.transform) - guanghuanTrans.localPosition = Vector3.zero - guanghuanTrans.localRotation = Quaternion.identity - self.guanghuanGo = guanghuanGo + AW.async(function() + MinePlayerEntityView.super.InitGenerateView(self) + -- 添加主角光环 + local guanghuanGo = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(Constants.EffectPath, 'Hero/Common/FX_Hero_guanghuan')) + local guanghuanTrans = guanghuanGo.transform + guanghuanTrans:SetParent(self.transform) + guanghuanTrans.localPosition = Vector3.zero + guanghuanTrans.localRotation = Quaternion.identity + self.guanghuanGo = guanghuanGo + end) end function MinePlayerEntityView:RefreshGenerateView() diff --git a/Assets/Lua/Entities/PlayerEntityView.lua b/Assets/Lua/Entities/PlayerEntityView.lua index e539e4a46..8805cb17a 100644 --- a/Assets/Lua/Entities/PlayerEntityView.lua +++ b/Assets/Lua/Entities/PlayerEntityView.lua @@ -46,44 +46,34 @@ function PlayerEntityView:CollectPreloadAssets() end function PlayerEntityView:InitGenerateView() - -- 创建Model - local modelGo = self.roleViewSystem:Create() - local modelTrans = modelGo.transform - modelTrans:SetParent(self.avatarTrans) - modelTrans.localPosition = Vector3.zero - modelTrans.localRotation = Quaternion.identity - -- 删除Prefab上的默认的碰撞体 (临时) - local colliders = modelGo:GetComponentsInChildren(typeof(UnityEngine.Collider)) - for i = 0, colliders.Length - 1 do - UnityEngine.Component.Destroy(colliders[i]) - end - -- 添加阴影 - local shadowGo = ManagerContainer.ResMgr:LuaGetGoFromPool(Constants.EffectPath, 'Common/FX_Yinying') - local shadowTrans = shadowGo.transform - shadowTrans:SetParent(self.transform) - shadowTrans.localPosition = Vector3.zero - shadowTrans.localRotation = Quaternion.identity + AW.async(function() + -- 创建Model + local modelGo = self.roleViewSystem:Create() + local modelTrans = modelGo.transform + modelTrans:SetParent(self.avatarTrans) + modelTrans.localPosition = Vector3.zero + modelTrans.localRotation = Quaternion.identity + -- 删除Prefab上的默认的碰撞体 (临时) + local colliders = modelGo:GetComponentsInChildren(typeof(UnityEngine.Collider)) + for i = 0, colliders.Length - 1 do + UnityEngine.Component.Destroy(colliders[i]) + end + -- 添加阴影 + local shadowGo = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(Constants.EffectPath, 'Common/FX_Yinying')) + local shadowTrans = shadowGo.transform + shadowTrans:SetParent(self.transform) + shadowTrans.localPosition = Vector3.zero + shadowTrans.localRotation = Quaternion.identity + self.animator = modelGo:GetComponent(Enum.TypeInfo.Animator) + self.shadowGo = shadowGo + -- self.uiGo = uiGo + -- self.uiPlayerView = uiPlayerView - -- local uipoint = modelTrans:Find("ui_point") - -- local uiPosition = uipoint.position - -- 添加UI - -- local uiAssetName = Constants.UI3DPath .. "/MainCity/UIPlayerView" - -- local uiGo = ManagerContainer.ResMgr:LuaGetGoFromPool(nil, uiAssetName) - -- local uiTrans = uiGo.transform - -- uiTrans:SetParent(self.transform) - -- uiTrans.position = uiPosition - -- uiTrans.rotation = Quaternion.identity - -- local uiPlayerView = UIPlayerView:new(uiTrans, ManagerContainer.LuaMainCityMgr:GetMainCamera(), self.uid) - - self.animator = modelGo:GetComponent(Enum.TypeInfo.Animator) - self.shadowGo = shadowGo - -- self.uiGo = uiGo - -- self.uiPlayerView = uiPlayerView - - if self.isUpdate then - self:RefreshGenerateView() - end + if self.isUpdate then + self:RefreshGenerateView() + end + end) end function PlayerEntityView:RefreshGenerateView() diff --git a/Assets/Lua/Managers/GoPoolMgr.lua b/Assets/Lua/Managers/GoPoolMgr.lua index 6abc22dc1..dec2034bd 100644 --- a/Assets/Lua/Managers/GoPoolMgr.lua +++ b/Assets/Lua/Managers/GoPoolMgr.lua @@ -45,14 +45,16 @@ function GoPoolMgr:SpawnGo(prefabName, cb) if gridItemView.GridItemName ~= "" then local itemlua = require("GridViewItem/"..gridItemView.GridItemName.."_Generate"):new() --itemlua.gameObject = UnityEngine.GameObject.Instantiate(go) - local goName = gridItemView.OriName ~= "" and gridItemView.OriName or gridItemView.GridItemName - itemlua.gameObject = ManagerContainer.ResMgr:LuaGetGoFromPool(Constants.UIItemDir, goName) - itemlua.prefabName = gridItemView.GridItemName - itemlua.oriName = goName - itemlua:InitGenerate(itemlua.gameObject.transform) - itemlua.gameObject:SetActive(true) - v(itemlua) - --v = nil + AW.async(function() + local goName = gridItemView.OriName ~= "" and gridItemView.OriName or gridItemView.GridItemName + itemlua.gameObject = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(Constants.UIItemDir, goName)) + itemlua.prefabName = gridItemView.GridItemName + itemlua.oriName = goName + itemlua:InitGenerate(itemlua.gameObject.transform) + itemlua.gameObject:SetActive(true) + v(itemlua) + --v = nil + end) end end loadingPrefabList[prefabName] = nil diff --git a/Assets/Lua/Managers/LuaGuildLobbyMgr.lua b/Assets/Lua/Managers/LuaGuildLobbyMgr.lua index 053f20d98..4e88c790e 100644 --- a/Assets/Lua/Managers/LuaGuildLobbyMgr.lua +++ b/Assets/Lua/Managers/LuaGuildLobbyMgr.lua @@ -193,20 +193,22 @@ function LuaGuildLobbyMgr:_LoadProgressChanged(progress) end function LuaGuildLobbyMgr:_PreloadAssetsComplete() - local modelGo = ManagerContainer.ResMgr:LuaGetGoFromPool("Assets/Content/Prefabs/Camera", "DefaultCVC") - local defaultCVC = modelGo:GetComponent(typeof(Cinemachine.CinemachineVirtualCamera)) - self.mainCamera = LuaBattleBridge.InitMainCamera() - self.cullingMask = self.mainCamera.cullingMask - -- 所有的实体对象进入游戏世界 - self.entityMgr:AllEntityEnterWorld() - self.curState = State.EnterEnd - self:_OnLoadComplete() - -- 设置摄像机跟随 - local entityType = Enum.EntityType.MinePlayer - local uid = ManagerContainer.DataMgr.UserData:GetUserId() - defaultCVC.Follow = self.entityMgr:GetTransform(entityType, uid) - -- 打开UI界面 - ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIGuildLobby) + AW.async(function() + local modelGo = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync("Assets/Content/Prefabs/Camera", "DefaultCVC")) + local defaultCVC = modelGo:GetComponent(typeof(Cinemachine.CinemachineVirtualCamera)) + self.mainCamera = LuaBattleBridge.InitMainCamera() + self.cullingMask = self.mainCamera.cullingMask + -- 所有的实体对象进入游戏世界 + self.entityMgr:AllEntityEnterWorld() + self.curState = State.EnterEnd + self:_OnLoadComplete() + -- 设置摄像机跟随 + local entityType = Enum.EntityType.MinePlayer + local uid = ManagerContainer.DataMgr.UserData:GetUserId() + defaultCVC.Follow = self.entityMgr:GetTransform(entityType, uid) + -- 打开UI界面 + ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIGuildLobby) + end) end function LuaGuildLobbyMgr:_OnLoadProgress(progress) diff --git a/Assets/Lua/Managers/RedPointSimpleMgr.lua b/Assets/Lua/Managers/RedPointSimpleMgr.lua index a23952dc6..3b75f7506 100644 --- a/Assets/Lua/Managers/RedPointSimpleMgr.lua +++ b/Assets/Lua/Managers/RedPointSimpleMgr.lua @@ -245,39 +245,41 @@ function RedPointSimpleMgr:RefreshRedPointDisplayPriority(treeNode, needCheckLoc end function RedPointSimpleMgr:FillContentCompeleted(wnd) - local list = ManagerContainer.CfgMgr:GetUIRedPointCfgDataByUIId(wnd.uiData.id) - for k,v in pairs(list) do - if Constant.OpenPay or not v.NoPay then - local treeNode = rpTree[v.Id] - if treeNode then - local data = treeNode.data - local target = CommonUtil.ParseUITargetPath(wnd, data.FuncEnterPath) - if target then - local redPointGo = target.transform:Find("redPoint"..data.Id) - if not redPointGo then - redPointGo = ManagerContainer.ResMgr:LuaGetGoFromPool(Constants.UICommonPath, Enum.RPPrefab[data.RPType]) - else - redPointGo = redPointGo.gameObject - end - if redPointGo then - redPointGo.name = "redPoint"..data.Id - redPointGo.transform:SetParent(target.transform) - local rectTrans = redPointGo:GetComponent(Enum.TypeInfo.RectTransform) - rectTrans.anchoredPosition3D = Vector3(data.Position[1], data.Position[2], 0) - redPointGo.transform.localScale = Vector3.one - treeNode.target = redPointGo - - if data.UIId == Enum.UIPageName.UIPrivateChatBtn then - redPointGo.transform:SetAsFirstSibling() + AW.async(function() + local list = ManagerContainer.CfgMgr:GetUIRedPointCfgDataByUIId(wnd.uiData.id) + for k,v in pairs(list) do + if Constant.OpenPay or not v.NoPay then + local treeNode = rpTree[v.Id] + if treeNode then + local data = treeNode.data + local target = CommonUtil.ParseUITargetPath(wnd, data.FuncEnterPath) + if target then + local redPointGo = target.transform:Find("redPoint"..data.Id) + if not redPointGo then + redPointGo = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(Constants.UICommonPath, Enum.RPPrefab[data.RPType])) + else + redPointGo = redPointGo.gameObject + end + if redPointGo then + redPointGo.name = "redPoint"..data.Id + redPointGo.transform:SetParent(target.transform) + local rectTrans = redPointGo:GetComponent(Enum.TypeInfo.RectTransform) + rectTrans.anchoredPosition3D = Vector3(data.Position[1], data.Position[2], 0) + redPointGo.transform.localScale = Vector3.one + treeNode.target = redPointGo + + if data.UIId == Enum.UIPageName.UIPrivateChatBtn then + redPointGo.transform:SetAsFirstSibling() + end + + redPointGo:SetActive(false) + self:RefreshRedPointDisplayPriority(treeNode, true) end - - redPointGo:SetActive(false) - self:RefreshRedPointDisplayPriority(treeNode, true) end end end end - end + end) end function RedPointSimpleMgr:UICloseCompeleted(wnd) diff --git a/Assets/Lua/Managers/ResMgr.lua b/Assets/Lua/Managers/ResMgr.lua index cd2f2345e..e3745a088 100644 --- a/Assets/Lua/Managers/ResMgr.lua +++ b/Assets/Lua/Managers/ResMgr.lua @@ -115,17 +115,26 @@ end ___G_Coroutine_Id_Dict = {} function ResMgr:LuaGetGoFromPool(path, asset) - local k = path.."/"..asset - local retgo = nil - ___G_Coroutine_Id_Dict[k] = coroutine.create(function() - self:GetGoFromPoolAsync(path, asset, function(go) - retgo = go - coroutine.resume(___G_Coroutine_Id_Dict[k]) - end) - coroutine.yield() - end) - coroutine.resume(___G_Coroutine_Id_Dict[k]) - return retgo + -- local k = path.."/"..asset + -- local retgo = nil + -- ___G_Coroutine_Id_Dict[k] = coroutine.create(function() + -- self:GetGoFromPoolAsync(path, asset, function(go) + -- retgo = go + -- coroutine.resume(___G_Coroutine_Id_Dict[k]) + -- end) + -- coroutine.yield() + -- end) + -- coroutine.resume(___G_Coroutine_Id_Dict[k]) + -- return retgo + + return self:GetGoFromPool(path, asset) +end + +function ResMgr:LuaGetGoFromPoolAsync(path, asset) + local func = function(cb) + self:GetGoFromPoolAsync(path, asset, function(go) cb(go) end) + end + return func end return ResMgr diff --git a/Assets/Lua/Managers/UIFuncUnlockMgr.lua b/Assets/Lua/Managers/UIFuncUnlockMgr.lua index 52395fd8d..ac6cb7b4d 100644 --- a/Assets/Lua/Managers/UIFuncUnlockMgr.lua +++ b/Assets/Lua/Managers/UIFuncUnlockMgr.lua @@ -359,158 +359,159 @@ end --只用于主城的建筑 function UIFuncUnlockMgr:SpecialLock(wnd, data, target, result, key, guideState, conds) - - local function InitTitle(lock, targetButtonField, targetTitle, textContent) - local title = lock.transform:Find("Title") - title.transform.position = targetTitle.transform.position - local titleText = title:Find("Text") - titleText:GetComponent(Enum.TypeInfo.TextMeshProUGUI).text = textContent - - local rectSize = targetButtonField:GetComponent(Enum.TypeInfo.RectTransform).sizeDelta - local lockButtonField = lock.transform:Find("TargetBox") - lockButtonField.transform.position = targetButtonField.transform.position - lockButtonField:GetComponent(Enum.TypeInfo.RectTransform).sizeDelta = rectSize - end - - local targetButtonField = target.transform:Find("TargetBox") - local targetTitle = target.transform:Find("Title") - local textContent = targetTitle:Find("Text"):GetComponent(Enum.TypeInfo.TextMeshProUGUI).text - - targetTitle.gameObject:SetActive(result or (not result and data.NeedDisplay)) - - if result and not guideState then - local lockBtn = target.transform:Find("LockbtnItem") - if lockBtn then - lockBtn.gameObject:SetActive(false) + AW.async(function() + local function InitTitle(lock, targetButtonField, targetTitle, textContent) + local title = lock.transform:Find("Title") + title.transform.position = targetTitle.transform.position + local titleText = title:Find("Text") + titleText:GetComponent(Enum.TypeInfo.TextMeshProUGUI).text = textContent + + local rectSize = targetButtonField:GetComponent(Enum.TypeInfo.RectTransform).sizeDelta + local lockButtonField = lock.transform:Find("TargetBox") + lockButtonField.transform.position = targetButtonField.transform.position + lockButtonField:GetComponent(Enum.TypeInfo.RectTransform).sizeDelta = rectSize end - local lockBubble = target.transform:Find("LockBubbleItem") - if lockBubble then - lockBubble.gameObject:SetActive(false) - end - return - end - - local lockBtn = target.transform:Find("LockbtnItem") - if not result and data.NeedMask then - if lockBtn == nil then - lockBtn = ManagerContainer.ResMgr:LuaGetGoFromPool(Constants.UICommonPath, "LockbtnItem") - lockBtn.name = "LockbtnItem" - lockBtn.transform:SetParent(target.transform) - lockBtn.transform.localPosition = Vector3.zero - lockBtn.transform.localScale = Vector3.one - - InitTitle(lockBtn, targetButtonField, targetTitle, textContent) - end - - local lockButton = lockBtn.gameObject:GetOrAddComponent(Enum.TypeInfo.Button) - if lockButton then - wnd.uiBase:AddButtonUniqueEventListener(lockButton, wnd, function (button, params) - local result, val, content = self:CheckConditionPassResult(data) - if not result then - ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(content..I18N.T(data.FunName)..I18N.T("Fun")) - end - end) - end - lockBtn.gameObject:SetActive(true) - else - if lockBtn then - lockBtn.gameObject:SetActive(false) - end - end - - if funcBtns[wnd.uiData.id][key] == nil then - funcBtns[wnd.uiData.id][key] = {} - end - funcBtns[wnd.uiData.id][key]["target"] = target - funcBtns[wnd.uiData.id][key]["data"] = data - funcBtns[wnd.uiData.id][key]["lockBtn"] = lockBtn - - funcBtns[wnd.uiData.id][key]["needGuide"] = data.NeedGuide - if not result and not guideState then - self:SaveLockBubbleStatus(data.Id, data.NeedGuide) - end - - local lockBubble = target.transform:Find("LockBubbleItem") - if result and funcBtns[wnd.uiData.id][key]["needGuide"] then - if lockBubble == nil then - lockBubble = ManagerContainer.ResMgr:LuaGetGoFromPool(Constants.UICommonPath, "LockBubbleItem") - lockBubble.name = "LockBubbleItem" - lockBubble.transform:SetParent(target.transform) - lockBubble.transform.localPosition = Vector3.zero - lockBubble.transform.localScale = Vector3.one - - local canvas = lockBubble:GetComponent(Enum.TypeInfo.Canvas) - if canvas then - canvas.overrideSorting = true - canvas.sortingOrder = Enum.UISibling[Enum.UIType.MAIN + 1] - 1 + + local targetButtonField = target.transform:Find("TargetBox") + local targetTitle = target.transform:Find("Title") + local textContent = targetTitle:Find("Text"):GetComponent(Enum.TypeInfo.TextMeshProUGUI).text + + targetTitle.gameObject:SetActive(result or (not result and data.NeedDisplay)) + + if result and not guideState then + local lockBtn = target.transform:Find("LockbtnItem") + if lockBtn then + lockBtn.gameObject:SetActive(false) end - - InitTitle(lockBubble, targetButtonField, targetTitle, textContent) - - local light = lockBubble.transform:Find("BtnLightItem") - light.transform.position = targetTitle.transform.position - - local talk = lockBubble.transform:Find("Talk") - local vec2 = data.DscPos and Vector2(data.DscPos[1], data.DscPos[2]) or Vector2.zero - talk:GetComponent(Enum.TypeInfo.RectTransform).anchoredPosition = vec2 - - local arrowUp = talk.transform:Find("bg/upArrow") - local arrowDown = talk.transform:Find("bg/downArrow") - local arrowLeft = talk.transform:Find("bg/leftArrow") - local arrowRight = talk.transform:Find("bg/rightArrow") - arrowUp.gameObject:SetActive(data.ArrowDir == 1) - arrowDown.gameObject:SetActive(data.ArrowDir == 2) - arrowLeft.gameObject:SetActive(data.ArrowDir == 3) - arrowRight.gameObject:SetActive(data.ArrowDir == 4) - - local talkContent = talk.transform:Find("bg/Text") - talkContent:GetComponent(Enum.TypeInfo.Text).text = I18N.T(data.LockDsc) + local lockBubble = target.transform:Find("LockBubbleItem") + if lockBubble then + lockBubble.gameObject:SetActive(false) + end + return end - - local lockButton = lockBubble.gameObject:GetOrAddComponent(Enum.TypeInfo.Button) - if lockButton then - wnd.uiBase:AddButtonUniqueEventListener(lockButton, wnd, function (button, params) - if target then - self:SaveLockBubbleStatus(data.Id, false) - - target:SetActive(true) - - local lockBtn = funcBtns[wnd.uiData.id][key]["lockBtn"] - if lockBtn then - lockBtn.gameObject:SetActive(false) + + local lockBtn = target.transform:Find("LockbtnItem") + if not result and data.NeedMask then + if lockBtn == nil then + lockBtn = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(Constants.UICommonPath, "LockbtnItem")) + lockBtn.name = "LockbtnItem" + lockBtn.transform:SetParent(target.transform) + lockBtn.transform.localPosition = Vector3.zero + lockBtn.transform.localScale = Vector3.one + + InitTitle(lockBtn, targetButtonField, targetTitle, textContent) + end + + local lockButton = lockBtn.gameObject:GetOrAddComponent(Enum.TypeInfo.Button) + if lockButton then + wnd.uiBase:AddButtonUniqueEventListener(lockButton, wnd, function (button, params) + local result, val, content = self:CheckConditionPassResult(data) + if not result then + ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(content..I18N.T(data.FunName)..I18N.T("Fun")) end - - local lockBubble = funcBtns[wnd.uiData.id][key]["lockBubble"] - if lockBubble then - lockBubble.gameObject:SetActive(false) - end - - targetTitle.gameObject:SetActive(true) - - curOpened[#curOpened + 1] = data.Id - - local button1 = target:GetComponent(Enum.TypeInfo.Button) - if button1 then - button1.onClick:Invoke() - end - - local nextFuncData = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgDataById(data.PostPose) - if nextFuncData and wnd.uiData.id == nextFuncData.UIId then - self:InsertFuncController(wnd, nextFuncData) - end - - funcBtns[wnd.uiData.id][key] = nil + end) + end + lockBtn.gameObject:SetActive(true) + else + if lockBtn then + lockBtn.gameObject:SetActive(false) + end + end + + if funcBtns[wnd.uiData.id][key] == nil then + funcBtns[wnd.uiData.id][key] = {} + end + funcBtns[wnd.uiData.id][key]["target"] = target + funcBtns[wnd.uiData.id][key]["data"] = data + funcBtns[wnd.uiData.id][key]["lockBtn"] = lockBtn + + funcBtns[wnd.uiData.id][key]["needGuide"] = data.NeedGuide + if not result and not guideState then + self:SaveLockBubbleStatus(data.Id, data.NeedGuide) + end + + local lockBubble = target.transform:Find("LockBubbleItem") + if result and funcBtns[wnd.uiData.id][key]["needGuide"] then + if lockBubble == nil then + lockBubble = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(Constants.UICommonPath, "LockBubbleItem")) + lockBubble.name = "LockBubbleItem" + lockBubble.transform:SetParent(target.transform) + lockBubble.transform.localPosition = Vector3.zero + lockBubble.transform.localScale = Vector3.one + + local canvas = lockBubble:GetComponent(Enum.TypeInfo.Canvas) + if canvas then + canvas.overrideSorting = true + canvas.sortingOrder = Enum.UISibling[Enum.UIType.MAIN + 1] - 1 end - end) + + InitTitle(lockBubble, targetButtonField, targetTitle, textContent) + + local light = lockBubble.transform:Find("BtnLightItem") + light.transform.position = targetTitle.transform.position + + local talk = lockBubble.transform:Find("Talk") + local vec2 = data.DscPos and Vector2(data.DscPos[1], data.DscPos[2]) or Vector2.zero + talk:GetComponent(Enum.TypeInfo.RectTransform).anchoredPosition = vec2 + + local arrowUp = talk.transform:Find("bg/upArrow") + local arrowDown = talk.transform:Find("bg/downArrow") + local arrowLeft = talk.transform:Find("bg/leftArrow") + local arrowRight = talk.transform:Find("bg/rightArrow") + arrowUp.gameObject:SetActive(data.ArrowDir == 1) + arrowDown.gameObject:SetActive(data.ArrowDir == 2) + arrowLeft.gameObject:SetActive(data.ArrowDir == 3) + arrowRight.gameObject:SetActive(data.ArrowDir == 4) + + local talkContent = talk.transform:Find("bg/Text") + talkContent:GetComponent(Enum.TypeInfo.Text).text = I18N.T(data.LockDsc) + end + + local lockButton = lockBubble.gameObject:GetOrAddComponent(Enum.TypeInfo.Button) + if lockButton then + wnd.uiBase:AddButtonUniqueEventListener(lockButton, wnd, function (button, params) + if target then + self:SaveLockBubbleStatus(data.Id, false) + + target:SetActive(true) + + local lockBtn = funcBtns[wnd.uiData.id][key]["lockBtn"] + if lockBtn then + lockBtn.gameObject:SetActive(false) + end + + local lockBubble = funcBtns[wnd.uiData.id][key]["lockBubble"] + if lockBubble then + lockBubble.gameObject:SetActive(false) + end + + targetTitle.gameObject:SetActive(true) + + curOpened[#curOpened + 1] = data.Id + + local button1 = target:GetComponent(Enum.TypeInfo.Button) + if button1 then + button1.onClick:Invoke() + end + + local nextFuncData = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgDataById(data.PostPose) + if nextFuncData and wnd.uiData.id == nextFuncData.UIId then + self:InsertFuncController(wnd, nextFuncData) + end + + funcBtns[wnd.uiData.id][key] = nil + end + end) + end + lockBubble.gameObject:SetActive(true) + else + if lockBubble then + lockBubble.gameObject:SetActive(false) + end end - lockBubble.gameObject:SetActive(true) - else - if lockBubble then - lockBubble.gameObject:SetActive(false) - end - end - - funcBtns[wnd.uiData.id][key]["lockBubble"] = lockBubble + + funcBtns[wnd.uiData.id][key]["lockBubble"] = lockBubble + end) end function UIFuncUnlockMgr:UICloseCompeleted(wnd) diff --git a/Assets/Lua/System/ModelViewSystem.lua b/Assets/Lua/System/ModelViewSystem.lua index 59e9d925e..a65c3392f 100644 --- a/Assets/Lua/System/ModelViewSystem.lua +++ b/Assets/Lua/System/ModelViewSystem.lua @@ -130,77 +130,81 @@ function ModelViewSystem:CancelCreate() end function ModelViewSystem:Create() - local newGo = nil - if self.loadModelPath and self.loadModelName then - newGo = ManagerContainer.ResMgr:LuaGetGoFromPool(self.loadModelPath, self.loadModelName) - self.modelPath = self.loadModelPath - self.modelName = self.loadModelName - end - if self.loadAcPath and self.loadAcName then - self.acPath = self.loadAcPath - self.acName = self.loadAcName - local go = newGo or self.modelGo - if go then - local animatorController = ManagerContainer.ResMgr:GetAsset(self.loadAcPath, self.loadAcName) - local animator = go:GetComponent(Enum.TypeInfo.Animator) - if not animator then - animator = go:AddComponent(Enum.TypeInfo.Animator) + AW.async(function() + local newGo = nil + if self.loadModelPath and self.loadModelName then + newGo = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(self.loadModelPath, self.loadModelName)) + self.modelPath = self.loadModelPath + self.modelName = self.loadModelName + end + if self.loadAcPath and self.loadAcName then + self.acPath = self.loadAcPath + self.acName = self.loadAcName + local go = newGo or self.modelGo + if go then + local animatorController = ManagerContainer.ResMgr:GetAsset(self.loadAcPath, self.loadAcName) + local animator = go:GetComponent(Enum.TypeInfo.Animator) + if not animator then + animator = go:AddComponent(Enum.TypeInfo.Animator) + end + animator.runtimeAnimatorController = animatorController end - animator.runtimeAnimatorController = animatorController end - end - if newGo then - self.modelGo = newGo - self:SetGoPosition(_goPosition); + if newGo then + self.modelGo = newGo + self:SetGoPosition(_goPosition); - self:SetDialogue(); + self:SetDialogue(); - if self.ownercb and self.cb then - self.cb(self.ownercb, newGo, true) + if self.ownercb and self.cb then + self.cb(self.ownercb, newGo, true) + end + else + if self.ownercb and self.cb then + self.cb(self.ownercb, self.modelGo, true) + end end - else - if self.ownercb and self.cb then - self.cb(self.ownercb, self.modelGo, true) - end - end - self.ownercb = nil - self.cb = nil + self.ownercb = nil + self.cb = nil + end) end --冒泡对话 function ModelViewSystem:SetDialogue() - if self._dialogueData then - if not self._dialogueGo then - local _newGo = ManagerContainer.ResMgr:LuaGetGoFromPool(Constants.ModelPath, _dialogueName); - if not _newGo then - LogError("冒泡预设的路径或者名字不对,请检查"); - else - self._dialogueGo = _newGo; + AW.async(function() + if self._dialogueData then + if not self._dialogueGo then + local _newGo = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(Constants.ModelPath, _dialogueName)) + if not _newGo then + LogError("冒泡预设的路径或者名字不对,请检查"); + else + self._dialogueGo = _newGo; + end end + self._dialogueGo.gameObject:SetActive(false); + local _scaleStr = GlobalConfig.Instance:GetConfigStrValue(164) + local _scale = string.split(_scaleStr, ";") + self._dialogueGo.transform.localScale = Vector3.New(tonumber(_scale[1]), tonumber(_scale[2]), tonumber(_scale[3])); + local _parent = self.modelGo.transform:Find(self._dialogueData._dialogueParent); + if not _parent then _parent = self.modelGo; end + self._dialogueGo.transform:SetParent(_parent.transform); + self:RemoveTimers(); + local _showDialogueText = function() + self._dialogueGo.transform.localPosition = Vector3.zero; + self._dialogueGo.transform:Find("Dialogue/Dialog/Text"):GetComponent("Text").text = self._dialogueData._textStr; + self._dialogueGo.gameObject:SetActive(true); + end + self._dialogueStartTimer = ManagerContainer.LuaTimerMgr:AddTimer(self._dialogueData._showStartTime, 1, self, _showDialogueText, nil); + local _endDialogueText = function() + --if not ManagerContainer.DataMgr.SignData:GetKeepDialogue() then + self._dialogueGo.gameObject:SetActive(false); + --end + end + self._dialogueEndTimer = ManagerContainer.LuaTimerMgr:AddTimer(self._dialogueData._showEndTime, 1, self, _endDialogueText, nil); end - self._dialogueGo.gameObject:SetActive(false); - local _scaleStr = GlobalConfig.Instance:GetConfigStrValue(164) - local _scale = string.split(_scaleStr, ";") - self._dialogueGo.transform.localScale = Vector3.New(tonumber(_scale[1]), tonumber(_scale[2]), tonumber(_scale[3])); - local _parent = self.modelGo.transform:Find(self._dialogueData._dialogueParent); - if not _parent then _parent = self.modelGo; end - self._dialogueGo.transform:SetParent(_parent.transform); - self:RemoveTimers(); - local _showDialogueText = function() - self._dialogueGo.transform.localPosition = Vector3.zero; - self._dialogueGo.transform:Find("Dialogue/Dialog/Text"):GetComponent("Text").text = self._dialogueData._textStr; - self._dialogueGo.gameObject:SetActive(true); - end - self._dialogueStartTimer = ManagerContainer.LuaTimerMgr:AddTimer(self._dialogueData._showStartTime, 1, self, _showDialogueText, nil); - local _endDialogueText = function() - --if not ManagerContainer.DataMgr.SignData:GetKeepDialogue() then - self._dialogueGo.gameObject:SetActive(false); - --end - end - self._dialogueEndTimer = ManagerContainer.LuaTimerMgr:AddTimer(self._dialogueData._showEndTime, 1, self, _endDialogueText, nil); - end + end) end function ModelViewSystem:GetGameObject() diff --git a/Assets/Lua/System/RoleViewSystem.lua b/Assets/Lua/System/RoleViewSystem.lua index e599fe8c7..e6fa9cfd6 100644 --- a/Assets/Lua/System/RoleViewSystem.lua +++ b/Assets/Lua/System/RoleViewSystem.lua @@ -422,7 +422,7 @@ end ---@generic 预加载的资源已加载完成 function RoleViewSystem:PreloadedAssets() - self:Create() + AW.async(function() self:Create() end) end function RoleViewSystem:BeginCreate() @@ -506,7 +506,7 @@ function RoleViewSystem:Create() local avatarData = ManagerContainer.CfgMgr:GetAvatarCfgById(roleCfg.AvatarId) assetName = avatarData.AvatarPrefab end - newGO = ManagerContainer.ResMgr:LuaGetGoFromPool(Constants.ModelPath, assetName) + newGO = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(Constants.ModelPath, assetName)) if ManagerContainer.LuaModelMgr and ManagerContainer.LuaModelMgr.ModelRoot then newGO.transform:SetParent(ManagerContainer.LuaModelMgr.ModelRoot.transform) else diff --git a/Assets/Lua/UI/Common/IconItemCtr.lua b/Assets/Lua/UI/Common/IconItemCtr.lua index a1828f7db..213ec23dc 100644 --- a/Assets/Lua/UI/Common/IconItemCtr.lua +++ b/Assets/Lua/UI/Common/IconItemCtr.lua @@ -141,46 +141,48 @@ function IconItemCtr:RefreshIcon(wnd, itemlua, logicData, enterType, onClickOwne itemlua.qualityFX:SetActive(false) else if itemlua.uiParticle == nil then - local fxGo = ManagerContainer.ResMgr:LuaGetGoFromPool(Constants.EffectPath,qualityFxName) - if fxGo~= nil then - fxGo.transform:SetParent(itemlua.qualityFX.transform) - fxGo.transform.localPosition = Vector3.zero - fxGo.transform.localRotation = Quaternion.identity - fxGo.transform.localScale = Vector3.one + AW.async(function() + local fxGo = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(Constants.EffectPath,qualityFxName)) + if fxGo~= nil then + fxGo.transform:SetParent(itemlua.qualityFX.transform) + fxGo.transform.localPosition = Vector3.zero + fxGo.transform.localRotation = Quaternion.identity + fxGo.transform.localScale = Vector3.one - --if tolua.getpeer(fxGo) == nil then - -- tolua.setpeer(fxGo, {}) - --end - itemlua.uiParticle = {} - itemlua.uiParticle.fxGo = fxGo - itemlua.uiParticle.EffectName = qualityFxName + --if tolua.getpeer(fxGo) == nil then + -- tolua.setpeer(fxGo, {}) + --end + itemlua.uiParticle = {} + itemlua.uiParticle.fxGo = fxGo + itemlua.uiParticle.EffectName = qualityFxName - local sizeX = itemlua.rectTransform.rect.width - --判断是否父节点为grid - if itemlua.transform.parent then - local parent = itemlua.transform.parent - local parentScale = parent.localScale.x + local sizeX = itemlua.rectTransform.rect.width + --判断是否父节点为grid + if itemlua.transform.parent then + local parent = itemlua.transform.parent + local parentScale = parent.localScale.x - local grid = parent:GetComponent(Enum.TypeInfo.GridLayoutGroup) - local width = sizeX - if grid then - width = grid.cellSize.x + local grid = parent:GetComponent(Enum.TypeInfo.GridLayoutGroup) + local width = sizeX + if grid then + width = grid.cellSize.x + end + + sizeX = width * parentScale end - sizeX = width * parentScale - end + local scaleX = sizeX/160 + --local sizeY = itemlua.layoutElement.preferredHeight + --local scaleY = sizeY/160 + local uiParticle = fxGo:GetComponent(Enum.TypeInfo.UIParticle) + if uiParticle then + uiParticle.scale = scaleX + end - local scaleX = sizeX/160 - --local sizeY = itemlua.layoutElement.preferredHeight - --local scaleY = sizeY/160 - local uiParticle = fxGo:GetComponent(Enum.TypeInfo.UIParticle) - if uiParticle then - uiParticle.scale = scaleX + wnd:AddNewEffect(itemlua,qualityFxName,fxGo) + itemlua.qualityFX:SetActive(true) end - - wnd:AddNewEffect(itemlua,qualityFxName,fxGo) - itemlua.qualityFX:SetActive(true) - end + end) end end end diff --git a/Assets/Lua/UI/UIBigMap/BigMapView.lua b/Assets/Lua/UI/UIBigMap/BigMapView.lua index 0f9d183a4..eb11eebc1 100644 --- a/Assets/Lua/UI/UIBigMap/BigMapView.lua +++ b/Assets/Lua/UI/UIBigMap/BigMapView.lua @@ -454,182 +454,184 @@ function BigMapView:_RefreshPoints() end function BigMapView:_PreloadedAssets() - local uiPath = Constants.UIPath - local enterType = self.enterType - local cfgMgr = ManagerContainer.CfgMgr - local resMgr = ManagerContainer.ResMgr - local showRect = self.showRect - local levelDatas = self.levelDatas - local levelPoss = self.levelPoss - local levelDataNum = #levelDatas - local isOneStory = true - local uiStoryMgr = nil - if enterType == Enum.BigMapEnterType.DropPoint then - self.executeSequenceData = ExecuteSequenceData:new() - uiStoryMgr = ManagerContainer.UIStoryMgr - end - - local startPos = self.levelStartPos - if self:_IsSelfAtCurMap() then - if not self.selfPlayerLuaCtr then - local selfGoItem = resMgr:LuaGetGoFromPool(uiPath, PointPlayerItemPath) - local iconImage, myRankGo, dscLeftGo, dscLeftTxt, dscRightGO, dscRightTxt, selfGoAnimator - if selfGoItem then - local selfGoItemTrans = selfGoItem.transform - selfGoItemTrans:SetParent(self.view.selfContainer.transform, false) - selfGoItemTrans.localPosition = startPos - selfGoItemTrans.localRotation = Quaternion.identity - selfGoItemTrans.localScale = Vector3.one - iconImage = selfGoItemTrans:Find('Root/Item/Content/Icon'):GetComponent(Enum.TypeInfo.Image) - myRankGo = selfGoItemTrans:Find('Root/Item/MyRank').gameObject - dscLeftGo = selfGoItemTrans:Find('Root/DscLeft').gameObject - dscLeftTxt = selfGoItemTrans:Find('Root/DscLeft/DesTxt'):GetComponent(Enum.TypeInfo.Text) - dscRightGO = selfGoItemTrans:Find('Root/DscRight').gameObject - dscRightTxt = selfGoItemTrans:Find('Root/DscRight/DesTxt'):GetComponent(Enum.TypeInfo.Text) - selfGoAnimator = selfGoItem:GetComponent(Enum.TypeInfo.Animator) - end - local luaCtr = {} - luaCtr.go = selfGoItem - luaCtr.iconImage = iconImage - luaCtr.myRankGo = myRankGo - luaCtr.dscLeftGo = dscLeftGo - if dscLeftGo then - luaCtr.dscLeftRect = dscLeftGo:GetComponent(Enum.TypeInfo.RectTransform) - end - luaCtr.dscLeftTxt = dscLeftTxt - luaCtr.dscRightGO = dscRightGO - luaCtr.dscRightTxt = dscRightTxt - luaCtr.animator = selfGoAnimator - self.selfPlayerLuaCtr = luaCtr + AW.async(function() + local uiPath = Constants.UIPath + local enterType = self.enterType + local cfgMgr = ManagerContainer.CfgMgr + local resMgr = ManagerContainer.ResMgr + local showRect = self.showRect + local levelDatas = self.levelDatas + local levelPoss = self.levelPoss + local levelDataNum = #levelDatas + local isOneStory = true + local uiStoryMgr = nil + if enterType == Enum.BigMapEnterType.DropPoint then + self.executeSequenceData = ExecuteSequenceData:new() + uiStoryMgr = ManagerContainer.UIStoryMgr end - self:RefreshSelfHead() - self:RefreshSelfRank() - self:RefreshSelfPos() - if enterType ~= Enum.BigMapEnterType.DropPoint then - self:AlginCenter() - end - end - if not showRect or showRect:Contains(startPos) then - self:_CreateStartPoint(startPos) - end - local smallStartIdx = 1 - local smallEndIdx = levelDataNum - for i = 1, levelDataNum do - local pointPos = levelPoss[i] - if not showRect or showRect:Contains(pointPos) then - if self:_IsPassedPoint(i) then - smallStartIdx = i + 1 - else - if not smallEndIdx then - smallEndIdx = i - 1 + local startPos = self.levelStartPos + if self:_IsSelfAtCurMap() then + if not self.selfPlayerLuaCtr then + local selfGoItem = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(uiPath, PointPlayerItemPath)) + local iconImage, myRankGo, dscLeftGo, dscLeftTxt, dscRightGO, dscRightTxt, selfGoAnimator + if selfGoItem then + local selfGoItemTrans = selfGoItem.transform + selfGoItemTrans:SetParent(self.view.selfContainer.transform, false) + selfGoItemTrans.localPosition = startPos + selfGoItemTrans.localRotation = Quaternion.identity + selfGoItemTrans.localScale = Vector3.one + iconImage = selfGoItemTrans:Find('Root/Item/Content/Icon'):GetComponent(Enum.TypeInfo.Image) + myRankGo = selfGoItemTrans:Find('Root/Item/MyRank').gameObject + dscLeftGo = selfGoItemTrans:Find('Root/DscLeft').gameObject + dscLeftTxt = selfGoItemTrans:Find('Root/DscLeft/DesTxt'):GetComponent(Enum.TypeInfo.Text) + dscRightGO = selfGoItemTrans:Find('Root/DscRight').gameObject + dscRightTxt = selfGoItemTrans:Find('Root/DscRight/DesTxt'):GetComponent(Enum.TypeInfo.Text) + selfGoAnimator = selfGoItem:GetComponent(Enum.TypeInfo.Animator) end - local levelData = levelDatas[i] - local pointType = levelData.LevelPointType or 0 - if pointType == 0 then - local storySection = levelData.StorySection - local storySectionData = cfgMgr:GetStorySectionById(storySection) - if storySectionData then - if enterType == Enum.BigMapEnterType.DropPoint then - local startDropMoveTime = storySectionData.StartDropMoveTime - if storySectionData.StartDropPos and #storySectionData.StartDropPos > 0 then - self.executeSequenceData:AppendFunc(false, self, self._AlginCenterPos, CommonUtil.TableToVector2(storySectionData.StartDropPos), startDropMoveTime) - if (startDropMoveTime and startDropMoveTime > 0) then - self.executeSequenceData:AppendInterval(startDropMoveTime) + local luaCtr = {} + luaCtr.go = selfGoItem + luaCtr.iconImage = iconImage + luaCtr.myRankGo = myRankGo + luaCtr.dscLeftGo = dscLeftGo + if dscLeftGo then + luaCtr.dscLeftRect = dscLeftGo:GetComponent(Enum.TypeInfo.RectTransform) + end + luaCtr.dscLeftTxt = dscLeftTxt + luaCtr.dscRightGO = dscRightGO + luaCtr.dscRightTxt = dscRightTxt + luaCtr.animator = selfGoAnimator + self.selfPlayerLuaCtr = luaCtr + end + + self:RefreshSelfHead() + self:RefreshSelfRank() + self:RefreshSelfPos() + if enterType ~= Enum.BigMapEnterType.DropPoint then + self:AlginCenter() + end + end + if not showRect or showRect:Contains(startPos) then + self:_CreateStartPoint(startPos) + end + local smallStartIdx = 1 + local smallEndIdx = levelDataNum + for i = 1, levelDataNum do + local pointPos = levelPoss[i] + if not showRect or showRect:Contains(pointPos) then + if self:_IsPassedPoint(i) then + smallStartIdx = i + 1 + else + if not smallEndIdx then + smallEndIdx = i - 1 + end + local levelData = levelDatas[i] + local pointType = levelData.LevelPointType or 0 + if pointType == 0 then + local storySection = levelData.StorySection + local storySectionData = cfgMgr:GetStorySectionById(storySection) + if storySectionData then + if enterType == Enum.BigMapEnterType.DropPoint then + local startDropMoveTime = storySectionData.StartDropMoveTime + if storySectionData.StartDropPos and #storySectionData.StartDropPos > 0 then + self.executeSequenceData:AppendFunc(false, self, self._AlginCenterPos, CommonUtil.TableToVector2(storySectionData.StartDropPos), startDropMoveTime) + if (startDropMoveTime and startDropMoveTime > 0) then + self.executeSequenceData:AppendInterval(startDropMoveTime) + end + end + if isOneStory and self.selfPlayerLuaCtr then + isOneStory = false + if self.selfPlayerLuaCtr.go then + self.selfPlayerLuaCtr.go:SetActive(false) + end + self.executeSequenceData:AppendFunc(false, self, self._PlayFallDownAnim, self.selfPlayerLuaCtr) + self.executeSequenceData:AppendInterval(1) + end + if storySectionData.StartDropDlgId > 0 then + -- 需要至少延迟一帧时间,避免对话框刚刚关闭就需要打开,导致逻辑混乱 + self.executeSequenceData:AppendFrameInterval(1) + self.executeSequenceData:AppendFunc(false, uiStoryMgr, uiStoryMgr.MapStartStoryByStoryId, storySectionData.StartDropDlgId) + self.executeSequenceData:AppendUIListener(Enum.UIPageName.UIStory, UIEventNames.UI_PAGE_OUT_END_NTF) end end - if isOneStory and self.selfPlayerLuaCtr then - isOneStory = false - if self.selfPlayerLuaCtr.go then - self.selfPlayerLuaCtr.go:SetActive(false) + local artType = storySectionData.ArtType + local artRes = storySectionData.ArtRes + if artType == Enum.StorySectionArtType.Icon then + local luaCtr = self:_CreateStoryIconLuaCtr(i, artRes, pointPos) + if enterType == Enum.BigMapEnterType.DropPoint then + if luaCtr.go then + luaCtr.go:SetActive(false) + end + self.executeSequenceData:AppendFunc(false, self, self._PlayFallDownAnim, luaCtr) + elseif enterType == Enum.BigMapEnterType.Default then + self.viewBase.uiBase:AddButtonUniqueEventListener(luaCtr.button, self, self._OnClickStoryItem, i) end - self.executeSequenceData:AppendFunc(false, self, self._PlayFallDownAnim, self.selfPlayerLuaCtr) + else + local luaCtr = self:_CreateStoryGoLuaCtr(i, artRes, pointPos) + if enterType == Enum.BigMapEnterType.DropPoint then + if luaCtr.go then + luaCtr.go:SetActive(false) + end + self.executeSequenceData:AppendFunc(false, self, self._PlayFallDownAnim, luaCtr) + elseif enterType == Enum.BigMapEnterType.Default then + self.viewBase.uiBase:AddButtonUniqueEventListener(luaCtr.button, self, self._OnClickStoryItem, i) + end + end + if enterType == Enum.BigMapEnterType.DropPoint then self.executeSequenceData:AppendInterval(1) - end - if storySectionData.StartDropDlgId > 0 then - -- 需要至少延迟一帧时间,避免对话框刚刚关闭就需要打开,导致逻辑混乱 - self.executeSequenceData:AppendFrameInterval(1) - self.executeSequenceData:AppendFunc(false, uiStoryMgr, uiStoryMgr.MapStartStoryByStoryId, storySectionData.StartDropDlgId) - self.executeSequenceData:AppendUIListener(Enum.UIPageName.UIStory, UIEventNames.UI_PAGE_OUT_END_NTF) - end - end - local artType = storySectionData.ArtType - local artRes = storySectionData.ArtRes - if artType == Enum.StorySectionArtType.Icon then - local luaCtr = self:_CreateStoryIconLuaCtr(i, artRes, pointPos) - if enterType == Enum.BigMapEnterType.DropPoint then - if luaCtr.go then - luaCtr.go:SetActive(false) + if storySectionData.EndDropDlgId > 0 then + self.executeSequenceData:AppendFunc(false, uiStoryMgr, uiStoryMgr.MapStartStoryByStoryId, storySectionData.EndDropDlgId) + self.executeSequenceData:AppendUIListener(Enum.UIPageName.UIStory, UIEventNames.UI_PAGE_OUT_END_NTF) end - self.executeSequenceData:AppendFunc(false, self, self._PlayFallDownAnim, luaCtr) - elseif enterType == Enum.BigMapEnterType.Default then - self.viewBase.uiBase:AddButtonUniqueEventListener(luaCtr.button, self, self._OnClickStoryItem, i) - end - else - local luaCtr = self:_CreateStoryGoLuaCtr(i, artRes, pointPos) - if enterType == Enum.BigMapEnterType.DropPoint then - if luaCtr.go then - luaCtr.go:SetActive(false) - end - self.executeSequenceData:AppendFunc(false, self, self._PlayFallDownAnim, luaCtr) - elseif enterType == Enum.BigMapEnterType.Default then - self.viewBase.uiBase:AddButtonUniqueEventListener(luaCtr.button, self, self._OnClickStoryItem, i) - end - end - if enterType == Enum.BigMapEnterType.DropPoint then - self.executeSequenceData:AppendInterval(1) - if storySectionData.EndDropDlgId > 0 then - self.executeSequenceData:AppendFunc(false, uiStoryMgr, uiStoryMgr.MapStartStoryByStoryId, storySectionData.EndDropDlgId) - self.executeSequenceData:AppendUIListener(Enum.UIPageName.UIStory, UIEventNames.UI_PAGE_OUT_END_NTF) end end end end end end - end - if enterType ~= Enum.BigMapEnterType.DropPoint then - if smallStartIdx < smallEndIdx and smallEndIdx <= levelDataNum then - for i = smallStartIdx, smallEndIdx do - local levelData = levelDatas[i] - local pointType = levelData.LevelPointType or 0 - if pointType == 0 then - break - end - if not self:_IsPassedPoint(i) then - local storySection = levelData.StorySection - local storySectionData = cfgMgr:GetStorySectionById(storySection) - if storySectionData then - local artType = storySectionData.ArtType - local artRes = storySectionData.ArtRes - local pointPos = levelPoss[i] - local luaCtr = nil - if artType == Enum.StorySectionArtType.Icon then - luaCtr = self:_CreateStoryIconLuaCtr(i, artRes, pointPos) - else - luaCtr = self:_CreateStoryGoLuaCtr(i, artRes, pointPos) - end - if luaCtr and enterType == Enum.BigMapEnterType.Default then - self.viewBase.uiBase:AddButtonUniqueEventListener(luaCtr.button, self, self._OnClickStoryItem, i) + if enterType ~= Enum.BigMapEnterType.DropPoint then + if smallStartIdx < smallEndIdx and smallEndIdx <= levelDataNum then + for i = smallStartIdx, smallEndIdx do + local levelData = levelDatas[i] + local pointType = levelData.LevelPointType or 0 + if pointType == 0 then + break + end + if not self:_IsPassedPoint(i) then + local storySection = levelData.StorySection + local storySectionData = cfgMgr:GetStorySectionById(storySection) + if storySectionData then + local artType = storySectionData.ArtType + local artRes = storySectionData.ArtRes + local pointPos = levelPoss[i] + local luaCtr = nil + if artType == Enum.StorySectionArtType.Icon then + luaCtr = self:_CreateStoryIconLuaCtr(i, artRes, pointPos) + else + luaCtr = self:_CreateStoryGoLuaCtr(i, artRes, pointPos) + end + if luaCtr and enterType == Enum.BigMapEnterType.Default then + self.viewBase.uiBase:AddButtonUniqueEventListener(luaCtr.button, self, self._OnClickStoryItem, i) + end end end end end end - end - if enterType == Enum.BigMapEnterType.DropPoint then - if not self.executeSequenceData:HasDelayMethod() then - self.executeSequenceData:AppendInterval(1) + if enterType == Enum.BigMapEnterType.DropPoint then + if not self.executeSequenceData:HasDelayMethod() then + self.executeSequenceData:AppendInterval(1) + end + self.executeSequenceData:AppendFunc(false, self, self._FallDownComplete) + if self.isExecutePlayEffect then + ManagerContainer.ExecuteSequenceMgr:Execute(self.executeSequenceData) + end + elseif enterType == Enum.BigMapEnterType.NextLevel then + self:_PlayNextLevelEffect() end - self.executeSequenceData:AppendFunc(false, self, self._FallDownComplete) - if self.isExecutePlayEffect then - ManagerContainer.ExecuteSequenceMgr:Execute(self.executeSequenceData) - end - elseif enterType == Enum.BigMapEnterType.NextLevel then - self:_PlayNextLevelEffect() - end + end) end function BigMapView:_OnClickStoryItem(btn, params) @@ -854,18 +856,20 @@ function BigMapView:_DisposeSmallPoints() end function BigMapView:_CreateStartPoint(pointPos) - if not self.startPoint then - local startItem = ManagerContainer.ResMgr:LuaGetGoFromPool(Constants.UIPath, PointStartItemPath) - self.startPoint = startItem - end - if self.startPoint then - local startItemTrans = self.startPoint.transform - startItemTrans:SetParent(self.view.startPoint.transform, false) - startItemTrans.localPosition = pointPos - startItemTrans.localRotation = Quaternion.identity - startItemTrans.localScale = Vector3.one - self.startPoint:SetActive(true) - end + AW.async(function() + if not self.startPoint then + local startItem = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(Constants.UIPath, PointStartItemPath)) + self.startPoint = startItem + end + if self.startPoint then + local startItemTrans = self.startPoint.transform + startItemTrans:SetParent(self.view.startPoint.transform, false) + startItemTrans.localPosition = pointPos + startItemTrans.localRotation = Quaternion.identity + startItemTrans.localScale = Vector3.one + self.startPoint:SetActive(true) + end + end) end @@ -877,7 +881,7 @@ function BigMapView:_DisposeStartPoint() end function BigMapView:_CreateStoryIconLuaCtr(levelId, artRes, pointPos) - local iconItem = ManagerContainer.ResMgr:LuaGetGoFromPool(Constants.UIPath, PointIconItemPath) + local iconItem = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(Constants.UIPath, PointIconItemPath)) local iconAnimator, iconImage, button if iconItem then local iconItemTrans = iconItem.transform @@ -924,7 +928,7 @@ function BigMapView:_DisposeStoryIconLuaCtr(levelId) end function BigMapView:_CreateStoryGoLuaCtr(levelId, artRes, pointPos) - local goItem = ManagerContainer.ResMgr:LuaGetGoFromPool(Constants.UIPath, artRes) + local goItem = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(Constants.UIPath, artRes)) local goAnimator, button if goItem then local goItemTrans = goItem.transform diff --git a/Assets/Lua/UI/UIRoleMain/UIRoleMain1View.lua b/Assets/Lua/UI/UIRoleMain/UIRoleMain1View.lua index a75f6628b..d8e8322d6 100644 --- a/Assets/Lua/UI/UIRoleMain/UIRoleMain1View.lua +++ b/Assets/Lua/UI/UIRoleMain/UIRoleMain1View.lua @@ -536,14 +536,16 @@ function UIRoleMain1View:RefreshRedPoint(rpType) end function UIRoleMain1View:CreateNormalRedPoint(parent) - local redPoint = ManagerContainer.ResMgr:LuaGetGoFromPool(Constants.UICommonPath, UIRedPointRP) - if redPoint then - redPoint.transform:SetParent(parent) - redPoint.transform.localPosition = Vector3.zero - redPoint.transform.localRotation = Quaternion.identity - redPoint.transform.localScale = Vector3.one - redPoint:SetActive(true) - end + AW.async(function() + local redPoint = AW.await(ManagerContainer.ResMgr:LuaGetGoFromPoolAsync(Constants.UICommonPath, UIRedPointRP)) + if redPoint then + redPoint.transform:SetParent(parent) + redPoint.transform.localPosition = Vector3.zero + redPoint.transform.localRotation = Quaternion.identity + redPoint.transform.localScale = Vector3.one + redPoint:SetActive(true) + end + end) end function UIRoleMain1View:RefreshOtherRedPoint()