miduo_client/Assets/ManagedResources/~Lua/Modules/Map/ShowEnemyInfoPanel.lua

218 lines
8.7 KiB
Lua
Raw Normal View History

2020-07-10 19:13:29 +08:00
require("Base/BasePanel")
2020-06-28 17:52:29 +08:00
local ShowEnemyInfoPanel = Inherit(BasePanel)
local this = ShowEnemyInfoPanel
local monsterGroupId
local _LiveName
local _LiveNode
local trailConfig = ConfigManager.GetConfig(ConfigName.TrialConfig)
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
local trialSetting=ConfigManager.GetConfig(ConfigName.TrialSetting)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local MonsterConfig=ConfigManager.GetConfig(ConfigName.MonsterConfig)
local MonsterGroupConfig = ConfigManager.GetConfig(ConfigName.MonsterGroup)
local ArtConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local herosList={}
function this:InitComponent()
this.root = self.gameObject
this.btnBack =Util.GetGameObject(this.root,"EnemyInfo/btnBack")
this.e_liveRoot=Util.GetGameObject(this.root,"EnemyInfo/liveRoot")
this.e_name=Util.GetGameObject(this.root,"EnemyInfo/name/text"):GetComponent("Text")
this.e_level=Util.GetGameObject(this.root,"EnemyInfo/name/level/Text"):GetComponent("Text")
this.e_cancelBtn=Util.GetGameObject(this.root,"EnemyInfo/cancelBtn")
this.e_fightBtn=Util.GetGameObject(this.root,"EnemyInfo/fightBtn")
this.heroGrid=Util.GetGameObject(this.root,"EnemyInfo/bottomBar/heroList")
this.iconPre=Util.GetGameObject(this.root,"EnemyInfo/bottomBar/heroList/pre")
end
function this:BindEvent()
Util.AddClick(this.e_cancelBtn,function()
Game.GlobalEvent:DispatchEvent(GameEvent.Event.PointTriggerEnd)
self:ClosePanel()
end)
Util.AddClick(this.btnBack,function()
Game.GlobalEvent:DispatchEvent(GameEvent.Event.PointTriggerEnd)
self:ClosePanel()
end)
Util.AddClick(this.e_fightBtn,function()
for i, v in ipairs(MapManager.trialHeroInfo) do
if MapTrialManager.selectHeroDid==v.heroId then
if v.heroHp<=0 then
PopupTipPanel.ShowTip(Language[11247])
return
end
end
end
--先保存编队
local curFormation = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_DREAMLAND)
local choosedList={}
table.insert(choosedList, {heroId = MapTrialManager.selectHeroDid, position=2})
FormationManager.RefreshFormation(FormationTypeDef.FORMATION_DREAMLAND,choosedList,
FormationManager.formationList[FormationTypeDef.FORMATION_DREAMLAND].teamPokemonInfos)
--请求战斗数据
NetManager.QuickFightRequest(function(msg)
--战斗赢了 击杀小怪数量+1包括BOSS吗
if msg.result==1 then
MapTrialManager.SetKillCount(MapTrialManager.GetKilCount()+1)
end
2020-07-02 20:50:49 +08:00
--更新英雄HP
MapTrialManager.SetHeroHp(msg.remainHpList, MapTrialManager.selectHeroDid)
2020-06-28 17:52:29 +08:00
CarbonManager.InitQuickFightData(monsterGroupId, nil, msg)
local fightData = BattleManager.GetBattleServerData(msg)
UIManager.OpenPanel(UIName.BattlePanel,fightData, BATTLE_TYPE.DAILY_CHALLENGE, function()
2020-07-02 20:50:49 +08:00
--更新精气值
2020-07-10 19:13:29 +08:00
LogGreen(Language[12222]..msg.essenceValue)
2020-07-02 20:50:49 +08:00
-- MapTrialManager.UpdatePowerValue(msg.essenceValue)--这句话会调用之后的event导致召唤boss特效播放两次直接把精气值付上就好了
MapTrialManager.powerValue = msg.essenceValue
2020-06-28 17:52:29 +08:00
--召唤Boss
if CarbonManager.difficulty == CARBON_TYPE.TRIAL and MapTrialManager.powerValue >= 100 then
MapTrialManager.isHaveBoss = true
MapTrialManager.UpdatePowerValue(0)
end
end)
self:ClosePanel()
end)
end)
end
function this:OnOpen(...)
monsterGroupId = ...
end
function this:OnShow()
this.SetSelectHero()
end
function this.SetSelectHero()
2020-07-02 17:04:46 +08:00
local itemId=trialSetting[1].HealingId[1]
local itemNum=trialSetting[1].HealingId[2]
2020-06-28 17:52:29 +08:00
if _LiveName then
poolManager:UnLoadLive(_LiveName, _LiveNode)
end
local t= MonsterGroupConfig[monsterGroupId].Contents[1][1]
local monsterId = MonsterConfig[t].MonsterId
local paintingId = heroConfig[monsterId].Live
local pos = heroConfig[monsterId].Position
_LiveName = ArtConfig[paintingId].Name
_LiveNode = poolManager:LoadLive(_LiveName, this.e_liveRoot.transform, Vector3.one * heroConfig[monsterId].Scale*0.7, Vector3.New(pos[1], pos[2], 0))
this.e_level.text = "lv."..MonsterConfig[t].Level
this.e_name.text = MonsterConfig[t].ReadingName
local d={}
d=MapManager.trialHeroInfo
for k = 1, this.heroGrid.transform.childCount do
this.heroGrid.transform:GetChild(k-1).gameObject:SetActive(false)
end
local closeChoosed=function() --有开着选择的全关了
for i, v in ipairs(herosList) do
local c=Util.GetGameObject(v,"choosed").gameObject
if c.activeSelf then
c:SetActive(false)
end
end
end
for index, value in ipairs(d) do
local item = herosList[index]
if not item then
item=newObjToParent(this.iconPre,this.heroGrid)
item.name="pre"..index
herosList[index]=item
end
item.gameObject:SetActive(true)
local frame=Util.GetGameObject(item,"frame"):GetComponent("Image")
local icon=Util.GetGameObject(item,"icon"):GetComponent("Image")
local pro=Util.GetGameObject(item,"proIcon"):GetComponent("Image")
local lv=Util.GetGameObject(item,"lv/Text"):GetComponent("Text")
local star=Util.GetGameObject(item,"star")
local choosed=Util.GetGameObject(item,"choosed")
local hpExp=Util.GetGameObject(item,"hpExp"):GetComponent("Slider")
frame.sprite=Util.LoadSprite(GetHeroQuantityImageByquality(heroConfig[value.tmpId].Quality))
icon.sprite= Util.LoadSprite(GetResourcePath(heroConfig[value.tmpId].Icon))
pro.sprite=Util.LoadSprite(GetProStrImageByProNum(heroConfig[value.tmpId].PropertyName))
lv.text=value.level
SetHeroStars(star, value.star)
--选择
2020-07-21 09:38:34 +08:00
choosed:SetActive(MapTrialManager.selectHeroDid==value.heroId)
2020-06-28 17:52:29 +08:00
Util.AddOnceClick(item,function()
2020-06-30 18:59:44 +08:00
if value.heroHp>0 then
closeChoosed()
choosed:SetActive(true)
MapTrialManager.selectHeroDid=value.heroId
Game.GlobalEvent:DispatchEvent(GameEvent.Map.RefreshHeroHp,false,nil,false)
2020-07-02 20:50:49 +08:00
else
PopupTipPanel.ShowTip(Language[11247])
2020-06-30 18:59:44 +08:00
end
2020-06-28 17:52:29 +08:00
end)
--血量相关
hpExp.value=value.heroHp/10000
Util.SetGray(item,value.heroHp<=0)--死啦
end
--刷新英雄选择面板时 检测血量 若有低于40%血量的英雄 给选择Hero加血
--再遍历一次防止下面的return 打断上面for循环表现的正常赋值
--这里只关于自动嗑药逻辑
for k, v in ipairs(d) do
--若存在该设置参数并为已勾选状态 =1 否则=0
local t=(PlayerPrefs.HasKey(PlayerManager.uid.."GeneralPopup_TrialSettingBtn"..2)
and PlayerPrefs.GetInt(PlayerManager.uid.."GeneralPopup_TrialSettingBtn"..2)==1) and 1 or 0
if t==0 then return end
if MapTrialManager.selectHeroDid== v.heroId then
if v.heroHp<=0 then
PopupTipPanel.ShowTip(string.format(Language[11262],itemConfig[itemId].Name))
return
end
end
--若血量小于自动回复百分比 并且 有血量
if v.heroHp/10000<trialSetting[1].HealingPercent/10000 and v.heroHp>0 then
if (itemNum-MapManager.addHpCount)<=0 then
PopupTipPanel.ShowTip(string.format(Language[11263],itemConfig[itemId].Name))
return
end
if BagManager.GetItemCountById(itemId)<=0 then
PopupTipPanel.ShowTip(string.format(Language[11264],itemConfig[itemId].Name,itemConfig[itemId].Name))
return
end
NetManager.UseAddHpItemRequest(MapTrialManager.selectHeroDid,function()
local curHeroHp=0
if v.heroId==MapTrialManager.selectHeroDid then
curHeroHp=v.heroHp
end
curHeroHp=curHeroHp+5000 --5000增加的血量也是要配表的
if curHeroHp>=10000 then
curHeroHp=10000
end
MapTrialManager.SetHeroHp({curHeroHp},MapTrialManager.selectHeroDid,function()
PopupTipPanel.ShowTip(string.format(Language[11265],itemConfig[itemId].Name))
end)
end)
end
end
end
function this:OnClose()
end
function this:OnDestroy()
_LiveName = {}
_LiveNode = {}
herosList={}
end
return this