282 lines
9.6 KiB
Lua
282 lines
9.6 KiB
Lua
|
------------------------------------------------
|
||
|
--作者: yangqf
|
||
|
--日期: 2019-08-28
|
||
|
--文件: RealmStifleSystem.lua
|
||
|
--模块: RealmStifleSystem
|
||
|
--描述: 灵压系统
|
||
|
------------------------------------------------
|
||
|
local RedPointCustomCondition = CS.Thousandto.Code.Logic.RedPointCustomCondition;
|
||
|
local RedPointItemCondition = CS.Thousandto.Code.Logic.RedPointItemCondition;
|
||
|
|
||
|
local RealmStifleSystem = {
|
||
|
--当前等级
|
||
|
CurLevel = 0,
|
||
|
--当前星级
|
||
|
CurStar = 0,
|
||
|
--当前配置
|
||
|
CurCfg = nil,
|
||
|
|
||
|
--是否有特殊条件
|
||
|
HaveCondition = false,
|
||
|
--当前条件当前值
|
||
|
ConditionCurValue = 0,
|
||
|
--当前需要条件最大值
|
||
|
ConditionMaxValue = 0,
|
||
|
|
||
|
--当前器灵列表
|
||
|
OrganDic = Dictionary:New(),
|
||
|
--器灵晋升总等级
|
||
|
TotalPromoteLv = 0,
|
||
|
|
||
|
--器灵进化需要的材料ID
|
||
|
OrganEvoNeedIdList = List:New(),
|
||
|
|
||
|
--是否已经满级
|
||
|
IsFullLevel = false,
|
||
|
};
|
||
|
function RealmStifleSystem:Initialize()
|
||
|
end
|
||
|
|
||
|
function RealmStifleSystem:UnInitialize()
|
||
|
end
|
||
|
|
||
|
function RealmStifleSystem:ReqOpenPanel()
|
||
|
GameCenter.Network.Send("MSG_StateStifle.ReqOpenStateStiflePanle", {});
|
||
|
end
|
||
|
|
||
|
function RealmStifleSystem:ReqLevelUP(isOnkey)
|
||
|
GameCenter.Network.Send("MSG_StateStifle.ReqUpLevel", {oneKey = isOnkey});
|
||
|
end
|
||
|
|
||
|
--请求器灵晋升
|
||
|
function RealmStifleSystem:ReqUpPromoteLevel(id)
|
||
|
local _msg = ReqMsg.MSG_StateStifle.ReqUpPromoteLevel:New()
|
||
|
_msg.id = id
|
||
|
_msg:Send()
|
||
|
end
|
||
|
|
||
|
--请求器灵进化
|
||
|
function RealmStifleSystem:ReqUpEvolveLevel(id)
|
||
|
local _msg = ReqMsg.MSG_StateStifle.ReqUpEvolveLevel:New()
|
||
|
_msg.id = id
|
||
|
_msg:Send()
|
||
|
end
|
||
|
|
||
|
--请求激活器灵
|
||
|
function RealmStifleSystem:ReqActiveSoulSpirit(id)
|
||
|
local _msg = ReqMsg.MSG_StateStifle.ReqActiveSoulSpirit:New()
|
||
|
_msg.id = id
|
||
|
_msg:Send()
|
||
|
end
|
||
|
|
||
|
function RealmStifleSystem:ResOpenPanel(msg)
|
||
|
self.CurLevel = msg.level.level;
|
||
|
self.CurStar = msg.level.star;
|
||
|
self.CurCfg = DataConfig.DataStateStifle[self.CurLevel * 100 + self.CurStar];
|
||
|
if msg.conditionValue ~= nil then
|
||
|
self.HaveCondition = true;
|
||
|
self.ConditionCurValue = msg.conditionValue[1].progress;
|
||
|
self.ConditionMaxValue = msg.conditionValue[1].total;
|
||
|
if msg.conditionReach then
|
||
|
self.ConditionCurValue = self.ConditionMaxValue;
|
||
|
end
|
||
|
else
|
||
|
self.HaveCondition = false;
|
||
|
end
|
||
|
|
||
|
--器灵数据缓存
|
||
|
if msg.soulSpiritList then
|
||
|
local _total = 0
|
||
|
for i = 1, #msg.soulSpiritList do
|
||
|
local _info = msg.soulSpiritList[i]
|
||
|
local _tmp = {}
|
||
|
_tmp.ActiveState = _info.state
|
||
|
_tmp.PromoteLv = _info.promoteLv
|
||
|
_tmp.PromoteValue = _info.promotePorgress
|
||
|
_tmp.EvolutionLv = _info.evolveLv
|
||
|
_tmp.Type = _info.id
|
||
|
_tmp.EvoCfg = DataConfig.DataStateStifleAdd[_info.id * 100 + _info.evolveLv]
|
||
|
_tmp.PromoteCfg = DataConfig.DataStateStifleAddLevel[_info.id * 100 + _info.promoteLv]
|
||
|
_total = _total + _info.promoteLv
|
||
|
if not self.OrganDic[_info.id] then
|
||
|
self.OrganDic:Add(_info.id, _tmp)
|
||
|
else
|
||
|
self.OrganDic[_info.id] = _tmp
|
||
|
end
|
||
|
end
|
||
|
self.TotalPromoteLv = _total
|
||
|
end
|
||
|
|
||
|
local _nextCfg = DataConfig.DataStateStifle[self.CurLevel * 100 + self.CurStar + 1];
|
||
|
if _nextCfg == nil then
|
||
|
_nextCfg = DataConfig.DataStateStifle[(self.CurLevel + 1) * 100 + 0];
|
||
|
end
|
||
|
|
||
|
if _nextCfg ~= nil then
|
||
|
self.IsFullLevel = false;
|
||
|
else
|
||
|
self.IsFullLevel = true;
|
||
|
end
|
||
|
self:CheckRedPoint();
|
||
|
self:SetOrganVisble();
|
||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_UPDATE_REALMSTIFLE_INFO);
|
||
|
end
|
||
|
|
||
|
--法宝升级反回
|
||
|
function RealmStifleSystem:ResUpLevel(msg)
|
||
|
self.CurLevel = msg.level.level;
|
||
|
self.CurStar = msg.level.star;
|
||
|
if msg.conditionValue ~= nil then
|
||
|
self.HaveCondition = true;
|
||
|
self.ConditionCurValue = msg.conditionValue[1].progress;
|
||
|
self.ConditionMaxValue = msg.conditionValue[1].total;
|
||
|
if msg.conditionReach then
|
||
|
self.ConditionCurValue = self.ConditionMaxValue;
|
||
|
end
|
||
|
else
|
||
|
self.HaveCondition = false;
|
||
|
end
|
||
|
self.CurCfg = DataConfig.DataStateStifle[self.CurLevel * 100 + self.CurStar];
|
||
|
local _nextCfg = DataConfig.DataStateStifle[self.CurLevel * 100 + self.CurStar + 1];
|
||
|
if _nextCfg == nil then
|
||
|
_nextCfg = DataConfig.DataStateStifle[(self.CurLevel + 1) * 100 + 0];
|
||
|
end
|
||
|
|
||
|
if _nextCfg ~= nil then
|
||
|
self.IsFullLevel = false;
|
||
|
else
|
||
|
self.IsFullLevel = true;
|
||
|
end
|
||
|
self:CheckRedPoint();
|
||
|
if GameCenter.NatureSystem.NatureFaBaoData.super then
|
||
|
GameCenter.NatureSystem.NatureFaBaoData.super.Fight = msg.fight
|
||
|
end
|
||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_UPDATE_REALMSTIFLE_INFO);
|
||
|
end
|
||
|
|
||
|
--晋升、进化返回
|
||
|
function RealmStifleSystem:ResSoulSpiritInfo(msg)
|
||
|
if msg.soulSpiritList then
|
||
|
local _info = msg.soulSpiritList
|
||
|
local _tmp = {}
|
||
|
_tmp.ActiveState = _info.state
|
||
|
_tmp.PromoteLv = _info.promoteLv
|
||
|
_tmp.PromoteValue = _info.promotePorgress
|
||
|
_tmp.EvolutionLv = _info.evolveLv
|
||
|
_tmp.Type = _info.id
|
||
|
_tmp.EvoCfg = DataConfig.DataStateStifleAdd[_info.id * 100 + _info.evolveLv]
|
||
|
_tmp.PromoteCfg = DataConfig.DataStateStifleAddLevel[_info.id * 100 + _info.promoteLv]
|
||
|
self.TotalPromoteLv = self.TotalPromoteLv + _info.promoteLv
|
||
|
if not self.OrganDic[_info.id] then
|
||
|
self.OrganDic:Add(_info.id, _tmp)
|
||
|
else
|
||
|
self.TotalPromoteLv = self.TotalPromoteLv - self.OrganDic[_info.id].PromoteLv
|
||
|
self.OrganDic[_info.id] = _tmp
|
||
|
end
|
||
|
end
|
||
|
self:SetOrganVisble()
|
||
|
if GameCenter.NatureSystem.NatureFaBaoData.super then
|
||
|
GameCenter.NatureSystem.NatureFaBaoData.super.Fight = msg.fight
|
||
|
end
|
||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_UPDATE_REALMSTIFLE_INFO);
|
||
|
GameCenter.OfflineOnHookSystem:ReqHookSetInfo()
|
||
|
end
|
||
|
|
||
|
function RealmStifleSystem:CheckRedPoint()
|
||
|
GameCenter.RedPointSystem:CleraFuncCondition(FunctionStartIdCode.FaBaoUpGrade);
|
||
|
if self.IsFullLevel == false then
|
||
|
local _itemParams = Utils.SplitStr(self.CurCfg.NeedItem, '_');
|
||
|
|
||
|
local _conditions = List:New();
|
||
|
_conditions:Add(RedPointItemCondition(tonumber(_itemParams[1]), tonumber(_itemParams[2])));
|
||
|
|
||
|
if self.HaveCondition then
|
||
|
_conditions:Add(RedPointCustomCondition(self.ConditionCurValue >= self.ConditionMaxValue));
|
||
|
end
|
||
|
GameCenter.RedPointSystem:LuaAddFuncCondition(FunctionStartIdCode.FaBaoUpGrade, 0, _conditions);
|
||
|
end
|
||
|
end
|
||
|
|
||
|
--设置器灵功能是否开放
|
||
|
function RealmStifleSystem:SetOrganVisble()
|
||
|
local _isOpen = false
|
||
|
local _promoteRed = false
|
||
|
GameCenter.RedPointSystem:CleraFuncCondition(FunctionStartIdCode.FaBaoActive);
|
||
|
GameCenter.RedPointSystem:CleraFuncCondition(FunctionStartIdCode.FaBaoEvolution);
|
||
|
self.OrganDic:Foreach(function(k, v)
|
||
|
if v.ActiveState == 2 then
|
||
|
_isOpen = true
|
||
|
if v.EvoCfg and v.EvoCfg.IfMax ~= 1 then
|
||
|
local _ar = Utils.SplitStr(v.EvoCfg.JinhuaNeedItem, ';')
|
||
|
--物品条件
|
||
|
local _conditions = List:New();
|
||
|
for i = 1, #_ar do
|
||
|
local _single = Utils.SplitNumber(_ar[i], '_')
|
||
|
if #_single >= 2 then
|
||
|
_conditions:Add(RedPointItemCondition(_single[1], _single[2]));
|
||
|
end
|
||
|
end
|
||
|
GameCenter.RedPointSystem:LuaAddFuncCondition(FunctionStartIdCode.FaBaoEvolution, k, _conditions);
|
||
|
end
|
||
|
else
|
||
|
self:GetOrganCanActive(k)
|
||
|
end
|
||
|
end)
|
||
|
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.FaBaoPromote, _promoteRed)
|
||
|
GameCenter.MainFunctionSystem:SetFunctionVisible(FunctionStartIdCode.FaBaoOrgan, _isOpen)
|
||
|
end
|
||
|
|
||
|
--某个器灵是否有晋升红点
|
||
|
function RealmStifleSystem:GetOrganPromoteRedByType(type)
|
||
|
if self.OrganDic[type] and self.OrganDic[type].ActiveState == 2 then
|
||
|
if self.OrganDic[type].PromoteCfg and self.OrganDic[type].PromoteCfg.IfMax ~= 1 then
|
||
|
local _ar = Utils.SplitNumber(self.OrganDic[type].PromoteCfg.NeedItem, '_')
|
||
|
if self.OrganDic[type].PromoteValue >= _ar[#_ar] and self.CurLevel >= self.OrganDic[type].PromoteCfg.NeedLevel then
|
||
|
return true
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
return false
|
||
|
end
|
||
|
--某个器灵是否有进化红点
|
||
|
function RealmStifleSystem:GetOrganEvoRedByType(type)
|
||
|
if self.OrganDic[type] and self.OrganDic[type].ActiveState == 2 then
|
||
|
|
||
|
end
|
||
|
end
|
||
|
|
||
|
--某个器灵是否可激活
|
||
|
function RealmStifleSystem:GetOrganCanActive(type)
|
||
|
if self.OrganDic[type] and self.OrganDic[type].ActiveState ~= 2 then
|
||
|
if self.OrganDic[type].EvoCfg and self.CurLevel >= self.OrganDic[type].EvoCfg.NeedLevel then
|
||
|
local _ar = Utils.SplitNumber(self.OrganDic[type].EvoCfg.NeedItem, '_')
|
||
|
GameCenter.RedPointSystem:AddFuncCondition(FunctionStartIdCode.FaBaoActive, type, RedPointItemCondition(_ar[1], _ar[2]))
|
||
|
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function RealmStifleSystem:GetStifleCfgID()
|
||
|
return self.CurLevel * 100 + self.CurStar;
|
||
|
end
|
||
|
|
||
|
--获取器灵名字
|
||
|
function RealmStifleSystem:GetOrganName(type)
|
||
|
local _str = ""
|
||
|
if type == 1 then
|
||
|
_str = DataConfig.DataMessageString.Get("ExpSpirit")
|
||
|
elseif type == 2 then
|
||
|
_str = DataConfig.DataMessageString.Get("FightSpirit")
|
||
|
elseif type == 3 then
|
||
|
_str = DataConfig.DataMessageString.Get("ChasedSpirit")
|
||
|
end
|
||
|
return _str
|
||
|
end
|
||
|
|
||
|
--根据类型获取当前器灵配置
|
||
|
function RealmStifleSystem:GetOrganDataByType(type)
|
||
|
local _organData = self.OrganDic[type]
|
||
|
return _organData
|
||
|
end
|
||
|
return RealmStifleSystem;
|