277 lines
8.4 KiB
Lua
277 lines
8.4 KiB
Lua
|
------------------------------------------------
|
|||
|
--作者: 杨全福
|
|||
|
--日期: 2021-11-10
|
|||
|
--文件: UnrealEquip.lua
|
|||
|
--模块: UnrealEquip
|
|||
|
--描述: 魔魂装备数据模型
|
|||
|
------------------------------------------------
|
|||
|
local FightUtils = require "Logic.Base.FightUtils.FightUtils"
|
|||
|
local L_ParentCSType = CS.Thousandto.Code.Logic.LuaItemBase
|
|||
|
local UnrealEquip = {
|
|||
|
--CS父类对象
|
|||
|
_SuperObj_ = 0,
|
|||
|
--配置表
|
|||
|
ItemInfo = nil,
|
|||
|
--基础属性字典
|
|||
|
BaseAttrs = nil,
|
|||
|
--特殊属性字典
|
|||
|
SpecialAttrs = nil,
|
|||
|
Power = 0,
|
|||
|
--自身套装id
|
|||
|
SuitID = 0,
|
|||
|
--参与激活的套装id
|
|||
|
ActiveSuits = Dictionary:New(),
|
|||
|
}
|
|||
|
|
|||
|
---------------------------继承父类接口begin------------------------
|
|||
|
function UnrealEquip:Initialization(id)
|
|||
|
self.ItemInfo = DataConfig.DataEquip[id]
|
|||
|
self.SuitID = 10000 + self.ItemInfo.Grade
|
|||
|
return true;
|
|||
|
end
|
|||
|
|
|||
|
function UnrealEquip:UnInitialization()
|
|||
|
if self.BaseAttrs then
|
|||
|
self.BaseAttrs:Clear()
|
|||
|
end
|
|||
|
end
|
|||
|
function UnrealEquip:GetItemType()
|
|||
|
return ItemType.UnrealEquip;
|
|||
|
end
|
|||
|
function UnrealEquip:GetName()
|
|||
|
local ret = "";
|
|||
|
if self.ItemInfo then
|
|||
|
ret = self.ItemInfo.Name;
|
|||
|
end
|
|||
|
return ret;
|
|||
|
end
|
|||
|
function UnrealEquip:GetIcon()
|
|||
|
local ret = -1;
|
|||
|
if self.ItemInfo then
|
|||
|
ret = self.ItemInfo.Icon;
|
|||
|
end
|
|||
|
return ret;
|
|||
|
end
|
|||
|
function UnrealEquip:GetEffect()
|
|||
|
local ret = -1;
|
|||
|
if self.ItemInfo then
|
|||
|
ret = self.ItemInfo.Effect;
|
|||
|
end
|
|||
|
return ret;
|
|||
|
end
|
|||
|
function UnrealEquip:GetQuality()
|
|||
|
local ret = -1;
|
|||
|
if self.ItemInfo then
|
|||
|
ret = self.ItemInfo.Quality;
|
|||
|
end
|
|||
|
return ret;
|
|||
|
end
|
|||
|
function UnrealEquip:GetStarNum()
|
|||
|
local ret = 0;
|
|||
|
if self.ItemInfo then
|
|||
|
ret = self.ItemInfo.DiamondNumber;
|
|||
|
end
|
|||
|
return ret;
|
|||
|
end
|
|||
|
function UnrealEquip:GetOcc()
|
|||
|
local ret = "";
|
|||
|
if self.ItemInfo then
|
|||
|
ret = self.ItemInfo.Gender;
|
|||
|
end
|
|||
|
return ret;
|
|||
|
end
|
|||
|
function UnrealEquip:GetPart()
|
|||
|
local ret = -1;
|
|||
|
if self.ItemInfo then
|
|||
|
ret = self.ItemInfo.Part;
|
|||
|
end
|
|||
|
return ret;
|
|||
|
end
|
|||
|
function UnrealEquip:GetGrade()
|
|||
|
local ret = 0;
|
|||
|
if self.ItemInfo then
|
|||
|
ret = self.ItemInfo.Grade;
|
|||
|
end
|
|||
|
return ret;
|
|||
|
end
|
|||
|
function UnrealEquip:GetPower()
|
|||
|
return self.Power;
|
|||
|
end
|
|||
|
function UnrealEquip:CheckLevel(level)
|
|||
|
return self.ItemInfo.Level <= level;
|
|||
|
end
|
|||
|
function UnrealEquip:CheackOcc(sex)
|
|||
|
if (string.find(self.Occ, "9") ~= nil) then
|
|||
|
return true;
|
|||
|
end
|
|||
|
local ret = false;
|
|||
|
if string.find(self.ItemInfo.Gender, tostring(sex)) ~= nil then
|
|||
|
ret = true;
|
|||
|
else
|
|||
|
ret = false;
|
|||
|
end
|
|||
|
return ret;
|
|||
|
end
|
|||
|
function UnrealEquip:CheckBetterThanDress()
|
|||
|
local dressEquip = GameCenter.UnrealEquipSystem:GetDressEquip(self.Part)
|
|||
|
if dressEquip ~= nil and dressEquip.Equip ~= nil then
|
|||
|
return self.Power > dressEquip.Equip.Power;
|
|||
|
end
|
|||
|
return true;
|
|||
|
end
|
|||
|
|
|||
|
function UnrealEquip:CheckClass()
|
|||
|
if (self.ItemInfo.Classlevel <= 0) then
|
|||
|
return true;
|
|||
|
else
|
|||
|
local p = GameCenter.GameSceneSystem:GetLocalPlayer();
|
|||
|
if p then
|
|||
|
if (p.ChangeJobLevel >= self.ItemInfo.Classlevel) then
|
|||
|
return true;
|
|||
|
else
|
|||
|
return false;
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
return false;
|
|||
|
end
|
|||
|
|
|||
|
--检测是否可以上架
|
|||
|
function UnrealEquip:CanAuction()
|
|||
|
if not GameCenter.MainFunctionSystem:FunctionIsVisible(FunctionStartIdCode.Auchtion) then
|
|||
|
return false;
|
|||
|
end
|
|||
|
if (self.IsBind) then
|
|||
|
return false;
|
|||
|
end
|
|||
|
if (self.ItemInfo.AuctionMaxPrice == 0) then
|
|||
|
return false;
|
|||
|
end
|
|||
|
return true;
|
|||
|
end
|
|||
|
--是否有效
|
|||
|
function UnrealEquip:IsValid()
|
|||
|
return self.ItemInfo ~= nil
|
|||
|
end
|
|||
|
---------------------------继承父类接口end--------------------------
|
|||
|
function UnrealEquip:NewWithMsg(msg)
|
|||
|
local _m = Utils.DeepCopy(self)
|
|||
|
_m._SuperObj_ = L_ParentCSType.CreateByMsg(msg);
|
|||
|
_m:_InitBindOverride_();
|
|||
|
_m:_InitContent_();
|
|||
|
if msg then
|
|||
|
_m:Initialization(msg.itemModelId);
|
|||
|
end
|
|||
|
_m:SetAttribute();
|
|||
|
Utils.BuildInheritRel(_m);
|
|||
|
return _m
|
|||
|
end
|
|||
|
function UnrealEquip:New(...)
|
|||
|
local _m = Utils.DeepCopy(self)
|
|||
|
_m._SuperObj_ = L_ParentCSType.Create(...);
|
|||
|
_m:_InitBindOverride_();
|
|||
|
_m:_InitContent_();
|
|||
|
_m:Initialization(...);
|
|||
|
_m:SetAttribute();
|
|||
|
Utils.BuildInheritRel(_m);
|
|||
|
return _m
|
|||
|
end
|
|||
|
--绑定Override的方法
|
|||
|
function UnrealEquip:_InitBindOverride_()
|
|||
|
--重载函数的重定义
|
|||
|
--重载函数的重定义
|
|||
|
self._SuperObj_.IsValidDelegate = Utils.Handler(self.IsValid, self, nil, true);
|
|||
|
self._SuperObj_.CanAuctionDelegate = Utils.Handler(self.CanAuction, self, nil, true);
|
|||
|
self._SuperObj_.IsUsedInBatchesDelegate = Utils.Handler(self.IsUsedInBatches, self, nil, true);
|
|||
|
self._SuperObj_.CheckClassDelegate = Utils.Handler(self.CheckClass, self, nil, true);
|
|||
|
self._SuperObj_.CheckOccDelegate = Utils.Handler(self.CheackOcc, self, nil, true);
|
|||
|
self._SuperObj_.CheckLevelDelegate = Utils.Handler(self.CheckLevel, self, nil, true);
|
|||
|
self._SuperObj_.GetPowerDelegate = Utils.Handler(self.GetPower, self, nil, true);
|
|||
|
self._SuperObj_.GetGradeDelegate = Utils.Handler(self.GetGrade, self, nil, true);
|
|||
|
self._SuperObj_.GetPartDelegate = Utils.Handler(self.GetPart, self, nil, true);
|
|||
|
self._SuperObj_.GetOccDelegate = Utils.Handler(self.GetOcc, self, nil, true);
|
|||
|
self._SuperObj_.GetStarNumDelegate = Utils.Handler(self.GetStarNum, self, nil, true);
|
|||
|
self._SuperObj_.GetQualityDelegate = Utils.Handler(self.GetQuality, self, nil, true);
|
|||
|
self._SuperObj_.GetEffectDelegate = Utils.Handler(self.GetEffect, self, nil, true);
|
|||
|
self._SuperObj_.GetIconDelegate = Utils.Handler(self.GetIcon, self, nil, true);
|
|||
|
self._SuperObj_.GetNameDelegate = Utils.Handler(self.GetName, self, nil, true);
|
|||
|
self._SuperObj_.GetItemTypeDelegate = Utils.Handler(self.GetItemType, self, nil, true);
|
|||
|
self._SuperObj_.UnInitializationDelegate = Utils.Handler(self.UnInitialization, self, nil, true);
|
|||
|
end
|
|||
|
|
|||
|
--初始化
|
|||
|
function UnrealEquip:_InitContent_()
|
|||
|
--定义临时变量,用户回调
|
|||
|
end
|
|||
|
function UnrealEquip:GetCSObj()
|
|||
|
return self._SuperObj_;
|
|||
|
end
|
|||
|
--获取装备的最基本的属性值
|
|||
|
function UnrealEquip:GetBaseAttribute()
|
|||
|
if self.BaseAttrs then
|
|||
|
return self.BaseAttrs;
|
|||
|
end
|
|||
|
return Dictionary:New()
|
|||
|
end
|
|||
|
|
|||
|
--获取装备的特殊属性值
|
|||
|
function UnrealEquip:GetSpecialAttribute()
|
|||
|
if self.SpecialAttrs then
|
|||
|
return self.SpecialAttrs;
|
|||
|
end
|
|||
|
return Dictionary:New()
|
|||
|
end
|
|||
|
|
|||
|
--计算当前装备的属性值
|
|||
|
function UnrealEquip:SetAttribute()
|
|||
|
if self.ItemInfo == nil then
|
|||
|
return;
|
|||
|
end
|
|||
|
if (LuaItemBase.EquipBaseAttDic == nil) then
|
|||
|
LuaItemBase.EquipBaseAttDic = Dictionary:New()
|
|||
|
end
|
|||
|
if(LuaItemBase.EquipBaseAttDic:ContainsKey(self.ItemInfo.Id)) then
|
|||
|
self.BaseAttrs = LuaItemBase.EquipBaseAttDic[self.ItemInfo.Id];
|
|||
|
else
|
|||
|
if self.BaseAttrs == nil then
|
|||
|
self.BaseAttrs = Dictionary:New()
|
|||
|
end
|
|||
|
self.BaseAttrs:Clear();
|
|||
|
local attrsArr = Utils.SplitStr(self.ItemInfo.Attribute1, ';')
|
|||
|
for i = 1, #attrsArr do
|
|||
|
local attrs = Utils.SplitNumber(attrsArr[i], '_')
|
|||
|
if #attrs == 2 then
|
|||
|
if not self.BaseAttrs:ContainsKey(attrs[1]) then
|
|||
|
self.BaseAttrs:Add(attrs[1], attrs[2]);
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
--将属性缓存起来,下次使用的时候不会再次GC
|
|||
|
LuaItemBase.EquipBaseAttDic[self.ItemInfo.Id] = self.BaseAttrs;
|
|||
|
end
|
|||
|
|
|||
|
if (LuaItemBase.EquipSpecialAttDic == nil) then
|
|||
|
LuaItemBase.EquipSpecialAttDic = Dictionary:New()
|
|||
|
end
|
|||
|
if (LuaItemBase.EquipSpecialAttDic:ContainsKey(self.ItemInfo.Id)) then
|
|||
|
self.SpecialAttrs = LuaItemBase.EquipSpecialAttDic[self.ItemInfo.Id];
|
|||
|
else
|
|||
|
if self.SpecialAttrs == nil then
|
|||
|
self.SpecialAttrs = Dictionary:New()
|
|||
|
end
|
|||
|
self.SpecialAttrs:Clear();
|
|||
|
local attrsArr = Utils.SplitStr(self.ItemInfo.Attribute2, ';')
|
|||
|
for i = 1, #attrsArr do
|
|||
|
local attrs = Utils.SplitNumber(attrsArr[i], '_')
|
|||
|
if #attrs == 2 then
|
|||
|
if not self.SpecialAttrs:ContainsKey(attrs[1]) then
|
|||
|
self.SpecialAttrs:Add(attrs[1], attrs[2]);
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
--将属性缓存起来,下次使用的时候不会再次GC
|
|||
|
LuaItemBase.EquipSpecialAttDic[self.ItemInfo.Id] = self.SpecialAttrs;
|
|||
|
end
|
|||
|
self.Power = self.ItemInfo.Score
|
|||
|
end
|
|||
|
return UnrealEquip
|