155 lines
6.5 KiB
Lua
155 lines
6.5 KiB
Lua
|
local JumpConfig=ConfigManager.GetConfig(ConfigName.JumpConfig)
|
|||
|
local ItemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|||
|
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.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)
|
|||
|
end
|
|||
|
|
|||
|
--绑定事件(用于子类重写)
|
|||
|
function JumpViewNew:BindEvent()
|
|||
|
Util.AddOnceClick(self.btnSure, function()
|
|||
|
self:GoToJumpData()
|
|||
|
if self.parent then
|
|||
|
self.parent:ClosePanel()
|
|||
|
end
|
|||
|
end)
|
|||
|
end
|
|||
|
|
|||
|
--添加事件监听(用于子类重写)
|
|||
|
function JumpViewNew:AddListener()
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
--移除事件监听(用于子类重写)
|
|||
|
function JumpViewNew:RemoveListener()
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
--界面打开时调用(用于子类重写)
|
|||
|
function JumpViewNew:OnOpen(jumpId,heroConfig,parent)
|
|||
|
self.parent = parent
|
|||
|
self.jumpSData=JumpConfig[jumpId]
|
|||
|
self.needChipId = heroConfig.PiecesId
|
|||
|
self.needChipNum = ItemConfig[self.needChipId].UsePerCount
|
|||
|
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 = "设为心愿神将会有更高概率"
|
|||
|
elseif self.jumpSData.Type == JumpType.Lottery then
|
|||
|
self.costIconPos.gameObject:SetActive(false)
|
|||
|
self.desc.text = "设为心愿神将会有更高概率"
|
|||
|
elseif self.jumpSData.Type == JumpType.ElementDrawCard then
|
|||
|
self.costIconPos.gameObject:SetActive(false)
|
|||
|
self.desc.text = "抽取时额外赠送元神玉"
|
|||
|
elseif self.jumpSData.Type == JumpType.ElementDrawCard then
|
|||
|
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.Store then
|
|||
|
LogGreen("self.jumpSData.Skipfactor[1]:"..self.jumpSData.Skipfactor[1])
|
|||
|
local storeTypeConfig = ConfigManager.GetConfigDataByKey(ConfigName.StoreTypeConfig,"StoreType",self.jumpSData.Skipfactor[1])
|
|||
|
local configs = ConfigManager.GetAllConfigsDataByKey(ConfigName.StoreConfig,"StoreId",storeTypeConfig.Id)
|
|||
|
local getChipNum = 1
|
|||
|
local costItemId = 0
|
|||
|
local costItemNum = 0
|
|||
|
for i = 1,#configs do
|
|||
|
LogGreen("self.needChipId:"..self.needChipId.." configs[i].Goods[1][1]:"..configs[i].Goods[1][1])
|
|||
|
if self.needChipId == configs[i].Goods[1][1] then
|
|||
|
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
|
|||
|
self.desc.text = ItemConfig[costItemId].Name..":"..BagManager.GetItemCountById(costItemId).."/"..needCostNum
|
|||
|
self.itemView:OnOpen(false, {costItemId,needCostNum}, 0.6, false, false, false, self.parent.sortingOrder)
|
|||
|
elseif self.jumpSData.Type == 30003 then
|
|||
|
self.btnSureText.text = "合成"
|
|||
|
self.itemView:OnOpen(false, {self.needChipId,self.needChipNum}, 0.6, false, false, false, self.parent.sortingOrder)
|
|||
|
self.desc.text = ItemConfig[self.needChipId].Name..":"..BagManager.GetItemCountById(self.needChipId).."/"..self.needChipNum
|
|||
|
end
|
|||
|
end
|
|||
|
function JumpViewNew:GoToJumpData()
|
|||
|
if self.jumpSData.Type == 30003 then
|
|||
|
if BagManager.GetItemCountById(self.needChipId) >= self.needChipNum then
|
|||
|
local gameSetting = ConfigManager.GetConfigData(ConfigName.GameSetting, 1)
|
|||
|
local endHeroNum=gameSetting.HeroNumlimit-LengthOfTable(HeroManager.GetAllHeroDatas())
|
|||
|
local sum = math.floor(BagManager.GetItemCountById(self.needChipId) / self.needChipNum)
|
|||
|
if sum > 1 then
|
|||
|
local _itemData = BagManager.bagDatas[self.needChipId]
|
|||
|
if endHeroNum > 0 then
|
|||
|
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 3, _itemData, function()
|
|||
|
func()
|
|||
|
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)
|
|||
|
this.SendBackCompoundReCallBack(drop)
|
|||
|
end)
|
|||
|
if compoundNum<=0 then
|
|||
|
PopupTipPanel.ShowTip(Language[10183])
|
|||
|
end
|
|||
|
else
|
|||
|
PopupTipPanel.ShowTip(Language[12157])
|
|||
|
end
|
|||
|
end
|
|||
|
else
|
|||
|
PopupTipPanel.ShowTip("碎片不足!")
|
|||
|
end
|
|||
|
else
|
|||
|
JumpManager.GoJump(self.jumpSData.Id)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--界面关闭时调用(用于子类重写)
|
|||
|
function JumpViewNew:OnClose()
|
|||
|
self.spLoader:Destroy()
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
--界面销毁时调用(用于子类重写)
|
|||
|
function JumpViewNew:OnDestroy()
|
|||
|
SubUIManager.Close(self.itemView)
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
return JumpViewNew
|