miduo_client/Assets/ManagedResources/~Lua/Modules/Guild/Skill/GuildSkillUpLvPopup.lua

380 lines
16 KiB
Lua
Raw Normal View History

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[2] },
[2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = GuildSkillType[1] },
2020-05-09 13:31:21 +08:00
[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,
}
2020-05-09 13:31:21 +08:00
local curSeletSkill = {}
local allSkillData = {}
local materialNoId = 0
local endLv = 0
local isMaxLv = true
2020-05-25 19:16:23 +08:00
local proInfo = {
2021-03-02 16:53:12 +08:00
[61] = Language[11052],
[62] = Language[11053],
[51] = Language[11054],
[52] = Language[11055],
[55] = Language[11056],
[56] = "暴伤加成",
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-12-29 16:15:11 +08:00
local oldLv
--长按升级状态
local _isClicked = false
local _isReqLvUp = false
local _isLongPress = false
this.timePressStarted = 0--监听长按事件
this.priThread = nil--协同程序播放升级属性提升值动画用
local isTriggerLongClick = false--长按是否升过级
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function GuildSkillUpLvPopup:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
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()
2020-12-29 16:15:11 +08:00
this.upLvTrigger = Util.GetEventTriggerListener(this.btnUpLv)
2020-05-09 13:31:21 +08:00
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()
2020-12-29 16:15:11 +08:00
if Time.realtimeSinceStartup - this.timePressStarted <= 0.4 then
this.LvUpClick(true)
2020-05-09 13:31:21 +08:00
end
end)
2020-12-29 16:15:11 +08:00
--长按升级按下状态
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)
2020-12-31 15:29:08 +08:00
-- LogPink("连续升级抬起请求升级 "..tostring(_isLongPress))
2020-12-29 16:15:11 +08:00
if _isLongPress then--and isTriggerLongClick
--连续升级抬起请求升级
2020-12-31 15:29:08 +08:00
-- LogPink("连续升级抬起请求升级 ")
2020-12-29 16:15:11 +08:00
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
2020-05-09 13:31:21 +08:00
Util.AddClick(this.btnRest,function()
if endLv <= 0 then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11060])
2020-05-09 13:31:21 +08:00
return
end
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.GuildSkill,
GuildSkillManager.GetResetGetDrop(curIndexChangeFun[curIndex]),curIndexChangeFun[curIndex],function()
2020-08-04 18:37:30 +08:00
-- CheckRedPointStatus(RedPointType.Guild_Skill)
GuildSkillManager.ResetGuildSkillData(curIndexChangeFun[curIndex])
2020-12-29 16:15:11 +08:00
this.OnClickTabBtn(curIndex,true)
2020-06-03 19:09:01 +08:00
this.RefreshTabRedPoint()
2020-12-31 15:29:08 +08:00
oldWarPowerValue = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
2020-05-09 13:31:21 +08:00
end)
end)
end
--添加事件监听(用于子类重写)
function GuildSkillUpLvPopup:AddListener()
end
--移除事件监听(用于子类重写)
function GuildSkillUpLvPopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function GuildSkillUpLvPopup:OnOpen(_curIndex)
2020-08-29 16:23:31 +08:00
GuildSkillManager.UpdataHeroProList = {}
2020-05-09 13:31:21 +08:00
curIndex = _curIndex or 1
2020-06-03 19:09:01 +08:00
tabRedPotList = {}
2020-12-31 15:29:08 +08:00
FixedUpdateBeat:Add(this.OnUpdate, self)--长按方法注册
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
2020-12-29 16:15:11 +08:00
--长按升级处理
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
2020-05-09 13:31:21 +08:00
-- tab节点显示自定义
function this.TabAdapter(tab, index, status)
local tabLab = Util.GetGameObject(tab, "Text")
local tabImage = Util.GetGameObject(tab,"Image")
2021-04-21 13:12:04 +08:00
tabImage:GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabData[index][status])
2020-05-09 13:31:21 +08:00
tabLab:GetComponent("Text").text = _TabData[index].name
tabLab:GetComponent("Text").color = _TabFontColor[status]
Util.GetGameObject(tab, "Redpot"):SetActive(GuildSkillManager.GuildSkillRedPoint(curIndexChangeFun[index]))
2020-06-03 19:09:01 +08:00
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
GuildSkillManager.SetGuildSkillRedPlayers(curIndexChangeFun[curIndex],1)
2020-06-03 19:09:01 +08:00
CheckRedPointStatus(RedPointType.Guild_Skill)
2020-05-09 13:31:21 +08:00
isMaxLv = true
allSkillData = GuildSkillManager.GetSkillDataByType(curIndexChangeFun[curIndex])
2020-05-09 13:31:21 +08:00
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)
2020-05-09 13:31:21 +08:00
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)
2021-03-02 16:53:12 +08:00
this.titleText.text = Language[11061].._TabData[curIndex].name
2020-06-13 11:47:13 +08:00
local isEqualityLv,maxLv
endLv,isEqualityLv,maxLv = GuildSkillManager.GetAllGuildSkillLv(curIndexChangeFun[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
2021-03-02 16:53:12 +08:00
Util.GetGameObject(this.btnUpLv,"Text"):GetComponent("Text").text = Language[11062]
2020-05-09 13:31:21 +08:00
else
this.btnUpLv:GetComponent("Button").enabled=true
2021-03-02 16:53:12 +08:00
Util.GetGameObject(this.btnUpLv,"Text"):GetComponent("Text").text = Language[11063]
2020-05-09 13:31:21 +08:00
end
2021-03-02 16:53:12 +08:00
this.skillAllLv.text = Language[11064]..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
2021-04-21 13:12:04 +08:00
Util.GetGameObject(skillGo,"icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(allSkillData[i].config.Icon))
2020-08-04 18:37:30 +08:00
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])
2021-01-26 17:08:39 +08:00
local proInfoStr = GetLanguageStrById(propertyConfig.Info)
2020-05-25 19:16:23 +08:00
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",curIndexChangeFun[curIndex],"TechId",curSeletSkill.id,"Level",curSeletSkill.level + 1)
2020-05-09 13:31:21 +08:00
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
2021-02-24 10:21:44 +08:00
proGo:GetComponent("Text").text = proInfoStr.. "" .. GetPropertyFormatStrOne(propertyConfig.Style, allSkillData[i].config.Values[2]) ..addValue
2020-05-09 13:31:21 +08:00
else
2021-02-24 10:21:44 +08:00
proGo:GetComponent("Text").text = proInfoStr.. "" .. 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 =
2021-04-21 13:12:04 +08:00
this.spLoader: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[curIndexChangeFun[i]]:SetActive(GuildSkillManager.GuildSkillRedPoint(curIndexChangeFun[i]))
2020-06-03 19:09:01 +08:00
end
2020-08-04 18:37:30 +08:00
end
2020-06-03 19:09:01 +08:00
end
2020-12-29 16:15:11 +08:00
--长按升级结束后请求协议
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
2020-12-31 15:29:08 +08:00
newWarPowerValue = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
2020-12-29 16:15:11 +08:00
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
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.ItemConfig,materialNoId).Name).." "..Language[11058])
2020-12-29 16:15:11 +08:00
if not isSingleLvUp then
this.LongLvUpClick(oldLv)
end
2020-12-31 15:53:05 +08:00
_isClicked = false
_isLongPress = false
2020-12-29 16:15:11 +08:00
return
end
if isMaxLv then
if not isSingleLvUp then
this.LongLvUpClick(oldLv)
end
2020-12-31 15:53:05 +08:00
_isClicked = false
_isLongPress = false
2020-12-29 16:15:11 +08:00
return
end
if isSingleLvUp then
NetManager.SinGleGuildSkillUpLv(curIndexChangeFun[curIndex],endLv,endLv + 1,function(msg)
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11059])
2020-12-29 16:15:11 +08:00
-- 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()
2020-12-31 15:29:08 +08:00
-- CheckRedPointStatus(RedPointType.Guild_Skill)
2020-12-29 16:15:11 +08:00
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()
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11059])
2020-12-29 16:15:11 +08:00
end
end
2020-05-09 13:31:21 +08:00
--界面关闭时调用(用于子类重写)
function GuildSkillUpLvPopup:OnClose()
2020-06-03 19:09:01 +08:00
tabRedPotList = {}
HeroManager.UpdateHeroPowerProfession()--也许会卡
2020-08-29 16:23:31 +08:00
GuildSkillManager.UpdataHeroProList = {}
2020-12-29 16:15:11 +08:00
FixedUpdateBeat:Remove(this.OnUpdate, self)
2020-05-09 13:31:21 +08:00
end
--界面销毁时调用(用于子类重写)
function GuildSkillUpLvPopup:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
end
return GuildSkillUpLvPopup