PGRData/Script/matrix/xui/xuicourse/xlesson/XUiCourseIntroduce.lua
2024-09-01 22:49:41 +02:00

119 lines
No EOL
4.2 KiB
Lua
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- ConditionShow
-- ================================================================================
local XUiGridConditionItem = XClass(nil, "XUiGridLessonItem")
function XUiGridConditionItem:Ctor(ui)
self.Ui = ui
XUiHelper.InitUiClass(self, self.Ui)
end
function XUiGridConditionItem:RefreshUi(desc, isClear)
self.Finish.gameObject:SetActiveEx(isClear)
self.UnFinish.gameObject:SetActiveEx(not isClear)
self.TxtFinish.text = desc
self.TxtUnFinish.text = desc
end
-- 课程详情界面
-- ================================================================================
local XUiCourseIntroduce = XLuaUiManager.Register(XLuaUi,"UiCourseIntroduce")
function XUiCourseIntroduce:OnAwake()
self:AddButtonListenr()
self.GridReward.gameObject:SetActive(false)
end
function XUiCourseIntroduce:OnStart(chapterId)
self.ChapterId = chapterId
self.RewardGrids = {}
self:RefreshUi()
end
function XUiCourseIntroduce:OnEnable()
end
function XUiCourseIntroduce:OnDisable()
end
function XUiCourseIntroduce:RefreshUi()
self:RefreshTxt()
self:RefreshCondition()
self:RefreshReward()
self:RefreshBtn()
end
function XUiCourseIntroduce:RefreshTxt()
local chapterId = self.ChapterId
self.NameTitle.text = XCourseConfig.GetCourseChapterName(chapterId)
self.DescTitle.text = XCourseConfig.GetCourseLessonDetailDescTitleById(chapterId)
self.Desc.text = XCourseConfig.GetCourseLessonDetailDescById(chapterId)
end
--参与条件
function XUiCourseIntroduce:RefreshCondition()
local chapterId = self.ChapterId
local unlockLessonPoint = XCourseConfig.GetCourseChapterUnlockLessonPoint(chapterId)
local prevChapterIdList = XCourseConfig.GetCourseChapterPrevChapterId(chapterId)
local unlockLv = XCourseConfig.GetCourseChapterUnlockLv(chapterId)
local lessonPointDesc, prevChapterDesc = XCourseConfig.GetChapterTipsUnlockDesc()
local desc, isClear
if unlockLessonPoint and unlockLessonPoint > 0 then
--条件1解锁需要总课程绩点
desc = string.format(lessonPointDesc, unlockLessonPoint)
isClear = XDataCenter.CourseManager.IsChapterUnlockPoint(chapterId)
local conditionUi = XUiGridConditionItem.New(XUiHelper.Instantiate(self.GridCondition, self.PanelAllCondition))
conditionUi:RefreshUi(desc, isClear)
end
if unlockLv and unlockLv > 0 then
--条件2解锁所需等级
local conditionUiLv = XUiGridConditionItem.New(XUiHelper.Instantiate(self.GridCondition, self.PanelAllCondition))
conditionUiLv:RefreshUi(XCourseConfig.GetCourseChapterLockDesc(chapterId), XPlayer.GetLevel() >= unlockLv)
end
for i, id in ipairs(prevChapterIdList) do
if XTool.IsNumberValid(id) then
local chapterName = XCourseConfig.GetCourseChapterName(id)
desc = string.format(prevChapterDesc, chapterName)
isClear = XDataCenter.CourseManager.IsChapterUnlockPrevChapter(id, i)
local item = XUiGridConditionItem.New(XUiHelper.Instantiate(self.GridCondition, self.PanelAllCondition))
item:RefreshUi(desc, isClear)
end
end
self.GridCondition.gameObject:SetActive(false)
end
--课程奖励
function XUiCourseIntroduce:RefreshReward()
local rewardId = XCourseConfig.GetLessonShowReward(self.ChapterId)
if not XTool.IsNumberValid(rewardId) then
return
end
local rewordGoodList = XRewardManager.GetRewardList(rewardId)
for i, rewardGood in ipairs(rewordGoodList or {}) do
local rewardGoodUi = self.RewardGrids[i]
if not rewardGoodUi then
rewardGoodUi = XUiGridCommon.New(XUiHelper.Instantiate(self.GridReward, self.PanelGift))
end
rewardGoodUi:Refresh(rewardGood)
end
end
function XUiCourseIntroduce:RefreshBtn()
local isOpen = XDataCenter.CourseManager.CheckChapterIsOpen(self.ChapterId)
self.BtnEnter:SetDisable(not isOpen, isOpen)
end
function XUiCourseIntroduce:AddButtonListenr()
self:RegisterClickEvent(self.BtnTanchuangClose, self.Close)
self.BtnEnter.CallBack = function() self:OnEnterChapter() end
end
function XUiCourseIntroduce:OnEnterChapter()
XLuaUiManager.PopThenOpen("UiCourseTutorial", self.ChapterId)
end