480 lines
17 KiB
Lua
480 lines
17 KiB
Lua
require("Modules.Battle.Config.PokemonEffectConfig")
|
|
require("Base/BasePanel")
|
|
local SpiritAnimal = ConfigManager.GetConfig(ConfigName.SpiritAnimal)
|
|
|
|
local DamageResultPanel = Inherit(BasePanel)
|
|
local this = DamageResultPanel
|
|
|
|
-- Tab管理器
|
|
local TabBox = require("Modules/Common/TabBox")
|
|
local _TabFontColor = { default = Color.New(168 / 255, 168 / 255, 167 / 255, 1),
|
|
select = Color.New(250 / 255, 227 / 255, 175 / 255, 1) }
|
|
local _TabData = {
|
|
[1] = { default = "UI_hz_gonghui_31", select = "UI_hz_gonghui_31", name = Language[10232] },
|
|
[2] = { default = "UI_hz_gonghui_32", select = "UI_hz_gonghui_32", name = Language[10233] },
|
|
[3] = { default = "UI_hz_gonghui_33", select = "UI_hz_gonghui_33", name = Language[11517] },
|
|
[4] = { default = "UI_hz_gonghui_34", select = "UI_hz_gonghui_34", name = Language[10214] },
|
|
}
|
|
|
|
-- 最大层数
|
|
local _MaxOrder = 0
|
|
|
|
-- 最大数值,以最大数值为比计算其他数值的比例
|
|
local _MaxDamageValue = 0
|
|
local _MaxTreatValue = 0
|
|
|
|
-- 节点保存
|
|
local _LeftItemPool = {}
|
|
local _RightItemPool = {}
|
|
|
|
local LEFT_CAMP = 0
|
|
local RIGHT_CAMP = 1
|
|
|
|
-- 数据重构
|
|
local _NormalMonsterList = {}
|
|
local _DiffMonsterList = {}
|
|
|
|
--初始化组件(用于子类重写)
|
|
function DamageResultPanel:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
|
|
this.BtnBack = Util.GetGameObject(this.transform, "btnBack")
|
|
|
|
this.leftResult = Util.GetGameObject(this.transform, "left/result"):GetComponent("Image")
|
|
this.leftName = Util.GetGameObject(this.transform, "left/name"):GetComponent("Text")
|
|
this.leftItem = Util.GetGameObject(this.transform, "left/item")
|
|
this.leftGrid = Util.GetGameObject(this.transform, "left/scrollRect/grid")
|
|
|
|
this.rightResult = Util.GetGameObject(this.transform, "right/result"):GetComponent("Image")
|
|
this.rightName = Util.GetGameObject(this.transform, "right/name"):GetComponent("Text")
|
|
this.rightItem = Util.GetGameObject(this.transform, "right/item")
|
|
this.rightGrid = Util.GetGameObject(this.transform, "right/scrollRect/grid")
|
|
|
|
-- 初始化Tab管理器
|
|
this.tabbox = Util.GetGameObject(this.transform, "top")
|
|
this.TabCtrl = TabBox.New()
|
|
this.TabCtrl:SetTabAdapter(this.TabAdapter)
|
|
this.TabCtrl:SetChangeTabCallBack(this.OnTabChange)
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function DamageResultPanel:BindEvent()
|
|
Util.AddClick(this.BtnBack, function()
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
this:ClosePanel()
|
|
end)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function DamageResultPanel:AddListener()
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function DamageResultPanel:RemoveListener()
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function DamageResultPanel:OnOpen(result)
|
|
this.TabCtrl:Init(this.tabbox, _TabData)
|
|
this.leftResult.sprite = this.spLoader:LoadSprite(result == 1 and "UI_effect_JJC_JieSuan_ShengLi_png_zh" or "UI_effect_JJC_JieSuan_ShiBai_png_zh")
|
|
this.rightResult.sprite = this.spLoader:LoadSprite(result == 0 and "UI_effect_JJC_JieSuan_ShengLi_png_zh" or "UI_effect_JJC_JieSuan_ShiBai_png_zh")
|
|
|
|
local nameStr = BattleRecordManager.GetBattleBothNameStr()
|
|
if nameStr then
|
|
local namelist = string.split(nameStr, "|")
|
|
this.leftName.text = namelist[1]
|
|
this.rightName.text = namelist[2]
|
|
else
|
|
this.leftName.text = Language[10234]
|
|
this.rightName.text = Language[10235]
|
|
end
|
|
-- 数据
|
|
this.battleRecord = BattleRecordManager.GetBattleRecord()
|
|
if not this.battleRecord then return end
|
|
-- 计算最大数据
|
|
_MaxDamageValue = 0
|
|
_MaxTreatValue = 0
|
|
if this.battleRecord.data then
|
|
for _, role in pairs(this.battleRecord.data) do
|
|
-- 计算最大值
|
|
if role.damage and role.damage > _MaxDamageValue then _MaxDamageValue = role.damage end
|
|
if role.treat and role.treat > _MaxTreatValue then _MaxTreatValue = role.treat end
|
|
end
|
|
end
|
|
-- tab节点管理
|
|
if this.TabCtrl then
|
|
this.TabCtrl:Init(this.tabbox, _TabData)
|
|
end
|
|
end
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function DamageResultPanel:OnShow()
|
|
|
|
end
|
|
|
|
function this.isTabShow(index)
|
|
if not this.battleRecord then
|
|
return false
|
|
end
|
|
local list
|
|
if index == 1 or index == 2 then
|
|
return true
|
|
elseif index == 3 then
|
|
list = this.battleRecord.data
|
|
elseif index == 4 then
|
|
list = this.battleRecord.mdata
|
|
end
|
|
--
|
|
if list and table.nums(list) ~= 0 then
|
|
for _, role in pairs(list) do
|
|
-- 还有除info, damage, treat之外的其他属性
|
|
if table.nums(role) > 3 then
|
|
return true
|
|
end
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
-- tab节点显示自定义
|
|
function this.TabAdapter(tab, index, status)
|
|
local tabLab = Util.GetGameObject(tab, "Text")
|
|
Util.GetGameObject(tab,"Img"):GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabData[index][status])
|
|
tabLab:GetComponent("Text").text = _TabData[index].name
|
|
tabLab:GetComponent("Text").color = _TabFontColor[status]
|
|
local select=Util.GetGameObject(tab, "select")
|
|
select:SetActive(status=="select")
|
|
tab.gameObject:SetActive(this.isTabShow(index))
|
|
end
|
|
-- tab改变回调事件
|
|
function this.OnTabChange(index, lastIndex)
|
|
|
|
local showType = index -- 1 伤害 2 治疗 3 特殊 4 灵兽
|
|
|
|
-- 关闭显示
|
|
for _, item in pairs(_LeftItemPool) do
|
|
item:SetActive(false)
|
|
end
|
|
for _, item in pairs(_RightItemPool) do
|
|
item:SetActive(false)
|
|
end
|
|
|
|
-- 数据匹配
|
|
if not this.battleRecord then return end
|
|
local leftIndex, rightIndex = 0, 0
|
|
local function CreateMonsterItem(data)
|
|
local pool, item, grid, index
|
|
if data.info.camp == LEFT_CAMP then
|
|
leftIndex = leftIndex + 1
|
|
pool, item, grid, index = _LeftItemPool, this.leftItem, this.leftGrid, leftIndex
|
|
elseif data.info.camp == RIGHT_CAMP then
|
|
rightIndex = rightIndex + 1
|
|
pool, item, grid, index = _RightItemPool, this.rightItem, this.rightGrid, rightIndex
|
|
end
|
|
|
|
if not pool[index] then
|
|
pool[index] = newObjToParent(item, grid)
|
|
end
|
|
pool[index]:SetActive(true)
|
|
this.ItemAdapter(pool[index], data, showType)
|
|
end
|
|
|
|
-- 创建
|
|
local monster=this.battleRecord.mdata
|
|
local showList = this.battleRecord.data
|
|
if showType == 4 then
|
|
showList={}
|
|
--= this.battleRecord.mdata
|
|
for key, value in pairs(monster) do
|
|
if key~=100 and key~=106 then
|
|
--table.remove(showList,key)
|
|
table.insert(showList,value)
|
|
end
|
|
end
|
|
else
|
|
for key, value in pairs(monster) do
|
|
if key==100 or key==106 then
|
|
value.info.type=1
|
|
showList[key]=value
|
|
end
|
|
end
|
|
end
|
|
for _, data in pairs(showList) do
|
|
CreateMonsterItem(data)
|
|
end
|
|
-- 播放动画
|
|
this.StartPlayAnim(showType)
|
|
end
|
|
|
|
-- 开始播放动画
|
|
function this.StartPlayAnim(showType)
|
|
if showType > 2 then
|
|
return
|
|
end
|
|
-- 根据showType播放动画
|
|
DoTween.To(
|
|
DG.Tweening.Core.DOGetter_float( function () return 0 end),
|
|
DG.Tweening.Core.DOSetter_float(
|
|
function (progress)
|
|
local leftIndex, rightIndex = 0, 0
|
|
local function _Play(data)
|
|
local pool, index, drt
|
|
if data.info.camp == LEFT_CAMP then
|
|
leftIndex = leftIndex + 1
|
|
pool, index = _LeftItemPool, leftIndex
|
|
drt = 1
|
|
elseif data.info.camp == RIGHT_CAMP then
|
|
rightIndex = rightIndex + 1
|
|
pool, index = _RightItemPool, rightIndex
|
|
drt = -1
|
|
end
|
|
if pool[index] then
|
|
local _progress = Util.GetGameObject(pool[index], "progress")
|
|
local value = 0
|
|
if showType == 1 then
|
|
if _MaxDamageValue ~= 0 then
|
|
value = (data.damage or 0)/_MaxDamageValue
|
|
end
|
|
else
|
|
if _MaxTreatValue ~= 0 then
|
|
value = (data.treat or 0)/_MaxTreatValue
|
|
end
|
|
end
|
|
_progress.transform.localScale = Vector3(value * progress * drt, 1, 1)
|
|
end
|
|
end
|
|
-- 创建
|
|
for _, data in pairs(this.battleRecord.data) do
|
|
_Play(data)
|
|
end
|
|
end),
|
|
1, 1)
|
|
:SetEase(Ease.OutQuad)
|
|
end
|
|
|
|
-- 数据匹配
|
|
function this.ItemAdapter(item, data, showType)
|
|
local head = Util.GetGameObject(item, "headpos/head")
|
|
this.HeadAdapter(head, data.info, showType)
|
|
local damage = Util.GetGameObject(item, "damage"):GetComponent("Text")
|
|
local progress = Util.GetGameObject(item, "progress")
|
|
local scroll = Util.GetGameObject(item, "scroll")
|
|
local content = Util.GetGameObject(item, "scroll/Viewport/Content"):GetComponent("Text")
|
|
|
|
-- 显隐
|
|
damage.gameObject:SetActive(showType <= 2)
|
|
progress.gameObject:SetActive(showType <= 2)
|
|
scroll:SetActive(showType > 2)
|
|
|
|
--
|
|
if showType == 1 then
|
|
damage.text = data.damage or 0
|
|
progress:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_guaji_zhandoutongjitiao_01")
|
|
progress.transform.localScale = Vector3(0, 1, 1)
|
|
|
|
elseif showType == 2 then
|
|
damage.text = data.treat or 0
|
|
progress:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_guaji_zhandoutongjitiao_02")
|
|
progress.transform.localScale = Vector3(0, 1, 1)
|
|
elseif showType == 3 or showType == 4 then
|
|
local txt = ""
|
|
for key, value in pairs(data) do
|
|
local s = this.GetSpecialText(key, value)
|
|
if s and s ~= "" then
|
|
if txt ~= "" then
|
|
txt = txt.."\n"
|
|
end
|
|
txt = txt..s
|
|
end
|
|
end
|
|
-- 没有显示则不显示
|
|
if txt == "" then
|
|
item.gameObject:SetActive(false)
|
|
else
|
|
content.text = txt
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
function this.GetSpecialText(key, value)
|
|
if key == "buff" then
|
|
local s = ""
|
|
for id, v in pairs(value) do
|
|
local type = math.floor(id/100)
|
|
local subType = id%100
|
|
print(id, type, subType)
|
|
local config = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.BuffEffectConfig, "Type", type, "CType", subType)
|
|
if config then
|
|
if s ~= "" then
|
|
s = s.."\n"
|
|
end
|
|
local color = UIColorStr.RED
|
|
if type == BuffName.Shield then
|
|
color = UIColorStr.GREEN
|
|
end
|
|
s = s .. string.format(Language[12158], GetLanguageStrById(config.Describe), color, v)
|
|
end
|
|
end
|
|
return s
|
|
elseif key == "addRage" then
|
|
return string.format(Language[12159], UIColorStr.GREEN, value)
|
|
elseif key == "subRage" then
|
|
return string.format(Language[12160], UIColorStr.RED, value)
|
|
elseif key == "transRage" then
|
|
return string.format(Language[12161], UIColorStr.GREEN, value)
|
|
elseif key == "secKill" then
|
|
return string.format(Language[12162], UIColorStr.RED, value)
|
|
end
|
|
end
|
|
|
|
-- 头像数据匹配
|
|
function this.HeadAdapter(head,data,type)
|
|
local frame = Util.GetGameObject(head, "frame"):GetComponent("Image")
|
|
local icon = Util.GetGameObject(head, "icon"):GetComponent("Image")
|
|
local prefess = Util.GetGameObject(head, "pro")
|
|
prefess:SetActive(false)
|
|
local prefessIcon = Util.GetGameObject(head, "pro/icon"):GetComponent("Image")
|
|
local proto = Util.GetGameObject(head, "prott")
|
|
local protoIcon = Util.GetGameObject(head, "prott/Image"):GetComponent("Image")
|
|
local lv = Util.GetGameObject(head, "lv")
|
|
local lvText = Util.GetGameObject(head, "lv/Text"):GetComponent("Text")
|
|
local starRoot = Util.GetGameObject(head, "star")
|
|
local deadObj = Util.GetGameObject(head, "deadObj")
|
|
deadObj:GetComponent("Image").sprite=this.spLoader:LoadSprite("r_zhandou_zhenwang_zh")
|
|
local aa=0
|
|
|
|
local frameStr="r_characterbg_goden"
|
|
if data.type == BattleUnitType.Role then
|
|
local roleId = data.roleData.monsterId or data.roleData.roleId
|
|
local roleLv = data:GetRoleData(RoleDataName.Level)
|
|
local skinId = data.roleData.skinId
|
|
local star = data.star
|
|
-- LogError("id=="..roleId.."star=="..star.." data.roleData.godSoulLv=="..data.roleData.godSoulLv.." ")
|
|
local config = {}
|
|
if data.position==100 then
|
|
config.Quality=4
|
|
if data.roleData.sex==ROLE_SEX.BOY then
|
|
aa=3201
|
|
else
|
|
aa=3202
|
|
end
|
|
config.lv=data.roleData.star
|
|
star=0
|
|
SetHeroFlyEffect(head,this.spLoader,0,this.sortingOrder+1,0.95)
|
|
else
|
|
if roleId > 10100 then
|
|
local MonsterConfig = ConfigManager.GetConfigData(ConfigName.MonsterConfig, roleId)
|
|
config.Quality = MonsterConfig.Quality
|
|
config.lv = MonsterConfig.Level
|
|
star=MonsterConfig.Star
|
|
if MonsterConfig.MonsterId > 10000 then
|
|
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, MonsterConfig.MonsterId)
|
|
config.Icon = heroConfig.Icon
|
|
config.Profession = heroConfig.Profession
|
|
config.PropertyName = heroConfig.PropertyName
|
|
else
|
|
local monsterViewInfo = ConfigManager.GetConfigData(ConfigName.MonsterViewConfig, MonsterConfig.MonsterId)
|
|
config.Icon = monsterViewInfo.MonsterIcon
|
|
end
|
|
else
|
|
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, roleId)
|
|
config.Quality = heroConfig.Quality
|
|
config.Icon = heroConfig.Icon
|
|
config.Profession = heroConfig.Profession
|
|
config.PropertyName = heroConfig.PropertyName
|
|
config.lv = roleLv
|
|
end
|
|
aa=config.Icon
|
|
frameStr=GetHeroQuantityImageByquality(config.Quality, star)
|
|
SetHeroFlyEffect(head,this.spLoader,data.roleData.star,this.sortingOrder+1,0.95)
|
|
end
|
|
-- 头像
|
|
frame.sprite = this.spLoader:LoadSprite(frameStr)
|
|
if skinId and skinId>0 then
|
|
local skinConfig=ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Type",skinId)
|
|
if skinConfig then
|
|
aa=skinConfig.Icon
|
|
end
|
|
end
|
|
icon.sprite = this.spLoader:LoadSprite(GetResourcePath(aa))
|
|
-- 等级
|
|
lv:SetActive(true)
|
|
lvText.text = config.lv
|
|
-- 星级
|
|
|
|
local starType = 1
|
|
if data.roleData.godSoulLv and data.roleData.godSoulLv > 0 then
|
|
star = data.roleData.godSoulLv
|
|
starType = 3
|
|
end
|
|
local starSize=Vector2.New(35,35)
|
|
if starType==3 then
|
|
starSize=Vector2.New(0.8,-15)
|
|
elseif starType==2 then
|
|
starSize=Vector2.New(48,48)
|
|
end
|
|
SetHeroStars(this.spLoader, starRoot, star)
|
|
Util.SetParticleSortLayer(starRoot,this.sortingOrder + 1)
|
|
-- 职业
|
|
prefess:SetActive(false)
|
|
-- 属性
|
|
proto:SetActive(false)
|
|
if config.PropertyName then
|
|
protoIcon.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(data.roleData.element))
|
|
proto:SetActive(true)
|
|
end
|
|
|
|
elseif data.type == BattleUnitType.Monster then
|
|
local id = data.uid
|
|
local roleLv = data:GetRoleData(RoleDataName.Level)
|
|
local star = data.star
|
|
prefess:SetActive(false)
|
|
proto:SetActive(false)
|
|
-- 等级
|
|
lv:SetActive(true)
|
|
lvText.text = roleLv
|
|
-- 星级
|
|
SetHeroStars(this.spLoader, starRoot, star)
|
|
Util.SetParticleSortLayer(starRoot,this.sortingOrder + 1)
|
|
-- 头像
|
|
frame.sprite = this.spLoader:LoadSprite(GetHeroQuantityImageByquality(SpiritAnimal[id].Quality))
|
|
icon:GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(SpiritAnimal[id].Icon))
|
|
end
|
|
if data.isRealDead and (type==1 or type==2 or type==3) then
|
|
-- Util.SetGray(icon.gameObject ,true)
|
|
-- Util.SetGray(frame.gameObject ,true)
|
|
-- Util.SetGray(protoIcon.gameObject ,true)
|
|
-- Util.SetGray(starRoot.gameObject ,true)
|
|
deadObj:SetActive(true)
|
|
Util.SetGray(head.gameObject ,true)
|
|
else
|
|
-- Util.SetGray(icon.gameObject,false)
|
|
-- Util.SetGray(frame.gameObject ,false)
|
|
-- Util.SetGray(starRoot.gameObject ,false)
|
|
-- Util.SetGray(protoIcon.gameObject ,false)
|
|
deadObj:SetActive(false)
|
|
Util.SetGray(head.gameObject ,false)
|
|
|
|
end
|
|
end
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function DamageResultPanel:OnClose()
|
|
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function DamageResultPanel:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
_LeftItemPool = {}
|
|
_RightItemPool = {}
|
|
|
|
_MaxDamageValue = 0
|
|
_MaxTreatValue = 0
|
|
end
|
|
|
|
return DamageResultPanel
|
|
|