2024-03-13 18:56:19 +08:00
|
|
|
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={}
|
2024-08-12 14:35:26 +08:00
|
|
|
local isMax=false
|
2024-03-13 18:56:19 +08:00
|
|
|
local activityId=0
|
|
|
|
|
local curLv=0
|
|
|
|
|
local progress=0
|
|
|
|
|
local curType=0
|
|
|
|
|
local rewardConfig=nil
|
|
|
|
|
local isCan=false
|
|
|
|
|
local curConfig
|
|
|
|
|
local quaName={"粗糙","普通","优良","优秀","稀有","史诗","传说","神话"}
|
|
|
|
|
local quaColor={
|
2024-04-16 17:24:59 +08:00
|
|
|
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)
|
2024-03-13 18:56:19 +08:00
|
|
|
}
|
|
|
|
|
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="立即完成"
|
2024-04-07 14:43:42 +08:00
|
|
|
self.timeDown=Util.GetGameObject(self.gameObject, "bg/timeTxt"):GetComponent("Text")
|
2024-03-13 18:56:19 +08:00
|
|
|
self.skipCostImg=Util.GetGameObject(self.gameObject, "bg/skipObj/costImg"):GetComponent("Image")
|
|
|
|
|
self.skipCostTxt=Util.GetGameObject(self.gameObject, "bg/skipObj/Text"):GetComponent("Text")
|
2024-03-13 19:07:44 +08:00
|
|
|
self.curInfo=Util.GetGameObject(self.gameObject, "bg/curInfo"):GetComponent("Text")
|
|
|
|
|
self.nextInfo=Util.GetGameObject(self.gameObject, "bg/nextInfo"):GetComponent("Text")
|
2024-03-13 18:56:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function SmallSoldierLvInfoPanel:BindEvent()
|
|
|
|
|
Util.AddClick(self.btn_close, function ()
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
Util.AddClick(self.btn_go,function()
|
2024-08-12 14:35:26 +08:00
|
|
|
if isMax then
|
|
|
|
|
PopupTipPanel.ShowTip("已提升到最高等级")
|
|
|
|
|
return
|
|
|
|
|
end
|
2024-03-13 18:56:19 +08:00
|
|
|
if isCan==false then
|
|
|
|
|
PopupTipPanel.ShowTip("兵力不足")
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if BagManager.GetItemCountById(curConfig.Consume[1])<curConfig.Consume[2] then
|
|
|
|
|
PopupTipPanel.ShowTip(BagManager.GetItemNameById(curConfig.Consume[1]).."不足")
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
NetManager.UpSoldierLevelRequest(1,function()
|
|
|
|
|
self.skipObj:SetActive(true)
|
|
|
|
|
self.upObj:SetActive(false)
|
|
|
|
|
self:ShowLeftTime()
|
2024-05-10 23:17:47 +08:00
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Solider.RefreshSoliderInfoWindow)
|
2024-03-13 18:56:19 +08:00
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Util.AddClick(self.btn_skip,function()
|
|
|
|
|
NetManager.UpSoldierLevelRequest(2,function()
|
|
|
|
|
-- self.skipObj:SetActive(false)
|
|
|
|
|
-- self.upObj:SetActive(true)
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
self:OnShow()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function SmallSoldierLvInfoPanel:AddListener()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function SmallSoldierLvInfoPanel:RemoveListener()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--待功能扩展(试图打开某个状态)
|
|
|
|
|
function SmallSoldierLvInfoPanel:OnOpen(...)
|
|
|
|
|
local args={...}
|
|
|
|
|
curType=args[1]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function SmallSoldierLvInfoPanel:OnSortingOrderChange()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
local itemList={}
|
|
|
|
|
function SmallSoldierLvInfoPanel:OnShow()
|
|
|
|
|
curLv=SmallSoldierManager.level
|
|
|
|
|
local nextLv=curLv+1
|
2024-08-12 14:35:26 +08:00
|
|
|
if nextLv>50 then
|
|
|
|
|
nextLv=50
|
|
|
|
|
isMax=true
|
|
|
|
|
|
|
|
|
|
end
|
2024-03-13 18:56:19 +08:00
|
|
|
--local
|
|
|
|
|
self.curlv.text="当前等级:"..curLv
|
|
|
|
|
self.nextlv.text="下一等级:"..nextLv
|
|
|
|
|
local qua=0
|
|
|
|
|
local lotteryData={}
|
|
|
|
|
|
|
|
|
|
curConfig=ConfigManager.GetConfigData(ConfigName.SoldiersLotteryConfig,curLv)
|
2024-04-01 15:12:36 +08:00
|
|
|
local nextConfig=ConfigManager.TryGetConfigData(ConfigName.SoldiersLotteryConfig,nextLv)
|
2024-03-13 18:56:19 +08:00
|
|
|
if nextConfig==nil then
|
|
|
|
|
nextConfig=curConfig
|
2024-04-01 15:12:36 +08:00
|
|
|
self.nextlv.text="下一等级:"..curLv
|
2024-03-13 18:56:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local qua=0
|
2024-07-02 14:40:22 +08:00
|
|
|
local priviConfig=ConfigManager.GetConfigData(ConfigName.PrivilegeTypeConfig,2044)
|
|
|
|
|
self.curInfo.text=string.format(priviConfig.Name,priviConfig.Condition[curLv][2]/100)
|
|
|
|
|
self.nextInfo.text=string.format(priviConfig.Name,priviConfig.Condition[nextLv][2]/100)
|
2024-03-13 18:56:19 +08:00
|
|
|
for i=1,#curConfig.Show do
|
|
|
|
|
local data={}
|
|
|
|
|
data.leftData={}
|
|
|
|
|
data.rightData={}
|
|
|
|
|
|
|
|
|
|
local settingConfig=ConfigManager.GetConfigDataByKey(ConfigName.SoldiersSetting,"ShowQuality",curConfig.Show[i][1])
|
|
|
|
|
local str=""
|
|
|
|
|
if settingConfig.QualityLevel>0 then
|
|
|
|
|
str=quaName[settingConfig.Quality].."+"..settingConfig.QualityLevel
|
|
|
|
|
else
|
|
|
|
|
str=quaName[settingConfig.Quality]
|
|
|
|
|
end
|
|
|
|
|
data.leftData.quaStr=str
|
2024-04-03 17:43:23 +08:00
|
|
|
data.leftData.qua=settingConfig.Quality
|
|
|
|
|
data.rightData.qua=settingConfig.Quality
|
2024-07-02 14:40:22 +08:00
|
|
|
data.leftData.pro=curConfig.Show[i][2]/100
|
|
|
|
|
data.rightData.pro=nextConfig.Show[i][2]/100
|
2024-03-13 18:56:19 +08:00
|
|
|
table.insert(lotteryData,data)
|
|
|
|
|
end
|
2024-04-01 15:12:36 +08:00
|
|
|
--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
|
2024-03-13 18:56:19 +08:00
|
|
|
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])))
|
2024-04-07 14:43:42 +08:00
|
|
|
self.timeDown.text=TimeToFelaxible(curConfig.Time)
|
2024-05-06 17:49:43 +08:00
|
|
|
if SmallSoldierManager.upEndTime>0 then
|
|
|
|
|
self:ShowLeftTime()
|
|
|
|
|
end
|
2024-08-12 14:35:26 +08:00
|
|
|
|
2024-03-13 18:56:19 +08:00
|
|
|
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()
|
2024-04-25 10:52:10 +08:00
|
|
|
--leftTime=60
|
2024-03-13 18:56:19 +08:00
|
|
|
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
|
2024-05-06 15:19:51 +08:00
|
|
|
if self.timer then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
end
|
2024-04-23 19:07:18 +08:00
|
|
|
self:OnShow()
|
2024-03-13 18:56:19 +08:00
|
|
|
end
|
|
|
|
|
end, 1, -1, true)
|
|
|
|
|
self.timer:Start()
|
|
|
|
|
else
|
2024-05-02 12:10:45 +08:00
|
|
|
if self.timer then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
end
|
2024-05-30 15:16:35 +08:00
|
|
|
SmallSoldierManager.upEndTime=0
|
2024-03-13 18:56:19 +08:00
|
|
|
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")
|
2024-04-25 10:52:10 +08:00
|
|
|
local leftValue=Util.GetGameObject(go, "curLv/value"):GetComponent("Text")
|
2024-03-13 18:56:19 +08:00
|
|
|
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)
|
2024-04-03 17:43:23 +08:00
|
|
|
|
2024-03-13 18:56:19 +08:00
|
|
|
if data.leftData then
|
2024-04-25 10:52:10 +08:00
|
|
|
leftTxt.text=data.leftData.quaStr
|
2024-04-03 17:43:23 +08:00
|
|
|
leftObj:GetComponent("Image").color=quaColor[data.leftData.qua]
|
2024-04-25 10:52:10 +08:00
|
|
|
leftValue.text=data.leftData.pro
|
2024-03-13 18:56:19 +08:00
|
|
|
end
|
|
|
|
|
if data.rightData then
|
|
|
|
|
rightTxt.text=data.rightData.pro
|
2024-04-03 17:43:23 +08:00
|
|
|
rightObj:GetComponent("Image").color=quaColor[data.rightData.qua]
|
2024-03-13 18:56:19 +08:00
|
|
|
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
|