230 lines
10 KiB
Lua
230 lines
10 KiB
Lua
local JumpConfig=ConfigManager.GetConfig(ConfigName.JumpConfig)
|
|
local ItemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local RechargeCommodityConfig=ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig)
|
|
JumpViewNew = {}
|
|
function JumpViewNew:New(gameObject)
|
|
local b = {}
|
|
b.gameObject = gameObject
|
|
b.transform = gameObject.transform
|
|
setmetatable(b,{ __index = JumpViewNew })
|
|
return b
|
|
end
|
|
--初始化组件(用于子类重写)
|
|
function JumpViewNew:InitComponent()
|
|
self.spLoader = SpriteLoader.New()
|
|
local tran = Util.GetGameObject(self.gameObject, "content")
|
|
self.info = Util.GetGameObject(tran, "info"):GetComponent("Text")
|
|
self.btnSure = Util.GetGameObject(tran, "btnSure")
|
|
self.btnSureIma = self.btnSure:GetComponent("Image")
|
|
self.btnSureText = Util.GetGameObject(tran, "btnSure/Text"):GetComponent("Text")
|
|
|
|
self.desc = Util.GetGameObject(tran, "grid/Text"):GetComponent("Text")
|
|
self.costIconPos = Util.GetGameObject(tran, "grid/itemPos")
|
|
self.itemView = SubUIManager.Open(SubUIConfig.ItemView,self.costIconPos.transform)
|
|
self.itemView.transform:SetAsFirstSibling()
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function JumpViewNew:BindEvent()
|
|
Util.AddOnceClick(self.btnSure, function()
|
|
self:GoToJumpData()
|
|
end)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function JumpViewNew:AddListener()
|
|
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function JumpViewNew:RemoveListener()
|
|
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function JumpViewNew:OnOpen(jumpId,heroConfig,parent)
|
|
self.parent = parent
|
|
self.jumpSData=JumpConfig[jumpId]
|
|
self.heroId = heroConfig.Id
|
|
self.needChipId = heroConfig.PiecesId
|
|
self.needChipNum = ItemConfig[self.needChipId].UsePerCount
|
|
self.btnSureIma.sprite = self.parent.spLoader:LoadSprite("r_hero_button_002")
|
|
local color = "EBCC97"
|
|
if self.jumpSData then
|
|
self.info.text=GetLanguageStrById(self.jumpSData.Title)
|
|
self.btnSureText.text = Language[10556]
|
|
end
|
|
if self.jumpSData.Type == JumpType.firstRecharge then
|
|
self.costIconPos.gameObject:SetActive(false)
|
|
self.desc.text = "首次充值可直接获得孙悟空"
|
|
elseif self.jumpSData.Type == JumpType.ZhiZunJiangShi then
|
|
self.costIconPos.gameObject:SetActive(false)
|
|
self.desc.text = "完成至尊降世可直接获得玉皇大帝"
|
|
elseif self.jumpSData.Type == JumpType.Lottery then
|
|
self.costIconPos.gameObject:SetActive(false)
|
|
--self.desc.text = "设为心愿神将会有更高概率"
|
|
self.desc.text = "使用点将神符抽取神将"
|
|
elseif self.jumpSData.Type == JumpType.Lottery then
|
|
self.costIconPos.gameObject:SetActive(false)
|
|
--self.desc.text = "设为心愿神将会有更高概率"
|
|
self.desc.text = "使用点将神符抽取神将"
|
|
elseif self.jumpSData.Type == JumpType.ElementDrawCard then
|
|
self.info.text = GetLanguageStrById(self.jumpSData.Title)
|
|
self.costIconPos.gameObject:SetActive(false)
|
|
self.desc.text = "抽取时额外赠送元神玉"
|
|
elseif self.jumpSData.Type == JumpType.ZhuTiHuoDong then
|
|
self.costIconPos.gameObject:SetActive(false)
|
|
self.desc.text = "每期轮替可召唤的神将"
|
|
elseif self.jumpSData.Type == JumpType.StateActivity then
|
|
self.costIconPos.gameObject:SetActive(false)
|
|
self.desc.text = "需要设置为心愿神将"
|
|
elseif self.jumpSData.Type == JumpType.Store then
|
|
if self.jumpSData.Skipfactor[1] == SHOP_TYPE.ENDLESS_SHOP then
|
|
self.info.text = self.info.text.."(需刷新)"
|
|
end
|
|
local storeTypeConfig = ConfigManager.GetConfigDataByKey(ConfigName.StoreTypeConfig,"StoreType",self.jumpSData.Skipfactor[1])
|
|
self.shopType = storeTypeConfig.Id
|
|
local configs = ConfigManager.GetAllConfigsDataByKey(ConfigName.StoreConfig,"StoreId",storeTypeConfig.Id)
|
|
local getChipNum = 1
|
|
local costItemId = 0
|
|
local costItemNum = 0
|
|
local rate = 0
|
|
for i = 1,#configs do
|
|
if self.needChipId == configs[i].Goods[1][1] then
|
|
self.ShopId = configs[i].Id
|
|
getChipNum = configs[i].Goods[1][2]
|
|
costItemId = configs[i].Cost[1][1]
|
|
local a,b,c,d = configs[i].Cost[2][1],configs[i].Cost[2][2],configs[i].Cost[2][3],configs[i].Cost[2][4]
|
|
local x = 1
|
|
costItemNum = a*x^3+b*x^2+c*x+d
|
|
rate = configs[i].DiscountDegree
|
|
break
|
|
end
|
|
end
|
|
local needCostNum
|
|
if rate ~= 0 then
|
|
needCostNum = math.ceil(self.needChipNum/getChipNum)*costItemNum*rate/10
|
|
else
|
|
needCostNum = math.ceil(self.needChipNum/getChipNum)*costItemNum
|
|
end
|
|
local itemcount = BagManager.GetItemCountById(costItemId)
|
|
self.costIconPos.gameObject:SetActive(true)
|
|
self.itemView:OnOpen(false, {costItemId,0}, 0.4, false, false, false, self.parent.sortingOrder)
|
|
if itemcount >= needCostNum then
|
|
color = "12C10B"
|
|
self.btnSureIma.sprite = self.parent.spLoader:LoadSprite("r_hero_button_001")
|
|
end
|
|
self.desc.text = string.format("<color=#%s>%s:%s/%s</color>",color, ItemConfig[costItemId].Name,itemcount,needCostNum)
|
|
elseif self.jumpSData.Type == JumpType.XingChenShangDian then
|
|
local storeTypeConfig = ConfigManager.GetConfigDataByKey(ConfigName.StoreTypeConfig,"StoreType",70)
|
|
self.shopType = 70
|
|
local configs = ConfigManager.GetAllConfigsDataByKey(ConfigName.StoreConfig,"StoreId",storeTypeConfig.Id)
|
|
local getChipNum = 1
|
|
local costItemId = 0
|
|
local costItemNum = 0
|
|
for i = 1,#configs do
|
|
if self.needChipId == configs[i].Goods[1][1] then
|
|
self.ShopId = configs[i].Id
|
|
getChipNum = configs[i].Goods[1][2]
|
|
costItemId = configs[i].Cost[1][1]
|
|
local a,b,c,d = configs[i].Cost[2][1],configs[i].Cost[2][2],configs[i].Cost[2][3],configs[i].Cost[2][4]
|
|
local x = 1
|
|
costItemNum = a*x^3+b*x^2+c*x+d
|
|
break
|
|
end
|
|
end
|
|
local needCostNum = math.ceil(self.needChipNum/getChipNum)*costItemNum
|
|
local itemcount = BagManager.GetItemCountById(costItemId)
|
|
self.costIconPos.gameObject:SetActive(true)
|
|
self.itemView:OnOpen(false, {costItemId,0}, 0.4, false, false, false, self.parent.sortingOrder)
|
|
if itemcount >= needCostNum then
|
|
color = "12C10B"
|
|
self.btnSureIma.sprite = self.parent.spLoader:LoadSprite("r_hero_button_001")
|
|
end
|
|
self.desc.text = string.format("<color=#%s>%s:%s/%s</color>",color, ItemConfig[costItemId].Name,itemcount,needCostNum)
|
|
elseif self.jumpSData.Type == 30003 then
|
|
self.btnSureText.text = "合成"
|
|
self.itemView:OnOpen(false, {self.needChipId,0}, 0.4, false, false, false, self.parent.sortingOrder)
|
|
local itemcount = BagManager.GetItemCountById(self.needChipId)
|
|
if itemcount >= self.needChipNum then
|
|
color = "12C10B"
|
|
self.btnSureIma.sprite = self.parent.spLoader:LoadSprite("r_hero_button_001")
|
|
end
|
|
self.desc.text = string.format("<color=#%s>%s:%s/%s</color>",color,ItemConfig[self.needChipId].Name,itemcount,self.needChipNum)
|
|
elseif self.jumpSData.Type == JumpType.recharge then
|
|
self.costIconPos.gameObject:SetActive(false)
|
|
self.desc.text = string.format("快速提升%s星级",heroConfig.ReadingName)
|
|
elseif self.jumpSData.Type == 40 then
|
|
self.costIconPos.gameObject:SetActive(false)
|
|
self.desc.text = "助力玉帝升星"
|
|
end
|
|
end
|
|
function JumpViewNew:GoToJumpData()
|
|
if self.jumpSData.Type == 30003 then
|
|
local itemcount = BagManager.GetItemCountById(self.needChipId)
|
|
if itemcount >= self.needChipNum then
|
|
local gameSetting = ConfigManager.GetConfigData(ConfigName.GameSetting, 1)
|
|
local endHeroNum=gameSetting.HeroNumlimit-LengthOfTable(HeroManager.GetAllHeroDatas())
|
|
local sum = math.floor(itemcount / self.needChipNum)
|
|
if sum > 1 then
|
|
local _itemData = BagManager.bagDatas[self.needChipId]
|
|
if endHeroNum > 0 then
|
|
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 3, _itemData, function()
|
|
self.parent:OnShow()
|
|
end)
|
|
else
|
|
PopupTipPanel.ShowTip(Language[12157])
|
|
end
|
|
else
|
|
-- body
|
|
local compoundNum = 1
|
|
local _itemData = BagManager.bagDatas[self.needChipId]
|
|
local item={}
|
|
item.itemId= _itemData.id
|
|
item.itemNum=compoundNum*self.needChipNum
|
|
if endHeroNum > 0 then
|
|
NetManager.HeroComposeRequest(item,function (drop)
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,drop,1,function()
|
|
self.parent:OnShow()
|
|
end)
|
|
end)
|
|
if compoundNum<=0 then
|
|
PopupTipPanel.ShowTip(Language[10183])
|
|
end
|
|
else
|
|
PopupTipPanel.ShowTip(Language[12157])
|
|
end
|
|
end
|
|
else
|
|
PopupTipPanel.ShowTip("碎片不足!")
|
|
end
|
|
else
|
|
if self.jumpSData.Type == JumpType.Store then
|
|
ShopManager.SetSelectIndex(self.jumpSData.Skipfactor[1],{self.ShopId})
|
|
elseif self.jumpSData.Type == JumpType.XingChenShangDian then
|
|
ShopManager.SetSelectIndex(self.shopType,{self.ShopId})
|
|
elseif self.jumpSData.Type == JumpType.recharge then
|
|
DynamicActivityManager.Index = 6
|
|
elseif (self.jumpSData.type ~= JumpType.firstRecharge or self.jumpSData.type ~= JumpType.ZhiZunJiangShi) then
|
|
PlayerManager.RewardItemSingleShowPopupIsRoleUpStarLayout2 = false
|
|
end
|
|
JumpManager.GoJump(self.jumpSData.Id,function(isOpen)
|
|
if isOpen then
|
|
self.parent:ClosePanel()
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function JumpViewNew:OnClose()
|
|
self.spLoader:Destroy()
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function JumpViewNew:OnDestroy()
|
|
SubUIManager.Close(self.itemView)
|
|
self.itemView = nil
|
|
end
|
|
|
|
return JumpViewNew |