2020-08-25 15:46:38 +08:00
|
|
|
|
require("Base/BasePanel")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
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
|
2020-05-25 19:16:23 +08:00
|
|
|
|
local proInfo = {
|
2020-06-23 18:36:24 +08:00
|
|
|
|
[61] = Language[11079],
|
|
|
|
|
[62] = Language[11080],
|
|
|
|
|
[51] = Language[11081],
|
|
|
|
|
[52] = Language[11082],
|
|
|
|
|
[55] = Language[11083],
|
|
|
|
|
[56] = Language[11084],
|
2020-05-25 19:16:23 +08:00
|
|
|
|
}
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local tabRedPotList = {}
|
2020-06-13 11:47:13 +08:00
|
|
|
|
local oldWarPowerValue = 0
|
|
|
|
|
local newWarPowerValue = 0
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
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()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.GuildSkill,this.helpPos.x,this.helpPos.y)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(this.backBtn,function()
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(this.btnUpLv,function()
|
|
|
|
|
if materialNoId > 0 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(ConfigManager.GetConfigData(ConfigName.ItemConfig,materialNoId).Name..Language[11085])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
NetManager.SinGleGuildSkillUpLv(curIndex,function(msg)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11086])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
GuildSkillManager.SetSkillDataLv(curIndex,curSeletSkill.id,curSeletSkill.level + 1)
|
2020-08-04 18:37:30 +08:00
|
|
|
|
this.OnClickTabBtn(curIndex,true)
|
|
|
|
|
this.RefreshTabRedPoint(curIndex)
|
2020-06-13 11:47:13 +08:00
|
|
|
|
newWarPowerValue = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
|
|
|
if oldWarPowerValue ~= newWarPowerValue then
|
|
|
|
|
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldWarPowerValue,newValue = newWarPowerValue})
|
2020-06-18 20:39:29 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnChangeName)
|
2020-06-19 20:19:35 +08:00
|
|
|
|
oldWarPowerValue = newWarPowerValue
|
2020-06-13 11:47:13 +08:00
|
|
|
|
end
|
2020-06-19 20:19:35 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnChangeName)
|
2020-08-04 18:37:30 +08:00
|
|
|
|
-- CheckRedPointStatus(RedPointType.Guild_Skill)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(this.btnRest,function()
|
|
|
|
|
if endLv <= 0 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11087])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.GuildSkill,
|
|
|
|
|
GuildSkillManager.GetResetGetDrop(curIndex),curIndex,function()
|
2020-08-04 18:37:30 +08:00
|
|
|
|
-- CheckRedPointStatus(RedPointType.Guild_Skill)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
GuildSkillManager.ResetGuildSkillData(curIndex)
|
2020-08-04 18:37:30 +08:00
|
|
|
|
this.OnClickTabBtn(curIndex,true)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
this.RefreshTabRedPoint()
|
2020-06-19 20:19:35 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnChangeName)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function GuildSkillUpLvPopup:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function GuildSkillUpLvPopup:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function GuildSkillUpLvPopup:OnOpen(_curIndex)
|
|
|
|
|
curIndex = _curIndex or 1
|
2020-06-03 19:09:01 +08:00
|
|
|
|
tabRedPotList = {}
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
|
|
|
function GuildSkillUpLvPopup:OnShow()
|
|
|
|
|
this.TabCtrl:SetTabAdapter(this.TabAdapter)
|
|
|
|
|
this.TabCtrl:SetChangeTabCallBack(this.SwitchView)
|
|
|
|
|
this.TabCtrl:Init(this.tabBox, _TabData,curIndex)
|
2020-06-13 11:47:13 +08:00
|
|
|
|
oldWarPowerValue = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
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]
|
2020-06-03 19:09:01 +08:00
|
|
|
|
Util.GetGameObject(tab, "Redpot"):SetActive(GuildSkillManager.GuildSkillRedPoint(index))
|
|
|
|
|
if #tabRedPotList < 4 then
|
|
|
|
|
table.insert(tabRedPotList,Util.GetGameObject(tab, "Redpot"))
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
--切换视图
|
|
|
|
|
function this.SwitchView(index)
|
|
|
|
|
this.OnClickTabBtn(index)
|
|
|
|
|
end
|
2020-08-04 18:37:30 +08:00
|
|
|
|
function this.OnClickTabBtn(index,isNoLoadSprite)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--数据组拼
|
|
|
|
|
curIndex = index
|
2020-06-03 19:09:01 +08:00
|
|
|
|
GuildSkillManager.SetGuildSkillRedPlayers(curIndex,1)
|
|
|
|
|
CheckRedPointStatus(RedPointType.Guild_Skill)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
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
|
2020-08-04 18:37:30 +08:00
|
|
|
|
this.ShowSkillsAndPros(isNoLoadSprite)--展示技能 展示属性
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.ShowMaterials()--展示消耗材料 及 按钮状态
|
|
|
|
|
end
|
|
|
|
|
--展示技能
|
2020-08-04 18:37:30 +08:00
|
|
|
|
function this.ShowSkillsAndPros(isNoLoadSprite)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
this.titleText.text = Language[11088].._TabData[curIndex].name
|
2020-06-13 11:47:13 +08:00
|
|
|
|
local isEqualityLv,maxLv
|
|
|
|
|
endLv,isEqualityLv,maxLv = GuildSkillManager.GetAllGuildSkillLv(curIndex)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
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
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Util.GetGameObject(this.btnUpLv,"Text"):GetComponent("Text").text = Language[11089]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
|
|
|
|
this.btnUpLv:GetComponent("Button").enabled=true
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Util.GetGameObject(this.btnUpLv,"Text"):GetComponent("Text").text = Language[11090]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-06-23 18:36:24 +08:00
|
|
|
|
this.skillAllLv.text = Language[11091]..endLv
|
2020-06-13 11:47:13 +08:00
|
|
|
|
for i = 1, #allSkillData do
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local skillGo = skills[i]
|
|
|
|
|
if skillGo then
|
2020-08-04 18:37:30 +08:00
|
|
|
|
if not isNoLoadSprite then
|
|
|
|
|
Util.GetGameObject(skillGo,"icon"):GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(allSkillData[i].config.Icon))
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
Util.GetGameObject(skillGo,"lvImage/Text"):GetComponent("Text").text = allSkillData[i].level
|
2020-06-13 11:47:13 +08:00
|
|
|
|
if isEqualityLv then
|
|
|
|
|
Util.SetGray(skillGo, true)
|
|
|
|
|
elseif allSkillData[i].level > 0 and allSkillData[i].level >= maxLv then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
Util.SetGray(skillGo, false)
|
|
|
|
|
else
|
|
|
|
|
--if curSeletSkill.id == allSkillData[i].id then
|
|
|
|
|
-- Util.SetGray(skillGo, false)
|
|
|
|
|
--else
|
2020-06-13 11:47:13 +08:00
|
|
|
|
Util.SetGray(skillGo, true)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--end
|
|
|
|
|
end
|
2020-06-13 11:47:13 +08:00
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local proGo = pros[i]
|
|
|
|
|
if proGo then
|
|
|
|
|
local propertyConfig = ConfigManager.GetConfigData(ConfigName.PropertyConfig, allSkillData[i].config.Values[1])
|
2020-05-25 19:16:23 +08:00
|
|
|
|
local proInfoStr = propertyConfig.Info
|
|
|
|
|
if proInfo[propertyConfig.PropertyId] then
|
|
|
|
|
proInfoStr = proInfo[propertyConfig.PropertyId]
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
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
|
2020-06-03 19:09:01 +08:00
|
|
|
|
addValue = "<color=#529864>+"..GetPropertyFormatStrOne(propertyConfig.Style, config.Values[2] - allSkillData[i].config.Values[2]).."</color>"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-05-25 19:16:23 +08:00
|
|
|
|
proGo:GetComponent("Text").text = proInfoStr.. ":" .. "\t\t" .. GetPropertyFormatStrOne(propertyConfig.Style, allSkillData[i].config.Values[2]) ..addValue
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2020-05-25 19:16:23 +08:00
|
|
|
|
proGo:GetComponent("Text").text = proInfoStr.. ":" .. "\t\t" .. GetPropertyFormatStrOne(propertyConfig.Style, allSkillData[i].config.Values[2])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
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))
|
2020-06-13 11:47:13 +08:00
|
|
|
|
materalGo:GetComponent("Text").text = PrintWanNum3(consume[2])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
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
|
2020-08-04 18:37:30 +08:00
|
|
|
|
function this.RefreshTabRedPoint(index)
|
|
|
|
|
if index then
|
|
|
|
|
tabRedPotList[index]:SetActive(false)
|
|
|
|
|
else
|
2020-06-03 19:09:01 +08:00
|
|
|
|
for i = 1, #tabRedPotList do
|
|
|
|
|
tabRedPotList[i]:SetActive(GuildSkillManager.GuildSkillRedPoint(i))
|
|
|
|
|
end
|
2020-08-04 18:37:30 +08:00
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function GuildSkillUpLvPopup:OnClose()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
tabRedPotList = {}
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function GuildSkillUpLvPopup:OnDestroy()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return GuildSkillUpLvPopup
|