local SmallSoldierLvInfoPanel = quick_class("SmallSoldierLvInfoPanel", BasePanel) local itemData = ConfigManager.GetConfig(ConfigName.ItemConfig) local gemConfig = ConfigManager.GetConfig(ConfigName.GemConfigNew) local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig) local lotteryConfig=ConfigManager.GetConfig(ConfigName.SoldiersLotteryConfig) local specialConfig=ConfigManager.GetConfigData(ConfigName.SpecialConfig,178).Value local aaa=string.split(specialConfig,"#") local list={} local activityId=0 local curLv=0 local progress=0 local curType=0 local rewardConfig=nil local isCan=false local curConfig local quaName={"粗糙","普通","优良","优秀","稀有","史诗","传说","神话"} local quaColor={ Color.New(165/255,165/255,165/255,1), Color.New(184/255,200/255,110/255,1), Color.New(139/255,126/255,192/255,1), Color.New(169/255,84/255,149/255,1), Color.New(243/255,164/255,79/255,1), Color.New(181/255,21/255,6/255,1), Color.New(255/255,193/255,0/255,1), Color.New(149/255,178/255,229/255,1) } function SmallSoldierLvInfoPanel:InitComponent() self.spLoader = SpriteLoader.New() self.btn_close=Util.GetGameObject(self.gameObject, "bg/close") Util.GetGameObject(self.gameObject, "bg/title"):GetComponent("Text").text="兵力等级" self.info=Util.GetGameObject(self.gameObject, "bg/info"):GetComponent("Text") self.curlv=Util.GetGameObject(self.gameObject, "bg/curLv/Text"):GetComponent("Text") self.nextlv=Util.GetGameObject(self.gameObject, "bg/nextLv/Text"):GetComponent("Text") self.btn_go=Util.GetGameObject(self.gameObject, "bg/upObj/Button") Util.GetGameObject(self.gameObject, "bg/upObj/Button/Text"):GetComponent("Text").text="升级" self.btn_Text=Util.GetGameObject(self.gameObject, "bg/upObj/Button/Text"):GetComponent("Text") self.infoGrid=Util.GetGameObject(self.gameObject, "bg/grid") self.infoPre=Util.GetGameObject(self.gameObject, "bg/pre") local rootHight = self.infoGrid.transform.rect.height local width = self.infoGrid.transform.rect.width self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.infoGrid.transform,self.infoPre, self.Scrollbar, Vector2.New(width, rootHight), 1, 1, Vector2.New(0,0)) self.ScrollView.moveTween.MomentumAmount = 1 self.ScrollView.moveTween.Strength = 2 self.ScrollView.elastic = false self.upObj=Util.GetGameObject(self.gameObject, "bg/upObj") self.costImg=Util.GetGameObject(self.gameObject, "bg/upObj/costImg"):GetComponent("Image") self.costTxt=Util.GetGameObject(self.gameObject, "bg/upObj/costTxt"):GetComponent("Text") self.skipObj=Util.GetGameObject(self.gameObject, "bg/skipObj") self.btn_skip=Util.GetGameObject(self.gameObject, "bg/skipObj/skipBtn") Util.GetGameObject(self.gameObject, "bg/skipObj/skipBtn/Text"):GetComponent("Text").text="立即完成" self.timeDown=Util.GetGameObject(self.gameObject, "bg/timeTxt"):GetComponent("Text") self.skipCostImg=Util.GetGameObject(self.gameObject, "bg/skipObj/costImg"):GetComponent("Image") self.skipCostTxt=Util.GetGameObject(self.gameObject, "bg/skipObj/Text"):GetComponent("Text") self.curInfo=Util.GetGameObject(self.gameObject, "bg/curInfo"):GetComponent("Text") self.nextInfo=Util.GetGameObject(self.gameObject, "bg/nextInfo"):GetComponent("Text") end function SmallSoldierLvInfoPanel:BindEvent() Util.AddClick(self.btn_close, function () self:ClosePanel() end) Util.AddClick(self.btn_go,function() if isCan==false then PopupTipPanel.ShowTip("兵力不足") return end if BagManager.GetItemCountById(curConfig.Consume[1])0 then str=quaName[settingConfig.Quality].."+"..settingConfig.QualityLevel else str=quaName[settingConfig.Quality] end data.leftData.quaStr=str data.leftData.qua=settingConfig.Quality data.rightData.qua=settingConfig.Quality data.leftData.pro=curConfig.Show[i][2]/100 .."%" data.rightData.pro=nextConfig.Show[i][2]/100 .."%" table.insert(lotteryData,data) end --LogError("GetResourcePath(curConfig.Consume[1])=="..GetResourcePath(curConfig.Consume[1]).." "..curConfig.Consume[1]) --self.spLoader:LoadSprite(GetResourcePath(curConfig.Consume[1])) if curConfig.Consume and type(curConfig.Consume[1])~="userdata" then self.costImg.gameObject:SetActive(true) self.costTxt.gameObject:SetActive(true) self.costImg.sprite=SetIcon(self.spLoader, curConfig.Consume[1]) self.costTxt.text=curConfig.Consume[2] else self.costImg.gameObject:SetActive(false) self.costTxt.gameObject:SetActive(false) end self.skipObj:SetActive(SmallSoldierManager.upEndTime>0) self.upObj:SetActive(SmallSoldierManager.upEndTime==0) self.skipCostImg.sprite=SetIcon(self.spLoader,tonumber(aaa[1])) --self.spLoader:LoadSprite(GetResourcePath(tonumber(aaa[1]))) self.timeDown.text=TimeToFelaxible(curConfig.Time) self:ShowLeftTime() self.ScrollView:SetData(lotteryData, function (index, go) self:SingleDataShow(go,lotteryData[index]) end,false) if BagManager.GetItemCountById(curConfig.Soldiers[1])>=curConfig.Soldiers[2] then isCan=true Util.SetGray(self.btn_go,false) else isCan=false Util.SetGray(self.btn_go,true) end --self:CheckReward() end function SmallSoldierLvInfoPanel:ShowLeftTime() --显示倒计时 if SmallSoldierManager.upEndTime>0 then if self.timer then self.timer:Stop() self.timer = nil end local leftTime=SmallSoldierManager.upEndTime- GetTimeStamp() if leftTime>0 then self.timeDown.text=TimeToFelaxible(leftTime) local time=0 if leftTime%60>0 then time=math.floor(leftTime/60)+1 else time=math.floor(leftTime/60) end self.skipCostTxt.text=time*tonumber(aaa[2]) self.timer = Timer.New(function () self.timeDown.text=TimeToFelaxible(leftTime) leftTime=leftTime-1 local time=0 if leftTime%60>0 then time=math.floor(leftTime/60)+1 else time=math.floor(leftTime/60) end LogError("time================================"..time) self.skipCostTxt.text=time*tonumber(aaa[2]) if leftTime<=0 then SmallSoldierManager.upEndTime=0 SmallSoldierManager.level=SmallSoldierManager.level+1 end end, 1, -1, true) self.timer:Start() else self.timer:Stop() self.timer = nil self:OnShow() end end end function SmallSoldierLvInfoPanel:SingleDataShow(go,data) local leftObj=Util.GetGameObject(go, "curLv") local leftTxt=Util.GetGameObject(go, "curLv/Text"):GetComponent("Text") local rightObj=Util.GetGameObject(go, "nextLv") local rightTxt=Util.GetGameObject(go, "nextLv/Text"):GetComponent("Text") leftObj:SetActive(data.leftData~=nil) rightObj:SetActive(data.rightData~=nil) if data.leftData then leftTxt.text=data.leftData.quaStr.." "..data.leftData.pro leftObj:GetComponent("Image").color=quaColor[data.leftData.qua] end if data.rightData then rightTxt.text=data.rightData.pro rightObj:GetComponent("Image").color=quaColor[data.rightData.qua] end end --检测奖励 function SmallSoldierLvInfoPanel:CheckReward() end function SmallSoldierLvInfoPanel:OnClose() end function SmallSoldierLvInfoPanel:OnDestroy() self.spLoader:Destroy() if self.timer then self.timer:Stop() self.timer = nil end end return SmallSoldierLvInfoPanel