374 lines
16 KiB
Lua
374 lines
16 KiB
Lua
local SmallSoldierInfoPanel = quick_class("SmallSoldierInfoPanel", BasePanel)
|
|
local itemData = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local gemConfig = ConfigManager.GetConfig(ConfigName.GemConfigNew)
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local lotteryConfig = ConfigManager.GetConfig(ConfigName.SoldiersLotteryConfig)
|
|
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
|
local specialConfig = ConfigManager.GetConfigData(ConfigName.SpecialConfig, 178).Value
|
|
local aaa = string.split(specialConfig, "#")
|
|
local oldWarPower = 0
|
|
local team
|
|
local state
|
|
local quaName = { Language[10992], Language[10349], Language[10993], Language[10994], Language[10995], Language[10996],
|
|
Language[10997], Language[10391] }
|
|
local isUp = true
|
|
local type = 0
|
|
local oldData = nil
|
|
local newData = nil
|
|
local isNewUp = false --新抽取的是否比老的大
|
|
local soliderAutoTimer = nil
|
|
function SmallSoldierInfoPanel:InitComponent()
|
|
self.spLoader = SpriteLoader.New()
|
|
self.btn_close = Util.GetGameObject(self.gameObject, "mask")
|
|
self.topObj = Util.GetGameObject(self.gameObject, "bg/topBar")
|
|
self.newObj = Util.GetGameObject(self.gameObject, "bg/newBar")
|
|
self.btnObj = Util.GetGameObject(self.gameObject, "bg/newBar/bottomBar")
|
|
self.btn_up = Util.GetGameObject(self.gameObject, "bg/newBar/bottomBar/btnUp")
|
|
self.btn_change = Util.GetGameObject(self.gameObject, "bg/newBar/bottomBar/btnChange")
|
|
self.btn_remove = Util.GetGameObject(self.gameObject, "bg/newBar/bottomBar/btnRemove")
|
|
self.btn_skip = Util.GetGameObject(self.gameObject, "bg/newBar/jumpFight/btn")
|
|
self.skipImg = Util.GetGameObject(self.gameObject, "bg/newBar/jumpFight/Image")
|
|
self.skipObj = Util.GetGameObject(self.gameObject, "bg/newBar/jumpFight")
|
|
Util.GetGameObject(self.gameObject, "bg/newBar/jumpFight/Text"):GetComponent("Text").text = Language[11004]
|
|
end
|
|
|
|
function SmallSoldierInfoPanel:BindEvent()
|
|
--跳过按钮
|
|
Util.AddClick(self.btn_skip, function()
|
|
if state == 0 then
|
|
state = 1
|
|
elseif state == 1 then
|
|
state = 0
|
|
end
|
|
self.skipImg:SetActive(state == 1)
|
|
PlayerPrefs.SetInt(PlayerManager.uid .. "isSoliderSkip", state)
|
|
end)
|
|
|
|
Util.AddClick(self.btn_close, function()
|
|
self:ClosePanel()
|
|
end)
|
|
--上阵按钮
|
|
Util.AddClick(self.btn_up, function()
|
|
NetManager.ReplaceSoldierRequest(1, 0, function()
|
|
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.Solider)
|
|
NetManager.RequestUserForceChange(FormationTypeDef.FORMATION_NORMAL)
|
|
local tempPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
if oldWarPower ~= tempPower then
|
|
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2, { oldValue = oldWarPower, newValue = tempPower })
|
|
end
|
|
isUp = true
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Solider.ShowSoliderChangeInfo, newData.type, isUp)
|
|
self:ClosePanel()
|
|
end)
|
|
end)
|
|
|
|
--替换按钮
|
|
Util.AddClick(self.btn_change, function()
|
|
local sureFunc = function()
|
|
NetManager.ReplaceSoldierRequest(1, state, function()
|
|
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.Solider)
|
|
NetManager.RequestUserForceChange(FormationTypeDef.FORMATION_NORMAL)
|
|
local tempPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
if oldWarPower ~= tempPower then
|
|
LogError("tempPower-old==================" .. tempPower - oldWarPower)
|
|
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2, {
|
|
oldValue = oldWarPower,
|
|
newValue =
|
|
tempPower
|
|
})
|
|
isUp = tempPower - oldWarPower > 0
|
|
oldWarPower = tempPower
|
|
end
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Solider.ShowSoliderChangeInfo, newData.type, isUp)
|
|
if state == 1 then
|
|
self:ClosePanel()
|
|
else
|
|
self:OnShow()
|
|
end
|
|
end)
|
|
end
|
|
if state == 1 then
|
|
if isNewUp == false then
|
|
local args = {}
|
|
args[1] = Language[11005]
|
|
args[2] = Language[10686]
|
|
args[3] = Language[10685]
|
|
args[4] = sureFunc
|
|
UIManager.OpenPanel(UIName.GMCommonConfirmPanel, args)
|
|
else
|
|
sureFunc()
|
|
end
|
|
else
|
|
sureFunc()
|
|
end
|
|
end)
|
|
--遣散按钮
|
|
Util.AddClick(self.btn_remove, function()
|
|
local sureFunc = function()
|
|
NetManager.ReplaceSoldierRequest(2, 0, function()
|
|
self:ClosePanel()
|
|
end)
|
|
end
|
|
if isNewUp then
|
|
local args = {}
|
|
args[1] = Language[11006]
|
|
args[2] = Language[10686]
|
|
args[3] = Language[10685]
|
|
args[4] = sureFunc
|
|
UIManager.OpenPanel(UIName.GMCommonConfirmPanel, args)
|
|
else
|
|
sureFunc()
|
|
end
|
|
end)
|
|
end
|
|
|
|
function SmallSoldierInfoPanel:AddListener()
|
|
|
|
end
|
|
|
|
function SmallSoldierInfoPanel:RemoveListener()
|
|
|
|
end
|
|
|
|
--待功能扩展(试图打开某个状态)
|
|
function SmallSoldierInfoPanel:OnOpen(...)
|
|
local args = { ... }
|
|
type = args[1]
|
|
--data=args[2]
|
|
-- newData=args[3]
|
|
state = PlayerPrefs.GetInt(PlayerManager.uid .. "isSoliderSkip")
|
|
end
|
|
|
|
function SmallSoldierInfoPanel:OnSortingOrderChange()
|
|
|
|
end
|
|
|
|
local itemList = {}
|
|
function SmallSoldierInfoPanel:OnShow()
|
|
oldWarPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
team = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_NORMAL)
|
|
newData = SmallSoldierManager.changeSolider
|
|
if SmallSoldierManager.soldierList[newData.type] then
|
|
oldData = SmallSoldierManager.soldierList[newData.type]
|
|
end
|
|
if oldData then
|
|
--LogError("显示上面的")
|
|
self.topObj:SetActive(true)
|
|
self:ShwoSoliderInfo(self.topObj, oldData, 1)
|
|
else
|
|
self.topObj:SetActive(false)
|
|
end
|
|
if newData then
|
|
--LogError("显示下面的")
|
|
self:ShwoSoliderInfo(self.newObj, newData, 2)
|
|
end
|
|
self.btn_up:SetActive(oldData == nil)
|
|
self.btn_remove:SetActive(oldData ~= nil)
|
|
self.btn_change:SetActive(oldData ~= nil)
|
|
|
|
self.skipObj:SetActive(oldData ~= nil)
|
|
self.skipImg:SetActive(state == 1)
|
|
|
|
if SmallSoldierManager.isAuto then
|
|
--soliderAutoTimer = Timer.New(function ()
|
|
if SmallSoldierManager.isAuto then
|
|
if oldData == nil then
|
|
NetManager.ReplaceSoldierRequest(1, 0, function()
|
|
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.Solider)
|
|
NetManager.RequestUserForceChange(FormationTypeDef.FORMATION_NORMAL)
|
|
local tempPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
if oldWarPower ~= tempPower then
|
|
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,
|
|
{ oldValue = oldWarPower, newValue = tempPower })
|
|
end
|
|
isUp = true
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Solider.ShowSoliderChangeInfo, newData.type, isUp)
|
|
soliderAutoTimer = Timer.New(function()
|
|
self:ClosePanel()
|
|
end, 0.3, 1, true):Start()
|
|
end)
|
|
else
|
|
if isNewUp then
|
|
NetManager.ReplaceSoldierRequest(1, 1, function()
|
|
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.Solider)
|
|
NetManager.RequestUserForceChange(FormationTypeDef.FORMATION_NORMAL)
|
|
local tempPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
if oldWarPower ~= tempPower then
|
|
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,
|
|
{ oldValue = oldWarPower, newValue = tempPower })
|
|
isUp = tempPower - oldWarPower > 0
|
|
oldWarPower = tempPower
|
|
end
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Solider.ShowSoliderChangeInfo, newData.type, isUp)
|
|
soliderAutoTimer = Timer.New(function()
|
|
self:ClosePanel()
|
|
end, 0.3, 1, true):Start()
|
|
end)
|
|
else
|
|
NetManager.ReplaceSoldierRequest(2, 0, function()
|
|
soliderAutoTimer = Timer.New(function()
|
|
self:ClosePanel()
|
|
end, 0.3, 1, true):Start()
|
|
end)
|
|
end
|
|
end
|
|
end
|
|
--end,0.3,1,true):Start()
|
|
end
|
|
end
|
|
|
|
--显示小兵信息
|
|
function SmallSoldierInfoPanel:ShwoSoliderInfo(go, data, _type)
|
|
if go == nil or data == nil then
|
|
--LogError("111111111111111111111111111111111111")
|
|
return
|
|
end
|
|
local title = Util.GetGameObject(go, "infoObj/title"):GetComponent("Text")
|
|
local frame = Util.GetGameObject(go, "infoObj/frame"):GetComponent("Image")
|
|
local icon = Util.GetGameObject(go, "infoObj/icon"):GetComponent("Image")
|
|
local quaImg = Util.GetGameObject(go, "infoObj/quaImg"):GetComponent("Image")
|
|
local name = Util.GetGameObject(go, "infoObj/name"):GetComponent("Text")
|
|
local lv = Util.GetGameObject(go, "infoObj/lv"):GetComponent("Text")
|
|
local proPre = Util.GetGameObject(go, "infoObj/proPre")
|
|
local grid = Util.GetGameObject(go, "infoObj/proGrid")
|
|
local skillObj = Util.GetGameObject(go, "skillObj")
|
|
local skillinfo = Util.GetGameObject(go, "skillObj/Text"):GetComponent("Text")
|
|
local config = ConfigManager.GetConfigData(ConfigName.SoldiersSetting, data.id)
|
|
local powerObj = Util.GetGameObject(go, "infoObj/powerImg")
|
|
powerObj:GetComponent("Image").sprite = self.spLoader:LoadSprite("r_hero_zhanlitishen_zh")
|
|
local powerDown = Util.GetGameObject(go, "infoObj/powerImg/changeValueDown")
|
|
local powerDownTxt = Util.GetGameObject(go, "infoObj/powerImg/changeValueDown"):GetComponent("Text")
|
|
local powerUp = Util.GetGameObject(go, "infoObj/powerImg/changeValueUp")
|
|
local powerUpTxt = Util.GetGameObject(go, "infoObj/powerImg/changeValueUp"):GetComponent("Text")
|
|
local skillBg = Util.GetGameObject(go, "skillObj/skillBG"):GetComponent("Image")
|
|
local skillIcon = Util.GetGameObject(go, "skillObj/skillBG/skillIcon"):GetComponent("Image")
|
|
skillBg.sprite = self.spLoader:LoadSprite(GetQuantityImageByquality(config.Quality))
|
|
skillIcon.sprite = self.spLoader:LoadSprite(GetResourcePath(config.SkillImage))
|
|
if _type == 1 then
|
|
title.text = GetLanguageStrById(config.Name)
|
|
elseif _type == 2 then
|
|
title.text = Language[11007]
|
|
end
|
|
frame.sprite = self.spLoader:LoadSprite(GetQuantityImageByquality(config.Quality))
|
|
icon.sprite = self.spLoader:LoadSprite(GetResourcePath(config.ResourceID))
|
|
quaImg.sprite = self.spLoader:LoadSprite(GetHeroQualityStr(config.Quality))
|
|
name.text = GetLanguageStrById(config.Name)
|
|
lv.text = data.level
|
|
local skillStr = ""
|
|
if config.PropertyName and #config.PropertyName > 0 and tonumber(config.PropertyName[1][1]) ~= nil then
|
|
for i = 1, #config.PropertyName do
|
|
local aa = config.PropertyName[i]
|
|
if aa[2] and aa[2] > 0 and aa[1] then
|
|
skillStr = skillStr .. PropertyType2[aa[1]] .. "+" .. aa[2] / 100 .. Language[11008]
|
|
end
|
|
end
|
|
end
|
|
if config.Profession and #config.Profession > 0 and tonumber(config.Profession[1][1]) ~= nil then
|
|
for i = 1, #config.Profession do
|
|
local aa = config.Profession[i]
|
|
if aa[2] and aa[2] > 0 and aa[1] then
|
|
skillStr = skillStr .. ProfessionType2[aa[1]] .. "+" .. aa[2] / 100 .. Language[11008]
|
|
end
|
|
end
|
|
end
|
|
skillinfo.text = skillStr
|
|
local addDamage = 0
|
|
--LogError("data.attributes len============="..#data.attributes)
|
|
for i = 1, 4 do
|
|
local go = Util.GetGameObject(grid, "proPre (" .. i .. ")")
|
|
if i > #data.attributes then
|
|
go:SetActive(false)
|
|
else
|
|
go:SetActive(true)
|
|
local proName = Util.GetGameObject(go, "name"):GetComponent("Text")
|
|
local value = Util.GetGameObject(go, "value"):GetComponent("Text")
|
|
local img = Util.GetGameObject(go, "Image"):GetComponent("Image")
|
|
proName.text = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.PropertyConfig,
|
|
data.attributes[i].id).Info)
|
|
value.text = data.attributes[i].value
|
|
if oldData and newData then
|
|
img.gameObject:SetActive(true)
|
|
local imgStr = nil
|
|
if _type == 1 then
|
|
LogError("判断上面的标")
|
|
if oldData.attributes[i].value > newData.attributes[i].value then
|
|
imgStr = "r_hero_zhanlishangsheng_png"
|
|
elseif oldData.attributes[i].value < newData.attributes[i].value then
|
|
imgStr = "r_hero_zhanlixiajiang_png"
|
|
end
|
|
else
|
|
--LogError("判断下面的标 data.attributes[i].value=="..data.attributes[i].value.." newData.attributes[i].value=="..newData.attributes[i].value)
|
|
if oldData.attributes[i].value > newData.attributes[i].value then
|
|
imgStr = "r_hero_zhanlixiajiang_png"
|
|
elseif oldData.attributes[i].value < newData.attributes[i].value then
|
|
imgStr = "r_hero_zhanlishangsheng_png"
|
|
end
|
|
end
|
|
if imgStr then
|
|
img.gameObject:SetActive(true)
|
|
img.sprite = self.spLoader:LoadSprite(imgStr)
|
|
else
|
|
img.gameObject:SetActive(false)
|
|
end
|
|
addDamage = addDamage + (newData.attributes[i].value - oldData.attributes[i].value) *
|
|
propertyConfig[i].Score
|
|
else
|
|
addDamage = addDamage + data.attributes[i].value * propertyConfig[i].Score
|
|
img.gameObject:SetActive(false)
|
|
end
|
|
end
|
|
end
|
|
local allDaamge = math.floor(addDamage * #team.teamHeroInfos + 0.5)
|
|
if newData ~= nil then
|
|
if _type == 1 then
|
|
powerObj:SetActive(false)
|
|
else
|
|
powerObj:SetActive(true)
|
|
powerDown:SetActive(allDaamge < 0)
|
|
powerUp:SetActive(allDaamge > 0)
|
|
if allDaamge > 0 then
|
|
powerUpTxt.text = allDaamge
|
|
isNewUp = true
|
|
else
|
|
powerDownTxt.text = allDaamge * -1
|
|
isNewUp = false
|
|
end
|
|
end
|
|
else
|
|
powerObj:SetActive(true)
|
|
powerDown:SetActive(allDaamge < 0)
|
|
powerUp:SetActive(allDaamge > 0)
|
|
if allDaamge > 0 then
|
|
powerUpTxt.text = allDaamge
|
|
else
|
|
powerDownTxt.text = allDaamge * -1
|
|
end
|
|
end
|
|
end
|
|
|
|
function SmallSoldierInfoPanel:OnClose()
|
|
oldData = nil
|
|
newData = nil
|
|
if soliderAutoTimer then
|
|
soliderAutoTimer:Stop()
|
|
soliderAutoTimer = nil
|
|
end
|
|
end
|
|
|
|
function SmallSoldierInfoPanel:OnDestroy()
|
|
self.spLoader:Destroy()
|
|
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.Solider)
|
|
local formationList = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_NORMAL)
|
|
for i = 1, 6 do
|
|
if formationList.teamHeroInfos[i] then
|
|
HeroPropManager.SetDirtyByType(formationList.teamHeroInfos[i].heroId, Hero_Prop_Type.Base)
|
|
end
|
|
end
|
|
if self.timer then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
end
|
|
end
|
|
|
|
return SmallSoldierInfoPanel
|