主城侧边栏
This commit is contained in:
parent
5e2644ee6e
commit
04e6bdcfda
@ -197,6 +197,26 @@ function UIPrefabObject:fastGetAnchoredPosition()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function UIPrefabObject:fastGetAnchoredPositionX()
|
||||||
|
if self.prefabHelper then
|
||||||
|
self.prefabHelper:CacheAnchoredPosition(self.objectIndex)
|
||||||
|
return self.prefabHelper.PositionX
|
||||||
|
else
|
||||||
|
local anchoredPosition = self:getTransform().anchoredPosition
|
||||||
|
return anchoredPosition.x
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function UIPrefabObject:fastGetAnchoredPositionY()
|
||||||
|
if self.prefabHelper then
|
||||||
|
self.prefabHelper:CacheAnchoredPosition(self.objectIndex)
|
||||||
|
return self.prefabHelper.PositionY
|
||||||
|
else
|
||||||
|
local anchoredPosition = self:getTransform().anchoredPosition
|
||||||
|
return anchoredPosition.y
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function UIPrefabObject:getAnchoredPosition()
|
function UIPrefabObject:getAnchoredPosition()
|
||||||
if self.prefabHelper then
|
if self.prefabHelper then
|
||||||
return self.prefabHelper:GetAnchoredPosition(self.objectIndex)
|
return self.prefabHelper:GetAnchoredPosition(self.objectIndex)
|
||||||
|
|||||||
@ -16,4 +16,20 @@ function MaincityManager:firstEnterMainCity()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function MaincityManager:changeMainCityLeftSideBarOpenOrClose()
|
||||||
|
self.isLeftSideBarClose = not self.isLeftSideBarClose
|
||||||
|
end
|
||||||
|
|
||||||
|
function MaincityManager:getIsMainCityLeftSideBarClose()
|
||||||
|
return self.isLeftSideBarClose
|
||||||
|
end
|
||||||
|
|
||||||
|
function MaincityManager:changeMainCityRightSideBarOpenOrClose()
|
||||||
|
self.isRightSideBarClose = not self.isRightSideBarClose
|
||||||
|
end
|
||||||
|
|
||||||
|
function MaincityManager:getIsMainCityRightSideBarClose()
|
||||||
|
return self.isRightSideBarClose
|
||||||
|
end
|
||||||
|
|
||||||
return MaincityManager
|
return MaincityManager
|
||||||
@ -94,6 +94,10 @@ function SideBarBaseCellComp:setAnchoredPositionY(y)
|
|||||||
self.baseObject:setAnchoredPositionY(y)
|
self.baseObject:setAnchoredPositionY(y)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function SideBarBaseCellComp:setVisible(visible)
|
||||||
|
self.baseObject:setVisible(visible)
|
||||||
|
end
|
||||||
|
|
||||||
function SideBarBaseCellComp:getCellPath()
|
function SideBarBaseCellComp:getCellPath()
|
||||||
return self.cellPath
|
return self.cellPath
|
||||||
end
|
end
|
||||||
|
|||||||
@ -6,7 +6,7 @@ function SideBarGodPigCell:getIsOpen()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SideBarGodPigCell:getIconRes()
|
function SideBarGodPigCell:getIconRes()
|
||||||
return "main_btn_godpig"
|
return "main_btn_pig"
|
||||||
end
|
end
|
||||||
|
|
||||||
function SideBarGodPigCell:onClick()
|
function SideBarGodPigCell:onClick()
|
||||||
|
|||||||
@ -6,7 +6,7 @@ function SideBarIdleCell:getIsOpen()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SideBarIdleCell:getIconRes()
|
function SideBarIdleCell:getIconRes()
|
||||||
return "main_btn_idle"
|
return "main_btn_hang"
|
||||||
end
|
end
|
||||||
|
|
||||||
function SideBarIdleCell:onClick()
|
function SideBarIdleCell:onClick()
|
||||||
|
|||||||
@ -10,9 +10,6 @@ function MainComp:init()
|
|||||||
self.uiMap = self:getBaseObject():genAllChildren()
|
self.uiMap = self:getBaseObject():genAllChildren()
|
||||||
self:initChapter()
|
self:initChapter()
|
||||||
self:initStageFormation()
|
self:initStageFormation()
|
||||||
self:initTask()
|
|
||||||
self:initBounty()
|
|
||||||
self:initSetting()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function MainComp:initChapter()
|
function MainComp:initChapter()
|
||||||
@ -51,29 +48,9 @@ function MainComp:initStageFormation()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function MainComp:initTask()
|
|
||||||
self.taskBtn = self.uiMap["main_comp.task_btn"]
|
|
||||||
self.taskBtn:addClickListener(function()
|
|
||||||
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function MainComp:initBounty()
|
|
||||||
self.bountyNode = self.uiMap["main_comp.bounty_node"]
|
|
||||||
self.bountyBanner = self.uiMap["main_comp.bounty_node.banner"]
|
|
||||||
end
|
|
||||||
|
|
||||||
function MainComp:initSetting()
|
|
||||||
self.settingbtn = self.uiMap["main_comp.setting_btn"]
|
|
||||||
self.settingbtn:addClickListener(function()
|
|
||||||
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function MainComp:refresh()
|
function MainComp:refresh()
|
||||||
self:refreshChapter()
|
self:refreshChapter()
|
||||||
self:refreshStageFormaion()
|
self:refreshStageFormaion()
|
||||||
self:refreshBounty()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function MainComp:onFightBtnClick()
|
function MainComp:onFightBtnClick()
|
||||||
@ -211,15 +188,4 @@ function MainComp:refreshStageFormaion()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function MainComp:refreshBounty()
|
|
||||||
local isOpen = DataManager.BountyData:getIsOpen()
|
|
||||||
if not isOpen then
|
|
||||||
self.bountyNode:setVisible(false)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self.bountyNode:setVisible(true)
|
|
||||||
local bannerName = DataManager.BountyData:getBannerName()
|
|
||||||
self.bountyBanner:setSprite(GConst.ATLAS_PATH.BOUNTY, bannerName)
|
|
||||||
end
|
|
||||||
|
|
||||||
return MainComp
|
return MainComp
|
||||||
@ -96,6 +96,7 @@ function MainCityUI:_display()
|
|||||||
self:initComp()
|
self:initComp()
|
||||||
self:initLeftRightBtns()
|
self:initLeftRightBtns()
|
||||||
self:initPlayerInfo()
|
self:initPlayerInfo()
|
||||||
|
self:initTopNode()
|
||||||
self:refreshBottom()
|
self:refreshBottom()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -230,9 +231,23 @@ function MainCityUI:refreshBottomCell(showAni)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MainCityUI:initLeftRightBtns()
|
function MainCityUI:initLeftRightBtns()
|
||||||
|
self.leftNode = self.uiMap["main_ui.left_node"]
|
||||||
self.leftSideBar = self.uiMap["main_ui.left_node.side_bar"]
|
self.leftSideBar = self.uiMap["main_ui.left_node.side_bar"]
|
||||||
|
self.leftArrowNode = self.uiMap["main_ui.left_node.arrow_node"]
|
||||||
|
self.leftArrowBtn = self.uiMap["main_ui.left_node.arrow_node.arrow"]
|
||||||
|
self.leftArrowBtn:addClickListener(function()
|
||||||
|
self:openOrCloseLeftSideBar()
|
||||||
|
end)
|
||||||
|
self.rightNode = self.uiMap["main_ui.right_node"]
|
||||||
self.rightSideBar = self.uiMap["main_ui.right_node.side_bar"]
|
self.rightSideBar = self.uiMap["main_ui.right_node.side_bar"]
|
||||||
|
self.rightArrowNode = self.uiMap["main_ui.right_node.arrow_node"]
|
||||||
|
self.rightArrowBtn = self.uiMap["main_ui.right_node.arrow_node.arrow"]
|
||||||
|
self.rightArrowBtn:addClickListener(function()
|
||||||
|
self:openOrCloseRightSideBar()
|
||||||
|
end)
|
||||||
self.sideBarCellObject = self.uiMap["main_ui.cache_node.side_bar_cell"]
|
self.sideBarCellObject = self.uiMap["main_ui.cache_node.side_bar_cell"]
|
||||||
|
local w, h = self.sideBarCellObject:fastGetSizeDelta()
|
||||||
|
self.sideBarHeight = h
|
||||||
if self.leftBarList == nil then
|
if self.leftBarList == nil then
|
||||||
self.leftBarList = {}
|
self.leftBarList = {}
|
||||||
end
|
end
|
||||||
@ -256,12 +271,18 @@ function MainCityUI:addSideBarCellComp(cellClassPath)
|
|||||||
return prefabObject:addLuaComponent(cellClassPath)
|
return prefabObject:addLuaComponent(cellClassPath)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function MainCityUI:openOrCloseLeftSideBar()
|
||||||
|
ModuleManager.MaincityManager:changeMainCityLeftSideBarOpenOrClose()
|
||||||
|
self:refreshLeftBtns()
|
||||||
|
end
|
||||||
|
|
||||||
function MainCityUI:refreshLeftBtns()
|
function MainCityUI:refreshLeftBtns()
|
||||||
|
self:clearSideBarList(self.leftBarList)
|
||||||
local list = GConst.MainCityConst.LEFT_SIDE_BARS
|
local list = GConst.MainCityConst.LEFT_SIDE_BARS
|
||||||
if #list <= 0 then
|
if #list <= 0 then
|
||||||
self:clearSideBarList(self.leftBarList)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local isClose = ModuleManager.MaincityManager:getIsMainCityLeftSideBarClose()
|
||||||
for k, v in ipairs(list) do
|
for k, v in ipairs(list) do
|
||||||
local CellClass = self.sideBarClassMap[v]
|
local CellClass = self.sideBarClassMap[v]
|
||||||
if CellClass == nil then
|
if CellClass == nil then
|
||||||
@ -278,20 +299,42 @@ function MainCityUI:refreshLeftBtns()
|
|||||||
table.insert(self.leftBarList, cell)
|
table.insert(self.leftBarList, cell)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local y = 0
|
local y = - 2 - self.sideBarHeight/2
|
||||||
for k, v in ipairs(self.leftBarList) do
|
if isClose then -- 只显示一个
|
||||||
v:setAnchoredPositionY(y)
|
local first = self.leftBarList[1]
|
||||||
v:refresh()
|
first:setAnchoredPositionY(y)
|
||||||
y = y - 80
|
first:setVisible(true)
|
||||||
|
first:refresh()
|
||||||
|
y = y - self.sideBarHeight - 2
|
||||||
|
for i = 2, #self.leftBarList do
|
||||||
|
self.leftBarList[i]:setVisible(false)
|
||||||
|
self.leftBarList[i]:refresh()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for k, v in ipairs(self.leftBarList) do
|
||||||
|
v:setAnchoredPositionY(y)
|
||||||
|
v:setVisible(true)
|
||||||
|
v:refresh()
|
||||||
|
y = y - self.sideBarHeight - 2
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
self.leftSideBar:setSizeDeltaY(-y)
|
||||||
|
self.leftArrowNode:setLocalScale(1, isClose and -1 or 1, 1)
|
||||||
|
self.leftArrowNode:setAnchoredPositionY(self.leftSideBar:fastGetAnchoredPositionY() + y + 20)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainCityUI:openOrCloseRightSideBar()
|
||||||
|
ModuleManager.MaincityManager:changeMainCityRightSideBarOpenOrClose()
|
||||||
|
self:refreshRightBtns()
|
||||||
end
|
end
|
||||||
|
|
||||||
function MainCityUI:refreshRightBtns()
|
function MainCityUI:refreshRightBtns()
|
||||||
|
self:clearSideBarList(self.rightBarList)
|
||||||
local list = GConst.MainCityConst.RIGHT_SIDE_BARS
|
local list = GConst.MainCityConst.RIGHT_SIDE_BARS
|
||||||
if #list <= 0 then
|
if #list <= 0 then
|
||||||
self:clearSideBarList(self.rightBarList)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local isClose = ModuleManager.MaincityManager:getIsMainCityRightSideBarClose()
|
||||||
for k, v in ipairs(list) do
|
for k, v in ipairs(list) do
|
||||||
local CellClass = self.sideBarClassMap[v]
|
local CellClass = self.sideBarClassMap[v]
|
||||||
if CellClass == nil then
|
if CellClass == nil then
|
||||||
@ -308,12 +351,27 @@ function MainCityUI:refreshRightBtns()
|
|||||||
table.insert(self.rightBarList, cell)
|
table.insert(self.rightBarList, cell)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local y = 0
|
local y = -2 - self.sideBarHeight/2
|
||||||
for k, v in ipairs(self.rightBarList) do
|
if isClose then -- 只显示一个
|
||||||
v:setAnchoredPositionY(y)
|
local first = self.rightBarList[1]
|
||||||
v:refresh()
|
first:setAnchoredPositionY(y)
|
||||||
y = y - 80
|
first:setVisible(true)
|
||||||
|
first:refresh()
|
||||||
|
y = y - self.sideBarHeight - 2
|
||||||
|
for i = 2, #self.rightBarList do
|
||||||
|
self.rightBarList[i]:setVisible(false)
|
||||||
|
self.rightBarList[i]:refresh()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for k, v in ipairs(self.rightBarList) do
|
||||||
|
v:setAnchoredPositionY(y)
|
||||||
|
v:refresh()
|
||||||
|
y = y - self.sideBarHeight - 2
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
self.rightSideBar:setSizeDeltaY(-y)
|
||||||
|
self.rightArrowNode:setLocalScale(1, isClose and -1 or 1, 1)
|
||||||
|
self.rightArrowNode:setAnchoredPositionY(self.rightSideBar:fastGetAnchoredPositionY() + y + 20)
|
||||||
end
|
end
|
||||||
|
|
||||||
function MainCityUI:clearSideBarList(sideBarList)
|
function MainCityUI:clearSideBarList(sideBarList)
|
||||||
@ -325,8 +383,8 @@ function MainCityUI:clearSideBarList(sideBarList)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MainCityUI:setSideBarVisible(visible)
|
function MainCityUI:setSideBarVisible(visible)
|
||||||
self.leftSideBar:setVisible(visible)
|
self.leftNode:setVisible(visible)
|
||||||
self.rightSideBar:setVisible(visible)
|
self.rightNode:setVisible(visible)
|
||||||
end
|
end
|
||||||
|
|
||||||
function MainCityUI:initPlayerInfo()
|
function MainCityUI:initPlayerInfo()
|
||||||
@ -340,6 +398,49 @@ function MainCityUI:refreshPlayerInfo()
|
|||||||
self.playerSlider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = DataManager.PlayerData:getExpPercent()
|
self.playerSlider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = DataManager.PlayerData:getExpPercent()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function MainCityUI:initTopNode()
|
||||||
|
self.topNode = self.uiMap["main_ui.top_node"]
|
||||||
|
self:initTask()
|
||||||
|
self:initBounty()
|
||||||
|
self:initSetting()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainCityUI:initTask()
|
||||||
|
self.taskBtn = self.uiMap["main_ui.top_node.task_btn"]
|
||||||
|
self.taskBtn:addClickListener(function()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainCityUI:initBounty()
|
||||||
|
self.bountyNode = self.uiMap["main_ui.top_node.bounty_node"]
|
||||||
|
self.bountyBanner = self.uiMap["main_ui.top_node.bounty_node.banner"]
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainCityUI:initSetting()
|
||||||
|
self.settingbtn = self.uiMap["main_ui.top_node.setting_btn"]
|
||||||
|
self.settingbtn:addClickListener(function()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainCityUI:setTopNodeVisible(visible)
|
||||||
|
self.topNode:setVisible(visible)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainCityUI:refreshTopNode()
|
||||||
|
self:refreshBounty()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainCityUI:refreshBounty()
|
||||||
|
local isOpen = DataManager.BountyData:getIsOpen()
|
||||||
|
if not isOpen then
|
||||||
|
self.bountyNode:setVisible(false)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.bountyNode:setVisible(true)
|
||||||
|
local bannerName = DataManager.BountyData:getBannerName()
|
||||||
|
self.bountyBanner:setSprite(GConst.ATLAS_PATH.BOUNTY, bannerName)
|
||||||
|
end
|
||||||
|
|
||||||
function MainCityUI:switchComp(index)
|
function MainCityUI:switchComp(index)
|
||||||
index = index or self.selectedIndex
|
index = index or self.selectedIndex
|
||||||
for i, comp in pairs(self.subComps) do
|
for i, comp in pairs(self.subComps) do
|
||||||
@ -352,8 +453,11 @@ function MainCityUI:switchComp(index)
|
|||||||
self:updateCurrencyBar()
|
self:updateCurrencyBar()
|
||||||
if self.selectedIndex == MAIN_COMP_INDEX then
|
if self.selectedIndex == MAIN_COMP_INDEX then
|
||||||
self:checkMainPop()
|
self:checkMainPop()
|
||||||
|
self:setTopNodeVisible(true)
|
||||||
|
self:refreshTopNode()
|
||||||
self:setSideBarVisible(true)
|
self:setSideBarVisible(true)
|
||||||
else
|
else
|
||||||
|
self:setTopNodeVisible(false)
|
||||||
self:setSideBarVisible(false)
|
self:setSideBarVisible(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user