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

120 lines
5.4 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
--[[
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")
2020-05-25 19:16:23 +08:00
local GlobalActivity = ConfigManager.GetConfig(ConfigName.GlobalActivity)
local GrowthRewardId = nil
2020-05-09 13:31:21 +08:00
function GrowthGiftTaskItem:ctor(prefab, parent)
self.cloneObj = newObjToParent(prefab, parent)
self.itemPos = Util.GetGameObject(self.cloneObj, "itemPos_1")
self.giftInfo = SubUIManager.Open(SubUIConfig.ItemView, self.itemPos.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)
2020-05-25 19:16:23 +08:00
GrowthRewardId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.GrowthReward)
2020-05-09 13:31:21 +08:00
self.context = configData
sortingOrder = _sortingOrder or 0
self.giftInfo:OnOpen(false, configData.Reward[1], 0.8,false,false,false,sortingOrder)
if configData.Values[1][1] == ConditionType.Level then
2021-03-02 15:49:02 +08:00
self.desc.text = string.format("玩家等级达到%s", configData.Values[1][2])
2020-05-09 13:31:21 +08:00
else
2021-03-02 15:49:02 +08:00
self.desc.text = string.format("通关故事关卡%s", configData.Values[1][2])
2020-05-09 13:31:21 +08:00
end
self.finished:SetActive(false)
Util.SetGray(self.receiveBtn, true)
end
function GrowthGiftTaskItem:OnSortingOrderChange(cursortingOrder)
if self.giftInfo then
self.giftInfo:OnOpen(false, self.context.Reward[1], 0.8,false,false,false,cursortingOrder)
end
end
function GrowthGiftTaskItem:SetValue()
2020-05-25 19:16:23 +08:00
local activityInfo = ActivityGiftManager.GetActivityInfo(GrowthRewardId, self.context.Id)--获取活动数据 self.context.Id
local goods = OperatingManager.GetGiftGoodsInfo(GoodsTypeDef.GrowthReward, GlobalActivity[GrowthRewardId].CanBuyRechargeId[1])--判断当前礼包是否已投资
2020-05-25 19:16:23 +08:00
2020-05-09 13:31:21 +08:00
if activityInfo then
self.state = activityInfo.state
self.finished:SetActive(self.state == 1)
self.receiveBtn.gameObject:SetActive(self.state == 0)
2020-05-25 19:16:23 +08:00
if self.state == 0 then --未领取
self.receiveStatus = PlayerManager.level >= self.context.Values[1][2]
Util.SetGray(self.receiveBtn, not self.receiveStatus)
self.redPoint:SetActive(self.receiveStatus)
-- if self.receiveStatus then--判断是否达到等级
-- Util.SetGray(self.receiveBtn, not self.receiveStatus)
-- if(GrowthRewardId == ActivityTypeDef.GrowthReward)then--吸引玩家点击
-- self.redPoint:SetActive(true)
-- self.receiveStatus = true
-- else
-- self.redPoint:SetActive(not goods)
-- end
-- else
-- self.redPoint:SetActive(false)
-- end
else
--已达成,领取完毕
2020-05-09 13:31:21 +08:00
self.receiveStatus = false
2020-05-25 19:16:23 +08:00
self.redPoint:SetActive(false)
2020-05-09 13:31:21 +08:00
end
else
self.finished:SetActive(false)
self.receiveStatus = false
self.receiveBtn.gameObject:SetActive(true)
Util.SetGray(self.receiveBtn, true)
end
--本地红点处理
2020-05-25 19:16:23 +08:00
--OperatingManager.GetGrowthRedPointState(GrowthRewardId)
2020-05-09 13:31:21 +08:00
end
2020-08-22 16:43:39 +08:00
function GrowthGiftTaskItem:OnBtnDealClicked()
local openStatus = ActivityGiftManager.GetActivityOpenStatus(ActivityTypeDef.GrowthReward)
local goods = OperatingManager.GetGiftGoodsInfo(GoodsTypeDef.GrowthReward, GlobalActivity[GrowthRewardId].CanBuyRechargeId[1])
2020-06-03 19:09:01 +08:00
if not openStatus or (goods and goods.buyTimes < 1) then
2021-03-02 15:49:02 +08:00
PopupTipPanel.ShowTip("请先进行投资")
2020-05-09 13:31:21 +08:00
return
end
if self.receiveStatus then
2020-05-25 19:16:23 +08:00
NetManager.GetActivityRewardRequest(self.context.Id,GrowthRewardId, function(drop)
2020-05-09 13:31:21 +08:00
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
RedpotManager.CheckRedPointStatus(RedPointType.GrowthGift)
2020-05-25 19:16:23 +08:00
--检测奖励是否全部领完
local t = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig, "ActivityId", GrowthRewardId)
for i = 1, #t do
local info = ActivityGiftManager.GetActivityInfo(GrowthRewardId, t[i].Id)
if info.state ~= 1 then
Game.GlobalEvent:DispatchEvent(GameEvent.GrowGift.GetAllGift)
return
end
end
if(GrowthRewardId == 16)then--16是最后一个礼包的ActivityId
2021-03-02 15:49:02 +08:00
MsgPanel.ShowOne("恭喜!您已领取全部成长基金!")
2020-05-25 19:16:23 +08:00
else
2021-03-02 15:49:02 +08:00
MsgPanel.ShowOne("恭喜!您已激活更高等级成长基金,大量妖晶福利等您领取,快来激活吧!")
2020-05-25 19:16:23 +08:00
end
Game.GlobalEvent:DispatchEvent(GameEvent.GrowGift.GetAllGift)
2020-05-09 13:31:21 +08:00
end)
else
2021-03-02 15:49:02 +08:00
PopupTipPanel.ShowTip("条件未满足")
2020-05-09 13:31:21 +08:00
end
end
2020-06-23 18:36:24 +08:00
return GrowthGiftTaskItem