2021-10-19 18:34:10 +08:00
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
local Cultivation = Inherit(BasePanel)
|
|
|
|
|
local IMAGE = {
|
|
|
|
|
[1] = "r_hero_jinengdian02",
|
|
|
|
|
[2] = "r_hero_jinengdian04",
|
|
|
|
|
[3] = "r_hero_jinengdian03",
|
|
|
|
|
[4] = "r_hero_jinengdian01",
|
|
|
|
|
}
|
|
|
|
|
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
2021-10-20 13:15:31 +08:00
|
|
|
|
local maxLevel = tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig,133).Value)
|
|
|
|
|
local statePower = tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig,134).Value)
|
2021-10-19 15:34:43 +08:00
|
|
|
|
|
|
|
|
|
function Cultivation:InitComponent()
|
|
|
|
|
self.spLoader = SpriteLoader.New()
|
|
|
|
|
self.mask = Util.GetGameObject(self.gameObject,"Mask")
|
|
|
|
|
self.backBtn = Util.GetGameObject(self.gameObject,"Frame/backBtn")
|
2021-10-20 13:15:31 +08:00
|
|
|
|
self.helpBtn = Util.GetGameObject(self.gameObject,"Frame/helpBtn")
|
|
|
|
|
self.helpPosition = self.helpBtn:GetComponent("RectTransform").localPosition
|
2021-10-19 15:34:43 +08:00
|
|
|
|
self.grid = Util.GetGameObject(self.gameObject,"Frame/Grid")
|
|
|
|
|
self.textPre = Util.GetGameObject(self.grid,"TextPre")
|
2021-10-19 18:34:10 +08:00
|
|
|
|
self.textPre:SetActive(false)
|
2021-10-19 15:34:43 +08:00
|
|
|
|
|
2021-10-19 18:34:10 +08:00
|
|
|
|
self.Slide = Util.GetGameObject(self.gameObject,"Frame/Slide")
|
2021-10-19 15:34:43 +08:00
|
|
|
|
self.level = Util.GetGameObject(self.Slide,"level"):GetComponent("Text")
|
|
|
|
|
self.power = Util.GetGameObject(self.Slide,"powerBtn/value"):GetComponent("Text")
|
2021-10-20 13:15:31 +08:00
|
|
|
|
self.value = Util.GetGameObject(self.Slide,"Text"):GetComponent("Text")
|
|
|
|
|
self.fill = Util.GetGameObject(self.Slide,"fill")
|
2021-10-19 18:34:10 +08:00
|
|
|
|
self.upGradeBtn = Util.GetGameObject(self.Slide,"Button")
|
2021-10-20 13:15:31 +08:00
|
|
|
|
self.btnText = Util.GetGameObject(self.upGradeBtn,"Text"):GetComponent("Text")
|
|
|
|
|
self.btnRed = Util.GetGameObject(self.upGradeBtn,"RedPoint")
|
2021-10-19 15:34:43 +08:00
|
|
|
|
self.textPreList = {}
|
2021-10-19 18:34:10 +08:00
|
|
|
|
self.changeList = {}
|
2021-10-19 15:34:43 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Cultivation:BindEvent()
|
|
|
|
|
--帮助按钮
|
2021-10-20 13:15:31 +08:00
|
|
|
|
Util.AddOnceClick(self.helpBtn, function()
|
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.Cultivation, self.helpPosition.x,self.helpPosition.y)
|
|
|
|
|
end)
|
2021-10-19 18:34:10 +08:00
|
|
|
|
Util.AddOnceClick(self.mask, function()
|
2021-10-19 15:34:43 +08:00
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
2021-10-19 18:34:10 +08:00
|
|
|
|
Util.AddOnceClick(self.backBtn, function()
|
2021-10-19 15:34:43 +08:00
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
2021-10-19 18:34:10 +08:00
|
|
|
|
Util.AddOnceClick(self.upGradeBtn, function()
|
2021-10-20 13:15:31 +08:00
|
|
|
|
if (self.curMaxPower-PracticeManager.CultivationLevel*statePower) < statePower then
|
2021-10-19 18:34:10 +08:00
|
|
|
|
PopupTipPanel.ShowTip("战力不足无法升级!")
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-10-20 13:15:31 +08:00
|
|
|
|
if maxLevel <= PracticeManager.CultivationLevel then
|
|
|
|
|
PopupTipPanel.ShowTip("等级已达上限!")
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
NetManager.PlayerCultivationRequest(function (_level)
|
|
|
|
|
local tempLevel = _level - self.lastLevel
|
2021-10-19 18:34:10 +08:00
|
|
|
|
for i = 1, #self.changeList do
|
2021-10-20 13:15:31 +08:00
|
|
|
|
self.changeList[i]:GetComponent("Text").text = string.format( " + %s",self.configData.ProLevel[i][2]*tempLevel)
|
2021-10-19 18:34:10 +08:00
|
|
|
|
PlayUIAnim(self.changeList[i])
|
|
|
|
|
end
|
|
|
|
|
NetManager.RequestUserForceChange(FormationTypeDef.FORMATION_NORMAL)
|
2021-10-20 13:15:31 +08:00
|
|
|
|
local tempPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
|
|
|
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = self.lastPower,newValue = tempPower})
|
|
|
|
|
self.lastPower = tempPower
|
2021-10-19 18:34:10 +08:00
|
|
|
|
self:OnShow()
|
|
|
|
|
end)
|
2021-10-19 15:34:43 +08:00
|
|
|
|
end)
|
2021-10-20 13:15:31 +08:00
|
|
|
|
BindRedPointObject(RedPointType.Practice_Cultivation,self.btnRed)
|
2021-10-19 15:34:43 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Cultivation:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Cultivation:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Cultivation:OnSortingOrderChange()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Cultivation:OnOpen()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Cultivation:OnShow()
|
2021-10-20 13:15:31 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.Practice_Cultivation)
|
2021-10-19 18:34:10 +08:00
|
|
|
|
--获取当前修行等级的表数据
|
|
|
|
|
FormationManager.UserPowerChanged()
|
|
|
|
|
self.configData = PracticeManager.GetCurConfigData()
|
|
|
|
|
--战力
|
2021-10-20 13:15:31 +08:00
|
|
|
|
self.curMaxPower = PlayerManager.maxForce
|
|
|
|
|
self.lastLevel = PracticeManager.CultivationLevel--上次的等级
|
|
|
|
|
self.lastPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
2021-10-19 18:34:10 +08:00
|
|
|
|
--设置四个属性
|
|
|
|
|
for i = 1, #self.configData.ProRank do
|
|
|
|
|
local go = self.textPreList[i]
|
|
|
|
|
if not go then
|
|
|
|
|
go = newObjToParent(self.textPre,self.grid)
|
|
|
|
|
go:SetActive(true)
|
|
|
|
|
self.textPreList[i] = go
|
|
|
|
|
end
|
|
|
|
|
self:SetSingleData(go,self.configData.ProRank[i],self.configData.ProLevel[i],i)
|
|
|
|
|
end
|
|
|
|
|
--设置等级
|
|
|
|
|
self.level.text = string.format("%s级",PracticeManager.CultivationLevel)
|
2021-10-20 13:15:31 +08:00
|
|
|
|
self.power.text = self.curMaxPower
|
2021-10-19 18:34:10 +08:00
|
|
|
|
--数字
|
2021-10-20 13:15:31 +08:00
|
|
|
|
if maxLevel > PracticeManager.CultivationLevel then
|
|
|
|
|
self.value.text = string.format("%s/%s",self.curMaxPower-statePower*PracticeManager.CultivationLevel,statePower)
|
|
|
|
|
if self.curMaxPower-statePower*PracticeManager.CultivationLevel > statePower then
|
|
|
|
|
self.fill:GetComponent("RectTransform").sizeDelta = Vector3.New(445,26,0)
|
|
|
|
|
else
|
|
|
|
|
local size = (self.curMaxPower%statePower)/statePower
|
|
|
|
|
self.fill:GetComponent("RectTransform").sizeDelta = Vector3.New(445*size,26,0)
|
|
|
|
|
end
|
|
|
|
|
self.btnText.text = "升 级"
|
|
|
|
|
else
|
|
|
|
|
self.value.text = string.format("")
|
|
|
|
|
self.fill:GetComponent("RectTransform").sizeDelta = Vector3.New(445,26,0)
|
|
|
|
|
self.btnText.text = "已达上限"
|
|
|
|
|
end
|
2021-10-19 18:34:10 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--设置单个数据
|
|
|
|
|
function Cultivation:SetSingleData(_go,data1,_data2,_index)
|
|
|
|
|
local proImg = Util.GetGameObject(_go,"Property"):GetComponent("Image")
|
|
|
|
|
local proName = Util.GetGameObject(_go,"PropertyName"):GetComponent("Text")
|
|
|
|
|
local Value = Util.GetGameObject(_go,"Value"):GetComponent("Text")
|
|
|
|
|
local Calculate = Util.GetGameObject(_go,"Calculate"):GetComponent("Text")
|
|
|
|
|
self.changeList[_index] = Util.GetGameObject(_go,"change")
|
|
|
|
|
|
|
|
|
|
proImg.sprite = self.spLoader:LoadSprite(IMAGE[_index])
|
|
|
|
|
if PracticeManager.CultivationLevel == 0 then
|
|
|
|
|
proName.text = string.format("%s:",propertyConfig[data1[1]].Info)
|
|
|
|
|
Value.text = string.format("0")
|
|
|
|
|
Calculate.text = string.format("")
|
|
|
|
|
else
|
|
|
|
|
proName.text = string.format("%s:",propertyConfig[data1[1]].Info)
|
|
|
|
|
Value.text = string.format("%s",data1[2]+_data2[2]*PracticeManager.CultivationLevel)
|
2021-10-20 13:15:31 +08:00
|
|
|
|
Calculate.text = string.format(" (%s + %s×%s)",data1[2],_data2[2],PracticeManager.CultivationLevel)
|
2021-10-19 18:34:10 +08:00
|
|
|
|
end
|
|
|
|
|
ForceRebuildLayout(_go.transform)
|
2021-10-19 15:34:43 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Cultivation:OnClose()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Cultivation:OnDestroy()
|
|
|
|
|
self.spLoader:Destroy()
|
2021-10-19 18:34:10 +08:00
|
|
|
|
self.textPreList = {}
|
2021-10-20 13:15:31 +08:00
|
|
|
|
self.changeList = {}
|
|
|
|
|
ClearRedPointObject(RedPointType.Practice_Cultivation,self.btnRed)
|
2021-10-19 15:34:43 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return Cultivation
|