2020-08-25 15:46:38 +08:00
|
|
|
|
----- 试练性药 -----
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local this = {}
|
|
|
|
|
--传入父脚本模块
|
|
|
|
|
local parent
|
|
|
|
|
--传入特效层级
|
|
|
|
|
local sortingOrder=0
|
|
|
|
|
|
|
|
|
|
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
local trialSetting=ConfigManager.GetConfig(ConfigName.TrialSetting)
|
|
|
|
|
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
|
|
|
|
local item
|
|
|
|
|
local heroList={} --英雄预设容器
|
|
|
|
|
local oldChoosed=nil--上一个选中英雄
|
2020-06-08 13:57:30 +08:00
|
|
|
|
local selectHeroDid --选中英雄did
|
|
|
|
|
local itemId=0 --消耗道具ID
|
|
|
|
|
local itemNum=0 --消耗道具数量
|
|
|
|
|
local optionType={ --选择类型
|
|
|
|
|
First=0,
|
|
|
|
|
Refresh=1,
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-03 19:09:01 +08:00
|
|
|
|
function this:InitComponent(gameObject)
|
|
|
|
|
this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
|
|
|
|
|
this.body=Util.GetGameObject(gameObject,"Body")
|
|
|
|
|
this.item=Util.GetGameObject(this.body,"Item")
|
|
|
|
|
this.desc=Util.GetGameObject(this.body,"Desc"):GetComponent("Text")
|
|
|
|
|
this.time=Util.GetGameObject(this.body,"Time"):GetComponent("Text")
|
|
|
|
|
this.num=Util.GetGameObject(this.body,"Num"):GetComponent("Text")
|
2020-06-08 13:57:30 +08:00
|
|
|
|
this.addBtn=Util.GetGameObject(this.body,"Add")
|
2020-06-03 19:09:01 +08:00
|
|
|
|
this.grid = Util.GetGameObject(gameObject, "Root/Grid")
|
|
|
|
|
this.pre=Util.GetGameObject(gameObject,"Root/Grid/Pre")
|
|
|
|
|
this.cancelBtn=Util.GetGameObject(gameObject,"CancelBtn")
|
|
|
|
|
this.confirmBtn=Util.GetGameObject(gameObject,"ConfirmBtn")
|
|
|
|
|
|
|
|
|
|
item=SubUIManager.Open(SubUIConfig.ItemView, this.item.transform)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:BindEvent()
|
|
|
|
|
--取消按钮
|
|
|
|
|
Util.AddClick(this.cancelBtn,function()
|
2020-10-12 16:08:13 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.OnTempBagChanged)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
parent:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
--使用按钮
|
|
|
|
|
Util.AddClick(this.confirmBtn,function()
|
2020-06-08 13:57:30 +08:00
|
|
|
|
local maxNum=trialSetting[1].HealingId[2]
|
|
|
|
|
local curHeroHp=0
|
|
|
|
|
for i, v in ipairs(MapManager.trialHeroInfo) do
|
|
|
|
|
if selectHeroDid==v.heroId then
|
|
|
|
|
curHeroHp= v.heroHp
|
|
|
|
|
if v.heroHp<=0 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11650])
|
2020-06-08 13:57:30 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if (maxNum-MapManager.addHpCount)<=0 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11651])
|
2020-06-03 19:09:01 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
if BagManager.GetItemCountById(itemId)<=0 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(string.format(Language[11652],itemConfig[itemId].Name))
|
2020-06-03 19:09:01 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
if curHeroHp>=10000 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11653])
|
2020-06-08 13:57:30 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
2021-01-14 17:07:18 +08:00
|
|
|
|
if not selectHeroDid then
|
|
|
|
|
PopupTipPanel.ShowTip("未选择目标神将")
|
|
|
|
|
return
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
NetManager.UseAddHpItemRequest(selectHeroDid,function()
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(string.format(Language[11654],itemConfig[itemId].Name))
|
2020-06-08 13:57:30 +08:00
|
|
|
|
MapManager.addHpCount=MapManager.addHpCount+1
|
|
|
|
|
curHeroHp=curHeroHp+5000 --5000增加的血量也是要配表的
|
2020-06-03 19:09:01 +08:00
|
|
|
|
if curHeroHp>=10000 then
|
|
|
|
|
curHeroHp=10000
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
MapTrialManager.SetHeroHp({curHeroHp},selectHeroDid)
|
2020-10-12 16:08:13 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Map.RefreshHeroHp,false,nil,false)
|
2020-08-31 16:06:57 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.OnTempBagChanged)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end)
|
|
|
|
|
end)
|
2020-06-08 13:57:30 +08:00
|
|
|
|
--购买道具按钮
|
|
|
|
|
Util.AddClick(this.addBtn,function()
|
|
|
|
|
UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = UpViewRechargeType.XingYao })
|
|
|
|
|
end)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:AddListener()
|
2020-06-08 13:57:30 +08:00
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.RefreshPanel)--监听背包信息改变刷新 用于回春散数量刷新
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:RemoveListener()
|
2020-06-08 13:57:30 +08:00
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, this.RefreshPanel)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnShow(_parent,...)
|
2020-08-28 10:14:46 +08:00
|
|
|
|
oldChoosed = nil
|
2020-06-03 19:09:01 +08:00
|
|
|
|
parent=_parent
|
|
|
|
|
sortingOrder = _parent.sortingOrder
|
|
|
|
|
--不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参
|
|
|
|
|
local _args = {...}
|
2020-06-08 13:57:30 +08:00
|
|
|
|
itemId=trialSetting[1].HealingId[1]
|
|
|
|
|
itemNum= BagManager.GetItemCountById(itemId)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
this.RefreshPanel()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnClose()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnDestroy()
|
|
|
|
|
item=nil
|
|
|
|
|
heroList={}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2020-06-08 13:57:30 +08:00
|
|
|
|
--刷新面板
|
2020-06-03 19:09:01 +08:00
|
|
|
|
function this.RefreshPanel()
|
2020-06-23 18:36:24 +08:00
|
|
|
|
this.titleText.text=Language[11655]
|
2020-06-08 13:57:30 +08:00
|
|
|
|
item:OnOpen(false, {itemId,1}, 1.2,false,false,false,sortingOrder)
|
|
|
|
|
item:Reset({itemId,1},ItemType.NoType,{nil,false,nil,false})
|
|
|
|
|
this.desc.text=itemConfig[itemId].ItemDescribe
|
2020-06-23 18:36:24 +08:00
|
|
|
|
this.time.text=Language[11656]..(trialSetting[1].HealingId[2]-MapManager.addHpCount)
|
|
|
|
|
this.num.text=Language[11657]..BagManager.GetItemCountById(itemId)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
|
|
|
|
|
for i, v in ipairs(MapManager.trialHeroInfo) do
|
|
|
|
|
local o= heroList[i]
|
|
|
|
|
if not o then
|
|
|
|
|
o=newObjToParent(this.pre,this.grid)
|
|
|
|
|
o.name="pre"..i
|
|
|
|
|
heroList[i]=o
|
|
|
|
|
end
|
|
|
|
|
o.gameObject:SetActive(true)
|
|
|
|
|
|
|
|
|
|
local frame=Util.GetGameObject(o,"frame"):GetComponent("Image")
|
|
|
|
|
local icon=Util.GetGameObject(o,"icon"):GetComponent("Image")
|
|
|
|
|
local pro=Util.GetGameObject(o,"proIcon"):GetComponent("Image")
|
|
|
|
|
local lv=Util.GetGameObject(o,"lv/Text"):GetComponent("Text")
|
|
|
|
|
local star=Util.GetGameObject(o,"star")
|
|
|
|
|
local choosed=Util.GetGameObject(o,"choosed")
|
|
|
|
|
local hpExp=Util.GetGameObject(o,"hpExp"):GetComponent("Slider")
|
2020-07-25 20:28:41 +08:00
|
|
|
|
frame.sprite=Util.LoadSprite(GetHeroQuantityImageByquality(heroConfig[v.tmpId].Quality,v.star))
|
2020-06-03 19:09:01 +08:00
|
|
|
|
icon.sprite= Util.LoadSprite(GetResourcePath(heroConfig[v.tmpId].Icon))
|
|
|
|
|
pro.sprite=Util.LoadSprite(GetProStrImageByProNum(heroConfig[v.tmpId].PropertyName))
|
|
|
|
|
lv.text=v.level
|
2020-07-24 20:03:06 +08:00
|
|
|
|
SetHeroStars(star, v.star,1,Vector2.New(30,30),-8.21)
|
2020-06-08 13:57:30 +08:00
|
|
|
|
--血量相关
|
2020-06-03 19:09:01 +08:00
|
|
|
|
hpExp.value=v.heroHp/10000
|
2020-06-08 13:57:30 +08:00
|
|
|
|
Util.SetGray(o,v.heroHp<=0)
|
|
|
|
|
|
2020-08-28 10:14:46 +08:00
|
|
|
|
choosed:SetActive(false)
|
|
|
|
|
if MapTrialManager.selectHeroDid == v.heroId then
|
|
|
|
|
choosed:SetActive(true)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
oldChoosed=choosed
|
2020-06-08 13:57:30 +08:00
|
|
|
|
selectHeroDid=v.heroId
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Util.AddOnceClick(o,function()
|
2020-06-08 13:57:30 +08:00
|
|
|
|
if v.heroHp<=0 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11658])
|
2020-06-08 13:57:30 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
if oldChoosed then
|
2020-06-08 13:57:30 +08:00
|
|
|
|
if selectHeroDid==v.heroId then
|
2020-06-03 19:09:01 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
oldChoosed:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
if oldChoosed~=choosed then
|
|
|
|
|
choosed:SetActive(true)
|
|
|
|
|
oldChoosed=choosed
|
2020-06-08 13:57:30 +08:00
|
|
|
|
selectHeroDid=v.heroId
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return this
|