| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- local UIDiffTaskView = require("UITask/UIDiffTaskView_Generate")
- function UIDiffTaskView:OnAwake(data)
- self.controller = require("UITask/UIDiffTaskCtr"):new()
- self.controller:Init(self)
- self.controller:SetData(data)
- self.CurGroup = nil
- end
- function UIDiffTaskView:AddEventListener()
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.UI_TASK_CHANGE, self, self.RefreshTask)
- self.uiBase:AddButtonEventListener(self.BtnClose.button,self,self.OnCloseClick)
- self.uiBase:AddButtonEventListener(self.getBtn.button,self,self.OnClickGetGroupReward)
- self.uiBase:AddButtonEventListener(self.btnGoto.button,self,self.OnClickJump)
- end
- function UIDiffTaskView:FillContent(data, uiBase)
- self.uiBase = uiBase
- local gameObject = self.uiBase:GetRoot()
- if gameObject ~= nil then
- self.gameObject = gameObject
- self.transform = gameObject.transform
- end
- self:InitGenerate(self.transform, data)
- self:Init()
- end
- function UIDiffTaskView:Init()
- self:SetItems()
- --self:SetGroupReward({{100,100},{110,50},{47,1000000},{529,5}})
- end
- function UIDiffTaskView:RemoveEventListener()
- ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
- end
- function UIDiffTaskView:AddUIEventListener()
- end
- function UIDiffTaskView:OnHide()
- end
- function UIDiffTaskView:OnShow(data)
- self.controller:SetData(data)
- end
- function UIDiffTaskView:OnClose()
- end
- function UIDiffTaskView:OnDispose()
- self.controller:OnDispose()
- self.scrollView.loopHorizontalScrollRect:ClearCells()
- self.scrollView.loopHorizontalScrollRect:ClearAnchoredPostion()
- self.goodsItems.loopHorizontalScrollRect:ClearCells()
- self.goodsItems.loopHorizontalScrollRect:ClearAnchoredPostion()
- end
- function UIDiffTaskView:OnCloseClick()
- self:UIClose()
- end
- function UIDiffTaskView:SetItems()
- local curgroup = self.controller:GetShowTaskData()
- LogError("--------curgroup---"..Inspect(curgroup))
- self.CurGroup = curgroup
- local datalist = {}--{1,2,3,}
- if curgroup ~= nil and curgroup.groupTask ~= nil then
- --LogError("--------curgroup 有值---")
-
- self:SetGroupReward(curgroup.rewardCfg.GroupReward)
- local got = curgroup.groupTask._got
- self.btnGoto:SetActive(got == 0)
- self.getBtn:SetActive(got == 1)
- self.sealBtn:SetActive(got == 2)
-
- --self.getBtn.button.interactable = curgroup.groupTask._got == 1
- else
- self.getBtn:SetActive(false)
- self.sealBtn:SetActive(false)
- self.btnGoto:SetActive(false)
- end
- if curgroup ~= nil and curgroup.taskList then
- datalist = self:GetTaskList(curgroup.taskList)
- end
- --datalist = self:GetTaskList(curgroup.taskList)
- LogError("--------datalist---"..Inspect(datalist))
- self.scrollView.loopHorizontalScrollRect:ClearCells()
- --self.scrollView.loopHorizontalScrollRect:ClearAnchoredPostion()
- CommonUtil.LoopGridViewEleCreateNew(self,
- self.scrollView.loopHorizontalScrollRect,
- self.content.horizontalLayoutGroup,
- datalist,
- 0,
- self,
- self.UpdateTaskItem,
- nil,nil,0);
- self.scrollView.loopHorizontalScrollRect:MoveTo(0)
- self:SetGroupTxt(curgroup)
- end
- function UIDiffTaskView:UpdateTaskItem(_itemLua, _idx,_data)
- if not _itemLua or not _data then return end
- --_itemLua.gameObject:SetParent(wnd.content.transform)
- CommonUtil.UpdateItemPrefab(self, _itemLua, _data, Enum.ItemIEnterType.Bag,self,self.OnClickGetReward)
- end
- function UIDiffTaskView:UpdateRewardItem(_itemLua, _idx,_data)
- if not _itemLua or not _data then return end
- --_itemLua.gameObject:SetParent(wnd.content.transform)
- CommonUtil.UpdateItemPrefab(self, _itemLua, _data, Enum.ItemIEnterType.Bag)
- end
- function UIDiffTaskView:SetGroupReward(rewards)
- local rewardlist = ManagerContainer.DataMgr.HardMissionDataMgr:GetReward(rewards)
- self.goodsItems.loopHorizontalScrollRect:ClearCells()
- --self.goodsItems.loopHorizontalScrollRect:ClearAnchoredPostion()
- CommonUtil.LoopGridViewEleCreateNew(self,
- self.goodsItems.loopHorizontalScrollRect,
- self.goodsItemsContent.horizontalLayoutGroup,
- rewardlist,
- 0,
- self,
- self.UpdateRewardItem,
- nil,nil,0);
- --self.goodsItems.loopHorizontalScrollRect:SetItemStartIdx(0)
- end
- function UIDiffTaskView:RefreshTask()
- self:SetItems()
- end
- function UIDiffTaskView:OnClickGetReward(btn,data)
- --LogError("-----btn-----------"..Inspect(btn))
- --LogError("-----data-----------"..Inspect(data))
- ManagerContainer.DataMgr.TaskDataNew:CSGetTaskScoreRewardReq(data[0]._taskType,data[0]._id)
- end
- function UIDiffTaskView:OnClickGetGroupReward()
- ManagerContainer.DataMgr.TaskDataNew:CSGetTaskScoreRewardReq(self.CurGroup.groupTask._taskType,self.CurGroup.groupTask._id)
- end
- function UIDiffTaskView:OnClickJump()
- self:OnCloseClick()
- if(ManagerContainer.LuaBattleMgr:GetBattleMode() ~= 1) then
- ManagerContainer.LuaBattleMgr:SendChangeMapLevelTypeReq(1)
- end
- end
- function UIDiffTaskView:SetGroupTxt(grouptask)
- local txt = ""
- if grouptask ~= nil then
- txt = I18N.SetLanguageValue("DiffGroupTaskConditionTxt",grouptask.value,grouptask.total)
- end
- self.taskTxt.text.text = txt
- end
- function UIDiffTaskView:GetTaskList(data)
- --LogError("----GetTaskList-data-----------"..Inspect(data))
- local tasklist = {}
- for _, v in pairs(data) do
- tasklist[#tasklist +1] = v
- end
- table.sort(tasklist,function (a,b)
- return a._id < b._id
- end)
- return tasklist
- end
- return UIDiffTaskView
|