local XiangYaoDuoBao = {} local lotterySetting=ConfigManager.GetConfig(ConfigName.LotterySetting) local privilegeConfig=ConfigManager.GetConfig(ConfigName.PrivilegeTypeConfig) local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) local artConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig) local artResourcesConfig =ConfigManager.GetConfig(ConfigName.ArtResourcesConfig) local SpiritAnimalConfig = ConfigManager.GetConfig(ConfigName.SpiritAnimal) local globalActive = ConfigManager.GetConfig(ConfigName.GlobalActivity) local activityId = 0 local singleRecruit = nil local tenRecruit = nil local sortingOrder = 0 local freeTime= 0 --免费抽取次数 local showData = {} local rewardData = {} local curScore = 0 local Live local bgName local RoleLiveGOGraphic local ActData=nil local LSrewardData=nil --按钮类型 local bType={ Btn1=1, Btn10=2 } --type与lotterySetting表中的id对应 local btns={ [bType.Btn1]={name="Btn1",isInfo=Language[10478]}, [bType.Btn10]={name="Btn10",isInfo=Language[10479]}} function XiangYaoDuoBao:New(gameObject) local b = {} b.gameObject = gameObject b.transform = gameObject.transform setmetatable(b, { __index = XiangYaoDuoBao }) return b end function XiangYaoDuoBao:InitComponent() self.spLoader = SpriteLoader.New() self.helpBtn = Util.GetGameObject(self.gameObject,"help") self.helpPosition=self.helpBtn:GetComponent("RectTransform").localPosition self.detailBtn = Util.GetGameObject(self.gameObject,"rightUp/detailBtn") self.xianshishangshiBtn = Util.GetGameObject(self.gameObject,"rightUp/xianshishangshiBtn") self.xianshishangshiBtn:SetActive(false) -- self.xxssEffect = Util.GetGameObject(self.xianshishangshiBtn,"Fx_Circle 1") self.zhenqibaogeBtn = Util.GetGameObject(self.gameObject,"rightUp/zqbg") self.zqbgEffect = Util.GetGameObject(self.zhenqibaogeBtn,"Fx_Circle 1") self.btn = Util.GetGameObject(self.gameObject,"Btn") self.upper=Util.GetGameObject(self.gameObject,"time/times"):GetComponent("Text") ---召唤上限 self.tip1=Util.GetGameObject(self.gameObject,"bottom/Tip1"):GetComponent("Text") ---刷新时间 self.tip2=Util.GetGameObject(self.gameObject,"bottom/Tip2"):GetComponent("Text") --妖晶限购 self.btnGroup=Util.GetGameObject(self.gameObject,"bottom/btngroup") self.leftTime=Util.GetGameObject(self.gameObject,"bottom/lefttime"):GetComponent("Text") self.canGet=Util.GetGameObject(self.gameObject,"bottom/canGet"):GetComponent("Text") self.grid = Util.GetGameObject(self.gameObject, "aniRoot") --mid self.progressValue = Util.GetGameObject(self.gameObject, "mid/progress/value"):GetComponent("Image")--fillAmount self.reward = Util.GetGameObject(self.gameObject, "mid/reward") self.value = Util.GetGameObject(self.gameObject, "mid/value") self.iconPre = Util.GetGameObject(self.reward, "iconPre") self.iconPre:SetActive(false) self.effect1 = Util.GetGameObject(self.gameObject, "Effect_xiaozhuanfeng_hit01") self.effect2 = Util.GetGameObject(self.gameObject, "Effect_xiaozhuanfeng_hit02") self.effect1:SetActive(false) self.effect2:SetActive(false) self.iconList = {} end function XiangYaoDuoBao:BindEvent() -- Util.AddOnceClick(self.xianshishangshiBtn, function() -- JumpManager.GoJump(40014) -- end) Util.AddOnceClick(self.zhenqibaogeBtn, function() JumpManager.GoJump(40050,nil,self.actId) end) Util.AddOnceClick(self.helpBtn, function() UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.XiangYaoDuoBao,self.helpPosition.x,self.helpPosition.y) end) Util.AddOnceClick(self.detailBtn, function() UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.RecrutDetail,self.actConfig.HelpId,self.actType,PRE_REWARD_POOL_TYPE.XIANG_YAO_UP,PRE_REWARD_POOL_TYPE.XIANG_YAO_UP) end) Util.AddOnceClick(self.btn,function () local thread=coroutine.start(function() RoleLiveGOGraphic.AnimationState:SetAnimation(0, "shuajian", true) self.btn:SetActive(false) coroutine.wait(2.5) RoleLiveGOGraphic.AnimationState:SetAnimation(0, "idle", true) if self.btn then self.btn:SetActive(true) end end) end) end function XiangYaoDuoBao:OnSortingOrderChange() end --界面打开时调用(用于子类重写) function XiangYaoDuoBao:OnOpen(_activityConfig,_index,parent) self.actConfig = _activityConfig self.pageIndex = _index self.parent = parent end function XiangYaoDuoBao:OnShow(_sortingOrder) self.sortingOrder = _sortingOrder Util.SetParticleSortLayer(self.effect1,self.sortingOrder + 1) Util.AddParticleSortLayer(self.effect2,self.sortingOrder + 1) -- Util.SetParticleSortLayer(self.xxssEffect, self.sortingOrder + 1) Util.SetParticleSortLayer(self.zqbgEffect, self.sortingOrder + 1) self.gameObject:SetActive(true) 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 actConfig = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.ActivityGroups,"ActId",globalActive[id].ShowArt,"PageType",self.actConfig.PageType,"ActiveType",self.actConfig.ActiveType) if not actConfig then actConfig = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.ActivityGroups,"ActId",id,"PageType",self.actConfig.PageType,"ActiveType",self.actConfig.ActiveType) end if actConfig then self.actConfig = actConfig end end end end self:Refresh() end function XiangYaoDuoBao:Refresh() ActData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.XiangYaoDuoBao) activityId = ActData.activityId LSrewardData = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig,"ActivityId",activityId) local array = ConfigManager.GetAllConfigsDataByKey(ConfigName.LotterySetting,"ActivityId",activityId) singleRecruit = array[1] tenRecruit = array[2] CheckRedPointStatus(RedPointType.XiangYaoDuoBao) self:refreshBtnShow()--刷新按钮显示 self:TimeCountDown()--时间 self:SetData()--加载界面数据立绘+进度条 CommonActPageManager.ShowIcon(self.zhenqibaogeBtn,activityId) end function XiangYaoDuoBao:SetData() rewardData={} showData={} rewardData,showData,curScore = DynamicActivityManager.XiangYaoBuildData() --设置立绘 if Live then poolManager:UnLoadLive(bgName, Live) end bgName = "live2d_xiaozhuanfeng" Live = poolManager:LoadLive(bgName, self.grid.transform, Vector3.New(0.4,0.4,0.4), Vector2.New(0,-300)) RoleLiveGOGraphic = Live:GetComponent("SkeletonGraphic") RoleLiveGOGraphic.AnimationState:SetAnimation(0, "idle", true) --设置奖励 self.progressValue.fillAmount = curScore/LSrewardData[#LSrewardData].Values[1][1] Util.GetGameObject(self.value, "num"):GetComponent("Text").text = curScore Util.GetGameObject(self.value, "tips"):GetComponent("Text").text = Language[12129] for i = 1, #LSrewardData do local number = LSrewardData[i].Values[1][1]/LSrewardData[#LSrewardData].Values[1][1] local item = self.iconList[i] if not item then item = newObjToParent(self.iconPre,self.reward.transform) item:SetActive(true) item:GetComponent("RectTransform").transform.localPosition = Vector3.New(number*750-360,0,0) self.iconList[i] = item end Util.GetGameObject(item, "num/Text"):GetComponent("Text").text = LSrewardData[i].Reward[1][2] Util.GetGameObject(item, "Text"):GetComponent("Text").text = LSrewardData[i].Values[1][1] Util.GetGameObject(item, "icon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(artConfig[itemConfig[rewardData[i].iconId].ResourceID].Name) Util.GetGameObject(item, "red"):SetActive(rewardData[i].state == 1) local btn = Util.GetGameObject(item, "icon") Util.AddOnceClick(btn,function () if rewardData[i].state == 1 then NetManager.GetActivityRewardRequest(rewardData[i].missionId,activityId,function (drop) UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1,function () self:Refresh() end) end) else UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,LSrewardData[i].Reward[1][1],nil) end end) end end function XiangYaoDuoBao:refreshBtnShow() --下方的数量显示 local maxtimesId=singleRecruit.MaxTimes local curTimes=PrivilegeManager.GetPrivilegeUsedTimes(maxtimesId) self.upper.text = Language[10483]..curTimes.."/"..privilegeConfig[maxtimesId].Condition[1][2]--召唤上限 --下方的数量显示 local curMoneyTimes=PrivilegeManager.GetPrivilegeRemainValue(singleRecruit.MoneyTimes) self.tip2.text = Language[12130]..curMoneyTimes..Language[10048] ActData.value = ActData.value > 1000 and math.floor(ActData.value/1000) or ActData.value self.canGet.text = Language[12131]..lotterySetting[singleRecruit.Id].DiamondBoxContain[1][2] - ActData.value..Language[12132] --是否是免费抽 local freeTimesId=singleRecruit.FreeTimes if freeTimesId > 0 then freeTime = PrivilegeManager.GetPrivilegeRemainValue(freeTimesId) RecruitManager.freeUseTimeList[freeTimesId] = freeTime end --按钮赋值 for n, m in ipairs(btns) do local btn = Util.GetGameObject(self.btnGroup,m.name) local redPot = Util.GetGameObject(btn.gameObject,"RedPoint") local info = Util.GetGameObject(btn.gameObject,"Content/Info"):GetComponent("Text") local icon = Util.GetGameObject(btn.gameObject,"Content/Icon"):GetComponent("Image") local num = Util.GetGameObject(btn.gameObject,"Content/Num"):GetComponent("Text") --存在免费次数 并且 免费>=1 并且是1按钮 local isFree = freeTime and freeTime >= 1 and n == bType.Btn1 redPot.gameObject:SetActive(isFree) icon.gameObject:SetActive(not isFree) num.gameObject:SetActive(not isFree) self.tip1.gameObject:SetActive(freeTime == 0) local itemId=0 local itemNum=0 local type = 0 type = n == bType.Btn1 and singleRecruit.Id or tenRecruit.Id local d = RecruitManager.GetExpendData(type) if isFree then info.text=" "..Language[10493] else itemId = d[1] itemNum = d[2] icon.sprite = self.spLoader:LoadSprite(artResourcesConfig[itemConfig[itemId].ResourceID].Name) info.text = m.isInfo num.text = "x"..itemNum end Util.AddOnceClick(btn,function() if not isFree then if BagManager.GetItemCountById(itemId)privilegeConfig[maxtimesId].Condition[1][2] then PopupTipPanel.ShowTip(Language[10485]) return end if d[1] == 16 and PrivilegeManager.GetPrivilegeUsedTimes(singleRecruit.MoneyTimes)+1>privilegeConfig[singleRecruit.MoneyTimes].Condition[1][2] and not isFree then PopupTipPanel.ShowTip(Language[11423]) return end local recruitOne = function() RoleLiveGOGraphic.AnimationState:SetAnimation(0, "hit1", true) self.effect1:SetActive(true) self.parent.mask:SetActive(true) Timer.New(function () RoleLiveGOGraphic.AnimationState:SetAnimation(0, "idle", true) self.effect1:SetActive(false) self.parent.mask:SetActive(false) RecruitManager.RecruitRequest(singleRecruit.Id, function(msg) PrivilegeManager.RefreshPrivilegeUsedTimes(maxtimesId,1)--记录抽卡次数 if not isFree and d[1] == 16 then PrivilegeManager.RefreshPrivilegeUsedTimes(singleRecruit.MoneyTimes,1)--记录妖晶抽卡次数 end UIManager.OpenPanel(UIName.SingleRecruitPanel, msg.drop.Hero[1],singleRecruit.Id,bType.Btn1,{RecruitType.XiangYaoSingle,RecruitType.XiangYaoTen}) CheckRedPointStatus(RedPointType.XiangYaoDuoBao) end,freeTimesId) end,1.2):Start() end if state==0 and d[1] == 16 and not isFree then UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.RecruitConfirm,singleRecruit.Id,recruitOne) else recruitOne() end elseif n==bType.Btn10 then if PrivilegeManager.GetPrivilegeUsedTimes(maxtimesId)+10>privilegeConfig[maxtimesId].Condition[1][2] then PopupTipPanel.ShowTip(Language[10485]) return end if d[1] == 16 and PrivilegeManager.GetPrivilegeUsedTimes(tenRecruit.MoneyTimes)+10>privilegeConfig[tenRecruit.MoneyTimes].Condition[1][2] then PopupTipPanel.ShowTip(Language[11423]) return end local recruitTen = function() RoleLiveGOGraphic.AnimationState:SetAnimation(0, "hit3", true) self.effect2:SetActive(true) self.parent.mask:SetActive(true) Timer.New(function () RoleLiveGOGraphic.AnimationState:SetAnimation(0, "idle", true) self.effect2:SetActive(false) self.parent.mask:SetActive(false) RecruitManager.RecruitRequest(tenRecruit.Id, function(msg) PrivilegeManager.RefreshPrivilegeUsedTimes(maxtimesId,10)--记录抽卡次数 if d[1] == 16 then PrivilegeManager.RefreshPrivilegeUsedTimes(singleRecruit.MoneyTimes,10)--记录妖晶抽卡次数 end UIManager.OpenPanel(UIName.SingleRecruitPanel, msg.drop.Hero,tenRecruit.Id,bType.Btn10,{RecruitType.XiangYaoTen,RecruitType.XiangYaoTen}) CheckRedPointStatus(RedPointType.XiangYaoDuoBao) end,freeTimesId) end,2.5):Start() end if state==0 and d[1] ==16 and not isFree then UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.RecruitConfirm,tenRecruit.Id,recruitTen) else recruitTen() end end end) end end --- 将一段时间转换为天时分秒 function XiangYaoDuoBao:TimeToDHMS(second) local day = math.floor(second / (24 * 3600)) local minute = math.floor(second / 60) % 60 local sec = math.floor(second % 60) local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600) if day <= 0 and hour <= 0 then return string.format(Language[10472],minute, sec) else return string.format(Language[10473],day, hour) end end --刷新时间 function XiangYaoDuoBao:TimeCountDown() if self.timer then self.timer:Stop() self.timer = nil end local timeDown=CalculateSecondsNowTo_N_OClock(0) self.tip1.text = TimeToHMS(timeDown)..Language[10488] local timeDown2 = ActData.endTime - GetTimeStamp() self.leftTime.text = Language[10512]..TimeToFelaxible(timeDown2) self.tip1.gameObject:SetActive( (freeTime == 0) and (timeDown < timeDown2)) self.timer = Timer.New(function() if timeDown < 1 then self.timer:Stop() self.timer = nil self:Refresh() return end if timeDown2 < 1 then self.timer:Stop() self.timer = nil self.parent:ClosePanel() return end timeDown = timeDown - 1 timeDown2 = timeDown2 -1 self.tip1.text = TimeToHMS(timeDown)..Language[10488] self.leftTime.text = Language[10512]..TimeToFelaxible(timeDown2) end, 1, -1, true) self.timer:Start() end function XiangYaoDuoBao:OnClose() if Live then poolManager:UnLoadLive(bgName, Live) end Live = nil self.gameObject:SetActive(false) if self.timer then self.timer:Stop() self.timer = nil end end function XiangYaoDuoBao:OnDestroy() self.spLoader:Destroy() if Live then poolManager:UnLoadLive(bgName, Live) end Live = nil self.btn = nil self.iconList = {} end --添加事件监听(用于子类重写) function XiangYaoDuoBao:AddListener() end --移除事件监听(用于子类重写) function XiangYaoDuoBao:RemoveListener() end return XiangYaoDuoBao