miduo_client/Assets/ManagedResources/~Lua/Modules/Operating/GrowthGiftTaskItem.lua

107 lines
4.5 KiB
Lua
Raw Normal View History

2020-05-09 13:31:21 +08:00
--[[
* @ClassName GrowthGiftTaskItem
* @Description Item
* @Date 2019/5/25 17:01
* @Author MagicianJoker, fengliudianshao@outlook.com
* @Copyright Copyright (c) 2019, MagicianJoker
--]]
---@class GrowthGiftTaskItem
local GrowthGiftTaskItem = quick_class("GrowthGiftTaskItem")
function GrowthGiftTaskItem:ctor(prefab, parent)
self.cloneObj = newObjToParent(prefab, parent)
self.itemPos = Util.GetGameObject(self.cloneObj, "itemPos_1")
self.itemPos_2 = Util.GetGameObject(self.cloneObj, "itemPos_2")
self.giftInfo = SubUIManager.Open(SubUIConfig.ItemView, self.itemPos.transform)
self.giftInfo_2 = SubUIManager.Open(SubUIConfig.ItemView, self.itemPos_2.transform)
self.desc = Util.GetGameObject(self.cloneObj, "desc"):GetComponent("Text")
self.receiveBtn = Util.GetGameObject(self.cloneObj, "btnDeal")
self.receiveBtn:GetComponent("Button").onClick:AddListener(function()
self:OnBtnDealClicked()
end)
self.finished = Util.GetGameObject(self.cloneObj, "finished")
self.redPoint = Util.GetGameObject(self.cloneObj,"redPoint")
end
local sortingOrder = 0
function GrowthGiftTaskItem:Init(configData,_sortingOrder)
self.context = configData
sortingOrder = _sortingOrder or 0
self.giftInfo:OnOpen(false, configData.Reward[1], 0.8,false,false,false,sortingOrder)
self.giftInfo_2:OnOpen(false, configData.Reward[2], 0.8,false,false,false,sortingOrder)
if configData.Values[1][1] == ConditionType.Level then
self.desc.text = string.format("玩家等级达到%s", configData.Values[1][2])
else
self.desc.text = string.format("通关故事关卡%s", configData.Values[1][2])
end
self.finished:SetActive(false)
Util.SetGray(self.receiveBtn, true)
--self.redPoint:SetActive(false)
end
function GrowthGiftTaskItem:OnSortingOrderChange(cursortingOrder)
if self.giftInfo then
self.giftInfo:OnOpen(false, self.context.Reward[1], 0.8,false,false,false,cursortingOrder)
end
if self.giftInfo_2 then
self.giftInfo_2:OnOpen(false, self.context.Reward[2], 0.8,false,false,false,cursortingOrder)
end
end
function GrowthGiftTaskItem:SetValue()
local activityInfo = ActivityGiftManager.GetActivityInfo(ActivityTypeDef.GrowthReward, self.context.Id)--获取活动数据
if activityInfo then
self.state = activityInfo.state
self.finished:SetActive(self.state == 1)
self.receiveBtn.gameObject:SetActive(self.state == 0)
if self.state == 0 then --未达成
if self.context.Values[1][1] == ConditionType.Level then --如果达到等级
self.receiveStatus = PlayerManager.level >= self.context.Values[1][2]
Util.SetGray(self.receiveBtn, not self.receiveStatus)
else
self.receiveStatus = FightPointPassManager.IsFightPointPass(self.context.Values[1][2])
end
else --已达成,领取完毕
self.receiveStatus = false
end
Util.SetGray(self.receiveBtn, not self.receiveStatus)
else
self.finished:SetActive(false)
self.receiveStatus = false
self.receiveBtn.gameObject:SetActive(true)
Util.SetGray(self.receiveBtn, true)
end
--本地红点处理
if OperatingManager.GetGrowthRedPointState() and self.receiveStatus then
self.redPoint:SetActive(true)
else
self.redPoint:SetActive(false)
end
--local openStatus = ActivityGiftManager.GetActivityOpenStatus(ActivityTypeDef.GrowthReward)
--if not openStatus then
-- Util.SetGray(self.receiveBtn, true)
--end
end
function GrowthGiftTaskItem:OnBtnDealClicked()
local openStatus = ActivityGiftManager.GetActivityOpenStatus(ActivityTypeDef.GrowthReward)
if not openStatus then
PopupTipPanel.ShowTip("请先进行投资")
return
end
if self.receiveStatus then
NetManager.GetActivityRewardRequest(self.context.Id,ActivityTypeDef.GrowthReward, function(drop)
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1)
ActivityGiftManager.SetActivityInfo(self.context.ActivityId, self.context.Id, 1)
self.receiveBtn.gameObject:SetActive(false)
self.redPoint:SetActive(false)
self.finished:SetActive(true)
self.state = 1
self.cloneObj.transform:SetAsLastSibling()
RedpotManager.CheckRedPointStatus(RedPointType.GrowthGift)
end)
else
PopupTipPanel.ShowTip("条件未满足")
end
end
return GrowthGiftTaskItem