2023-07-14 19:35:33 +00:00
|
|
|
local XUiGridAssignChapter = XClass(nil, "XUiGridAssignChapter")
|
|
|
|
|
|
|
|
function XUiGridAssignChapter:Ctor(rootUi, ui)
|
|
|
|
self.GameObject = ui.gameObject
|
|
|
|
self.Transform = ui.transform
|
|
|
|
self.RootUi = rootUi
|
|
|
|
XTool.InitUiObject(self)
|
|
|
|
self:InitComponent()
|
|
|
|
end
|
|
|
|
|
|
|
|
function XUiGridAssignChapter:InitComponent()
|
|
|
|
CsXUiHelper.RegisterClickEvent(self.BtnAssignChapter, function() self:OnBtnChapterClick() end)
|
|
|
|
CsXUiHelper.RegisterClickEvent(self.BtnOccupy, function() self:OnBtnOccupyClick() end)
|
|
|
|
|
|
|
|
self.NormalRed.gameObject:SetActiveEx(false)
|
|
|
|
self.NormalBlue.gameObject:SetActiveEx(false)
|
|
|
|
self.PressRed.gameObject:SetActiveEx(false)
|
|
|
|
self.PressBlue.gameObject:SetActiveEx(false)
|
|
|
|
self.RoleImg.gameObject:SetActiveEx(false)
|
|
|
|
self.Red.gameObject:SetActiveEx(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
function XUiGridAssignChapter:OnBtnChapterClick()
|
|
|
|
if not self.ChapterData then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
XDataCenter.FubenAssignManager.SelectChapterId = self.ChapterData:GetId()
|
|
|
|
XLuaUiManager.Open("UiPanelAssignStage")
|
|
|
|
end
|
|
|
|
|
|
|
|
function XUiGridAssignChapter:OnBtnOccupyClick()
|
|
|
|
if not self.ChapterData then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
XDataCenter.FubenAssignManager.SelectChapterId = self.ChapterData:GetId()
|
|
|
|
XDataCenter.FubenAssignManager.SelectCharacterId = self.ChapterData:GetCharacterId()
|
2024-09-01 20:49:41 +00:00
|
|
|
XLuaUiManager.Open("UiAssignOccupy", self.ChapterData:GetId())
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function XUiGridAssignChapter:Refresh(chapterId)
|
|
|
|
local data = XDataCenter.FubenAssignManager.GetChapterDataById(chapterId)
|
|
|
|
self.ChapterData = data
|
|
|
|
|
|
|
|
local icon = data:GetIcon()
|
|
|
|
self.RegionIcon:SetRawImage(icon)
|
|
|
|
|
|
|
|
local progressStr = data:GetProgressStr()
|
|
|
|
self.TxtCourseNormalBlue.text = progressStr
|
|
|
|
self.TxtCourseNormalRed.text = progressStr
|
|
|
|
self.TxtCoursePressBlue.text = progressStr
|
|
|
|
self.TxtCoursePressRed.text = progressStr
|
|
|
|
|
|
|
|
local chapterName = data:GetDesc()
|
|
|
|
self.TxtChapterNameNormalBlue.text = chapterName
|
|
|
|
self.TxtChapterNameNormalRed.text = chapterName
|
|
|
|
self.TxtChapterNamePressBlue.text = chapterName
|
|
|
|
self.TxtChapterNamePressRed.text = chapterName
|
|
|
|
|
|
|
|
|
|
|
|
local isCurrentChapter = XDataCenter.FubenAssignManager.IsCurrentChapter(chapterId)
|
|
|
|
|
|
|
|
self.NormalRed.gameObject:SetActiveEx(isCurrentChapter)
|
|
|
|
self.NormalBlue.gameObject:SetActiveEx(not isCurrentChapter)
|
|
|
|
self.PressRed.gameObject:SetActiveEx(isCurrentChapter)
|
|
|
|
self.PressBlue.gameObject:SetActiveEx(not isCurrentChapter)
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
self.BtnOccupy:SetDisable(false)
|
2023-07-14 19:35:33 +00:00
|
|
|
local isCanAssign = data:CanAssign()
|
2024-09-01 20:49:41 +00:00
|
|
|
local isOccupy = data:IsOccupy()
|
2023-07-14 19:35:33 +00:00
|
|
|
if isCanAssign then
|
|
|
|
self.BtnOccupy.gameObject:SetActiveEx(true)
|
|
|
|
local occupyState = isOccupy and CS.UiButtonState.Select or CS.UiButtonState.Normal
|
|
|
|
self.BtnOccupy:SetButtonState(occupyState)
|
|
|
|
if isOccupy then
|
|
|
|
local characterIcon = data:GetOccupyCharacterIcon()
|
|
|
|
self.RoleImg.gameObject:SetActiveEx(true)
|
|
|
|
self.RoleImg:SetRawImage(characterIcon)
|
|
|
|
else
|
|
|
|
self.RoleImg.gameObject:SetActiveEx(false)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
self.BtnOccupy.gameObject:SetActiveEx(false)
|
2024-09-01 20:49:41 +00:00
|
|
|
|
|
|
|
if chapterId == XDataCenter.FubenAssignManager.GetChapterIdList()[1] then
|
|
|
|
self.BtnOccupy.gameObject:SetActiveEx(true)
|
|
|
|
self.BtnOccupy:SetDisable(true)
|
|
|
|
end
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
self.Red.gameObject:SetActiveEx(data:IsRed())
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return XUiGridAssignChapter
|