196 lines
6.2 KiB
Lua
196 lines
6.2 KiB
Lua
|
------------------------------------------------
|
|||
|
--作者: 杨全福
|
|||
|
--日期: 2020-08-08
|
|||
|
--文件: YYHDBaseData.lua
|
|||
|
--模块: YYHDBaseData
|
|||
|
--描述: 运营活动基础数据
|
|||
|
------------------------------------------------
|
|||
|
|
|||
|
--自定义条件
|
|||
|
local RedPointCustomCondition = CS.Thousandto.Code.Logic.RedPointCustomCondition
|
|||
|
--战力条件
|
|||
|
local RedPointFightPowerCondition = CS.Thousandto.Code.Logic.RedPointFightPowerCondition
|
|||
|
--物品条件
|
|||
|
local RedPointItemCondition = CS.Thousandto.Code.Logic.RedPointItemCondition
|
|||
|
--等级条件
|
|||
|
local RedPointLevelCondition = CS.Thousandto.Code.Logic.RedPointLevelCondition
|
|||
|
--任务条件
|
|||
|
local RedPointTaskCondition = CS.Thousandto.Code.Logic.RedPointTaskCondition
|
|||
|
|
|||
|
local YYHDBaseData = {
|
|||
|
--活动类型
|
|||
|
TypeId = 0,
|
|||
|
--最小开放等级
|
|||
|
MinLevel = 0,
|
|||
|
--最大开放等级
|
|||
|
MaxLevel = 0,
|
|||
|
--标签(用于区分展示在哪个活动标签下)
|
|||
|
Tag = 0,
|
|||
|
--活动名称
|
|||
|
Name = nil,
|
|||
|
--活动开始时间(UTC时间,进行计算时需要加上时区)
|
|||
|
BeginTime = 0,
|
|||
|
--活动结束时间(UTC时间,进行计算时需要加上时区)
|
|||
|
EndTime = 0,
|
|||
|
--活动是否开启
|
|||
|
IsOpen = false,
|
|||
|
--排序值
|
|||
|
SortValue = 0,
|
|||
|
|
|||
|
--红点dataid列表
|
|||
|
RedPointDataids = nil,
|
|||
|
--是否显示到活动列表
|
|||
|
IsShowInList = true,
|
|||
|
--是否激活
|
|||
|
ActiveState = false,
|
|||
|
|
|||
|
--使用的逻辑类型
|
|||
|
UseLogicId = 0,
|
|||
|
--使用的uiid
|
|||
|
UseUIId = 0,
|
|||
|
}
|
|||
|
|
|||
|
function YYHDBaseData:New(typeId)
|
|||
|
local _m = Utils.DeepCopy(self)
|
|||
|
_m.TypeId = typeId
|
|||
|
local _cfg = DataConfig.DataActivityYunying[typeId]
|
|||
|
_m.UseLogicId = _cfg.LogicId
|
|||
|
_m.UseUIId = _cfg.UseUiId
|
|||
|
return _m
|
|||
|
end
|
|||
|
|
|||
|
--解析基础配置数据
|
|||
|
function YYHDBaseData:ParseBaseCfgData(jsonTable)
|
|||
|
self.MinLevel = jsonTable.minLv
|
|||
|
self.MaxLevel = jsonTable.maxLv
|
|||
|
self.Tag = jsonTable.tag
|
|||
|
self.Name = jsonTable.name
|
|||
|
self.BeginTime = math.floor(jsonTable.beginTime / 1000)
|
|||
|
self.EndTime = math.floor(jsonTable.endTime / 1000)
|
|||
|
self.IsOpen = jsonTable.isDelete == 0
|
|||
|
self.SortValue = jsonTable.sort
|
|||
|
|
|||
|
--先删除所有红点
|
|||
|
self:RemoveRedPoint(nil)
|
|||
|
self.ActiveState = self:IsActive()
|
|||
|
end
|
|||
|
|
|||
|
--判断活动是否开启
|
|||
|
function YYHDBaseData:IsActive()
|
|||
|
--活动是否开启
|
|||
|
if not self.IsOpen then
|
|||
|
self.ActiveState = false
|
|||
|
return false
|
|||
|
end
|
|||
|
local _lpLevel = GameCenter.GameSceneSystem:GetLocalPlayerLevel()
|
|||
|
--判断玩家等级是否足够
|
|||
|
if _lpLevel < self.MinLevel or _lpLevel > self.MaxLevel then
|
|||
|
self.ActiveState = false
|
|||
|
return false
|
|||
|
end
|
|||
|
--判断是否在开启时间范围内(都是UTC时间,所以直接判断值大小就可以了)
|
|||
|
local _serverTime = GameCenter.HeartSystem.ServerTime
|
|||
|
if self.BeginTime > _serverTime or self.EndTime < _serverTime then
|
|||
|
self.ActiveState = false
|
|||
|
return false
|
|||
|
end
|
|||
|
self.ActiveState = true
|
|||
|
return true
|
|||
|
end
|
|||
|
|
|||
|
function YYHDBaseData:ToUsedDataId(dataId)
|
|||
|
return self.Tag * 1000000000000 + self.UseLogicId * 1000000000 + dataId
|
|||
|
end
|
|||
|
|
|||
|
--增加红点条件,将使用红点系统进行判断
|
|||
|
--itemCon = {{物品id,物品数量},{物品id,物品数量}...}
|
|||
|
--levelCon = 等级数值
|
|||
|
--fightPowerCon = 战斗力数值
|
|||
|
--cutCon = true or false
|
|||
|
--taskCon = 任务id
|
|||
|
function YYHDBaseData:AddRedPoint(dataId, itemCon, levelCon, fightPowerCon, cutCon, taskCon)
|
|||
|
if dataId == nil then
|
|||
|
return
|
|||
|
end
|
|||
|
if dataId < 0 or dataId >= 1000000000 then
|
|||
|
Debug.LogError("由于活动红点dataId不能大于等于1000000000,增加红点失败!")
|
|||
|
return
|
|||
|
end
|
|||
|
if itemCon == nil and levelCon == nil and fightPowerCon == nil and cutCon == nil and taskCon == nil then
|
|||
|
return
|
|||
|
end
|
|||
|
if not self:IsActive() then
|
|||
|
--未开启的活动不增加红点
|
|||
|
return
|
|||
|
end
|
|||
|
--先删除老的条件
|
|||
|
self:RemoveRedPoint(dataId)
|
|||
|
local _conTable = {}
|
|||
|
local _index = 1
|
|||
|
if itemCon ~= nil then
|
|||
|
for i = 1, #itemCon do
|
|||
|
_conTable[_index] = RedPointItemCondition(itemCon[i][1],itemCon[i][2])
|
|||
|
_index = _index + 1
|
|||
|
end
|
|||
|
end
|
|||
|
if levelCon ~= nil then
|
|||
|
_conTable[_index] = RedPointLevelCondition(levelCon)
|
|||
|
_index = _index + 1
|
|||
|
end
|
|||
|
if fightPowerCon ~= nil then
|
|||
|
_conTable[_index] = RedPointFightPowerCondition(fightPowerCon)
|
|||
|
_index = _index + 1
|
|||
|
end
|
|||
|
if cutCon ~= nil then
|
|||
|
_conTable[_index] = RedPointCustomCondition(cutCon)
|
|||
|
_index = _index + 1
|
|||
|
end
|
|||
|
if taskCon ~= nil then
|
|||
|
_conTable[_index] = RedPointTaskCondition(taskCon)
|
|||
|
_index = _index + 1
|
|||
|
end
|
|||
|
if _index > 1 then
|
|||
|
if self.RedPointDataids == nil then
|
|||
|
self.RedPointDataids = List:New()
|
|||
|
end
|
|||
|
self.RedPointDataids:Add(dataId)
|
|||
|
GameCenter.RedPointSystem:LuaAddFuncCondition(FunctionStartIdCode.YunYingHD, self:ToUsedDataId(dataId), _conTable)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--删除红点条件,dataId为nil表示清除本活动所有红点
|
|||
|
function YYHDBaseData:RemoveRedPoint(dataId)
|
|||
|
if dataId ~= nil then
|
|||
|
--删除单个
|
|||
|
if self.RedPointDataids ~= nil then
|
|||
|
self.RedPointDataids:Remove(dataId)
|
|||
|
end
|
|||
|
GameCenter.RedPointSystem:RemoveFuncCondition(FunctionStartIdCode.YunYingHD, self:ToUsedDataId(dataId))
|
|||
|
else
|
|||
|
--清除所有
|
|||
|
if self.RedPointDataids ~= nil then
|
|||
|
for i = 1, #self.RedPointDataids do
|
|||
|
GameCenter.RedPointSystem:RemoveFuncCondition(FunctionStartIdCode.YunYingHD, self:ToUsedDataId(self.RedPointDataids[i]))
|
|||
|
end
|
|||
|
self.RedPointDataids:Clear()
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--是否显示红点,dataId为nil表示本活动的红点
|
|||
|
function YYHDBaseData:IsShowRedPoint(dataId)
|
|||
|
if dataId == nil then
|
|||
|
if self.RedPointDataids ~= nil then
|
|||
|
for i = 1, #self.RedPointDataids do
|
|||
|
if GameCenter.RedPointSystem:OneConditionsIsReach(FunctionStartIdCode.YunYingHD, self:ToUsedDataId(self.RedPointDataids[i])) then
|
|||
|
return true
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
return false
|
|||
|
else
|
|||
|
return GameCenter.RedPointSystem:OneConditionsIsReach(FunctionStartIdCode.YunYingHD, self:ToUsedDataId(dataId))
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
return YYHDBaseData
|