Files
Main/Assets/GameAssets/Resources/Lua/Logic/Nature/NatureMountData.lua
2025-01-25 04:38:09 +08:00

303 lines
9.9 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--作者: xc
--日期: 2019-04-18
--文件: NatureMountData.lua
--模块: NatureMountData
--描述: 坐骑数据系统子类继承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 BaseAttrData = require "Logic.Nature.NatureBaseAttrData"
local BaseItemData = require "Logic.Nature.NatureBaseItemData"
local RedPointCustomCondition = CS.Thousandto.Code.Logic.RedPointCustomCondition
local LocalPlayerRoot = CS.Thousandto.Code.Logic.LocalPlayerRoot
local NatureMountData = {
Cfg = nil , --坐骑配置表数据
IsMax = 0, --升级最大等级
super = nil, --父类对象
BaseCfg = nil, --基础属性配置表
BaseExp = 0, --基础属性经验值,进度条
BaseIsMax = 0, --基础属性最大等级
BaseAttrList = List:New(), --属性列表存储NatureBaseAttrData
BaseStarDir = Dictionary:New(),--阶数对应的最大星数
BaseItemList = List:New(), --可以吃的道具
}
function NatureMountData:New()
local _obj = NatureBase:New(NatureEnum.Mount)
local _M = Utils.DeepCopy(self)
_M.super = _obj
return _M
end
--初始化技能
function NatureMountData:Initialize()
DataConfig.DataNatureHorse:Foreach(function(k, v)
if 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)
_data.NeedLevel = v.Steps
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.BaseStarDir:ContainsKey(v.Steps) then
if self.BaseStarDir[v.Steps] < v.Star then
self.BaseStarDir[v.Steps] = v.Star
end
else
self.BaseStarDir:Add(v.Steps,v.Star)
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.DataHuaxingHorse: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_MOUNTLV_ITEM_CHANGE, self.ItemsChange, self)
end
--反初始化
function NatureMountData:UnInitialize()
self.Cfg = nil
self.super = nil
self.IsMax = 0
self.BaseCfg = nil
self.BaseExp = 0
self.BaseIsMax = 0
self.BaseAttrList:Clear()
GameCenter.UnRegFixEventHandle(LogicEventDefine.EID_EVENT_ONLINE_ITEMINFO, self.ItemsChange, self)
GameCenter.UnRegFixEventHandle(LogicEventDefine.EVENT_MOUNTLV_ITEM_CHANGE, self.ItemsChange, self)
end
--初始化服务器数据
function NatureMountData:InitWingInfo(msg)
if msg and msg.natureInfo then
self.Cfg = DataConfig.DataNatureHorse[msg.natureInfo.curLevel]
--self.BaseCfg = DataConfig.DataHorseBasic[msg.natureInfo.mountinfo.Level]
--self.BaseExp = msg.natureInfo.mountinfo.Exp
--self.super.CurModel = msg.natureInfo.modelId
self.super:UpDateSkill(msg.natureInfo.haveActiveSkill) --设置技能
self.super:UpDateModel(msg.natureInfo.haveActiveModel) --设置模型
self.super:UpDataFashionInfos(msg.natureInfo.outlineInfo) --设置化形
if self.BaseCfg then
self:AnalysisAttr(self.BaseCfg.Attribute)
end
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.MountLevel, self.IsMax, _num, LogicEventDefine.EVENT_MOUNTLV_ITEM_CHANGE)
end
self.super:UpDateDrugHit(FunctionStartIdCode.MountDrug)
self.super:UpDateFashionHit(FunctionStartIdCode.MountFashion)
self:UpDateModelId(msg.natureInfo.modelId)
end
end
--更新基础属性升级
function NatureMountData:UpDateBaseAttr(msg)
self.super.Fight = msg.fight
self.BaseCfg = DataConfig.DataHorseBasic[msg.info.Level]
self.BaseExp = msg.info.Exp
if self.BaseCfg then
self:AnalysisAttr(self.BaseCfg.Attribute)
end
end
--更新技能升级
function NatureMountData:UpDateUpLevel(msg)
if msg.activeSkill then
self.super:UpDateSkill(msg.activeSkill)
end
self.super.Level = msg.level
self.Cfg = DataConfig.DataNatureHorse[msg.level]
if self.Cfg then
self.super:AnalysisAttr(self.Cfg.Attribute)
end
if msg.activeModel then
-- for i = 1, #msg.activeModel do
-- local _data = self.super:GetModelData(msg.activeModel[i])
-- if _data and not _data.IsActive then
-- GameCenter.ModelViewSystem:ShowModel(ShowModelType.Mount, msg.activeModel[i], 160, 0, self.super:GetModelsName(msg.activeModel[i]))
-- end
-- end
self.super:UpDateModel(msg.activeModel)
end
self.super.CurExp = msg.curexp
self.super.Fight = msg.fight
self.super:UpDateLevelHit(FunctionStartIdCode.MountLevel,self.IsMax, self.Cfg.Progress - msg.curexp, LogicEventDefine.EVENT_MOUNTLV_ITEM_CHANGE)
end
--更新吃果子信息
function NatureMountData:UpDateGrugInfo(msg)
self.super.Fight = msg.fight
self.super:UpDateDrug(msg.druginfo)
self.super:UpDateDrugHit(FunctionStartIdCode.MountDrug)
end
--更新设置模型ID
function NatureMountData:UpDateModelId(model)
self.super.CurModel = model
if model ~= nil and type(model) == "number" then
LocalPlayerRoot.CurMountId = model
else
LocalPlayerRoot.CurMountId = 0
end
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_UPDATMOUNTRIDE_STATE)
end
--更新化形升级结果
function NatureMountData:UpDateFashionInfo(msg)
local _info = DataConfig.DataHuaxingHorse[msg.id]
self.super:UpDataFashion(msg,_info)
self.super:UpDateFashionHit(FunctionStartIdCode.MountFashion)
end
function NatureMountData:ItemsChange()
if self.super then
self.super:UpdateLvRed(FunctionStartIdCode.MountLevel)
end
end
--功能函数!!!!!!!!!!!!!!!
--得到当前阶段中最大星数
function NatureMountData:GetCurMaxStar()
if self.BaseStarDir:ContainsKey(self.Cfg.Steps) then
return self.BaseStarDir[self.Cfg.Steps]
end
return 0
end
function NatureMountData:AnalysisAttr(str)
self.BaseAttrList:Clear()
if str then
local _cs = {';','_'}
local _attr = Utils.SplitStrByTableS(str,_cs)
for i=1,#_attr do
local _data = BaseAttrData:New(_attr[i][1],_attr[i][2],_attr[i][3])
self.BaseAttrList:Add(_data)
end
end
end
--得到道具经验
function NatureMountData:GetItemExp(itemid)
local _isHave = self.BaseItemList:Find(
function(code)
return code.ItemID == itemid
end
)
if _isHave then
return _isHave.ItemExp
end
return 0
end
--可以吃的道具
function NatureMountData:AnalysisItem(str)
self.BaseItemList:Clear()
if str then
local _attr = Utils.SplitStr(str,'_')
for i=1,#_attr do
local _itemid = tonumber(_attr[i])
local _itemInfo = DataConfig.DataItem[_itemid]
if _itemInfo then
local _value = Utils.SplitStr(_itemInfo.EffectNum,'_')
if _value[2] then
local _data = BaseItemData:New(_itemid,tonumber(_value[2]))
self.BaseItemList:Add(_data)
end
end
end
end
end
--是否满级了
function NatureMountData:IsMaxLevel()
return self.IsMax <= self.super.Level
end
--基础是否满级了
function NatureMountData:IsBaseMaxLevel()
return self.BaseIsMax <= self.BaseCfg.Id
end
--获取模型相机大小
function NatureMountData:Get3DUICamerSize(modelid)
local _info = DataConfig.DataHuaxingHorse[modelid]
if _info then
return _info.CameraSize
end
return self.super:GetCameraSize(modelid)
end
function NatureMountData:GetModelYPosition(modelid)
local _info = DataConfig.DataHuaxingHorse[modelid]
if _info and _info.ModelYPos then
return _info.ModelYPos / self:Get3DUICamerSize(modelid)
end
return 0
end
function NatureMountData:GetModelRotation(modelid)
local _info = DataConfig.DataHuaxingHorse[modelid]
if _info and _info.CameraRotation then
local _attr = Utils.SplitNumber(_info.CameraRotation, '_')
return _attr[1], _attr[2], _attr[3]
end
return 0, 0, 0
end
function NatureMountData:GetShowModelYPosition(modelid)
local _info = DataConfig.DataHuaxingHorse[modelid]
if _info and _info.ShowModelYPos then
return _info.ShowModelYPos / self:Get3DUICamerSize(modelid)
end
return 0
end
return NatureMountData