miduo_client/Assets/ManagedResources/~Lua/Modules/NewActivity/ExpertPre.lua

129 lines
5.0 KiB
Lua

ExpertPre = {}
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
function ExpertPre:New(gameObject)
local b = {}
b.gameObject = gameObject
b.transform = gameObject.transform
setmetatable(b, { __index = ExpertPre })
return b
end
local BtnState = {
[0] = {Img = "s_slbz_1anniuongse", isRed = true, isGray = false, Text = Language[11948],},
[1] = {Img = "s_slbz_1anniuhuangse", isRed = false, isGray = false, Text = Language[10556]},
[2] = {Img = "s_slbz_1anniuongse", isRed = false, isGray = true, Text = Language[10101]},
[3] = {Img = "s_slbz_1anniuongse", isRed = false, isGray = true, Text = Language[12300]},
}
--初始化组件(用于子类重写)
function ExpertPre:InitComponent()
self.spLoader = SpriteLoader.New()
self.title = Util.GetGameObject(self.gameObject,"Content/title"):GetComponent("Text")
self.info = Util.GetGameObject(self.gameObject,"Content/info"):GetComponent("Text")
self.grid = Util.GetGameObject(self.gameObject,"Content/scrollView")
self.btnGet = Util.GetGameObject(self.gameObject,"Content/button")
self.redPoint = Util.GetGameObject(self.btnGet,"redPoint")
self.btnText = Util.GetGameObject(self.btnGet,"Text"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function ExpertPre:BindEvent()
end
--添加事件监听(用于子类重写)
function ExpertPre:AddListener()
end
--移除事件监听(用于子类重写)
function ExpertPre:RemoveListener()
end
function ExpertPre:OnOpen()
end
function ExpertPre:SetData(_data,_parent,_sortingOrder,_actData,_actConfig)
self.data = _data
self.parent = _parent
self.sortingOrder = _sortingOrder
self.actData = _actData
self.actConfig = _actConfig
self:Refresh()
end
function ExpertPre:Refresh()
-- LogPink("self.data.missionId.:"..tostring(self.data.missionId).." self.data.progress:"..tostring(self.data.progress).." self.data.state:"..tostring(self.data.state))
-- local sConFigData = ConfigManager.GetConfigData(ConfigName.ActivityRewardConfig,self.data.missionId)
self.title.text = GetLanguageStrById(self.data.otherData.ContentsShow)
--设置内容
if not self.itemList then
self.itemList = {}
end
for i = 1, #self.data.otherData.Reward do
if not self.itemList[i] then
self.itemList[i] = SubUIManager.Open(SubUIConfig.ItemView,self.grid.transform)
end
self.itemList[i]:OnOpen(false, self.data.otherData.Reward[i], 0.9,false,false,false,self.sortingOrder)
end
self:SetButton()
end
function ExpertPre:SetButton()
local btnData = BtnState[self.data.otherData.state]
self.btnGet:GetComponent("Image").sprite = self.spLoader:LoadSprite(btnData.Img)
self.redPoint:SetActive(btnData.isRed)
Util.SetGray(self.btnGet,btnData.isGray)
self.btnText.text = btnData.Text
self.info.text = self.data.otherData.info
if self.actConfig then
if self.actConfig.ActiveType == ActivityTypeDef.ContinuityRecharge then
local bool = self:IsCurrentSortEnable(self.data.otherData.Sort)
self.btnGet:GetComponent("Button").interactable = bool
Util.SetGray(self.btnGet, not bool)
end
end
Util.AddOnceClick(self.btnGet, function()
if self.data.otherData.state == 0 then
if self.data.otherData.missionType and self.data.otherData.missionType == 0 then
NetManager.TakeMissionRewardRequest(self.data.otherData.taskType, self.data.missionId, function(drop)
TaskManager.SetTypeTaskState(self.data.otherData.taskType, self.data.missionId, 2, self.data.progress)
UIManager.OpenPanel(UIName.RewardItemPopup,drop.drop ,1,function()
self.parent:RefreshData(true,false)
CheckRedPointStatus(self.data.type + 98000)
end)
end)
else
NetManager.GetActivityRewardRequest(self.data.missionId, self.actData.activityId, function(drop)
UIManager.OpenPanel(UIName.RewardItemPopup,drop,1,function()
self.parent:RefreshData(true,false)
CheckRedPointStatus(RedPointType.Expert_FastExplore)
end)
end)
end
elseif self.data.otherData.state == 1 then
JumpManager.GoJump(self.data.otherData.Jump)
elseif self.data.otherData.state == 2 then
PopupTipPanel.ShowTip(Language[10101])
elseif self.data.otherData.state == 3 then
PopupTipPanel.ShowTip(Language[12301])
end
end)
end
function ExpertPre:OnClose()
self.spLoader:Destroy()
self.gridList = {}
for k,v in pairs(self.itemList) do
SubUIManager.Close(v)
end
end
--积天豪礼是否轮到当天可充了
function ExpertPre:IsCurrentSortEnable(sort)
local activityInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.ContinuityRecharge)
return activityInfo.value + 1 == sort
end
return ExpertPre