引导处理一下
This commit is contained in:
parent
592eb102ef
commit
f13f1f3e3a
@ -31,6 +31,7 @@ function HeroCell:init()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function HeroCell:refresh(heroEntity, isGray)
|
function HeroCell:refresh(heroEntity, isGray)
|
||||||
|
self.heroEntity = heroEntity
|
||||||
self.selfNode:setVisible(true)
|
self.selfNode:setVisible(true)
|
||||||
self.otherNode:setVisible(false)
|
self.otherNode:setVisible(false)
|
||||||
|
|
||||||
@ -80,6 +81,13 @@ function HeroCell:refresh(heroEntity, isGray)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function HeroCell:getHeroId()
|
||||||
|
if not self.heroEntity then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return self.heroEntity:getCfgId()
|
||||||
|
end
|
||||||
|
|
||||||
function HeroCell:refreshBriefInfo(id, level)
|
function HeroCell:refreshBriefInfo(id, level)
|
||||||
self.selfNode:setVisible(false)
|
self.selfNode:setVisible(false)
|
||||||
self.otherNode:setVisible(true)
|
self.otherNode:setVisible(true)
|
||||||
|
|||||||
@ -82,4 +82,15 @@ function HeroListCell:refresh(index, heroList, stageFormation, allHeroCount, act
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function HeroListCell:getHeroCellByHeroId(heroId)
|
||||||
|
if not self.heroCells then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for i, cell in ipairs(self.heroCells) do
|
||||||
|
if cell:getHeroId() == heroId then
|
||||||
|
return cell
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return HeroListCell
|
return HeroListCell
|
||||||
@ -255,4 +255,19 @@ function HeroComp:clearAdapt()
|
|||||||
viewport:setSizeDelta(self.viewDefaultSize.x, self.viewDefaultSize.y)
|
viewport:setSizeDelta(self.viewDefaultSize.x, self.viewDefaultSize.y)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function HeroComp:getHeroCell(heroId)
|
||||||
|
if not self.scrollRect then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local targetCell
|
||||||
|
for index, cell in pairs(self.scrollRect:getListCell()) do
|
||||||
|
local heroCell = cell:getHeroCellByHeroId(heroId)
|
||||||
|
if heroCell then
|
||||||
|
targetCell = heroCell
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return targetCell
|
||||||
|
end
|
||||||
|
|
||||||
return HeroComp
|
return HeroComp
|
||||||
@ -181,8 +181,13 @@ function TutorialUI:showTutorialText()
|
|||||||
end
|
end
|
||||||
self.fingerParentNode:setLocalPosition(fingerOffset[1], fingerOffset[2], 0)
|
self.fingerParentNode:setLocalPosition(fingerOffset[1], fingerOffset[2], 0)
|
||||||
|
|
||||||
|
if targetName or DataManager.TutorialData:getTargetHeroId() then
|
||||||
|
local targetGo
|
||||||
if targetName then
|
if targetName then
|
||||||
local targetGo = UIManager:getMainCanvasTransform():Find(targetName)
|
targetGo = UIManager:getMainCanvasTransform():Find(targetName)
|
||||||
|
else
|
||||||
|
targetGo = self:getHeroCellByHeroId(DataManager.TutorialData:getTargetHeroId())
|
||||||
|
end
|
||||||
local anchoredPosition = nil
|
local anchoredPosition = nil
|
||||||
local setGuideFingerPosition = nil
|
local setGuideFingerPosition = nil
|
||||||
setGuideFingerPosition = function(interval)
|
setGuideFingerPosition = function(interval)
|
||||||
@ -226,7 +231,11 @@ function TutorialUI:showTutorialText()
|
|||||||
ModuleManager.TutorialManager:unscheduleGlobal(self._findTargetSid)
|
ModuleManager.TutorialManager:unscheduleGlobal(self._findTargetSid)
|
||||||
end
|
end
|
||||||
self._findTargetSid = ModuleManager.TutorialManager:scheduleGlobal(function()
|
self._findTargetSid = ModuleManager.TutorialManager:scheduleGlobal(function()
|
||||||
|
if targetName then
|
||||||
targetGo = UIManager:getMainCanvasTransform():Find(targetName)
|
targetGo = UIManager:getMainCanvasTransform():Find(targetName)
|
||||||
|
else
|
||||||
|
targetGo = self:getHeroCellByHeroId(DataManager.TutorialData:getTargetHeroId())
|
||||||
|
end
|
||||||
if targetGo then
|
if targetGo then
|
||||||
anchoredPosition = self:getTargetAnchoredPosition(targetGo)
|
anchoredPosition = self:getTargetAnchoredPosition(targetGo)
|
||||||
ModuleManager.TutorialManager:unscheduleGlobal(self._findTargetSid)
|
ModuleManager.TutorialManager:unscheduleGlobal(self._findTargetSid)
|
||||||
@ -333,18 +342,28 @@ function TutorialUI:registerClickBtnListener(callback, targetName, clickType)
|
|||||||
if targetName == nil then
|
if targetName == nil then
|
||||||
targetName = DataManager.TutorialData:getTargetName()
|
targetName = DataManager.TutorialData:getTargetName()
|
||||||
end
|
end
|
||||||
if targetName == nil then
|
|
||||||
|
if targetName == nil and not DataManager.TutorialData:getTargetHeroId() then
|
||||||
ModuleManager.TutorialManager:stopTutorial()
|
ModuleManager.TutorialManager:stopTutorial()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local targetGo = UIManager:getMainCanvasTransform():Find(targetName)
|
local targetGo
|
||||||
|
if targetName then
|
||||||
|
targetGo = UIManager:getMainCanvasTransform():Find(targetName)
|
||||||
|
else
|
||||||
|
targetGo = self:getHeroCellByHeroId(DataManager.TutorialData:getTargetHeroId())
|
||||||
|
end
|
||||||
if targetGo == nil then -- 没有找到说明需要找的ui还没打开
|
if targetGo == nil then -- 没有找到说明需要找的ui还没打开
|
||||||
-- 每隔一定时间在重新找一次
|
-- 每隔一定时间在重新找一次
|
||||||
if self._findTargetSid then
|
if self._findTargetSid then
|
||||||
ModuleManager.TutorialManager:unscheduleGlobal(self._findTargetSid)
|
ModuleManager.TutorialManager:unscheduleGlobal(self._findTargetSid)
|
||||||
end
|
end
|
||||||
self._findTargetSid = ModuleManager.TutorialManager:scheduleGlobal(function()
|
self._findTargetSid = ModuleManager.TutorialManager:scheduleGlobal(function()
|
||||||
|
if targetName then
|
||||||
targetGo = UIManager:getMainCanvasTransform():Find(targetName)
|
targetGo = UIManager:getMainCanvasTransform():Find(targetName)
|
||||||
|
else
|
||||||
|
targetGo = self:getHeroCellByHeroId(DataManager.TutorialData:getTargetHeroId())
|
||||||
|
end
|
||||||
if targetGo then
|
if targetGo then
|
||||||
ModuleManager.TutorialManager:unscheduleGlobal(self._findTargetSid)
|
ModuleManager.TutorialManager:unscheduleGlobal(self._findTargetSid)
|
||||||
self._findTargetSid = nil
|
self._findTargetSid = nil
|
||||||
@ -579,4 +598,20 @@ function TutorialUI:setVisible(visible)
|
|||||||
self.baseObject:setActive(visible)
|
self.baseObject:setActive(visible)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function TutorialUI:getHeroCellByHeroId(heroId)
|
||||||
|
local uiObj = UIManager:getUIByIndex(UIManager.UI_PATH.MAINCITY_UI)
|
||||||
|
if not uiObj then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local heroComp = uiObj:getHeroComp()
|
||||||
|
if not heroComp then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local cell = heroComp:getHeroCell(heroId)
|
||||||
|
if not cell then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return cell:getBaseObject():getTransform()
|
||||||
|
end
|
||||||
|
|
||||||
return TutorialUI
|
return TutorialUI
|
||||||
@ -191,6 +191,10 @@ function TutorialData:getTargetName()
|
|||||||
return self.tutorialInfo.target_name
|
return self.tutorialInfo.target_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function TutorialData:getTargetHeroId()
|
||||||
|
return self.tutorialInfo.heroid
|
||||||
|
end
|
||||||
|
|
||||||
function TutorialData:getTutorialTalkRoleId()
|
function TutorialData:getTutorialTalkRoleId()
|
||||||
return self.tutorialInfo.head
|
return self.tutorialInfo.head
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user