2021-04-21 13:12:04 +08:00
|
|
|
|
require("Base/BasePanel")
|
2020-10-19 20:37:53 +08:00
|
|
|
|
local XiaoYaoLuckyBossPopup = Inherit(BasePanel)
|
|
|
|
|
local this = XiaoYaoLuckyBossPopup
|
|
|
|
|
local monsterGroup = {}
|
|
|
|
|
local curMonsterGroup
|
|
|
|
|
|
|
|
|
|
local _LiveName
|
|
|
|
|
local _LiveNode
|
|
|
|
|
|
|
|
|
|
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
|
|
|
|
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
local rewardGroupConfig=ConfigManager.GetConfig(ConfigName.RewardGroup)
|
|
|
|
|
local MonsterGroup=ConfigManager.GetConfig(ConfigName.MonsterGroup)
|
|
|
|
|
local MonsterConfig=ConfigManager.GetConfig(ConfigName.MonsterConfig)
|
|
|
|
|
local ArtConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
|
|
|
|
|
|
|
|
|
local monsterGroupPrefabs = {}
|
|
|
|
|
local rewardPrefabs = {}
|
|
|
|
|
local costId = 0
|
|
|
|
|
local costNum = 0
|
|
|
|
|
local cost = {}
|
|
|
|
|
|
|
|
|
|
local fightBossIndex = 0
|
|
|
|
|
function XiaoYaoLuckyBossPopup:InitComponent()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader = SpriteLoader.New()
|
2020-10-19 20:37:53 +08:00
|
|
|
|
this.root = self.gameObject
|
|
|
|
|
this.btnBack =Util.GetGameObject(this.root,"Panel/bg/btnBack")
|
|
|
|
|
this.title =Util.GetGameObject(this.root,"Panel/bg/title"):GetComponent("Text")
|
2021-04-07 17:46:56 +08:00
|
|
|
|
--this.liveRoot=Util.GetGameObject(this.root,"Panel/EnemyInfo/root")
|
2021-04-07 16:30:20 +08:00
|
|
|
|
this.e_liveRoot=Util.GetGameObject(this.root,"Panel/EnemyInfo/root/liveRoot")
|
2020-10-19 20:37:53 +08:00
|
|
|
|
this.e_name=Util.GetGameObject(this.root,"Panel/EnemyInfo/name/text"):GetComponent("Text")
|
|
|
|
|
this.e_level=Util.GetGameObject(this.root,"Panel/EnemyInfo/name/level/Text"):GetComponent("Text")
|
|
|
|
|
this.hp = Util.GetGameObject(this.root,"Panel/EnemyInfo/hp/Image"):GetComponent("Image")
|
|
|
|
|
|
|
|
|
|
this.e_fightBtn=Util.GetGameObject(this.root,"Panel/EnemyInfo/fight")
|
|
|
|
|
this.heroList=Util.GetGameObject(this.root,"Panel/EnemyInfo/Scroll/heroList")
|
|
|
|
|
this.rewardList=Util.GetGameObject(this.root,"Panel/EnemyInfo/rewardScroll/rewardList")
|
|
|
|
|
this.iconPre=Util.GetGameObject(this.root,"Panel/EnemyInfo/Scroll/pre")
|
|
|
|
|
|
|
|
|
|
this.timeText = Util.GetGameObject(this.root,"Panel/EnemyInfo/remainTime"):GetComponent("Text")
|
|
|
|
|
this.selectKuang = Util.GetGameObject(this.root,"Panel/EnemyInfo/Scroll/choosed")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XiaoYaoLuckyBossPopup:BindEvent()
|
|
|
|
|
Util.AddClick(this.btnBack,function()
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
Util.AddClick(this.e_fightBtn,function()
|
|
|
|
|
if BagManager.GetItemCountById(costId) < costNum then
|
2021-04-09 12:26:35 +08:00
|
|
|
|
PopupTipPanel.ShowTip(GetLanguageStrById(itemConfig[costId].Name)..Language[10657])
|
2020-10-19 20:37:53 +08:00
|
|
|
|
else
|
|
|
|
|
XiaoYaoManager.ExecuteFightBattle(curMonsterGroup.monsterIndex,function()
|
|
|
|
|
if _LiveNode then
|
|
|
|
|
poolManager:UnLoadLive(_LiveName, _LiveNode)
|
|
|
|
|
_LiveNode = nil
|
|
|
|
|
end
|
|
|
|
|
this:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function XiaoYaoLuckyBossPopup:OnOpen()
|
2021-04-09 12:26:35 +08:00
|
|
|
|
this.title.text = Language[12003]
|
2020-10-19 20:37:53 +08:00
|
|
|
|
local config = ConfigManager.GetConfigDataByKey(ConfigName.FreeTravel,"MapID",XiaoYaoManager.curMapId)
|
|
|
|
|
cost = config.BossConsume
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XiaoYaoLuckyBossPopup:OnShow()
|
|
|
|
|
monsterGroup = XiaoYaoManager.GetMonsterDatas()
|
|
|
|
|
if not monsterGroup or #monsterGroup < 1 then
|
|
|
|
|
LogBlue("得到得怪物不存在")
|
|
|
|
|
this:ClosePanel()
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
fightBossIndex = XiaoYaoManager.fightBossIndex
|
|
|
|
|
LogYellow("fightBossIndex:"..fightBossIndex)
|
|
|
|
|
if fightBossIndex == 0 then
|
|
|
|
|
curMonsterGroup = monsterGroup[1]
|
|
|
|
|
else
|
|
|
|
|
local isExist = false
|
|
|
|
|
for i = 1,#monsterGroup do
|
|
|
|
|
if monsterGroup[i].monsterIndex == fightBossIndex then
|
|
|
|
|
curMonsterGroup = monsterGroup[i]
|
|
|
|
|
isExist = true
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if not isExist then
|
|
|
|
|
curMonsterGroup = monsterGroup[1]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
LogYellow("curMonsterGroup.monsterInDex:"..curMonsterGroup.monsterIndex)
|
|
|
|
|
this:InitMonsterList()
|
|
|
|
|
this:SetSelectHero(curMonsterGroup)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:TimerDown()
|
|
|
|
|
if this.timer then
|
|
|
|
|
this.timer:Stop()
|
|
|
|
|
this.timer = nil
|
|
|
|
|
end
|
|
|
|
|
local timeDown = curMonsterGroup.remainTime - PlayerManager.serverTime
|
|
|
|
|
local temp = 0
|
2021-04-09 12:26:35 +08:00
|
|
|
|
this.timeText.text = Language[10023]..TimeToHMS(timeDown)
|
2020-10-19 20:37:53 +08:00
|
|
|
|
this.timer = Timer.New(function()
|
|
|
|
|
if timeDown < 1 then
|
|
|
|
|
XiaoYaoManager.fightBossIndex = 0
|
|
|
|
|
this:OnShow()
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
for i = 1 , #monsterGroup do
|
|
|
|
|
temp = monsterGroup[i].remainTime - PlayerManager.serverTime
|
|
|
|
|
if temp < 1 then
|
|
|
|
|
this:OnShow()
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
timeDown = timeDown - 1
|
2021-04-09 12:26:35 +08:00
|
|
|
|
this.timeText.text = Language[10023]..TimeToHMS(timeDown)
|
2020-10-19 20:37:53 +08:00
|
|
|
|
end, 1, -1, true)
|
|
|
|
|
this.timer:Start()
|
|
|
|
|
end
|
|
|
|
|
function this:InitMonsterList()
|
|
|
|
|
for i = 1 ,#monsterGroupPrefabs do
|
|
|
|
|
monsterGroupPrefabs[i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
for i = 1 , #monsterGroup do
|
|
|
|
|
if not monsterGroupPrefabs[i] then
|
|
|
|
|
monsterGroupPrefabs[i] = newObjToParent(this.iconPre,this.heroList)
|
|
|
|
|
end
|
|
|
|
|
monsterGroupPrefabs[i].gameObject:SetActive(true)
|
|
|
|
|
this:SetSingleMonster(monsterGroupPrefabs[i],monsterGroup[i])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XiaoYaoLuckyBossPopup:SetSingleMonster(go,data)
|
|
|
|
|
local frame = Util.GetGameObject(go,"frame"):GetComponent("Image")
|
|
|
|
|
local icon = Util.GetGameObject(go,"icon"):GetComponent("Image")
|
|
|
|
|
local lv = Util.GetGameObject(go,"lv/Text"):GetComponent("Text")
|
|
|
|
|
local choosed = Util.GetGameObject(go,"choosed")
|
2021-04-21 16:36:12 +08:00
|
|
|
|
--LogGreen("data.monsterId:"..data.monsterId.." "..MonsterGroup[data.monsterId].Contents[1][2])
|
2020-10-19 20:37:53 +08:00
|
|
|
|
local id = MonsterGroup[data.monsterId].Contents[1][2]
|
|
|
|
|
local _data = MonsterConfig[id]
|
2021-04-21 13:12:04 +08:00
|
|
|
|
frame.sprite = this.spLoader:LoadSprite("r_hero_qingbao-jineng-002")
|
|
|
|
|
icon.sprite = this.spLoader:LoadSprite(GetResourcePath(heroConfig[_data.MonsterId].Icon))
|
2020-10-19 20:37:53 +08:00
|
|
|
|
lv.text = _data.Level
|
|
|
|
|
if data.monsterIndex == curMonsterGroup.monsterIndex then
|
|
|
|
|
this.selectKuang.transform:SetParent(go.transform)
|
|
|
|
|
this.selectKuang:GetComponent("RectTransform").localPosition = Vector3.zero
|
|
|
|
|
end
|
|
|
|
|
Util.AddOnceClick(go,function()
|
|
|
|
|
if curMonsterGroup.monsterIndex == data.monsterIndex then
|
|
|
|
|
else
|
|
|
|
|
curMonsterGroup = data
|
|
|
|
|
XiaoYaoManager.fightBossIndex = curMonsterGroup.monsterIndex
|
|
|
|
|
this.selectKuang.transform:SetParent(go.transform)
|
|
|
|
|
this.selectKuang:GetComponent("RectTransform").localPosition = Vector3.zero
|
|
|
|
|
this:SetSelectHero(data)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XiaoYaoLuckyBossPopup:SetSelectHero(monsterData)
|
|
|
|
|
XiaoYaoManager.fightBossIndex = monsterData.monsterIndex
|
|
|
|
|
local _data = MonsterConfig[MonsterGroup[monsterData.monsterId].Contents[1][2]]
|
|
|
|
|
local monsterId = _data.MonsterId
|
|
|
|
|
local paintingId = heroConfig[monsterId].Live
|
|
|
|
|
local pos = heroConfig[monsterId].Position
|
|
|
|
|
if _LiveNode then
|
|
|
|
|
poolManager:UnLoadLive(_LiveName, _LiveNode)
|
|
|
|
|
_LiveNode = nil
|
|
|
|
|
end
|
|
|
|
|
_LiveName = ArtConfig[paintingId].Name
|
2021-04-07 20:28:12 +08:00
|
|
|
|
_LiveNode = poolManager:LoadLive(_LiveName, this.e_liveRoot.transform, Vector3.one * heroConfig[monsterId].Scale, Vector3.New(pos[1], pos[2], 0))
|
2021-04-07 17:46:56 +08:00
|
|
|
|
--this.liveRoot.transform.localScale = Vector3.one*0.7
|
2020-10-19 20:37:53 +08:00
|
|
|
|
this.e_level.text = "lv.".. _data.Level
|
2021-01-26 17:08:39 +08:00
|
|
|
|
this.e_name.text = GetLanguageStrById(_data.ReadingName)
|
2020-10-19 20:37:53 +08:00
|
|
|
|
this.hp.fillAmount = monsterData.monsterHp/_data.Hp
|
|
|
|
|
if monsterData.attackNum > 0 then
|
|
|
|
|
if not cost[monsterData.attackNum+1] then
|
|
|
|
|
costId = cost[#cost][1]
|
|
|
|
|
costNum = cost[#cost][2]
|
|
|
|
|
else
|
|
|
|
|
costId = cost[monsterData.attackNum+1][1]
|
|
|
|
|
costNum = cost[monsterData.attackNum+1][2]
|
|
|
|
|
end
|
2021-04-21 16:36:12 +08:00
|
|
|
|
--LogGreen("costId:"..costId.." costNum:"..costNum)
|
2020-10-19 20:37:53 +08:00
|
|
|
|
Util.GetGameObject(this.e_fightBtn,"Text").gameObject:SetActive(false)
|
|
|
|
|
Util.GetGameObject(this.e_fightBtn,"layout").gameObject:SetActive(true)
|
2021-04-21 13:12:04 +08:00
|
|
|
|
Util.GetGameObject(this.e_fightBtn,"layout/icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(ArtConfig[itemConfig[costId].ResourceID].Name)
|
2020-10-19 20:37:53 +08:00
|
|
|
|
if BagManager.GetItemCountById(costId) < costNum then
|
|
|
|
|
Util.GetGameObject(this.e_fightBtn,"layout/num"):GetComponent("Text").text = "<color=#FF0000>" .. costNum .. "</color>"
|
|
|
|
|
else
|
|
|
|
|
Util.GetGameObject(this.e_fightBtn,"layout/num"):GetComponent("Text").text = "<color=#1B262E>" .. costNum .. "</color>"
|
|
|
|
|
end
|
|
|
|
|
else
|
2021-03-18 12:01:35 +08:00
|
|
|
|
costId = 16
|
|
|
|
|
costNum = 0
|
2020-10-19 20:37:53 +08:00
|
|
|
|
Util.GetGameObject(this.e_fightBtn,"Text").gameObject:SetActive(true)
|
|
|
|
|
Util.GetGameObject(this.e_fightBtn,"layout").gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
this:SetSingleReward(monsterData.reward)
|
|
|
|
|
this:TimerDown()
|
|
|
|
|
end
|
|
|
|
|
function XiaoYaoLuckyBossPopup:SetSingleReward(id)
|
|
|
|
|
for i = 1 ,#rewardPrefabs do
|
|
|
|
|
rewardPrefabs[i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
local data = rewardGroupConfig[id].ShowItem
|
|
|
|
|
for i = 1 , #data do
|
|
|
|
|
if not rewardPrefabs[i] then
|
|
|
|
|
rewardPrefabs[i] = SubUIManager.Open(SubUIConfig.ItemView,this.rewardList.transform)
|
|
|
|
|
end
|
|
|
|
|
rewardPrefabs[i].gameObject:SetActive(true)
|
|
|
|
|
LogRed("id:"..data[i][1].." data[i][2]:"..data[i][2])
|
2020-10-19 22:42:39 +08:00
|
|
|
|
rewardPrefabs[i]:OnOpen(false, {data[i][1],0},0.8,false,false,false)
|
2020-10-19 20:37:53 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
function this:OnClose()
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.XiaoYao.RefreshEventShow)
|
|
|
|
|
if _LiveNode then
|
|
|
|
|
poolManager:UnLoadLive(_LiveName, _LiveNode)
|
|
|
|
|
_LiveNode = nil
|
|
|
|
|
end
|
|
|
|
|
if this.timer then
|
|
|
|
|
this.timer:Stop()
|
|
|
|
|
this.timer = nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnDestroy()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader:Destroy()
|
2020-10-19 20:37:53 +08:00
|
|
|
|
if _LiveNode then
|
|
|
|
|
poolManager:UnLoadLive(_LiveName, _LiveNode)
|
|
|
|
|
_LiveNode = nil
|
|
|
|
|
end
|
|
|
|
|
monsterGroupPrefabs = {}
|
|
|
|
|
rewardPrefabs = {}
|
|
|
|
|
if this.timer then
|
|
|
|
|
this.timer:Stop()
|
|
|
|
|
this.timer = nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return this
|