380 lines
16 KiB
Lua
380 lines
16 KiB
Lua
require("Base/BasePanel")
|
||
GuildSkillUpLvPopup = Inherit(BasePanel)
|
||
local this = GuildSkillUpLvPopup
|
||
local TabBox = require("Modules/Common/TabBox")
|
||
local _TabData={ [1] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = GuildSkillType[2] },
|
||
[2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = GuildSkillType[1] },
|
||
[3] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = GuildSkillType[3] },
|
||
[4] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = GuildSkillType[4]},
|
||
}
|
||
local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
|
||
select = Color.New(243 / 255, 235 / 255, 202 / 255, 1)}
|
||
local skills = {}
|
||
local pros = {}
|
||
local materals = {}
|
||
local curIndex = 1
|
||
--界面肉盾 和 输出 交换位置
|
||
local curIndexChangeFun = {
|
||
[1] = 2,
|
||
[2] = 1,
|
||
[3] = 3,
|
||
[4] = 4,
|
||
}
|
||
local curSeletSkill = {}
|
||
local allSkillData = {}
|
||
local materialNoId = 0
|
||
local endLv = 0
|
||
local isMaxLv = true
|
||
local proInfo = {
|
||
[61] = Language[11052],
|
||
[62] = Language[11053],
|
||
[51] = Language[11054],
|
||
[52] = Language[11055],
|
||
[55] = Language[11056],
|
||
[56] = "暴伤加成",
|
||
}
|
||
local tabRedPotList = {}
|
||
local oldWarPowerValue = 0
|
||
local newWarPowerValue = 0
|
||
local oldLv
|
||
|
||
|
||
--长按升级状态
|
||
local _isClicked = false
|
||
local _isReqLvUp = false
|
||
local _isLongPress = false
|
||
this.timePressStarted = 0--监听长按事件
|
||
this.priThread = nil--协同程序播放升级属性提升值动画用
|
||
local isTriggerLongClick = false--长按是否升过级
|
||
|
||
--初始化组件(用于子类重写)
|
||
function GuildSkillUpLvPopup:InitComponent()
|
||
this.spLoader = SpriteLoader.New()
|
||
this.tabBox = Util.GetGameObject(self.gameObject, "bg/TabBox")
|
||
this.backBtn = Util.GetGameObject(self.gameObject, "bg/btnBack")
|
||
this.btnUpLv = Util.GetGameObject(self.gameObject, "bg/btnUpLv")
|
||
this.btnRest = Util.GetGameObject(self.gameObject, "bg/btnRest")
|
||
this.helpBtn = Util.GetGameObject(self.gameObject,"bg/HelpBtn")
|
||
this.helpPos = this.helpBtn:GetComponent("RectTransform").localPosition
|
||
this.titleText = Util.GetGameObject(self.gameObject,"bg/titleText"):GetComponent("Text")
|
||
this.skillAllLv = Util.GetGameObject(self.gameObject,"bg/skillAllLv"):GetComponent("Text")
|
||
this.selectImage = Util.GetGameObject(self.gameObject,"bg/skills/selectImage")
|
||
for i = 1, 6 do
|
||
skills[i] = Util.GetGameObject(self.gameObject,"bg/skills/frame ("..i..")")
|
||
pros[i] = Util.GetGameObject(self.gameObject,"bg/proScroll/grid/proVale ("..i..")")
|
||
end
|
||
this.materialGrid = Util.GetGameObject(self.gameObject,"bg/materialGrid")
|
||
for i = 1, 2 do
|
||
materals[i] = Util.GetGameObject(self.gameObject,"bg/materialGrid/needGoldText ("..i..")")
|
||
end
|
||
this.TabCtrl = TabBox.New()
|
||
|
||
this.upLvTrigger = Util.GetEventTriggerListener(this.btnUpLv)
|
||
end
|
||
|
||
--绑定事件(用于子类重写)
|
||
function GuildSkillUpLvPopup:BindEvent()
|
||
Util.AddClick(this.helpBtn,function()
|
||
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.GuildSkill,this.helpPos.x,this.helpPos.y)
|
||
end)
|
||
Util.AddClick(this.backBtn,function()
|
||
self:ClosePanel()
|
||
end)
|
||
Util.AddClick(this.btnUpLv,function()
|
||
if Time.realtimeSinceStartup - this.timePressStarted <= 0.4 then
|
||
this.LvUpClick(true)
|
||
end
|
||
end)
|
||
--长按升级按下状态
|
||
this._onPointerDown = function(Pointgo, data)
|
||
-- isTriggerLongClick = false
|
||
_isClicked = true
|
||
this.timePressStarted = Time.realtimeSinceStartup
|
||
oldLv = endLv
|
||
-- allAddProVal = PokemonManager.GetSinglePokemonAddProData(curPokemonData.dynamicId)
|
||
end
|
||
--长按升级抬起状态
|
||
this._onPointerUp = function(Pointgo, data)
|
||
-- LogPink("连续升级抬起请求升级 "..tostring(_isLongPress))
|
||
if _isLongPress then--and isTriggerLongClick
|
||
--连续升级抬起请求升级
|
||
-- LogPink("连续升级抬起请求升级 ")
|
||
this.LongLvUpClick(oldLv)
|
||
end
|
||
_isClicked = false
|
||
_isLongPress = false
|
||
end
|
||
this.upLvTrigger.onPointerDown = this.upLvTrigger.onPointerDown + this._onPointerDown
|
||
this.upLvTrigger.onPointerUp = this.upLvTrigger.onPointerUp + this._onPointerUp
|
||
|
||
|
||
Util.AddClick(this.btnRest,function()
|
||
if endLv <= 0 then
|
||
PopupTipPanel.ShowTip(Language[11060])
|
||
return
|
||
end
|
||
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.GuildSkill,
|
||
GuildSkillManager.GetResetGetDrop(curIndexChangeFun[curIndex]),curIndexChangeFun[curIndex],function()
|
||
-- CheckRedPointStatus(RedPointType.Guild_Skill)
|
||
GuildSkillManager.ResetGuildSkillData(curIndexChangeFun[curIndex])
|
||
this.OnClickTabBtn(curIndex,true)
|
||
this.RefreshTabRedPoint()
|
||
oldWarPowerValue = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
||
end)
|
||
end)
|
||
end
|
||
--添加事件监听(用于子类重写)
|
||
function GuildSkillUpLvPopup:AddListener()
|
||
end
|
||
|
||
--移除事件监听(用于子类重写)
|
||
function GuildSkillUpLvPopup:RemoveListener()
|
||
end
|
||
|
||
--界面打开时调用(用于子类重写)
|
||
function GuildSkillUpLvPopup:OnOpen(_curIndex)
|
||
GuildSkillManager.UpdataHeroProList = {}
|
||
curIndex = _curIndex or 1
|
||
tabRedPotList = {}
|
||
FixedUpdateBeat:Add(this.OnUpdate, self)--长按方法注册
|
||
end
|
||
|
||
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
||
function GuildSkillUpLvPopup:OnShow()
|
||
this.TabCtrl:SetTabAdapter(this.TabAdapter)
|
||
this.TabCtrl:SetChangeTabCallBack(this.SwitchView)
|
||
this.TabCtrl:Init(this.tabBox, _TabData,curIndex)
|
||
oldWarPowerValue = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
||
end
|
||
|
||
--长按升级处理
|
||
function this.OnUpdate()
|
||
if _isClicked then
|
||
if Time.realtimeSinceStartup - this.timePressStarted > 0.4 then
|
||
_isLongPress = true
|
||
if not _isReqLvUp then
|
||
_isReqLvUp = true
|
||
this.LvUpClick(false)
|
||
end
|
||
end
|
||
end
|
||
end
|
||
-- tab节点显示自定义
|
||
function this.TabAdapter(tab, index, status)
|
||
local tabLab = Util.GetGameObject(tab, "Text")
|
||
local tabImage = Util.GetGameObject(tab,"Image")
|
||
tabImage:GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabData[index][status])
|
||
tabLab:GetComponent("Text").text = _TabData[index].name
|
||
tabLab:GetComponent("Text").color = _TabFontColor[status]
|
||
Util.GetGameObject(tab, "Redpot"):SetActive(GuildSkillManager.GuildSkillRedPoint(curIndexChangeFun[index]))
|
||
if #tabRedPotList < 4 then
|
||
table.insert(tabRedPotList,Util.GetGameObject(tab, "Redpot"))
|
||
end
|
||
end
|
||
--切换视图
|
||
function this.SwitchView(index)
|
||
this.OnClickTabBtn(index)
|
||
end
|
||
function this.OnClickTabBtn(index,isNoLoadSprite)
|
||
--数据组拼
|
||
curIndex = index
|
||
GuildSkillManager.SetGuildSkillRedPlayers(curIndexChangeFun[curIndex],1)
|
||
CheckRedPointStatus(RedPointType.Guild_Skill)
|
||
isMaxLv = true
|
||
allSkillData = GuildSkillManager.GetSkillDataByType(curIndexChangeFun[curIndex])
|
||
curSeletSkill = allSkillData[1]
|
||
for i = 1, #allSkillData do
|
||
if curSeletSkill.level > allSkillData[i].level then
|
||
curSeletSkill = allSkillData[i]
|
||
isMaxLv = false
|
||
end
|
||
end
|
||
local allCurSkillConfig = ConfigManager.GetAllConfigsDataByDoubleKey(ConfigName.GuildTechnology,"Profession",curIndexChangeFun[curIndex],"TechId",curSeletSkill.id)
|
||
if isMaxLv and curSeletSkill.level ~= #allCurSkillConfig - 1 then
|
||
isMaxLv = false
|
||
end
|
||
this.ShowSkillsAndPros(isNoLoadSprite)--展示技能 展示属性
|
||
this.ShowMaterials()--展示消耗材料 及 按钮状态
|
||
end
|
||
--展示技能
|
||
function this.ShowSkillsAndPros(isNoLoadSprite)
|
||
this.titleText.text = Language[11061].._TabData[curIndex].name
|
||
local isEqualityLv,maxLv
|
||
endLv,isEqualityLv,maxLv = GuildSkillManager.GetAllGuildSkillLv(curIndexChangeFun[curIndex])
|
||
Util.SetGray(this.btnRest, endLv <= 0)
|
||
this.materialGrid:SetActive(not isMaxLv)
|
||
this.selectImage:SetActive(not isMaxLv)
|
||
if isMaxLv then
|
||
this.btnUpLv:GetComponent("Button").enabled=false
|
||
Util.GetGameObject(this.btnUpLv,"Text"):GetComponent("Text").text = Language[11062]
|
||
else
|
||
this.btnUpLv:GetComponent("Button").enabled=true
|
||
Util.GetGameObject(this.btnUpLv,"Text"):GetComponent("Text").text = Language[11063]
|
||
end
|
||
this.skillAllLv.text = Language[11064]..endLv
|
||
for i = 1, #allSkillData do
|
||
local skillGo = skills[i]
|
||
if skillGo then
|
||
if not isNoLoadSprite then
|
||
Util.GetGameObject(skillGo,"icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(allSkillData[i].config.Icon))
|
||
end
|
||
Util.GetGameObject(skillGo,"lvImage/Text"):GetComponent("Text").text = allSkillData[i].level
|
||
if isEqualityLv then
|
||
Util.SetGray(skillGo, true)
|
||
elseif allSkillData[i].level > 0 and allSkillData[i].level >= maxLv then
|
||
Util.SetGray(skillGo, false)
|
||
else
|
||
--if curSeletSkill.id == allSkillData[i].id then
|
||
-- Util.SetGray(skillGo, false)
|
||
--else
|
||
Util.SetGray(skillGo, true)
|
||
--end
|
||
end
|
||
end
|
||
local proGo = pros[i]
|
||
if proGo then
|
||
local propertyConfig = ConfigManager.GetConfigData(ConfigName.PropertyConfig, allSkillData[i].config.Values[1])
|
||
local proInfoStr = GetLanguageStrById(propertyConfig.Info)
|
||
if proInfo[propertyConfig.PropertyId] then
|
||
proInfoStr = proInfo[propertyConfig.PropertyId]
|
||
end
|
||
if curSeletSkill.id == allSkillData[i].id then
|
||
local config = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.GuildTechnology,"Profession",curIndexChangeFun[curIndex],"TechId",curSeletSkill.id,"Level",curSeletSkill.level + 1)
|
||
local addValue = ""
|
||
if config then
|
||
addValue = "<color=#529864>+"..GetPropertyFormatStrOne(propertyConfig.Style, config.Values[2] - allSkillData[i].config.Values[2]).."</color>"
|
||
end
|
||
proGo:GetComponent("Text").text = proInfoStr.. ":" .. GetPropertyFormatStrOne(propertyConfig.Style, allSkillData[i].config.Values[2]) ..addValue
|
||
else
|
||
proGo:GetComponent("Text").text = proInfoStr.. ":" .. GetPropertyFormatStrOne(propertyConfig.Style, allSkillData[i].config.Values[2])
|
||
end
|
||
end
|
||
end
|
||
end
|
||
--展示消耗材料 及 按钮状态
|
||
function this.ShowMaterials()
|
||
materialNoId = 0
|
||
this.selectImage.transform:SetParent(Util.GetGameObject(skills[curSeletSkill.id],"selectImageParent").transform)
|
||
this.selectImage.transform.localScale = Vector3.one
|
||
this.selectImage.transform.localPosition=Vector3.zero;
|
||
for i = 1, #materals do
|
||
if curSeletSkill.config.Consume then
|
||
|
||
if curSeletSkill.config.Consume[i] then
|
||
local consume = curSeletSkill.config.Consume[i]
|
||
local materalGo = materals[i]
|
||
Util.GetGameObject(materalGo,"Image"):GetComponent("Image").sprite =
|
||
this.spLoader:LoadSprite(GetResourcePath(ConfigManager.TryGetConfigData(ConfigName.ItemConfig,consume[1]).ResourceID))
|
||
materalGo:GetComponent("Text").text = PrintWanNum3(consume[2])
|
||
if BagManager.GetItemCountById(consume[1]) >= consume[2] then
|
||
materalGo:GetComponent("Text").text ="<color=#FCEBCA>".. consume[2].."</color>"
|
||
else
|
||
materalGo:GetComponent("Text").text ="<color=#C66366>".. consume[2].."</color>"
|
||
if materialNoId == 0 then
|
||
materialNoId = consume[1]
|
||
end
|
||
end
|
||
else
|
||
materals[i]:SetActive(false)
|
||
end
|
||
end
|
||
end
|
||
end
|
||
function this.RefreshTabRedPoint(index)
|
||
if index then
|
||
tabRedPotList[index]:SetActive(false)
|
||
else
|
||
for i = 1, #tabRedPotList do
|
||
tabRedPotList[curIndexChangeFun[i]]:SetActive(GuildSkillManager.GuildSkillRedPoint(curIndexChangeFun[i]))
|
||
end
|
||
end
|
||
end
|
||
|
||
|
||
--长按升级结束后请求协议
|
||
function this.LongLvUpClick(oldLv)
|
||
local oldWarPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
||
NetManager.SinGleGuildSkillUpLv(curIndexChangeFun[curIndex],oldLv,endLv,function (msg)
|
||
-- GuildSkillManager.SetSkillDataLv(curIndex,curSeletSkill.id,msg.curlevel)
|
||
GuildSkillManager.LongLvUpClickBackFun(msg)
|
||
this.OnClickTabBtn(curIndex,true)
|
||
this.RefreshTabRedPoint(curIndex)
|
||
_isReqLvUp = false
|
||
newWarPowerValue = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
||
if oldWarPowerValue ~= newWarPowerValue then
|
||
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldWarPowerValue,newValue = newWarPowerValue})
|
||
oldWarPowerValue = newWarPowerValue
|
||
end
|
||
end)
|
||
end
|
||
--升级按钮点击事件处理
|
||
function this.LvUpClick(isSingleLvUp)
|
||
|
||
|
||
|
||
--各种判断能否升级
|
||
if materialNoId > 0 then
|
||
PopupTipPanel.ShowTip(GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.ItemConfig,materialNoId).Name).." "..Language[11058])
|
||
if not isSingleLvUp then
|
||
this.LongLvUpClick(oldLv)
|
||
end
|
||
_isClicked = false
|
||
_isLongPress = false
|
||
return
|
||
end
|
||
|
||
|
||
if isMaxLv then
|
||
if not isSingleLvUp then
|
||
this.LongLvUpClick(oldLv)
|
||
end
|
||
_isClicked = false
|
||
_isLongPress = false
|
||
return
|
||
end
|
||
if isSingleLvUp then
|
||
NetManager.SinGleGuildSkillUpLv(curIndexChangeFun[curIndex],endLv,endLv + 1,function(msg)
|
||
PopupTipPanel.ShowTip(Language[11059])
|
||
-- GuildSkillManager.SetSkillDataLv(msg.type,curSeletSkill.id,msg.curlevel)
|
||
GuildSkillManager.LongLvUpClickBackFun(msg)
|
||
this.OnClickTabBtn(curIndex,true)
|
||
this.RefreshTabRedPoint(curIndex)
|
||
newWarPowerValue = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
||
if oldWarPowerValue ~= newWarPowerValue then
|
||
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldWarPowerValue,newValue = newWarPowerValue})
|
||
oldWarPowerValue = newWarPowerValue
|
||
end
|
||
Game.GlobalEvent:DispatchEvent()
|
||
-- CheckRedPointStatus(RedPointType.Guild_Skill)
|
||
end)
|
||
else
|
||
--前端先扣除材料
|
||
local curUpLvConsume = curSeletSkill.config.Consume
|
||
for i = 1, #curUpLvConsume do
|
||
BagManager.HeroLvUpUpdateItemsNum(curUpLvConsume[i][1],curUpLvConsume[i][2])
|
||
end
|
||
endLv = endLv + 1
|
||
-- GuildSkillManager.SetSkillDataLv(curIndex,curSeletSkill.id,curSeletSkill.level + 1)
|
||
GuildSkillManager.LongLvUpClickBackFun({type = curIndexChangeFun[curIndex],curlevel = endLv})
|
||
this.OnClickTabBtn(curIndex,true)
|
||
this.RefreshTabRedPoint(curIndex)
|
||
Timer.New(function ()
|
||
_isReqLvUp = false
|
||
end,0.3):Start()
|
||
PopupTipPanel.ShowTip(Language[11059])
|
||
end
|
||
end
|
||
--界面关闭时调用(用于子类重写)
|
||
function GuildSkillUpLvPopup:OnClose()
|
||
tabRedPotList = {}
|
||
HeroManager.UpdateHeroPowerProfession()--也许会卡
|
||
GuildSkillManager.UpdataHeroProList = {}
|
||
FixedUpdateBeat:Remove(this.OnUpdate, self)
|
||
end
|
||
|
||
--界面销毁时调用(用于子类重写)
|
||
function GuildSkillUpLvPopup:OnDestroy()
|
||
this.spLoader:Destroy()
|
||
end
|
||
|
||
return GuildSkillUpLvPopup |