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