Files
Main/Assets/GameAssets/Resources/Lua/Logic/Nature/NatureWingsData.lua

180 lines
5.9 KiB
Lua
Raw Normal View History

2025-01-25 04:38:09 +08:00
--作者: xc
--日期: 2019-04-18
--文件: NatureWingsData.lua
--模块: NatureWingsData
--描述: 翅膀数据系统子类继承NatureBaseData
------------------------------------------------
local NatureBase = require "Logic.Nature.NatureBaseData"
local SkillSetDate = require "Logic.Nature.NatureSkillSetData"
local ModelData= require "Logic.Nature.NatureBaseModelData"
local FashionData = require "Logic.Nature.NatureFashionData"
local NatureWingsData = {
Cfg = nil , --翅膀配置表数据
IsMax = 0, --翅膀最大等级
super = nil, --父类对象
}
function NatureWingsData:New()
local _obj = NatureBase:New(NatureEnum.Wing)
local _M = Utils.DeepCopy(self)
_M.super = _obj
return _M
end
--初始化技能
function NatureWingsData:Initialize()
DataConfig.DataNatureWing:Foreach(function(k, v)
if v.Skill and v.Skill ~= "" then
local _cs = {'_'}
local _skill = Utils.SplitStrByTable(v.Skill,_cs)
local skilllevel = tonumber(_skill[2])
if _skill and #_skill >= 2 and skilllevel == 1 then
local _data = SkillSetDate:New(v)
self.super.SkillList:Add(_data)
elseif _skill and #_skill >= 2 then
self.super.AllSkillList:Add(v)
end
end
if v.ModelID ~= 0 then
local _data = ModelData:New(v,self.super.NatureType)
self.super.ModelList:Add(_data)
end
if self.IsMax < v.Id then
self.IsMax = v.Id
end
end)
self.super.AllSkillList:Sort(
function(a,b)
return tonumber(a.Id) < tonumber(b.Id)
end
)
self.super.SkillList:Sort(
function(a,b)
if a.SkillInfo and b.SkillInfo then
return tonumber(a.SkillInfo.Id) < tonumber(b.SkillInfo.Id)
end
return true
end
)
self.super.ModelList:Sort(
function(a,b)
return tonumber(a.Stage) < tonumber(b.Stage)
end
)
--初始化化形数据
DataConfig.DataHuaxingWing:Foreach(function(k, v)
if v.IfFashion == 1 and v.IsIgnore == 1 then
local _data = FashionData:New(v)
self.super.FishionList:Add(_data)
end
end)
self.super.FishionList:Sort(
function(a,b)
return tonumber(a.SortNum) < tonumber(b.SortNum)
end
)
GameCenter.RegFixEventHandle(LogicEventDefine.EID_EVENT_ONLINE_ITEMINFO, self.ItemsChange, self)
GameCenter.RegFixEventHandle(LogicEventDefine.EVENT_WINGLV_ITEM_CHANGE, self.ItemsChange, self)
end
--反初始化
function NatureWingsData:UnInitialize()
self.Cfg = nil
self.super = nil
self.IsMax = 0
GameCenter.UnRegFixEventHandle(LogicEventDefine.EID_EVENT_ONLINE_ITEMINFO, self.ItemsChange, self)
GameCenter.UnRegFixEventHandle(LogicEventDefine.EVENT_WINGLV_ITEM_CHANGE, self.ItemsChange, self)
end
function NatureWingsData:ItemsChange()
if self.super then
self.super:UpdateLvRed(FunctionStartIdCode.NatureWingLevel)
end
end
--初始化服务器数据
function NatureWingsData:InitWingInfo(msg)
if msg and msg.natureInfo then
self.Cfg = DataConfig.DataNatureWing[msg.natureInfo.curLevel]
self.super:UpDateSkill(msg.natureInfo.haveActiveSkill) --设置技能
self.super:UpDateModel(msg.natureInfo.haveActiveModel) --设置模型
self.super:UpDataFashionInfos(msg.natureInfo.outlineInfo) --设置化形
if self.Cfg then
self.super:AnalysisAttr(self.Cfg.Attribute)
self.super:AnalysisItem(self.Cfg.UpItem)
self.super:Parase(msg.natureType,msg.natureInfo)
local _num = self.Cfg.Progress - self.super.CurExp
self.super:UpDateLevelHit(FunctionStartIdCode.NatureWingLevel, self.IsMax, _num, LogicEventDefine.EVENT_WINGLV_ITEM_CHANGE)
end
self.super:UpDateDrugHit(FunctionStartIdCode.NatureWingDrug)
self.super:UpDateFashionHit(FunctionStartIdCode.NatureWingFashion)
if msg.natureInfo.modelId > 0 then
self:UpDateModelId(msg.natureInfo.modelId)
end
end
end
--更新技能升级
function NatureWingsData:UpDateUpLevel(msg)
if msg.activeSkill then
self.super:UpDateSkill(msg.activeSkill)
end
self.super.Level = msg.level
self.Cfg = DataConfig.DataNatureWing[msg.level]
if self.Cfg then
self.super:AnalysisAttr(self.Cfg.Attribute)
end
if msg.activeModel then
self.super:UpDateModel(msg.activeModel)
end
self.super.CurExp = msg.curexp
self.super.Fight = msg.fight
local _num = self.Cfg.Progress - self.super.CurExp
self.super:UpDateLevelHit(FunctionStartIdCode.NatureWingLevel, self.IsMax, _num, LogicEventDefine.EVENT_WINGLV_ITEM_CHANGE)
end
--更新吃果子信息
function NatureWingsData:UpDateGrugInfo(msg)
self.super.Fight = msg.fight
self.super:UpDateDrug(msg.druginfo)
self.super:UpDateDrugHit(FunctionStartIdCode.NatureWingDrug)
end
--更新设置模型ID
function NatureWingsData:UpDateModelId(model)
self.super.CurModel = model
end
--更新化形升级结果
function NatureWingsData:UpDateFashionInfo(msg)
local _config = DataConfig.DataHuaxingWing[msg.id]
self.super:UpDataFashion(msg,_config)
self.super:UpDateFashionHit(FunctionStartIdCode.NatureWingFashion)
end
--功能函数!!!!!!!!!!!!!!!
--翅膀是否满级了
function NatureWingsData:IsMaxLevel()
return self.IsMax <= self.super.Level
end
--获取模型相机大小
function NatureWingsData:Get3DUICamerSize(modelid)
local _info = DataConfig.DataHuaxingWing[modelid]
if _info then
return _info.CameraSize
end
return self.super:GetCameraSize(modelid)
end
function NatureWingsData:GetModelYPosition(modelid)
local _info = DataConfig.DataHuaxingWing[modelid]
if _info and _info.ModelYPos then
return _info.ModelYPos / self:Get3DUICamerSize(modelid)
end
return 0
end
return NatureWingsData