2021-12-14 19:16:30 +08:00
|
|
|
|
local EveryDayGiftNew = {}
|
|
|
|
|
local rechargeNum = 0
|
2021-12-15 14:34:21 +08:00
|
|
|
|
local growData = {}
|
2021-12-16 10:46:11 +08:00
|
|
|
|
local rechargeCommodityConfig = ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig)
|
2022-02-10 18:22:48 +08:00
|
|
|
|
local onKeyPackId = 545
|
2021-12-14 19:16:30 +08:00
|
|
|
|
function EveryDayGiftNew:New(gameObject)
|
|
|
|
|
local b = {}
|
|
|
|
|
b.gameObject = gameObject
|
|
|
|
|
b.transform = gameObject.transform
|
|
|
|
|
setmetatable(b, { __index = EveryDayGiftNew })
|
|
|
|
|
return b
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function EveryDayGiftNew:AddListener()
|
2021-12-16 11:59:18 +08:00
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess,self.SetGrowGift,self)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function EveryDayGiftNew:RemoveListener()
|
2021-12-16 11:59:18 +08:00
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess,self.SetGrowGift,self)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function EveryDayGiftNew:InitComponent()
|
|
|
|
|
self.spLoader = SpriteLoader.New()
|
|
|
|
|
Util.GetGameObject(self.gameObject, "rzyBg"):SetActive(false)
|
|
|
|
|
Util.GetGameObject(self.gameObject, "curObj"):SetActive(false)
|
|
|
|
|
Util.GetGameObject(self.gameObject, "GameObject"):SetActive(false)
|
2023-10-20 18:51:12 +08:00
|
|
|
|
Util.GetGameObject(self.gameObject, "Image"):SetActive(true)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
self.newPage = Util.GetGameObject(self.gameObject, "newPage")
|
|
|
|
|
self.newPage:SetActive(true)
|
|
|
|
|
self.itemPre = Util.GetGameObject(self.newPage,"ItemPre")
|
2021-12-15 14:34:21 +08:00
|
|
|
|
--===================成长礼包================
|
|
|
|
|
self.grow = Util.GetGameObject(self.newPage,"growPack/Content")
|
|
|
|
|
self.tip = Util.GetGameObject(self.grow,"Tip"):GetComponent("Text")
|
|
|
|
|
self.icon = Util.GetGameObject(self.grow,"Icon"):GetComponent("Image")
|
2024-01-13 17:53:47 +08:00
|
|
|
|
self.Level = Util.GetGameObject(self.grow,"Icon/Level"):GetComponent("Text")
|
2022-10-20 17:48:00 +08:00
|
|
|
|
self.name = Util.GetGameObject(self.grow,"Name"):GetComponent("Image")
|
|
|
|
|
self.name.sprite=self.spLoader:LoadSprite("gm_mingwang_title")
|
2021-12-15 14:34:21 +08:00
|
|
|
|
self.progress = Util.GetGameObject(self.grow,"Progress/Image")
|
|
|
|
|
self.value = Util.GetGameObject(self.grow,"Progress/Text"):GetComponent("Text")
|
|
|
|
|
self.reward = Util.GetGameObject(self.grow,"Reward")
|
|
|
|
|
self.btnLeft = Util.GetGameObject(self.grow,"btnLeft")
|
|
|
|
|
self.btnRight = Util.GetGameObject(self.grow,"btnRight")
|
|
|
|
|
self.btnGet = Util.GetGameObject(self.grow,"btnGet")
|
|
|
|
|
self.price = Util.GetGameObject(self.btnGet,"cost/Text"):GetComponent("Text")
|
|
|
|
|
self.cost = Util.GetGameObject(self.btnGet,"cost")
|
|
|
|
|
self.btnText = Util.GetGameObject(self.btnGet,"Text")
|
|
|
|
|
self.btnRed = Util.GetGameObject(self.btnGet,"red")
|
2022-01-17 13:16:18 +08:00
|
|
|
|
self.leftRed = Util.GetGameObject(self.btnLeft,"Red")
|
|
|
|
|
self.rightRed = Util.GetGameObject(self.btnRight,"Red")
|
2021-12-15 14:34:21 +08:00
|
|
|
|
|
|
|
|
|
--=================Rewards=================
|
|
|
|
|
self.Reward = Util.GetGameObject(self.newPage,"Reward")
|
2023-10-20 18:51:12 +08:00
|
|
|
|
self.Reward:GetComponent("RectTransform").sizeDelta = Vector2.New(1080,864.7)
|
|
|
|
|
self.Reward:GetComponent("RectTransform").localPosition = Vector3.New(0,209,-100)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
self.endTimeBg = Util.GetGameObject(self.newPage,"growPack/Time")
|
|
|
|
|
self.endTime = Util.GetGameObject(self.endTimeBg,"Text"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
self.ItemList = {}
|
|
|
|
|
self.sortingOrder = 0
|
2022-02-10 17:53:00 +08:00
|
|
|
|
|
|
|
|
|
--=================extraTitle================
|
|
|
|
|
self.extarTitle = Util.GetGameObject(self.newPage,"extarTitle")
|
|
|
|
|
self.extarTitle:SetActive(false)
|
|
|
|
|
self.extarFreeBtn = Util.GetGameObject(self.extarTitle,"freeBtn")
|
|
|
|
|
self.freeBtnAnim = Util.GetGameObject(self.extarFreeBtn,"UI_effect_TanSuo_Box"):GetComponent("Animator")
|
|
|
|
|
self.freeBtnRed = Util.GetGameObject(self.extarFreeBtn,"redPoint")
|
|
|
|
|
self.extarStoreBtn = Util.GetGameObject(self.extarTitle,"Bg/store")
|
2022-11-04 14:55:26 +08:00
|
|
|
|
self.extarBg = Util.GetGameObject(self.extarTitle,"Bg")
|
2022-02-10 17:53:00 +08:00
|
|
|
|
self.UI_Effect_jinkuang_Yuan = Util.GetGameObject(self.extarStoreBtn, "UI_Effect_jinkuang_Yuan")
|
|
|
|
|
self.extarOneKeyBtn = Util.GetGameObject(self.extarTitle,"Bg/oneKey/oneKeyBtn")
|
|
|
|
|
self.allSaoGuang = Util.GetGameObject(self.extarOneKeyBtn, "saoguang")
|
|
|
|
|
self.extarOneKeyprice1 = Util.GetGameObject(self.extarTitle,"Bg/oneKey/nowPrice"):GetComponent("Text")
|
|
|
|
|
self.extarOneKeyprice2 = Util.GetGameObject(self.extarTitle,"Bg/oneKey/oriPrice"):GetComponent("Text")
|
2022-07-06 13:21:40 +08:00
|
|
|
|
self.jiantou=Util.GetGameObject(self.gameObject, "jiantou")
|
2022-02-10 17:53:00 +08:00
|
|
|
|
self.lightList = {
|
|
|
|
|
Util.GetGameObject(self.freeBtnAnim.gameObject,"bg_ray"),
|
|
|
|
|
Util.GetGameObject(self.freeBtnAnim.gameObject,"yinying/ray 1"),
|
|
|
|
|
Util.GetGameObject(self.freeBtnAnim.gameObject,"yinying/ray 2"),
|
|
|
|
|
Util.GetGameObject(self.freeBtnAnim.gameObject,"yinying/ray 3"),
|
|
|
|
|
Util.GetGameObject(self.freeBtnAnim.gameObject,"yinying/ray 4"),
|
|
|
|
|
}
|
2022-11-07 15:00:36 +08:00
|
|
|
|
self.hintObj=Util.GetGameObject(self.gameObject, "hint")
|
|
|
|
|
self.hintTxt=Util.GetGameObject(self.gameObject, "hint/Text"):GetComponent("Text")
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function EveryDayGiftNew:BindEvent()
|
2022-02-10 17:53:00 +08:00
|
|
|
|
Util.AddOnceClick(self.extarOneKeyBtn,function ()
|
|
|
|
|
if self.actType ~= FUNCTION_OPEN_TYPE.MeiRiLiBao then return end
|
2021-12-21 16:51:40 +08:00
|
|
|
|
PayManager.Pay(onKeyPackId, function(id)
|
|
|
|
|
FirstRechargeManager.RefreshAccumRechargeValue(onKeyPackId)
|
|
|
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."czlb", 0)
|
|
|
|
|
CheckRedPointStatus(RedPointType.GrowthPackage)
|
|
|
|
|
MonthCardManager.CheckMonthCardPatFace()
|
|
|
|
|
self:RefreshData(nil,false,false)
|
|
|
|
|
end)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end)
|
2022-02-10 17:53:00 +08:00
|
|
|
|
Util.AddOnceClick(self.extarStoreBtn,function()
|
|
|
|
|
if self.actType ~= FUNCTION_OPEN_TYPE.MeiRiLiBao then return end
|
|
|
|
|
JumpManager.GoJump(40020)
|
|
|
|
|
end)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function EveryDayGiftNew:OnOpen(_activityConfig,_index,parent)
|
|
|
|
|
self.actConfig = _activityConfig
|
|
|
|
|
self.pageIndex = _index
|
|
|
|
|
self.parent = parent
|
|
|
|
|
self.gameObject.name = "EveryDayGiftNew"..self.actConfig.Id
|
2022-07-06 13:21:40 +08:00
|
|
|
|
if self.actConfig.Id==89 or self.actConfig.Id==61 or self.actConfig.Id==60 or self.actConfig.Id==67 then
|
|
|
|
|
self.jiantou.gameObject:SetActive(true)
|
|
|
|
|
local jiantouAnim = self.jiantou.gameObject:GetComponent(typeof(PlayFlyAnim))
|
|
|
|
|
jiantouAnim:PlayAnim(false)
|
|
|
|
|
end
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function EveryDayGiftNew:OnSortingOrderChange(_sortingOrder)
|
|
|
|
|
self.sortingOrder = _sortingOrder
|
2022-02-10 17:53:00 +08:00
|
|
|
|
Util.SetParticleSortLayer(self.UI_Effect_jinkuang_Yuan, _sortingOrder + 1)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 打开,重新打开时回调
|
|
|
|
|
function EveryDayGiftNew:OnShow(_sortingOrder)
|
|
|
|
|
self.gameObject:SetActive(true)
|
|
|
|
|
self.sortingOrder = _sortingOrder or self.sortingOrder
|
|
|
|
|
self.actId = self.actConfig.ActId
|
|
|
|
|
self.actType = self.actConfig.ActiveType > 0 and self.actConfig.ActiveType or self.actConfig.FunType
|
|
|
|
|
if self.actConfig.IfBack == 1 then
|
|
|
|
|
if self.actConfig.ActiveType > 0 then
|
|
|
|
|
local id = ActivityGiftManager.IsActivityTypeOpen(self.actConfig.ActiveType)
|
|
|
|
|
if id and id > 0 then
|
|
|
|
|
self.actId = id
|
|
|
|
|
local config = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.ActivityGroups,"PageType",self.actConfig.PageType,"ActiveType",self.actConfig.ActiveType,"ActId",id)
|
|
|
|
|
if config then
|
|
|
|
|
self.actConfig = config
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
self.parent.tabbox.gameObject:SetActive(true)
|
|
|
|
|
|
2021-12-16 10:46:11 +08:00
|
|
|
|
self:RefreshData(nil,true,true)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-16 10:46:11 +08:00
|
|
|
|
function EveryDayGiftNew:RefreshData(none,isTop,isAni)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
if self.actConfig.RpType > 0 then
|
|
|
|
|
CheckRedPointStatus(self.actConfig.RpType)
|
|
|
|
|
end
|
2021-12-15 14:34:21 +08:00
|
|
|
|
--成长礼包检测,现在放到每个页签,所有都要检测
|
|
|
|
|
VipManager.SetGrowthPackagePointStatus()
|
|
|
|
|
CheckRedPointStatus(RedPointType.GrowthPackage)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
self.shopData = DynamicActivityManager.GetGiftDataByType(self.actConfig.ShopData)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
--成长礼包
|
|
|
|
|
self:SetGrowGift()
|
2022-11-07 15:00:36 +08:00
|
|
|
|
self.hintObj:SetActive(false)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
--特殊处理部分
|
2021-12-15 14:34:21 +08:00
|
|
|
|
Log("actType:"..tostring(self.actType))
|
2022-11-04 14:55:26 +08:00
|
|
|
|
if self.actType == FUNCTION_OPEN_TYPE.MeiRiLiBao then
|
2022-02-10 17:53:00 +08:00
|
|
|
|
self.extarTitle:SetActive(true)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
--每日礼
|
|
|
|
|
self:RefreshFreeData()
|
2021-12-14 19:16:30 +08:00
|
|
|
|
-- 刷新一键购买显示
|
2021-12-15 14:34:21 +08:00
|
|
|
|
self:RefreshOneKeyShow()
|
2023-10-20 18:51:12 +08:00
|
|
|
|
self.Reward:GetComponent("RectTransform").sizeDelta = Vector2.New(1080,659)
|
|
|
|
|
self.Reward:GetComponent("RectTransform").localPosition = Vector3.New(0,202,-100)
|
2022-02-10 17:53:00 +08:00
|
|
|
|
end
|
2022-11-04 14:55:26 +08:00
|
|
|
|
if self.actType == 98 then
|
|
|
|
|
self.extarTitle:SetActive(true)
|
|
|
|
|
self.extarBg:SetActive(false)
|
2022-11-07 15:00:36 +08:00
|
|
|
|
self.hintObj:SetActive(true)
|
|
|
|
|
self.hintTxt.text="特权只生效当前激活最高的特权,不会相互叠加"
|
2022-11-04 14:55:26 +08:00
|
|
|
|
self:RefreshFreeData()
|
|
|
|
|
end
|
2022-02-10 17:53:00 +08:00
|
|
|
|
if not self.scrollView then
|
|
|
|
|
--更改完空间大小后再生成滚动条
|
|
|
|
|
local rootHight = self.Reward.transform.rect.height
|
|
|
|
|
local width = self.Reward.transform.rect.width
|
|
|
|
|
self.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.Reward.transform,
|
|
|
|
|
self.itemPre, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 10))
|
|
|
|
|
self.scrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
self.scrollView.moveTween.Strength = 2
|
|
|
|
|
self.scrollView.elastic = false
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end
|
2022-02-10 17:53:00 +08:00
|
|
|
|
|
|
|
|
|
-- 刷新剩余时间
|
|
|
|
|
self:GetRemainTime()
|
|
|
|
|
-- 刷新商品数据
|
|
|
|
|
self:RefreshGiftData(isTop,isAni)
|
|
|
|
|
|
|
|
|
|
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
2022-01-17 13:16:18 +08:00
|
|
|
|
--==============================成长礼包部分==========================(rechargeViewNew和EveryDayGiftNew中有完全相同的部分,复制过去)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
function EveryDayGiftNew:SetGrowGift()
|
2022-10-20 17:48:00 +08:00
|
|
|
|
growData = DynamicActivityManager.GetGiftDataByType({{2,95}})
|
|
|
|
|
local rechargeNum = BagManager.GetItemCountById(1351) --VipManager.GetChargedNum()--已经充值的金额
|
2021-12-15 14:34:21 +08:00
|
|
|
|
table.sort(growData,function (a,b)
|
|
|
|
|
return a.data.shopItemData.BuyRule[2] < b.data.shopItemData.BuyRule[2]
|
|
|
|
|
end)
|
2023-06-06 19:38:21 +08:00
|
|
|
|
--LogError("DynamicActivityManager.curLevel=="..DynamicActivityManager.curLevel)
|
2021-12-16 19:22:46 +08:00
|
|
|
|
--计算当前声望等级
|
2023-06-06 19:38:21 +08:00
|
|
|
|
if DynamicActivityManager.curLevel == 0 or DynamicActivityManager.curLevel == 1 then
|
2021-12-15 14:34:21 +08:00
|
|
|
|
for i = 1, #growData do
|
2022-10-20 17:48:00 +08:00
|
|
|
|
if rechargeNum < DynamicActivityManager.GetMingWangLv(growData[i].data.shopItemData.BuyRule[2]) then
|
2021-12-20 15:02:14 +08:00
|
|
|
|
if rechargeNum ~= 0 then
|
|
|
|
|
DynamicActivityManager.curLevel = i
|
|
|
|
|
if DynamicActivityManager.Index == 0 then
|
|
|
|
|
DynamicActivityManager.Index = DynamicActivityManager.curLevel
|
|
|
|
|
end
|
|
|
|
|
break
|
|
|
|
|
else
|
|
|
|
|
DynamicActivityManager.curLevel = 1
|
|
|
|
|
DynamicActivityManager.Index = 1
|
2021-12-17 11:28:37 +08:00
|
|
|
|
end
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-12-16 19:22:46 +08:00
|
|
|
|
--如果所有都没有,说明超范围了
|
2021-12-17 11:28:37 +08:00
|
|
|
|
if DynamicActivityManager.curLevel == 0 then
|
|
|
|
|
DynamicActivityManager.curLevel = #growData
|
|
|
|
|
if DynamicActivityManager.Index == 0 then
|
2021-12-17 14:13:41 +08:00
|
|
|
|
DynamicActivityManager.Index = DynamicActivityManager.curLevel
|
2021-12-17 11:28:37 +08:00
|
|
|
|
end
|
2021-12-16 19:22:46 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-20 15:02:14 +08:00
|
|
|
|
Log("当前声望Level:"..tostring(DynamicActivityManager.curLevel).." Index:"..tostring(DynamicActivityManager.Index))
|
2021-12-16 19:22:46 +08:00
|
|
|
|
--如果有当前声望数据,就显示,没有就显示上一档位
|
2022-10-20 17:48:00 +08:00
|
|
|
|
-- local data = not not growData[DynamicActivityManager.Index] and growData[DynamicActivityManager.Index] or growData[DynamicActivityManager.Index-1]
|
|
|
|
|
local data=growData[DynamicActivityManager.Index]
|
2023-06-06 17:16:28 +08:00
|
|
|
|
if data==nil then
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-12-16 19:22:46 +08:00
|
|
|
|
self:RefreshReward(data)
|
|
|
|
|
|
2021-12-15 14:34:21 +08:00
|
|
|
|
Util.AddOnceClick(self.btnLeft,function ()
|
2021-12-16 19:22:46 +08:00
|
|
|
|
if growData[DynamicActivityManager.Index - 1] then
|
|
|
|
|
DynamicActivityManager.Index = DynamicActivityManager.Index - 1
|
|
|
|
|
self:RefreshReward(growData[DynamicActivityManager.Index])
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
Util.AddOnceClick(self.btnRight,function ()
|
2021-12-16 19:22:46 +08:00
|
|
|
|
if growData[DynamicActivityManager.Index + 1] then
|
|
|
|
|
DynamicActivityManager.Index = DynamicActivityManager.Index + 1
|
|
|
|
|
self:RefreshReward(growData[DynamicActivityManager.Index])
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
--刷新奖励、按钮显示
|
|
|
|
|
function EveryDayGiftNew:RefreshReward(Data)
|
2022-10-20 17:48:00 +08:00
|
|
|
|
local rechargeNum =BagManager.GetItemCountById(1351) --VipManager.GetChargedNum()--已经充值的金额
|
2021-12-16 19:22:46 +08:00
|
|
|
|
self.btnLeft:SetActive(not not growData[DynamicActivityManager.Index - 1])--左按钮显示
|
|
|
|
|
self.btnRight:SetActive(not not growData[DynamicActivityManager.Index + 1])--右按钮显示
|
|
|
|
|
-- LogPink(DynamicActivityManager.Index.." 金额:"..tostring(Data.data.shopItemData.BuyRule[2]).." 限购:"..tostring(Data.data.limitNum).." 已购:"..tostring(Data.data.boughtNum).." rechargeNum:"..tostring(rechargeNum))
|
2022-10-20 17:48:00 +08:00
|
|
|
|
local text = 1
|
2021-12-16 19:22:46 +08:00
|
|
|
|
local num = 0
|
|
|
|
|
if DynamicActivityManager.Index < 2 then
|
2023-08-29 17:58:24 +08:00
|
|
|
|
num = growData[1].data.shopItemData.BuyRule[2]
|
2021-12-16 19:22:46 +08:00
|
|
|
|
elseif DynamicActivityManager.Index + 1 > #growData then
|
2022-10-20 17:48:00 +08:00
|
|
|
|
text = #growData
|
2021-12-16 19:22:46 +08:00
|
|
|
|
num = growData[#growData].data.shopItemData.BuyRule[2]
|
|
|
|
|
else
|
2022-10-20 17:48:00 +08:00
|
|
|
|
text = DynamicActivityManager.Index
|
2021-12-16 19:22:46 +08:00
|
|
|
|
num = growData[DynamicActivityManager.Index].data.shopItemData.BuyRule[2]
|
|
|
|
|
end
|
2022-10-20 17:48:00 +08:00
|
|
|
|
num=DynamicActivityManager.GetMingWangLv(num)
|
|
|
|
|
local aaa=growData[DynamicActivityManager.curLevel].data.shopItemData.BuyRule[2]
|
2021-12-17 16:05:51 +08:00
|
|
|
|
if DynamicActivityManager.curLevel <= 2 then
|
2022-11-22 15:30:03 +08:00
|
|
|
|
--self.tip.text = string.format("再获得%s积分升至名望1",num - rechargeNum)
|
2022-10-20 17:48:00 +08:00
|
|
|
|
elseif DynamicActivityManager.curLevel >= #growData and rechargeNum >= DynamicActivityManager.GetMingWangLv(aaa) then
|
2022-11-22 15:30:03 +08:00
|
|
|
|
--self.tip.text = ""
|
2021-12-17 11:28:37 +08:00
|
|
|
|
else
|
2022-11-22 15:30:03 +08:00
|
|
|
|
--self.tip.text = string.format("再获得%s积分升至名望%s",DynamicActivityManager.GetMingWangLv(aaa) - rechargeNum,DynamicActivityManager.curLevel+1)
|
2021-12-17 11:28:37 +08:00
|
|
|
|
end
|
2022-11-22 15:30:03 +08:00
|
|
|
|
self.tip.text="每充值1元可以获得10点名望经验"
|
2021-12-16 19:22:46 +08:00
|
|
|
|
local size = rechargeNum/num
|
2021-12-15 14:34:21 +08:00
|
|
|
|
size = size > 1 and 1 or size
|
2021-12-17 18:53:24 +08:00
|
|
|
|
-- LogRed(DynamicActivityManager.Index.." #growData:"..tostring(#growData).." text:"..tostring(text))
|
2024-01-13 17:53:47 +08:00
|
|
|
|
self.icon.sprite = self.spLoader:LoadSprite("UI_hz_huizhang")
|
|
|
|
|
self.Level.text=text
|
2021-12-15 14:34:21 +08:00
|
|
|
|
self.progress:GetComponent("RectTransform").sizeDelta = Vector3.New(483*size,12,0)
|
2021-12-16 19:22:46 +08:00
|
|
|
|
self.value.text = string.format("%s/%s",rechargeNum,num)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
self.price.text = Data.data.price
|
|
|
|
|
self.btnRed:SetActive(false)
|
2022-10-25 10:23:48 +08:00
|
|
|
|
local needNum=DynamicActivityManager.GetMingWangLv(Data.data.shopItemData.BuyRule[2]-1)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
if Data.data.limitNum - Data.data.boughtNum > 0 then
|
|
|
|
|
self.btnText:SetActive(false)
|
|
|
|
|
self.cost:SetActive(true)
|
|
|
|
|
self.btnGet:GetComponent("Button").interactable = true
|
|
|
|
|
Util.SetGray(self.btnGet, false)
|
2022-10-20 17:48:00 +08:00
|
|
|
|
if rechargeNum >= needNum then
|
2023-10-20 18:51:12 +08:00
|
|
|
|
-- self.btnGet:GetComponent("Image").sprite = self.spLoader:LoadSprite("s_slbz_1anniuongse")
|
2022-01-17 13:16:18 +08:00
|
|
|
|
if BagManager.GetTotalItemNum(Data.data.costId) >= Data.data.price then
|
2021-12-15 14:34:21 +08:00
|
|
|
|
self.btnRed:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
else
|
2023-10-20 18:51:12 +08:00
|
|
|
|
-- self.btnGet:GetComponent("Image").sprite = self.spLoader:LoadSprite("s_slbz_1anniuhuangse")
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
self.btnText:SetActive(true)
|
|
|
|
|
self.cost:SetActive(false)
|
|
|
|
|
self.btnGet:GetComponent("Button").interactable = false
|
|
|
|
|
Util.SetGray(self.btnGet, true)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Util.AddOnceClick(self.btnGet,function ()
|
|
|
|
|
-- LogGreen(tostring(Data.data.limitNum).." "..tostring(Data.data.boughtNum))
|
|
|
|
|
if Data.data.limitNum - Data.data.boughtNum > 0 then
|
|
|
|
|
-- LogYellow(tostring(rechargeNum).." "..tostring(Data.data.shopItemData.BuyRule[2]))
|
2022-10-20 17:48:00 +08:00
|
|
|
|
if rechargeNum >= needNum then
|
2022-01-26 13:40:13 +08:00
|
|
|
|
-- LogPink(tostring(BagManager.GetItemCountById(Data.data.costId)).." "..tostring(Data.data.price))
|
|
|
|
|
if BagManager.GetItemCountById(Data.data.costId) >= Data.data.price then
|
2021-12-15 14:34:21 +08:00
|
|
|
|
-- LogBlue(tostring(Data.data.shopItemData.buyType).." "..tostring(Data.data.shopData.id))
|
|
|
|
|
ShopManager.RequestBuyShopItem(Data.buyType, Data.data.shopData.id, 1, function()
|
|
|
|
|
self:SetGrowGift()
|
|
|
|
|
CheckRedPointStatus(RedPointType.DailyGift)
|
|
|
|
|
CheckRedPointStatus(RedPointType.GrowthPackage)
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
NotEnoughPopup:Show(Data.data.costId)
|
|
|
|
|
end
|
|
|
|
|
else
|
2022-10-20 17:48:00 +08:00
|
|
|
|
PopupTipPanel.ShowTip(string.format("名望等级不足,请升至%s级后才可购买!",DynamicActivityManager.Index))
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not self.ItemList then
|
|
|
|
|
self.ItemList = {}
|
|
|
|
|
end
|
|
|
|
|
for i = 1, #self.ItemList do
|
|
|
|
|
self.ItemList[i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
for i = 1, #Data.data.shows do
|
|
|
|
|
if not self.ItemList[i] then
|
|
|
|
|
self.ItemList[i] = SubUIManager.Open(SubUIConfig.ItemView,self.reward.transform)
|
|
|
|
|
end
|
|
|
|
|
self.ItemList[i]:OnOpen(false, {Data.data.shows[i][1],Data.data.shows[i][2],Data.data.shows[i][3]}, 0.9,false,false,false,self.sortingOrder)
|
|
|
|
|
self.ItemList[i].gameObject:SetActive(true)
|
|
|
|
|
end
|
2022-01-17 13:16:18 +08:00
|
|
|
|
|
|
|
|
|
--左右按钮红点检测
|
|
|
|
|
if growData[DynamicActivityManager.Index - 1] then
|
|
|
|
|
for i = DynamicActivityManager.Index - 1, 1,-1 do
|
|
|
|
|
local curData = growData[i]
|
|
|
|
|
if curData.data.limitNum - curData.data.boughtNum > 0 and
|
|
|
|
|
BagManager.GetTotalItemNum(curData.data.costId) >= curData.data.price and
|
2022-10-25 10:23:48 +08:00
|
|
|
|
rechargeNum >=DynamicActivityManager.GetMingWangLv(curData.data.shopItemData.BuyRule[2]-1) then
|
2022-01-17 13:16:18 +08:00
|
|
|
|
self.leftRed:SetActive(true)
|
|
|
|
|
break
|
|
|
|
|
else
|
|
|
|
|
self.leftRed:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if growData[DynamicActivityManager.Index + 1] then
|
2022-10-20 17:48:00 +08:00
|
|
|
|
for i = DynamicActivityManager.Index + 1, 20 do
|
2022-01-17 13:16:18 +08:00
|
|
|
|
local curData = growData[i]
|
|
|
|
|
if curData and curData.data.limitNum - curData.data.boughtNum > 0 and
|
|
|
|
|
BagManager.GetTotalItemNum(curData.data.costId) >= curData.data.price and
|
2022-10-25 10:23:48 +08:00
|
|
|
|
rechargeNum >=DynamicActivityManager.GetMingWangLv(curData.data.shopItemData.BuyRule[2]-1) then
|
2022-01-17 13:16:18 +08:00
|
|
|
|
self.rightRed:SetActive(true)
|
|
|
|
|
break
|
|
|
|
|
else
|
|
|
|
|
self.rightRed:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-12-15 14:34:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--===============================通用礼包数据==========================
|
2021-12-14 19:16:30 +08:00
|
|
|
|
-- 刷新礼包的数据
|
|
|
|
|
function EveryDayGiftNew:RefreshGiftData(isTop,isAni)
|
|
|
|
|
rechargeNum = VipManager.GetChargedNum()--已经充值的金额
|
2021-12-15 14:34:21 +08:00
|
|
|
|
self.scrollView:ForeachItemGO(function(growIndex, go)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
go.gameObject:SetActive(false)
|
|
|
|
|
end)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
|
|
|
|
|
local callBack = function(growIndex, item)
|
|
|
|
|
self:RefreshShowData(item, self.shopData[growIndex],growIndex)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end
|
2021-12-15 14:34:21 +08:00
|
|
|
|
local growIndex = 0
|
2021-12-14 19:16:30 +08:00
|
|
|
|
self.scrollView:SetData(self.shopData, callBack,not isTop,not isAni)
|
|
|
|
|
for i = 1 ,#self.shopData do
|
|
|
|
|
if self.shopData[i].DataType == DynamicActivityManager.selectIndex.dataType then
|
|
|
|
|
for j = 1 , #DynamicActivityManager.selectIndex.goodsId do
|
|
|
|
|
if (self.shopData[i].data.shopData.id or self.shopData[i].data.shopData.goodsId) == DynamicActivityManager.selectIndex.goodsId[j] then
|
|
|
|
|
DynamicActivityManager.SetSelectIndex(0,{},1)
|
2021-12-15 14:34:21 +08:00
|
|
|
|
growIndex = i
|
2021-12-14 19:16:30 +08:00
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-12-15 14:34:21 +08:00
|
|
|
|
if growIndex ~= 0 then
|
2021-12-14 19:16:30 +08:00
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-12-15 14:34:21 +08:00
|
|
|
|
if growIndex ~= 0 then
|
|
|
|
|
self.scrollView:SetIndex(growIndex)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--刷新每一条的显示数据
|
2021-12-15 14:34:21 +08:00
|
|
|
|
function EveryDayGiftNew:RefreshShowData(item,_data,growIndex)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
if not self.ItemList then
|
|
|
|
|
self.ItemList = {}
|
|
|
|
|
end
|
|
|
|
|
if not self.ItemList[item] then
|
|
|
|
|
local subConfig = SubUIConfig[self.actConfig.UIName[2]]
|
|
|
|
|
self.ItemList[item] = SubUIManager.Open(subConfig,item.transform)
|
|
|
|
|
end
|
|
|
|
|
if not _data then
|
|
|
|
|
item.gameObject:SetActive(false)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
item.gameObject:SetActive(true)
|
|
|
|
|
self.ItemList[item]:SetData(_data,self,rechargeNum,self.sortingOrder)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--每种礼包的剩余时间
|
|
|
|
|
function EveryDayGiftNew:GetRemainTime()
|
|
|
|
|
if self.actConfig.ShowTime == 0 then
|
|
|
|
|
self.endTimeBg.gameObject:SetActive(false)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
self.endTimeBg.gameObject:SetActive(true)
|
|
|
|
|
--判断是否有timer
|
|
|
|
|
if self.localTimer then
|
|
|
|
|
self.localTimer:Stop()
|
|
|
|
|
self.localTimer = nil
|
|
|
|
|
end
|
|
|
|
|
local la = self.actConfig.ShowTime ~= 1 and Language[10023] or Language[11355]
|
2022-01-18 10:53:25 +08:00
|
|
|
|
if self.actConfig.ActiveType == ActivityTypeDef.XinRenShop then
|
|
|
|
|
la = "结束时间:"
|
|
|
|
|
end
|
2021-12-14 19:16:30 +08:00
|
|
|
|
local freshTime = 0
|
2022-02-18 15:14:25 +08:00
|
|
|
|
--此时间是七日礼包刷新时间
|
|
|
|
|
-- local packFreshTime = 0
|
2021-12-14 19:16:30 +08:00
|
|
|
|
|
|
|
|
|
if self.shopData and #self.shopData > 0 then
|
|
|
|
|
freshTime = self.shopData[#self.shopData].data.endTime - GetTimeStamp()
|
|
|
|
|
end
|
2022-02-18 15:14:25 +08:00
|
|
|
|
-- local actData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.MeiRiTeHui)
|
|
|
|
|
-- if actData then
|
|
|
|
|
-- packFreshTime = actData.endTime - GetTimeStamp()
|
|
|
|
|
-- end
|
|
|
|
|
--灵兽宝阁的珍奇宝阁礼包刷新时间显示
|
|
|
|
|
if self.actId == 5501 then
|
|
|
|
|
freshTime = TimeToCurWeekEnd()
|
2021-12-16 11:59:18 +08:00
|
|
|
|
end
|
2021-12-14 19:16:30 +08:00
|
|
|
|
self.endTime.text = la..TimeToFelaxible(freshTime)
|
|
|
|
|
self.localTimer = Timer.New(function ()
|
|
|
|
|
self.endTime.text = la..TimeToFelaxible(freshTime)
|
|
|
|
|
if freshTime <= 0 then
|
2021-12-17 14:44:44 +08:00
|
|
|
|
if self.actConfig.ActiveType > 0 then
|
|
|
|
|
local id = ActivityGiftManager.IsActivityTypeOpen(self.actConfig.ActiveType)
|
|
|
|
|
if id then
|
|
|
|
|
self:RefreshData(nil,true,true)
|
|
|
|
|
else
|
|
|
|
|
self.parent:ClosePanel()
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-12-16 10:46:11 +08:00
|
|
|
|
self:RefreshData(nil,true,true)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end
|
2022-02-10 17:53:00 +08:00
|
|
|
|
-- if actData then
|
|
|
|
|
-- self.btn2Text.text = string.format("剩余%s天",math.ceil(packFreshTime/86400))
|
|
|
|
|
-- else
|
|
|
|
|
-- self.btn2Text.text = string.format("60元七天特惠")
|
|
|
|
|
-- end
|
2021-12-14 19:16:30 +08:00
|
|
|
|
freshTime = freshTime - 1
|
2022-02-18 15:14:25 +08:00
|
|
|
|
-- packFreshTime = packFreshTime - 1
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end, 1, -1, true)
|
|
|
|
|
self.localTimer:Start()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--==============================每日特惠特殊处理部分===================
|
2021-12-15 14:34:21 +08:00
|
|
|
|
--刷新一键购买显示
|
|
|
|
|
function EveryDayGiftNew:RefreshOneKeyShow()
|
2022-02-10 17:53:00 +08:00
|
|
|
|
Util.SetParticleSortLayer(self.UI_Effect_jinkuang_Yuan, self.sortingOrder + 1)
|
|
|
|
|
Util.SetGray(self.extarOneKeyBtn,false)
|
|
|
|
|
self.extarOneKeyBtn:GetComponent("Button").interactable = true
|
2023-12-02 18:54:40 +08:00
|
|
|
|
self.allSaoGuang:SetActive(false)
|
2022-02-10 17:53:00 +08:00
|
|
|
|
-- 计算总价
|
|
|
|
|
local ori = 0
|
|
|
|
|
for i = 1 , #self.shopData do
|
|
|
|
|
ori = ori + self.shopData[i].data.finalNum
|
|
|
|
|
end
|
|
|
|
|
-- 计算现价
|
|
|
|
|
local now = 0
|
2022-02-10 18:22:48 +08:00
|
|
|
|
now = now + MoneyUtil.GetMoney(ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig,onKeyPackId).Price)
|
2022-02-10 17:53:00 +08:00
|
|
|
|
|
|
|
|
|
self.extarOneKeyprice2.text = Language[10582] .. string.format(MoneyUtil.GetMoneyUnitName(),ori)
|
|
|
|
|
self.extarOneKeyprice1.text = Language[10644] .. string.format(MoneyUtil.GetMoneyUnitName(),now)
|
|
|
|
|
|
|
|
|
|
for i = 1, #self.shopData do
|
|
|
|
|
if self.shopData[i].data.boughtNum > 0 then
|
|
|
|
|
Util.SetGray(self.extarOneKeyBtn,true)
|
|
|
|
|
self.extarOneKeyBtn:GetComponent("Button").interactable = false
|
|
|
|
|
self.allSaoGuang:SetActive(false)
|
|
|
|
|
break
|
2021-12-21 16:51:40 +08:00
|
|
|
|
end
|
2021-12-16 10:46:11 +08:00
|
|
|
|
end
|
2022-02-10 17:53:00 +08:00
|
|
|
|
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--刷新每日免费礼包
|
|
|
|
|
function EveryDayGiftNew:RefreshFreeData()
|
2022-11-04 14:55:26 +08:00
|
|
|
|
local type=0
|
|
|
|
|
if self.actType==90 then
|
|
|
|
|
type=SHOP_TYPE.FREE_GIFT
|
|
|
|
|
elseif self.actType==98 then
|
|
|
|
|
type=35
|
|
|
|
|
end
|
|
|
|
|
local freeData = ShopManager.GetShopDataByType(type).storeItem
|
|
|
|
|
local boughtNum = ShopManager.GetShopItemHadBuyTimes(type, freeData[1].id)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
local limitNum = ShopManager.GetShopItemLimitBuyCount(freeData[1].id)
|
2022-11-04 14:55:26 +08:00
|
|
|
|
--LogError("freeData[1].id=="..freeData[1].id)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
local isCanBuy = limitNum - boughtNum >= 1
|
2022-02-10 17:53:00 +08:00
|
|
|
|
self.freeBtnAnim.enabled = isCanBuy
|
|
|
|
|
self.freeBtnRed:SetActive(isCanBuy)
|
|
|
|
|
-- 光效显隐
|
|
|
|
|
for _, light in ipairs(self.lightList) do
|
|
|
|
|
light:SetActive(isCanBuy)
|
|
|
|
|
end
|
2021-12-14 19:16:30 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.DailyGift)
|
2022-02-10 17:53:00 +08:00
|
|
|
|
Util.AddOnceClick(self.extarFreeBtn,function()
|
2021-12-14 19:16:30 +08:00
|
|
|
|
if isCanBuy then
|
2022-11-04 14:55:26 +08:00
|
|
|
|
ShopManager.RequestBuyShopItem(type, freeData[1].id, 1, function()
|
2021-12-14 19:16:30 +08:00
|
|
|
|
self:RefreshFreeData()
|
|
|
|
|
CheckRedPointStatus(RedPointType.DailyGift)
|
|
|
|
|
CheckRedPointStatus(RedPointType.GrowthPackage)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
--============================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function EveryDayGiftNew:OnClose()
|
2022-12-15 17:18:16 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.TimeLimitWishStore)
|
2021-12-14 19:16:30 +08:00
|
|
|
|
if self.localTimer then
|
|
|
|
|
self.localTimer:Stop()
|
|
|
|
|
self.localTimer = nil
|
|
|
|
|
end
|
|
|
|
|
self.gameObject:SetActive(false)
|
|
|
|
|
self.parent.tabbox.gameObject:SetActive(true)
|
2022-12-15 17:18:16 +08:00
|
|
|
|
|
2021-12-14 19:16:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function EveryDayGiftNew:OnDestroy()
|
|
|
|
|
self.spLoader:Destroy()
|
|
|
|
|
for k,v in pairs(self.ItemList) do
|
|
|
|
|
SubUIManager.Close(v)
|
|
|
|
|
end
|
|
|
|
|
self.ItemList = {}
|
|
|
|
|
if self.scrollView then
|
|
|
|
|
SubUIManager.Close(self.scrollView)
|
|
|
|
|
end
|
|
|
|
|
self.scrollView=nil
|
|
|
|
|
if self.localTimer then
|
|
|
|
|
self.localTimer:Stop()
|
|
|
|
|
self.localTimer = nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--特权商城专属
|
|
|
|
|
function EveryDayGiftNew:SpecialTime(t)
|
|
|
|
|
if not t or t < 0 then
|
|
|
|
|
return Language[11749]
|
|
|
|
|
end
|
|
|
|
|
local _sec = t % 60
|
|
|
|
|
local allMin = math.floor(t / 60)
|
|
|
|
|
local _min = allMin % 60
|
|
|
|
|
local allHour = math.floor(t / 3600)
|
|
|
|
|
local _hour = allHour % 24
|
|
|
|
|
local allDays = math.floor(t / 86400)
|
|
|
|
|
|
|
|
|
|
if allDays>=1 then
|
|
|
|
|
return string.format(Language[11703],allDays),allDays
|
|
|
|
|
else
|
|
|
|
|
if _hour>=1 then
|
|
|
|
|
return string.format(Language[11704], _hour), _hour
|
|
|
|
|
else
|
|
|
|
|
if _min>=1 then
|
|
|
|
|
return string.format(Language[11705], _min), _min
|
|
|
|
|
else
|
|
|
|
|
return Language[12152]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return Language[11749]
|
|
|
|
|
end
|
|
|
|
|
return EveryDayGiftNew
|