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[1] },
[2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = GuildSkillType[2] },
[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 curSeletSkill = {}
local allSkillData = {}
local materialNoId = 0
local endLv = 0
local isMaxLv = true
local proInfo = {
[61] = Language[11079],
[62] = Language[11080],
[51] = Language[11081],
[52] = Language[11082],
[55] = Language[11083],
[56] = Language[11084],
}
local tabRedPotList = {}
local oldWarPowerValue = 0
local newWarPowerValue = 0
--初始化组件(用于子类重写)
function GuildSkillUpLvPopup:InitComponent()
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()
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 materialNoId > 0 then
PopupTipPanel.ShowTip(ConfigManager.GetConfigData(ConfigName.ItemConfig,materialNoId).Name..Language[11085])
return
end
NetManager.SinGleGuildSkillUpLv(curIndex,function(msg)
PopupTipPanel.ShowTip(Language[11086])
GuildSkillManager.SetSkillDataLv(curIndex,curSeletSkill.id,curSeletSkill.level + 1)
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})
Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnChangeName)
oldWarPowerValue = newWarPowerValue
end
Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnChangeName)
-- CheckRedPointStatus(RedPointType.Guild_Skill)
end)
end)
Util.AddClick(this.btnRest,function()
if endLv <= 0 then
PopupTipPanel.ShowTip(Language[11087])
return
end
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.GuildSkill,
GuildSkillManager.GetResetGetDrop(curIndex),curIndex,function()
-- CheckRedPointStatus(RedPointType.Guild_Skill)
GuildSkillManager.ResetGuildSkillData(curIndex)
this.OnClickTabBtn(curIndex,true)
this.RefreshTabRedPoint()
Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnChangeName)
end)
end)
end
--添加事件监听(用于子类重写)
function GuildSkillUpLvPopup:AddListener()
end
--移除事件监听(用于子类重写)
function GuildSkillUpLvPopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function GuildSkillUpLvPopup:OnOpen(_curIndex)
curIndex = _curIndex or 1
tabRedPotList = {}
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
-- tab节点显示自定义
function this.TabAdapter(tab, index, status)
local tabLab = Util.GetGameObject(tab, "Text")
local tabImage = Util.GetGameObject(tab,"Image")
tabImage:GetComponent("Image").sprite = Util.LoadSprite(_TabData[index][status])
tabLab:GetComponent("Text").text = _TabData[index].name
tabLab:GetComponent("Text").color = _TabFontColor[status]
Util.GetGameObject(tab, "Redpot"):SetActive(GuildSkillManager.GuildSkillRedPoint(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(curIndex,1)
CheckRedPointStatus(RedPointType.Guild_Skill)
isMaxLv = true
allSkillData = GuildSkillManager.GetSkillDataByType(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",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[11088].._TabData[curIndex].name
local isEqualityLv,maxLv
endLv,isEqualityLv,maxLv = GuildSkillManager.GetAllGuildSkillLv(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[11089]
else
this.btnUpLv:GetComponent("Button").enabled=true
Util.GetGameObject(this.btnUpLv,"Text"):GetComponent("Text").text = Language[11090]
end
this.skillAllLv.text = Language[11091]..endLv
for i = 1, #allSkillData do
local skillGo = skills[i]
if skillGo then
if not isNoLoadSprite then
Util.GetGameObject(skillGo,"icon"):GetComponent("Image").sprite = Util.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 = 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",curIndex,"TechId",curSeletSkill.id,"Level",curSeletSkill.level + 1)
local addValue = ""
if config then
addValue = "+"..GetPropertyFormatStrOne(propertyConfig.Style, config.Values[2] - allSkillData[i].config.Values[2])..""
end
proGo:GetComponent("Text").text = proInfoStr.. ":" .. "\t\t" .. GetPropertyFormatStrOne(propertyConfig.Style, allSkillData[i].config.Values[2]) ..addValue
else
proGo:GetComponent("Text").text = proInfoStr.. ":" .. "\t\t" .. 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 =
Util.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 ="".. consume[2]..""
else
materalGo:GetComponent("Text").text ="".. consume[2]..""
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[i]:SetActive(GuildSkillManager.GuildSkillRedPoint(i))
end
end
end
--界面关闭时调用(用于子类重写)
function GuildSkillUpLvPopup:OnClose()
tabRedPotList = {}
end
--界面销毁时调用(用于子类重写)
function GuildSkillUpLvPopup:OnDestroy()
end
return GuildSkillUpLvPopup