AppVer 1.28.0 | DocVer 1.28.1 | Release

This commit is contained in:
alt 2023-07-15 02:35:33 +07:00
parent c05e3a8a11
commit 01cd7f005c
4314 changed files with 671337 additions and 1 deletions

View file

@ -4,7 +4,7 @@
- Client - Client
- Share - Share
- Scripts (soon) - Scripts
- Sha1 - Sha1
## Known Issue ## Known Issue

View file

@ -0,0 +1,140 @@
local UnityApplication = CS.UnityEngine.Application
local UnityRuntimePlatform = CS.UnityEngine.RuntimePlatform
local CsApplication = CS.XApplication
-- local CsLog = CS.XLog
local CsInfo = CS.XInfo
-- 应用路径模块
local XLaunchAppPathModule = {}
local RuntimePlatform = {
ANDROID = 1,
IOS = 2,
EDITOR = 3,
STANDALONE = 4,
}
local CurRuntimePlatform
local IsEditorOrStandalone
local PLATFORM
-- platform
local DocumentUrl
local ConfigUrl
local ApplicationFilePath
-- editor/standalone
local ProductPath
local DebugFilePath
-- common
local AppUpgradeUrl
local DocumentFilePath
-- Local Function
local function Init()
AppUpgradeUrl = "client/patch"
DocumentFilePath = UnityApplication.persistentDataPath .. "/document"
if UnityApplication.platform == UnityRuntimePlatform.Android then
-- 安卓平台
CurRuntimePlatform = RuntimePlatform.ANDROID
PLATFORM = "android"
DocumentUrl = "client/patch/" .. CsInfo.Identifier .. "/" .. CsInfo.Version .. "/android"
ConfigUrl = "client/config/" .. CsInfo.Identifier .. "/" .. CsInfo.Version .. "/android"
ApplicationFilePath = UnityApplication.streamingAssetsPath .. "/resource"
elseif UnityApplication.platform == UnityRuntimePlatform.IPhonePlayer then
-- iOS平台
CurRuntimePlatform = RuntimePlatform.IOS
PLATFORM = "ios"
DocumentUrl = "client/patch/" .. CsInfo.Identifier .. "/" .. CsInfo.Version .. "/ios"
ConfigUrl = "client/config/" .. CsInfo.Identifier .. "/" .. CsInfo.Version .. "/ios"
ApplicationFilePath = UnityApplication.streamingAssetsPath .. "/resource"
else
--
PLATFORM = "win"
if UnityApplication.platform == UnityRuntimePlatform.WindowsEditor or
UnityApplication.platform == UnityRuntimePlatform.OSXEditor or
UnityApplication.platform == UnityRuntimePlatform.LinuxEditor then
-- 编辑器平台
PLATFORM = CS.XLaunchManager.PLATFORM --编辑器平台,随平台选择而变化
CurRuntimePlatform = RuntimePlatform.EDITOR
DocumentUrl = "client/patch/" .. CsInfo.Identifier .. "/" .. CsInfo.Version .. "/editor"
ConfigUrl = "client/config/" .. CsInfo.Identifier .. "/" .. CsInfo.Version .. "/editor"
ProductPath = UnityApplication.dataPath .. "/../../../Product"
DebugFilePath = ProductPath .. "/File/win/debug"
ApplicationFilePath = CsApplication.Debug and ProductPath .. "/File/" .. PLATFORM .. "/release"
or ProductPath .. "/Bin/Client/Win/Release/harukuroPC_Data/StreamingAssets/resource"
--DocumentUrl = "client/patch/" .. CsInfo.Identifier .. "/" .. CsInfo.Version .. "/android" --editor上 test androd
elseif UnityApplication.platform == UnityRuntimePlatform.WindowsPlayer or
UnityApplication.platform == UnityRuntimePlatform.OSXPlayer or
UnityApplication.platform == UnityRuntimePlatform.LinuxPlayer then
-- 电脑系统平台
CurRuntimePlatform = RuntimePlatform.STANDALONE
DocumentUrl = "client/patch/" .. CsInfo.Identifier .. "/" .. CsInfo.Version .. "/standalone"
ConfigUrl = "client/config/" .. CsInfo.Identifier .. "/" .. CsInfo.Version .. "/standalone"
ProductPath = UnityApplication.dataPath .. "/../../../../.."
DebugFilePath = ProductPath .. "/File/win/debug"
ApplicationFilePath = CsApplication.Debug and ProductPath .. "/File/" .. PLATFORM .. "/release"
or UnityApplication.streamingAssetsPath .. "/resource"
if not CsApplication.Debug then
-- Release包 资源目录跟安装目录相同
DocumentFilePath = UnityApplication.streamingAssetsPath .. "/document"
end
end
end
IsEditorOrStandalone = CurRuntimePlatform == RuntimePlatform.EDITOR or CurRuntimePlatform == RuntimePlatform.STANDALONE
end
-- local function PrintPath()
-- --
-- CsLog.Error("Check files. PLATFORM = " .. PLATFORM)
-- CsLog.Error("Check files. DocumentUrl = " .. DocumentUrl)
-- CsLog.Error("Check files. ConfigUrl = " .. ConfigUrl)
-- CsLog.Error("Check files. ApplicationFilePath = " .. ApplicationFilePath)
-- CsLog.Error("Check files. ProductPath = " .. ProductPath)
-- CsLog.Error("Check files. DebugFilePath = " .. DebugFilePath)
-- end
Init()
--PrintPath()
function XLaunchAppPathModule.IsEditorOrStandalone()
return IsEditorOrStandalone
end
function XLaunchAppPathModule.IsAndroid()
return CurRuntimePlatform == RuntimePlatform.ANDROID
end
function XLaunchAppPathModule.IsIos()
return CurRuntimePlatform == RuntimePlatform.IOS;
end
function XLaunchAppPathModule.GetApplicationFilePath()
return ApplicationFilePath
end
function XLaunchAppPathModule.GetDocumentFilePath()
return DocumentFilePath
end
function XLaunchAppPathModule.GetDebugFilePath()
return DebugFilePath
end
function XLaunchAppPathModule.GetDocumentUrl()
return DocumentUrl
end
function XLaunchAppPathModule.GetConfigUrl()
return ConfigUrl
end
function XLaunchAppPathModule.GetAppUpgradeUrl()
return AppUpgradeUrl
end
return XLaunchAppPathModule

View file

@ -0,0 +1,109 @@
local UnityPlayerPrefs = CS.UnityEngine.PlayerPrefs
local CsLog = CS.XLog
local CsInfo = CS.XInfo
local CsRemoteConfig = CS.XRemoteConfig
-- 应用版本模块
local XLaunchAppVersionModule = {}
local DOCUMENT_VERSION = "DOCUMENT_VERSION"
local LAUNCH_MODULE_VERSION = "LAUNCH_MODULE_VERSION"
local AppVersion
local OldDocVersion
local NewDocVersion
local OldLaunchModuleVersion
local NewLaunchModuleVersion
local IsCurAppVersionMatched = false
local IsCurDocVersionMatched = false
local IsCurLaunchModuleVersionMatched = false
local IsDocUpdated = true
local IsLaunchModuleUpdated = true
local PrintVersion
-- 初始化
local Init = function()
AppVersion = CsInfo.Version
IsCurAppVersionMatched = CsRemoteConfig.ApplicationVersion == AppVersion
OldDocVersion = UnityPlayerPrefs.GetString(DOCUMENT_VERSION, CsInfo.Version)
NewDocVersion = CsRemoteConfig.DocumentVersion
IsCurDocVersionMatched = NewDocVersion == AppVersion
IsDocUpdated = NewDocVersion == OldDocVersion
OldLaunchModuleVersion = UnityPlayerPrefs.GetString(LAUNCH_MODULE_VERSION, CsInfo.Version)
NewLaunchModuleVersion = CsRemoteConfig.LaunchModuleVersion
IsCurLaunchModuleVersionMatched = AppVersion == NewLaunchModuleVersion
IsLaunchModuleUpdated = OldLaunchModuleVersion == NewLaunchModuleVersion
PrintVersion()
end
PrintVersion = function()
CsLog.Debug("AppVersion: " .. tostring(AppVersion))
CsLog.Debug("OldDocVersion: " .. tostring(OldDocVersion))
CsLog.Debug("NewDocVersion: " .. tostring(NewDocVersion))
CsLog.Debug("OldLaunchModuleVersion: " .. tostring(OldLaunchModuleVersion))
CsLog.Debug("NewLaunchModuleVersion: " .. tostring(NewLaunchModuleVersion))
CsLog.Debug("IsCurDocVersionMatched: " .. tostring(IsCurDocVersionMatched))
end
function XLaunchAppVersionModule.GetAppVersion()
return AppVersion
end
function XLaunchAppVersionModule.GetNewDocVersion()
return NewDocVersion
end
function XLaunchAppVersionModule.GetNewLaunchModuleVersion()
return NewLaunchModuleVersion
end
function XLaunchAppVersionModule.CheckAppUpdate()
return not IsCurAppVersionMatched
end
function XLaunchAppVersionModule.CheckDocUpdate()
return not IsCurDocVersionMatched
end
function XLaunchAppVersionModule.CheckLaunchModuleUpdate()
return not IsCurLaunchModuleVersionMatched
end
function XLaunchAppVersionModule.HasDocUpdated()
return IsDocUpdated
end
function XLaunchAppVersionModule.HasLaunchModuleUpdated()
return IsLaunchModuleUpdated
end
function XLaunchAppVersionModule.UpdateDocVersion()
OldDocVersion = NewDocVersion
IsCurDocVersionMatched = NewDocVersion == AppVersion
IsDocUpdated = NewDocVersion == OldDocVersion
UnityPlayerPrefs.SetString(DOCUMENT_VERSION, CsRemoteConfig.DocumentVersion)
UnityPlayerPrefs.Save()
end
function XLaunchAppVersionModule.UpdateLaunchVersion()
OldLaunchModuleVersion = NewLaunchModuleVersion
IsCurLaunchModuleVersionMatched = AppVersion == NewLaunchModuleVersion
IsLaunchModuleUpdated = OldLaunchModuleVersion == NewLaunchModuleVersion
UnityPlayerPrefs.SetString(LAUNCH_MODULE_VERSION, CsRemoteConfig.LaunchModuleVersion)
UnityPlayerPrefs.Save()
end
Init()
--PrintVersion()
return XLaunchAppVersionModule

View file

@ -0,0 +1,165 @@
local UnityPlayerPrefs = CS.UnityEngine.PlayerPrefs
local DLC_HAS_DOWNLOADED_KEY = "DLC_HAS_DOWNLOADED_KEY"
local DLC_HAS_START_DOWNLOADED_KEY = "DLC_HAS_START_DOWNLOADED_KEY"
local HAS_SELECT_DOWNLOAD_PART_KEY = "HAS_SELECT_DOWNLOAD_PART_KEY"
local CsApplication = CS.XApplication
local CsLog = CS.XLog
local M = {}
local XLaunchDlcManager = M
local IndexTable = {}
local CommonIdSet = {}
local HasStartDownloadDic = {}
local DownloadedDic = {}
local DlcSizeDic = {}
local DlcIndexInfo = {}
local IsDlcBuild = false
local DLC_BASE_INDEX = 0 -- 基础资源包索引
local DLC_COMMON_INDEX = -1 -- 通用资源包索引
local STATE_DEFAULT = 0 -- 未开始下载
local STATE_START = 1 -- 已开始(选择)下载
--====启动逻辑接口 begin=====
M.Init = function(indexTable, commonIdList)
IndexTable = indexTable
for _, dlcId in pairs(commonIdList) do
CommonIdSet[dlcId] = true
end
for dlcId, info in pairs(IndexTable) do
HasStartDownloadDic[dlcId] = UnityPlayerPrefs.GetInt(DLC_HAS_START_DOWNLOADED_KEY .. dlcId, STATE_DEFAULT)
DownloadedDic[dlcId] = UnityPlayerPrefs.GetInt(DLC_HAS_DOWNLOADED_KEY .. dlcId, STATE_DEFAULT)
end
end
M.SetIsDlcBuild = function(isDlcBuild)
IsDlcBuild = isDlcBuild
end
M.SetDlcIndexInfo = function(dlcId, dlcIndexInfo) -- 记录size后即可丢弃
DlcIndexInfo[dlcId] = dlcIndexInfo
end
M.DoDownloadDlc = function(progressCb, doneCb, exitCb)
local PathModule = require("XLaunchAppPathModule")
local FileModuleCreator = require("XLaunchFileModule")
local VersionModule = require("XLaunchAppVersionModule")
if not PathModule.IsEditorOrStandalone() or CsApplication.Mode == CS.XMode.Release then
CsLog.Debug("Release 模式运行")
local DocFileModule = FileModuleCreator()
DocFileModule.Check(RES_FILE_TYPE.MATRIX_FILE, PathModule, VersionModule, doneCb, progressCb, exitCb)
elseif PathModule.IsEditorOrStandalone() and CsApplication.Mode == CS.XMode.Debug then
CsLog.Debug("Debug 模式运行")
doneCb()
elseif PathModule.IsEditorOrStandalone() and CsApplication.Mode == CS.XMode.Editor then
CsLog.Debug("Editor 模式运行")
doneCb()
end
end
-- 是否下载过指定id的分包
M.HasStartDownloadDlc = function(id)
return HasStartDownloadDic[id] == STATE_START
end
M.HasDownloadedDlc = function(id)
return DownloadedDic[id] == STATE_START
end
M.DoneDownload = function()
for dlcId, v in pairs(HasStartDownloadDic) do
if v == STATE_START then
DownloadedDic[dlcId] = STATE_START
UnityPlayerPrefs.SetInt(DLC_HAS_DOWNLOADED_KEY .. dlcId, STATE_START)
end
end
end
M.SetNeedDownload = function (id)
local state = STATE_START
CsLog.Debug("SetNeedDownload:" .. tostring(id))
HasStartDownloadDic[id] = state
UnityPlayerPrefs.SetInt(DLC_HAS_START_DOWNLOADED_KEY .. id, state)
-- 当依赖了通用资源的分包开始下载时,下载通用资源包
if CommonIdSet[id] and HasStartDownloadDic[DLC_COMMON_INDEX] ~= state then
HasStartDownloadDic[DLC_COMMON_INDEX] = state
UnityPlayerPrefs.SetInt(DLC_HAS_START_DOWNLOADED_KEY .. DLC_COMMON_INDEX, state)
end
end
M.SetAllNeedDownload = function()
for dlcId, info in pairs(IndexTable) do
M.SetNeedDownload(dlcId)
end
end
M.DownloadDlc = function (ids, processCb, doneCb)
for _, id in pairs(ids) do
M.SetNeedDownload(id)
end
XLuaUiManager.OpenWithCallback("UiLaunch",function()
M.DoDownloadDlc(processCb,
function()
XLuaUiManager.Close("UiLaunch")
if doneCb then
doneCb()
end
end,
function()
XLuaUiManager.Close("UiLaunch")
end)
end)
end
M.NeedShowSelectDownloadPart = function(appVer)
return UnityPlayerPrefs.GetInt(HAS_SELECT_DOWNLOAD_PART_KEY .. appVer, STATE_DEFAULT) == STATE_DEFAULT
end
M.DoneSelectDownloadPart = function(appVer)
UnityPlayerPrefs.SetInt(HAS_SELECT_DOWNLOAD_PART_KEY .. appVer, STATE_START)
end
--====启动逻辑接口 end=====
--======== 业务层接口 begin ====
M.NeedDownloadDlc = function(dlcId)
return DownloadedDic[dlcId] == STATE_DEFAULT
end
local GetDlcSize = function(dlcId)
if not DlcSizeDic[dlcId] then
local size = 0
local indexInfo = DlcIndexInfo[dlcId]
if indexInfo == nil then
return 0
end
for assetPath, docInfo in pairs(indexInfo) do
size = size + docInfo[3]
end
DlcSizeDic[dlcId] = size
end
return DlcSizeDic[dlcId]
end
M.GetDownloadSize = function(dlcIds)
local size = 0
for _, dlcId in pairs(dlcIds) do
size = size + GetDlcSize(dlcId)
end
return size
end
--======== 业务层接口 end ====
return XLaunchDlcManager

View file

@ -0,0 +1,873 @@
local UnityApplication = CS.UnityEngine.Application
local CsApplication = CS.XApplication
local CsLog = CS.XLog
local CsRemoteConfig = CS.XRemoteConfig
local CsTool = CS.XTool
local CsGameEventManager = CS.XGameEventManager.Instance
local CsInfo = CS.XInfo
local CsDownloadService = CS.XDownloadService.Instance
local DownloadState = {
NONE = -1,
DONE = 0,
ING = 1,
FAIL = 2
}
local IosDownloadState = {
PreparingLocalFiles = 0,
PreparingDownload = 1,
Downloading = 2,
AppendDownloading = 3,
Verifying = 4,
Finished = 5
}
-- 版更时需要强清本地资源的版本
local ForceVersion = {["1.22.0"] = true}
local ForceVersionNum = 22
local SPECIAL_DELETE_MATRIX_PREF_KEY = "__Kuro__reset_Matrix_files_"
local UNCHECKED_FILE_EXTENSION = ".unchecked"
local module_creator = function()
local XLaunchFileModule = {}
local MESSAGE_PACK_MODULE_NAME = "XLaunchCommon/XMessagePack"
require(MESSAGE_PACK_MODULE_NAME)
local XLaunchDlcManager = require("XLaunchDlcManager")
local SIZE = 10 * 1024 * 1024
local TIMEOUT = 5 * 1000
local READ_TIMEOUT = 10 * 1000
local RETRY = 10
local INDEX = "index"
local ResFileType
local AppPathModule
local AppVersionModule
local OnCompleteCallback
local OnProgressCallback
local OnExitCallback
local ApplicationFilePath
local DocumentFilePath
local DocumentUrl
local DocumentIndexDir
local DocumentIndexPath
local NewVersion
local NeedUpdate
local HasUpdated
-- common
local ApplicationIndexTable
local DocumentIndexTable
local DlcIndexTable
local DlcCommonIdList
local CurrentFileTable = nil
local AllFileTableDlc = nil
local NeedFileSet = nil
local UpdateTable = {}
local UpdateTableCount = 0
local UpdateSize = 0
local AllUpdateTable = {}
local AllUpdateTableCount = 0
local AllUpdateSize = 0
local CurrentUpdateSize = 0
--
local HasLocalFiles = false
-- Local Function
local CheckIndexFile
local ResolveResIndex
local PrepareDownload
local DownloadFiles
local CompleteDownload
local OnCompleteResFilesInit
local LoadIndexTable
local LoadIndexTableWithDlcInfo
local InitDocumentIndex
local DownloadDlcIndexs
local DoPrepareDownload
local OnNotifyEvent
local IsDlcBuild = false
local NeedShowSelect = false
function XLaunchFileModule.Check(resFileType, appPathModule, appVersionModule, completeCb,progressCb,exitCb)
ResFileType = resFileType
AppPathModule = appPathModule
AppVersionModule = appVersionModule
OnCompleteCallback = completeCb
OnProgressCallback = progressCb
OnExitCallback = exitCb
ApplicationFilePath = AppPathModule.GetApplicationFilePath()
DocumentFilePath = AppPathModule.GetDocumentFilePath()
DocumentUrl = AppPathModule.GetDocumentUrl()
IsDlcBuild = CsInfo.IsDlcBuild
XLaunchDlcManager.SetIsDlcBuild(IsDlcBuild)
DocumentIndexDir = DocumentFilePath .. "/" .. ResFileType .. "/"
DocumentIndexPath= DocumentIndexDir .. INDEX
NeedUpdate = false
NeedShowSelect = false
if ResFileType == RES_FILE_TYPE.LAUNCH_MODULE then
NeedUpdate = AppVersionModule.CheckLaunchModuleUpdate()
HasUpdated = AppVersionModule.HasLaunchModuleUpdated()
NewVersion = AppVersionModule.GetNewLaunchModuleVersion()
elseif ResFileType == RES_FILE_TYPE.MATRIX_FILE then
NeedUpdate = AppVersionModule.CheckDocUpdate()
HasUpdated = AppVersionModule.HasDocUpdated()
NewVersion = AppVersionModule.GetNewDocVersion()
NeedShowSelect = XLaunchDlcManager.NeedShowSelectDownloadPart(CsInfo.Version) and IsDlcBuild -- 每个大版本只会弹出一次选择更新,小更新沿用选择结果
end
if CS.XRemoteConfig.IsHideFunc then
--NeedUpdate = false
end
CsLog.Debug("NeedUpdate:"..tostring(NeedUpdate)..",type:"..ResFileType)
--
CheckIndexFile()
end
-- function XLaunchFileModule.GetOffset()
-- return OFFSET
-- end
DownloadDlcIndexs = function(cb)
if not IsDlcBuild then
cb()
return
end
DocumentIndexTable, DlcIndexTable, DlcCommonIdList = LoadIndexTableWithDlcInfo(DocumentIndexPath)
local count = 0
local totalCount = 0
if DlcIndexTable then
for _, _ in pairs(DlcIndexTable) do
totalCount = totalCount + 1
end
end
if totalCount > 0 then
CsGameEventManager:Notify(CS.XEventId.EVENT_LAUNCH_START_DOWNLOAD, totalCount, false, CsApplication.GetText("UpdateIndex") .. "(%d/%d)") -- 检查更新(0/10)
CsApplication.SetProgress(0)
end
local iter, t, key = pairs(DlcIndexTable)
local info
local iterKey = nil
local Loop
Loop = function()
key, info = iter(t, iterKey)
if not key then
CsApplication.SetProgress(1)
cb()
return
end
local id = key
local name = info[1]
local sha1 = info[2]
local cache = true -- 本地缓存 校验通过不重复下载
local str = string.format("%s/%s/%s/%s", DocumentUrl, NewVersion, ResFileType, name)
local str2 = DocumentFilePath .. "/" .. ResFileType .. "/" .. name
local downloader = CS.XUriPrefixDownloader(str, str2, cache, sha1, TIMEOUT, RETRY, READ_TIMEOUT)
local size = 0
--CsLog.Debug("DocumentUrl:"..DocumentUrl)
--CsLog.Debug("str:"..str)
--CsLog.Debug("str2:"..str2)
CsTool.WaitCoroutinePerFrame(downloader:Send(), function(isComplete)
if not isComplete then
--
else
if downloader.State ~= CS.XDownloaderState.Success then
local msg = "XFileManager Download error, state error, state: " .. tostring(downloader.State)
CsLog.Error(msg)
local dict = {}
dict.file_name = name
dict.file_size = 1
CS.XRecord.Record(dict, "80007", "XFileManagerDownloadError")
ShowStartErrorDialog("FileManagerInitFileTableDownloadError", CsApplication.Exit, function()
Loop()
end, CsApplication.GetText("Retry")) -- 重试
return
end
count = count + 1
CsApplication.SetProgress(count / totalCount)
CsLog.Debug("[] EVENT_LAUNCH_START_DOWNLOAD count:" .. tostring(count))
iterKey = key
Loop()
end
end)
end
Loop()
end
-- 检测资源列表文件
CheckIndexFile = function()
CS.XAppEventManager.LogAppEvent(CS.XAppEventConfig.Version_Checking_Start)
local documentFilePath = DocumentFilePath .. "/" .. ResFileType .. "/" .. INDEX
local keepLocalIndex = CS.System.IO.File.Exists(DocumentFilePath .. "/DevelopmentIndex") -- 用于Release环境不清理本地index文件兼顾覆盖安装和手动放资源的情况
CsLog.Debug("[Download] CheckIndexFile:"..ResFileType .. ", documentFilePath:" .. tostring(CS.System.IO.File.Exists(documentFilePath))
.. ", Debug:" .. tostring(CsRemoteConfig.Debug) .. ", NeedUpdate:" .. tostring(NeedUpdate) .. ", keepLocalIndex:" .. tostring(keepLocalIndex))
if not NeedUpdate then
if CS.System.IO.File.Exists(documentFilePath) and not CsRemoteConfig.Debug then -- debug情况下不需更新但要保留本地index
if not keepLocalIndex then
CS.XFileTool.DeleteFile(documentFilePath)
end
end
-- 原始版本,直接进
ResolveResIndex()
return
end
-- 下载/检测 当前index文件是否最新
local sha1 = "empty"
local newVersion = ""
if ResFileType == RES_FILE_TYPE.LAUNCH_MODULE then
sha1 = CsRemoteConfig.LaunchIndexSha1
newVersion = CsRemoteConfig.LaunchModuleVersion
elseif ResFileType == RES_FILE_TYPE.MATRIX_FILE then
sha1 = CsRemoteConfig.IndexSha1
newVersion = CsRemoteConfig.DocumentVersion
end
if HasUpdated and CS.XFileTool.CheckSha1(documentFilePath, sha1) then
CsLog.Debug("[Download] HasUpdated:" .. tostring(HasUpdated))
ResolveResIndex()
return
end
--CsLog.Debug("index download DocumentUrl:"..DocumentUrl)
local uriPrefixStr = DocumentUrl .. "/" .. newVersion .. "/" .. ResFileType .. "/" .. INDEX
local downloader = CS.XUriPrefixDownloader(uriPrefixStr, documentFilePath, false, sha1)
CsTool.WaitCoroutine(downloader:Send(), function()
if downloader.State ~= CS.XDownloaderState.Success then
ShowStartErrorDialog("FileManagerInitVersionDownLoadError")
else
if ResFileType == RES_FILE_TYPE.LAUNCH_MODULE then
AppVersionModule.UpdateLaunchVersion()
ResolveResIndex()
elseif ResFileType == RES_FILE_TYPE.MATRIX_FILE then
DownloadDlcIndexs(function()
AppVersionModule.UpdateDocVersion()
ResolveResIndex()
end)
end
end
end)
end
LoadIndexTable = function(indexPath)
local assetBundle = CS.UnityEngine.AssetBundle.LoadFromFile(indexPath)
if (assetBundle and assetBundle:Exist()) then
local assetName = assetBundle:GetAllAssetNames()[0]
local asset = assetBundle:LoadAsset(assetName, typeof(CS.UnityEngine.TextAsset))
local indexFile = XMessagePack.Decode(asset.bytes)
local indexTable = indexFile[1]
assetBundle:Unload(true)
return indexTable
end
return nil
end
LoadIndexTableWithDlcInfo = function(indexPath)
local assetBundle = CS.UnityEngine.AssetBundle.LoadFromFile(indexPath)
if (assetBundle and assetBundle:Exist()) then
local assetName = assetBundle:GetAllAssetNames()[0]
local asset = assetBundle:LoadAsset(assetName, typeof(CS.UnityEngine.TextAsset))
local indexFile = XMessagePack.Decode(asset.bytes)
local indexTable = indexFile[1]
local dlcIndexTable = indexFile[2] or {}
local dlcCommonIdList = indexFile[3] or {}
assetBundle:Unload(true)
return indexTable, dlcIndexTable, dlcCommonIdList
end
return nil
end
-- 解析doc目录下index
InitDocumentIndex = function()
if not CS.System.IO.File.Exists(DocumentIndexPath) then
CsLog.Error("[Download] Init DocumentIndex Failed, file not exist: " .. tostring(DocumentIndexPath))
return
end
if not DocumentIndexTable then
if IsDlcBuild then
DocumentIndexTable, DlcIndexTable, DlcCommonIdList = LoadIndexTableWithDlcInfo(DocumentIndexPath)
else
DocumentIndexTable = LoadIndexTable(DocumentIndexPath) -- {[assetPath] = value{[1] = Name, [2] = Sha1, [3] = Size}, ... }
end
end
CurrentFileTable = {} -- 当前需下载资源
AllFileTableDlc = {} -- DLC完整资源
local count = 0
NeedFileSet = {} -- 需下载标记
-- 基础补丁
for asset, info in pairs(DocumentIndexTable) do
NeedFileSet[info[1]] = true
CurrentFileTable[asset] = info
AllFileTableDlc[asset] = info
end
-- 统计资源
if IsDlcBuild then
XLaunchDlcManager.Init(DlcIndexTable, DlcCommonIdList)
-- 分包补丁
for dlcId, dlcIndexInfo in pairs(DlcIndexTable) do
local dlcIndexPath = DocumentIndexDir .. dlcIndexInfo[1]
local dlcTable = LoadIndexTable(dlcIndexPath)
XLaunchDlcManager.SetDlcIndexInfo(dlcId, dlcTable)
-- 历史选择的分包下载记录(不弹出选择框是用于默认下载)
local hasDownloadDlc = (not NeedShowSelect) and XLaunchDlcManager.HasStartDownloadDlc(dlcId)
CsLog.Debug("[DLC] dlcId: ".. tostring(dlcId) .. ", hasDownloadDlc: " .. tostring(hasDownloadDlc) .. ", NeedShowSelect:" .. tostring(NeedShowSelect))
for asset, info in pairs(dlcTable) do
NeedFileSet[info[1]] = true
if hasDownloadDlc then
CurrentFileTable[asset] = info
end
AllFileTableDlc[asset] = info
end
end
-- 剔除包内已有资源需asset与Name都对应
for asset, info in pairs(ApplicationIndexTable) do
local value = AllFileTableDlc[asset]
if value and value[1] == info[1] then
AllFileTableDlc[asset] = nil
CurrentFileTable[asset] = nil
count = count + 1
end
end
else
CurrentFileTable = DocumentIndexTable
-- 剔除包内已有资源需asset与Name都对应
for asset, info in pairs(ApplicationIndexTable) do
local value = CurrentFileTable[asset]
if value and value[1] == info[1] then
CurrentFileTable[asset] = nil
count = count + 1
end
end
end
CsLog.Debug("[Download] 包内已有资源数量:" .. count)
end
ResolveResIndex = function()
CS.XAppEventManager.LogAppEvent(CS.XAppEventConfig.Version_Checking_End)
local applicationIndexPath = ApplicationFilePath .. "/" .. ResFileType .. "/" .. INDEX
ApplicationIndexTable = LoadIndexTable(applicationIndexPath)
CsLog.Debug("[Download] ResolveResIndex. NeedUpdate:" .. tostring(NeedUpdate) .. ", applicationIndexPath:" .. applicationIndexPath .. ", documentIndexPath:" .. DocumentIndexPath)
if not NeedUpdate then -- 原始版本
if CS.System.IO.File.Exists(DocumentIndexPath) then
CsLog.Debug("Local index:" .. DocumentIndexPath)
InitDocumentIndex()
HasLocalFiles = true
end
OnCompleteResFilesInit() -- 无需更新,直接完成
return
end
InitDocumentIndex()
UpdateSize = 0
UpdateTableCount = 0
UpdateTable = {}
for _, info in pairs(CurrentFileTable) do
if UpdateTable[info[1]] then
local dict = {}
dict["file_name"] = info[1]
CS.XRecord.Record(dict, "80006", "UpdateTableAddFileError")
CsLog.Error("repeat update file:" .. tostring(info[1]))
ShowStartErrorDialog("FileManagerInitFileTableUpdateTableError")
return
end
UpdateTable[info[1]] = info
UpdateTableCount = UpdateTableCount + 1
UpdateSize = UpdateSize + info[3]
end
AllUpdateSize = 0
AllUpdateTable = {}
AllUpdateTableCount = 0
if NeedShowSelect then
for _, info in pairs(AllFileTableDlc) do
AllUpdateTable[info[1]] = info
AllUpdateTableCount = AllUpdateTableCount + 1
AllUpdateSize = AllUpdateSize + info[3]
end
end
CsLog.Debug("[Download] IsDlcBuild:" .. tostring(IsDlcBuild))
CsLog.Debug(string.format("[Download] UpdateSize: %d, UpdateTableCount: %d, AllUpdateSize: %d, AllUpdateTableCount: %d", UpdateSize, UpdateTableCount, AllUpdateSize, AllUpdateTableCount)) -- 2166 -- 基础包补丁
local deleteKey = SPECIAL_DELETE_MATRIX_PREF_KEY .. tostring(AppVersionModule.GetAppVersion())
local isMatrix = ResFileType == "matrix"
local cleanFlag = CS.UnityEngine.PlayerPrefs.GetInt(deleteKey, 0)
local checkClean = (isMatrix and (not cleanFlag or cleanFlag ~= 1))
local isForceClean = ForceVersion[CsInfo.Version]
if isMatrix and not isForceClean then -- 补充强删资源逻辑
local theDeleteKey = SPECIAL_DELETE_MATRIX_PREF_KEY .. "1." .. ForceVersionNum .. ".0"
local theCleanFlag = CS.UnityEngine.PlayerPrefs.GetInt(theDeleteKey, 0)
CsLog.Debug("key:" .. theDeleteKey .. ", cleanFlag:" .. tostring(cleanFlag) .. ", force cleanFlag :" .. tostring(theCleanFlag))
if cleanFlag ~= 1 and (theCleanFlag ~= 1) then -- 首次检测当前版本、 且没经历过强删版本
for versionNum = ForceVersionNum - 1, 10, -1 do -- 经历过再之前版本 -- 属于旧包覆盖安装,需要强清资源
local lastDeleteKey = SPECIAL_DELETE_MATRIX_PREF_KEY .. "1." .. versionNum .. ".0"
local lastCleanFlag = CS.UnityEngine.PlayerPrefs.GetInt(lastDeleteKey, 0)
CsLog.Debug("[Download] Check Force Clean Key:" .. lastDeleteKey .. ", cleanFlag:" .. tostring(lastCleanFlag) .. ", " .. type(lastCleanFlag))
if lastCleanFlag == 1 then
isForceClean = true
CsLog.Debug("[Download] 过旧版本 需要全面清理资源, version:" .. lastDeleteKey)
-- 完成后增加强删版本的标记
CS.UnityEngine.PlayerPrefs.SetInt(theDeleteKey, 1)
CS.UnityEngine.PlayerPrefs.Save()
break
end
end
end
end
CsLog.Debug("[Download] 上一版本资源key: " .. tostring(deleteKey) .. ", type: " .. tostring(ResFileType) .. ", checkClean: " .. tostring(checkClean) .. ", force:" .. tostring(isForceClean) .. ", CsInfo.Version:" .. tostring(CsInfo.Version))
local files = CS.XFileTool.GetFiles(DocumentFilePath .. "/" .. ResFileType)
local lastVerCount = 0
local otherCount = 0
local totalCount = 0
--是否启用IOS后台下载
--在启用时由于IOS校验流程的统一需要因此文件下载完可能还未校验需要假设资源是完整的
--在以上条件下,需要合理估计仍然需要下载的文件大小,因此需要减去对仅未验证的文件的大小
local isUseIosDownloadService = (CS.XRemoteConfig.DownloadMethod == 0) and AppPathModule.IsIos()
for i = 0, files.Length - 1 do
local file = files[i]
local name = CS.XFileTool.GetFileName(file)
totalCount = totalCount + 1
local isIndex = IsDlcBuild and (string.sub(name,1,5) == INDEX) or (name == INDEX)
if isIndex then
goto CONTINUE
end
if checkClean then
if isForceClean or not NeedFileSet[name] then
CsLog.Debug("[Download] 清理上一版本资源" .. tostring(name) .. ", need:" .. tostring((not NeedFileSet[name])))
CS.XFileTool.DeleteFile(file)
lastVerCount = lastVerCount + 1
goto CONTINUE
end
end
-- 检查更新文件是否存在
local hasUpdated = false
local info = UpdateTable[name]
if info then
UpdateTable[name] = nil
UpdateTableCount = UpdateTableCount - 1
UpdateSize = UpdateSize - info[3]
hasUpdated = true
end
if NeedShowSelect then
local infoDlc = AllUpdateTable[name]
if infoDlc then
AllUpdateTable[name] = nil
AllUpdateTableCount = AllUpdateTableCount - 1
AllUpdateSize = AllUpdateSize - infoDlc[3]
hasUpdated = true
end
end
if hasUpdated then
goto CONTINUE
end
local nameWithOutExtension = CS.XFileTool.GetFileNameWithoutExtension(file)
if UpdateTable[nameWithOutExtension] then -- 下载时临时文件name.download将会保留
info = UpdateTable[nameWithOutExtension]
if isUseIosDownloadService then
if CS.XFileTool.GetFileExtension(file) == UNCHECKED_FILE_EXTENSION then
UpdateSize = UpdateSize - info[3]
end
end
goto CONTINUE
end
otherCount = otherCount + 1
CS.XFileTool.DeleteFile(file)
:: CONTINUE ::
end
CsLog.Debug(string.format("[Download] 资源清理 本地总数:%d, 清理上版本数:%d, 其他清理:%d, 需更新: %d dlc需更新%d",
totalCount, lastVerCount, otherCount, UpdateTableCount, AllUpdateTableCount))
if checkClean then
CsLog.Debug("[Download] 清理上一版本资源完成。")
CS.UnityEngine.PlayerPrefs.SetInt(deleteKey, 1)
CS.UnityEngine.PlayerPrefs.Save()
end
PrepareDownload()
end
local GetSizeAndUnit = function(size)
local unit = "k"
local num = size / 1024
if (num > 100) then
unit = "MB"
num = num / 1024
end
return unit,num
end
OnDoneSelect = function(isFullDownload)
DlcManager.DoneSelectDownloadPart(CsInfo.Version)
if isFullDownload then
DlcManager.SetAllNeedDownload()
UpdateTable = AllUpdateTable
end
DoPrepareDownload()
end
PrepareDownload = function()
if UpdateTableCount <= 0 and (not NeedShowSelect or AllUpdateTableCount <=0) then
OnCompleteResFilesInit()
return
end
--todo 如果是dlc打包显示选择框选择完重新下载
if NeedShowSelect then
CsGameEventManager:RegisterEvent(CS.XEventId.EVENT_LAUNCH_DONE_DOWNLOAD_SELECT, function(evt,data)
OnDoneSelect(data[0])
end)
CsGameEventManager:Notify(CS.XEventId.EVENT_LAUNCH_SHOW_DOWNLOAD_SELECT,UpdateSize,AllUpdateSize)
else
DoPrepareDownload()
end
end
DoPrepareDownload = function()
local dict = {["type"] = ResFileType, ["version"] = NewVersion}
CS.XRecord.Record(dict, "80011", "StartDownloadNewFiles")
local unit,num = GetSizeAndUnit(UpdateSize)
-- 日服不做热更时网络状态判断
--if (UnityApplication.internetReachability == CS.UnityEngine.NetworkReachability.ReachableViaCarrierDataNetwork and UpdateSize > SIZE) then
--BDC
-- CS.XHeroBdcAgent.BdcUpdateGame("203", "1", "0")
-- local tmpStr = string.format("%0.2f%s%s", num, unit, CsApplication.GetText("UpdateCheck"))
-- CsTool.WaitCoroutine(CsApplication.CoDialog(CsApplication.GetText("Tip"), tmpStr, CsApplication.Exit, function()
-- DownloadFiles()
-- end))
-- return
--end
--BDC
CS.XHeroBdcAgent.BdcUpdateGame("203", "1", "0")
local tmpStr = string.format("%s%0.2f %s", CsApplication.GetText("UpdateCheck"), num, unit) -- 海外调整热更文本 -- #104203 文本最后与单位新增一个空格
CsTool.WaitCoroutine(CsApplication.CoDialog(CsApplication.GetText("Tip"), tmpStr, CsApplication.Exit, function()
DownloadFiles()
end))
return
end
local AndroidBackgroundDownload = function()
--android background download todo
--1.组建好一个数组传给backgroud download组件开始下载
--2.每帧获取下载状态,更新界面(当前下载文件,下载进度)
--3.重试状态
--4.下载完成状态
local urlPrefix = string.format("%s/%s/%s/", DocumentUrl, NewVersion, ResFileType)
local downloadDir = DocumentFilePath .. "/" .. ResFileType .. "/"
local allNameTable = {}
local allSha1Table = {}
local allSizeTable = {}
for name, info in pairs(UpdateTable) do
table.insert(allNameTable, info[1])
table.insert(allSha1Table, info[2])
table.insert(allSizeTable, info[3])
end
local names = table.concat(allNameTable,";")
local sha1s = table.concat(allSha1Table,";")
local sizes = table.concat(allSizeTable,";")
CsDownloadService:Download(urlPrefix, downloadDir, names, sha1s, TIMEOUT, RETRY, sizes)
local waitTimeCnt = 0
local updateInfoCb = nil
updateInfoCb = function()
-- 下载进度
local state = CsDownloadService:GetDownloadState()
local fileSize = CsDownloadService:GetCurrentFileSize()
local curDoneSize = CsDownloadService:GetCurrentDownloadSize()
if state == DownloadState.ING then
waitTimeCnt = 0
local updateProgress = UpdateSize == 0 and 0 or curDoneSize / UpdateSize
if updateProgress>1 then updateProgress =1 end
CsApplication.SetProgress(updateProgress)
if OnProgressCallback then
OnProgressCallback(updateProgress)
end
elseif state == DownloadState.FAIL or (state == DownloadState.NONE and waitTimeCnt > 20) then
CsTool.RemoveUpdateEvent(updateInfoCb)
local errMsg = CsDownloadService:GetExceptionInfo()
local name = CsDownloadService:GetCurrentFileName()
CsLog.Error("[Download] Android Download error, state error, state: " .. tostring(state)..", err:" .. errMsg .. ", name:" .. tostring(name) .. ", fileSize:" .. tostring(fileSize))
local exitCb = OnExitCallback or CsApplication.Exit
CsLog.Debug("[Download Android Backgroud] Istate " .. tostring(state) .. ",waitTimeCnt: " .. tostring(waitTimeCnt))
ShowStartErrorDialog("FileManagerInitFileTableDownloadError", exitCb, function()
CheckIndexFile()
end, CsApplication.GetText("Retry"))
elseif state == DownloadState.DONE then
CsLog.Debug("[Download Android Backgroud] Istate == DownloadState.DONE! ")
CsTool.RemoveUpdateEvent(updateInfoCb)
CompleteDownload()
elseif state == DownloadState.NONE then
waitTimeCnt = waitTimeCnt + CS.UnityEngine.Time.deltaTime
end
end
CsTool.AddUpdateEvent(updateInfoCb)
end
local IosBackgroundDownload = function()
local urlPrefix = string.format("%s/%s/%s", DocumentUrl, NewVersion, ResFileType)
CS.XIOSDownloadConfig.PrepareCNDList(urlPrefix);
local taskArr = {}
for _,v in pairs(UpdateTable) do
table.insert(taskArr, string.format("%s %s %s", v[1], v[3], v[2]))
end
local taskInfo = table.concat(taskArr,"\n")
CS.XIOSDownloadCustomer.Instance:SetTaskInfo(taskInfo)
local manager = CS.XIOSDownloadManager.Instance
local verifier = CS.XIOSDownloadVerifier.Instance
local updateEvent
updateEvent = function()
if manager.StateInt == IosDownloadState.PreparingLocalFiles then
--Nothing Here
elseif manager.StateInt == IosDownloadState.PreparingDownload then
--Nothing Here
elseif manager.StateInt == IosDownloadState.Downloading or manager.StateInt == IosDownloadState.AppendDownloading then
if manager.StateInt == IosDownloadState.AppendDownloading and manager.TotalTaskBytes ~= 0 then
CsGameEventManager:Notify(CS.XEventId.EVENT_LAUNCH_START_DOWNLOAD, manager.TotalTaskBytes)
end
local progress = manager.CurDownloadedBytes / manager.TotalTaskBytes;
if progress and progress ~= math.huge then
CsApplication.SetProgress(progress)
end
if OnProgressCallback then
OnProgressCallback(progress)
end
elseif manager.StateInt == IosDownloadState.Verifying then
CS.XGameEventManager.Instance:Notify(CS.XEventId.EVENT_LAUNCH_START_LOADING)
CsApplication.SetMessage(string.format("正在校验中(%d/%d)", verifier.CurrentCheckCount, verifier.TotalNeedCheckCount))
CsApplication.SetProgress(verifier.CurrentCheckCount / verifier.TotalNeedCheckCount)
elseif manager.StateInt == IosDownloadState.Finished then
CsTool.RemoveUpdateEvent(updateEvent)
manager:Clear()
CompleteDownload()
end
end
manager:Prepare()
manager:SetDownloadErrorHandler(function(file)
local exitCb = OnExitCallback or CsApplication.Exit
ShowStartErrorDialog("FileManagerInitFileTableDownloadError", exitCb, function()
manager:ContinueDownloading()
end, CsApplication.GetText("Retry")) -- 重试
end)
CsTool.AddUpdateEvent(updateEvent)
end
local TraditionalDownload = function()
local updateFileText = CsApplication.GetText("UpdateFile")
local iter, t, key = pairs(UpdateTable)
local info
local iterKey = nil
local Loop
Loop = function()
key, info = iter(t, iterKey)
if not key then
CompleteDownload()
return
end
local name = info[1]
local sha1 = info[2] -- 补丁index中记录的sha1和下载后文件sha1对比
CsApplication.SetMessage(updateFileText .. ": " .. name)
local str = string.format("%s/%s/%s/%s", DocumentUrl, NewVersion, ResFileType, name)
local str2 = DocumentFilePath .. "/" .. ResFileType .. "/" .. name
local downloader = CS.XUriPrefixDownloader(str, str2, true, sha1, TIMEOUT, RETRY, READ_TIMEOUT)
local size = 0
CsTool.WaitCoroutinePerFrame(downloader:Send(), function(isComplete)
if not isComplete then
--
CurrentUpdateSize = CurrentUpdateSize - size + downloader.CurrentSize
size = downloader.CurrentSize
local updateProgress = UpdateSize == 0 and 0 or CurrentUpdateSize / UpdateSize
CsApplication.SetProgress(updateProgress)
if OnProgressCallback then
OnProgressCallback(updateProgress)
end
else
if downloader.State ~= CS.XDownloaderState.Success then
local msg = "[Download] error, state error, state: " .. tostring(downloader.State)
CsLog.Error(msg)
local dict = {}
dict.file_name = name
dict.file_size = info[3]
CS.XRecord.Record(dict, "80007", "XFileManagerDownloadError")
local exitCb = OnExitCallback or CsApplication.Exit
ShowStartErrorDialog("FileManagerInitFileTableDownloadError",exitCb, function()
Loop()
end, CsApplication.GetText("Retry")) -- 重试
return
end
CurrentUpdateSize = CurrentUpdateSize - size + downloader.Size
iterKey = key
Loop()
end
end)
end
Loop()
end
DownloadFiles = function()
CsGameEventManager:Notify(CS.XEventId.EVENT_LAUNCH_START_DOWNLOAD, UpdateSize)
CS.XAppEventManager.LogAppEvent(CS.XAppEventConfig.Resource_Download_Start)
CS.XHeroBdcAgent.BdcUpdateGame("204", "1", "0")
CsApplication.SetMessage(CsApplication.GetText("GameUpdate"))
CsApplication.SetProgress(0)
local isUseAndroidDownloadService = (CS.XRemoteConfig.DownloadMethod == 0) and AppPathModule.IsAndroid()
local isUseIosDownloadService = (CS.XRemoteConfig.DownloadMethod == 0) and AppPathModule.IsIos()
if isUseAndroidDownloadService and ResFileType == RES_FILE_TYPE.MATRIX_FILE then
CsLog.Debug("安卓后台下载模式")
AndroidBackgroundDownload()
elseif isUseIosDownloadService and ResFileType == RES_FILE_TYPE.MATRIX_FILE then
CsLog.Debug("IOS后台下载模式")
IosBackgroundDownload()
else
CsLog.Debug("传统下载模式")
TraditionalDownload()
end
end
CompleteDownload = function()
CsApplication.SetProgress(1)
local dict = {["type"] = ResFileType, ["version"] = NewVersion}
CS.XRecord.Record(dict, "80012", "DownloadNewFilesEnd")
CS.XAppEventManager.LogAppEvent(CS.XAppEventConfig.Resource_Download_End)
OnCompleteResFilesInit()
end
OnCompleteResFilesInit = function()
local urlTable = {}
if IsDlcBuild then
if AllFileTableDlc then
for asset, info in pairs(AllFileTableDlc) do
urlTable[asset] = DocumentFilePath .. "/" .. ResFileType .. "/" .. info[1]
end
XLaunchDlcManager.DoneDownload()
end
else
if DocumentIndexTable then
for asset, info in pairs(DocumentIndexTable) do
urlTable[asset] = DocumentFilePath .. "/" .. ResFileType .. "/" .. info[1]
end
end
end
for asset, info in pairs(ApplicationIndexTable) do
if not urlTable[asset] or HasLocalFiles then -- 包体资源优先于本地测试资源
urlTable[asset] = ApplicationFilePath .. "/" .. ResFileType .. "/" .. info[1]
end
end
ApplicationIndexTable = nil
DocumentIndexTable = nil
CurrentFileTable = nil
DlcIndexTable = nil
AllFileTableDlc = nil
if NeedShowSelect then
CsGameEventManager:RemoveEvent(CS.XEventId.EVENT_LAUNCH_DONE_DOWNLOAD_SELECT, OnNotifyEvent)
XLaunchDlcManager.DoneSelectDownloadPart(CsInfo.Version) -- 下载完成后才记录选择记录
end
-- 完成回调
if OnCompleteCallback then
OnCompleteCallback(urlTable, NeedUpdate, HasLocalFiles)
end
end
return XLaunchFileModule
end
return module_creator

View file

@ -0,0 +1,438 @@
local CsApplication = CS.XApplication
local CsLog = CS.XLog
local CsInfo = CS.XInfo
local CsTool = CS.XTool
local CsStringEx = CS.XStringEx
local CsGameEventManager = CS.XGameEventManager.Instance
local IO = CS.System.IO
local CsRemoteConfig = CS.XRemoteConfig
--Test 设置模式
--CsApplication.Mode = CS.XMode.Debug
print("Launch Version Code 1." )
RES_FILE_TYPE = {
LAUNCH_MODULE = "launch",
MATRIX_FILE = "matrix",
CG_FILE = "cg",
}
local APP_PATH_MODULE_NAME = "XLaunchAppPathModule"
local APP_VERSION_MODULE_NAME = "XLaunchAppVersionModule"
local FILE_MODULE_NAME = "XLaunchFileModule"
local UI_MODULE_NAME = "XLaunchUiModule"
local PathModule = require(APP_PATH_MODULE_NAME)
local FileModuleCreator = require(FILE_MODULE_NAME)
local XLaunchUiModule = require(UI_MODULE_NAME)
local VersionModule
local LaunchFileModule
local DocFileModule
local IsReloaded = false
local ResFileUrlTable = {}
-- 游戏内强更
local DOWNLOAD_APK_VERSION = "download_apk_ver"
local OPPO_CHANNEL_ID = 1
local ApkListUrl = "client/patch/config.js"
local ApkFileName = "Punishing.apk"
local ApkSavePath = string.format("%s/%s", CS.UnityEngine.Application.persistentDataPath, ApkFileName)
local ApkFileSize = 0
local APK_TIMEOUT = 5000
-- local IsApkTesting = true -- 调试用
--- >>>>>>>>>>>>>>>>>>>>>>>>>> 私有方法 * 声明 >>>>>>>>>>>>>>>>>>>>>>>>>>
local CheckLaunchModuleUpdate
local CheckDocUpdate
local DownloadDlc
local OnCheckLaunchModuleComplete
local InitGame
local CheckDownloadChannel
local TryDownloadApk
local BeforeDownloadApk
local StartDownloadApk
local CheckLocalZipFile
--- <<<<<<<<<<<<<<<<<<<<<<<<<< 私有方法 * 声明 <<<<<<<<<<<<<<<<<<<<<<<<<<
GetResFileUrl = GetResFileUrl or nil
-- 注意:重载模块需要释放的对象
ShowStartErrorDialog = function(errorCode, confirmCB, cancelCB, cancelStr)
CS.XHeroBdcAgent.BdcStartUpError(errorCode)
confirmCB = confirmCB or CsApplication.Exit
CsTool.WaitCoroutine(CsApplication.CoDialog(CsApplication.GetText("Tip"), CsApplication.GetText(errorCode), cancelCB, confirmCB, cancelStr))
end
--- >>>>>>>>>>>>>>>>>>>>>>>>>> 私有方法 * 定义 >>>>>>>>>>>>>>>>>>>>>>>>>>
CheckLaunchModuleUpdate = function()
if not PathModule.IsEditorOrStandalone() or CsApplication.Mode == CS.XMode.Release then
LaunchFileModule = FileModuleCreator()
LaunchFileModule.Check(RES_FILE_TYPE.LAUNCH_MODULE, PathModule, VersionModule, OnCheckLaunchModuleComplete)
else
CheckDocUpdate()
end
end
CheckDocUpdate = function()
if not PathModule.IsEditorOrStandalone() or CsApplication.Mode == CS.XMode.Release then
CsLog.Debug("Release 模式运行")
DocFileModule = FileModuleCreator()
DocFileModule.Check(RES_FILE_TYPE.MATRIX_FILE, PathModule, VersionModule, InitGame)
elseif PathModule.IsEditorOrStandalone() and CsApplication.Mode == CS.XMode.Debug then
CsLog.Debug("Debug 模式运行")
InitGame()
elseif PathModule.IsEditorOrStandalone() and CsApplication.Mode == CS.XMode.Editor then
CsLog.Debug("Editor 模式运行")
CS.XResourceManager.InitEditor()
InitGame()
end
end
OnCheckLaunchModuleComplete = function(urlTable, needUpdate, hasLocalFiles)
if not needUpdate or IsReloaded then
CheckDocUpdate()
if hasLocalFiles then
CS.XLaunchManager.SetUrlTable(urlTable)
end
return
end
CS.XUiManager.Instance:Clear()
CS.XResourceManager.Clear()
CS.XResourceManager.ClearFileDelegate()
CS.XLaunchManager.SetUrlTable(urlTable)
CS.XResourceManager.ResolveBundleManifest("launchmanifest")
ShowStartErrorDialog = nil
CheckUpdate = nil
CS.XLaunchManager.GetLaunchUi = nil
CS.XGame.ReloadLaunchModule()
end
InitGame = function(urlTable)
urlTable = urlTable or {}
for k, v in pairs(urlTable) do
local url = ResFileUrlTable[k]
if url then
CS.XLog.Error("资源文件key重复key:" .. tostring(k))
return
end
ResFileUrlTable[k] = v
end
CsGameEventManager:Notify(CS.XEventId.EVENT_LAUNCH_START_LOADING)
local import = CS.XLuaEngine.Import
import("XLaunchCommon")
import("XLaunchUi")
--TODO
GetResFileUrl = function(path)
if not PathModule.IsEditorOrStandalone() or CsApplication.Mode == CS.XMode.Release then
return ResFileUrlTable[path]
elseif PathModule.IsEditorOrStandalone() and CsApplication.Mode == CS.XMode.Debug then
return PathModule.GetDebugFilePath() .. "/" .. path
else
return path
end
end
CS.XLaunchManager.GetPrimaryFileUrl = GetResFileUrl
if not PathModule.IsEditorOrStandalone() or CsApplication.Mode == CS.XMode.Release then
--
--CS.XResourceManager.ClearFileDelegate()
CS.XResourceManager.AddFileDelegate(GetResFileUrl)
CS.XResourceManager.ResolveBundleManifest("matrixmanifest")
end
CS.XGame.InitGame()
end
--- <<<<<<<<<<<<<<<<<<<<<<<<<< 私有方法 * 定义 <<<<<<<<<<<<<<<<<<<<<<<<<<
CheckUpdate = function(isReloaded)
IsReloaded = isReloaded or false
CS.XLaunchManager.GetLaunchUi = XLaunchUiModule.NewLaunchUi
if not IsReloaded then
XLaunchUiModule.RegisterLaunchUi()
end
--测试模式,初始化资源管理器
if PathModule.IsEditorOrStandalone() and CsApplication.Mode == CS.XMode.Debug then
CS.XResourceManager.InitBundleDebug(PathModule.GetDebugFilePath())
elseif PathModule.IsEditorOrStandalone() and CsApplication.Mode == CS.XMode.Editor then
CS.XResourceManager.InitEditor()
end
-- 开启Launch模块Ui
CS.XUiManager.Instance:Open("UiLaunch")
CS.XRecord.Record("50000", "UiLaunchand")
VersionModule = require(APP_VERSION_MODULE_NAME)
if not PathModule.IsEditorOrStandalone() or CsApplication.Mode == CS.XMode.Release then
CS.XHeroBdcAgent.BdcUpdateGame("201", "1", "0")
end
if VersionModule.CheckAppUpdate() then
-- if IsApkTesting or VersionModule.CheckAppUpdate() then
local tmpStr = CsStringEx.Format(CsApplication.GetText("UpdateApplication"), CsInfo.Version)
CsTool.WaitCoroutine(CsApplication.CoDialog(CsApplication.GetText("Tip"), tmpStr, nil, function()
local jumpCB = function()
print("[Apk] - Failed to Download Apk.")
CsTool.WaitCoroutine(CsApplication.GoToUpdateURL(PathModule.GetAppUpgradeUrl()), nil)
end
local downloadCB = function(url)
BeforeDownloadApk(url)
end
TryDownloadApk(downloadCB, jumpCB)
end))
else
-- 无需更新并删除本地下载的Apk
if CheckDownloadChannel() and IO.File.Exists(ApkSavePath) then
print("[Apk] - Clean Apk path:" .. ApkSavePath)
CS.XFileTool.DeleteFile(ApkSavePath)
end
local LaunchUpdateFunc = function()
if not PathModule.IsEditorOrStandalone() or CsApplication.Mode == CS.XMode.Release then
CS.XHeroBdcAgent.BdcUpdateGame("202", "1", "0")
end
CheckLaunchModuleUpdate()
end
if CsRemoteConfig.Debug then
CheckLocalZipFile(LaunchUpdateFunc)
else
LaunchUpdateFunc()
end
end
end
GetAppUpgradeUrl = function ()
return PathModule.GetAppUpgradeUrl()
end
--============检查本地压缩包=========
function CheckLocalZipFile(cb)
local documentPath = CS.UnityEngine.Application.persistentDataPath .. "/document"
if not CS.System.IO.Directory.Exists(documentPath) then
cb()
return
end
local files = CS.System.IO.Directory.GetFiles(documentPath, "*.zip", CS.System.IO.SearchOption.TopDirectoryOnly)
print("[Unzip] DocumentPath:" .. tostring(documentPath) .. ", files.length:" .. tostring(files.Length))
local length = files.Length
local function UnzipFile(index)
if index >= length then
if index > 0 then
CsApplication.SetProgress(1)
print("[Unzip] Finished.")
end
cb()
return
end
local file = files[index]
local nextIndex = index + 1
if string.find(file, "source") then
local overwrite = true
local password = nil
local totalCount = CS.ZipUtility.GetZipEntityCount(file, password)
print("[Unzip] Start File: " .. tostring(file))
if (totalCount > 0) then
local cancelCB = function()
UnzipFile(nextIndex)
end
local confirmCB = function()
CsGameEventManager:Notify(CS.XEventId.EVENT_LAUNCH_START_DOWNLOAD, totalCount, false, CsApplication.GetText("Unzip") .. "(%d/%d)") -- 解压资源
CsApplication.SetProgress(0)
local progressCB = function(counter, name)
local progress = counter / totalCount
CsApplication.SetProgress(progress)
print("[Unzip] progress:" .. tostring(counter) .. "/" .. tostring(totalCount) .. ", name:" .. tostring(name) .. ", zipFile: " .. tostring(file) .. ", outputPath:" .. tostring(documentPath))
end
local finishCB = function(counter)
if counter >= totalCount then
print("[Unzip] Completed file:" .. tostring(file))
CS.XFileTool.DeleteFile(file)
UnzipFile(nextIndex)
end
end
CS.ZipUtility.UnzipFile(file, documentPath, progressCB, finishCB, overwrite, password)
end
local text = "检查到本地压缩文件" .. CS.XFileTool.GetFileNameWithoutExtension(file) .. ", 是否进行解压?"
CsTool.WaitCoroutine(CsApplication.CoDialog(CsApplication.GetText("Tip"), text, cancelCB, confirmCB))
else
print("[Unzip] count <= 0, zipFile: " .. tostring(file))
UnzipFile(nextIndex)
end
else
print("[Unzip] name not Contains 'source', zipFile: " .. tostring(file))
UnzipFile(nextIndex)
end
end
local index = 0
UnzipFile(index)
end
--============包内下载apk逻辑=========
function CheckDownloadChannel()
local channelId = CS.XHgSdkAgent.GetChannelId()
return (channelId == OPPO_CHANNEL_ID)
end
-- 可在包内强更 调用downloadCB 否则调用jumpCB跳转外链下载
function TryDownloadApk(downloadCB, jumpCB)
if not CheckDownloadChannel() then
-- if not IsApkTesting and not CheckDownloadChannel() then
jumpCB()
return
end
-- 清理过期的下载临时文件
local curVersion = CsRemoteConfig.ApplicationVersion
local tempFile = ApkSavePath .. ".download"
if IO.File.Exists(tempFile) then
local lastDownloadVersion = CS.UnityEngine.PlayerPrefs.GetString(DOWNLOAD_APK_VERSION, "")
print("[APK] - Last down load versin:" .. lastDownloadVersion .. ", current:" .. curVersion)
if lastDownloadVersion ~= curVersion then
CS.XFileTool.DeleteFile(tempFile)
end
end
CS.UnityEngine.PlayerPrefs.SetString(DOWNLOAD_APK_VERSION, curVersion)
CS.UnityEngine.PlayerPrefs.Save()
local channelId = CS.XHgSdkAgent.GetChannelId()
-- local channelId = IsApkTesting and OPPO_CHANNEL_ID or CS.XHeroSdkAgent.GetChannelId()
local request = CS.XUriPrefixRequest.Get(ApkListUrl, nil, APK_TIMEOUT)
CS.XTool.WaitCoroutine(request:SendWebRequest(), function()
if request.isNetworkError or request.isHttpError or not request.downloadHandler then
CsLog.Error("[Apk] - Request apkList error:" .. tostring(request.error))
jumpCB()
return
end
local content = request.downloadHandler.text
local url = nil
for k, v in string.gmatch(content, "\"(%d+)\" : \"(.-)\"") do
local cid = tonumber(k)
if cid == channelId then
url = v
break
end
end
if url then
downloadCB(url)
else
jumpCB()
end
end)
end
-- 获取apk大小并开始下载
function BeforeDownloadApk(apkUrl)
print("[Apk] - Start Downloading Apk:" .. apkUrl)
local request = CS.UnityEngine.Networking.UnityWebRequest.Head(apkUrl)
request.timeout = APK_TIMEOUT
CS.XTool.WaitNativeCoroutine(request:SendWebRequest(), function()
if request.isNetworkError or request.isHttpError then
CsLog.Error("[Apk] - Request ApkUrl error:" .. tostring(request.error))
ShowStartErrorDialog("DownloadAPKError", function()
BeforeDownloadApk(apkUrl)
end)
return
end
ApkFileSize = request:GetResponseHeader("Content-Length")
print("[Apk] - Request ApkFileSize is " .. tostring(ApkFileSize))
ApkFileSize = tonumber(ApkFileSize)
StartDownloadApk(apkUrl)
end)
end
function StartDownloadApk(apkUrl)
print("[Apk] - Start to download.")
CsGameEventManager:Notify(CS.XEventId.EVENT_LAUNCH_START_DOWNLOAD, ApkFileSize)
local cache = true
local sha1 = nil
local downloader = CS.XDownloader(apkUrl, ApkSavePath, cache, sha1, APK_TIMEOUT)
local isDownloading = false
CS.XTool.WaitCoroutinePerFrame(downloader:Send(), function(isComplete)
if not isComplete then
if not isDownloading then
isDownloading = true
print("[Apk] - Init Download Apk Info:", downloader.CurrentSize, ApkFileSize)
CsGameEventManager:Notify(CS.XEventId.EVENT_LAUNCH_START_DOWNLOAD, ApkFileSize)
end
local downloadedSize = downloader.CurrentSize
local progress = downloadedSize / ApkFileSize
CsApplication.SetProgress(progress)
else
local localFileSize = 0
if isDownloading then
localFileSize = downloader.CurrentSize
elseif IO.File.Exists(ApkSavePath) then
local fs = IO.File.Open(ApkSavePath, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
localFileSize = tonumber(fs.Length)
fs:Close()
end
local isFinish = (localFileSize == ApkFileSize)
print("[Apk] - Finish Download:" .. tostring(downloader.State) .. ", localFileSize:" .. localFileSize.. ", Size:" .. ApkFileSize .. ", isFinish:" .. tostring(isFinish))
if not isFinish then
local function CleanAndDownload()
if IO.File.Exists(ApkSavePath) then
print("[Apk] - Clean downloaded Error File:" .. ApkSavePath)
CS.XFileTool.DeleteFile(ApkSavePath)
end
StartDownloadApk(apkUrl)
end
if isDownloading then -- 下载过程失败才询问
ShowStartErrorDialog("DownloadAPKError", CleanAndDownload, CsApplication.Exit)
else
CleanAndDownload()
end
return
end
if downloader.State ~= CS.XDownloaderState.Success then
CsLog.Error("[Apk] - Download Error state:" .. tostring(downloader.State) .. ", Exception:" .. tostring(downloader.Exception and downloader.Exception.Message))
ShowStartErrorDialog("DownloadAPKError", function()
StartDownloadApk(apkUrl)
end)
return
end
CsApplication.SetProgress(1)
CS.XTool.OpenFile(ApkSavePath, function(result)
print("[Apk] - Open File result:" .. tostring(result))
CsApplication.Exit()
end)
end
end)
end
--============包内下载apk逻辑 end=========

View file

@ -0,0 +1,24 @@
local XLaunchUiModule = {}
local LAUNCH_UI = "XLaunchUi/XLaunchUi"
local LAUNCH_UI_PREFAB = "Assets/Launch/Ui/Prefab/UiLaunch.prefab"
local hot_ui_ctor = require(LAUNCH_UI)
function XLaunchUiModule.RegisterLaunchUi()
local success = CS.XUiManager.Instance:Register("UiLaunch", CS.XUiType.Normal, CS.XUiResType.Bundle, true, LAUNCH_UI_PREFAB, nil, nil, 0, false, false)
if not success then
CS.XLog.Error("注册UI: UiLaunch 失败!!")
end
return success
end
function XLaunchUiModule.NewLaunchUi(uiName, uiProxy)
if uiName == "UiLaunch" then
local ui = hot_ui_ctor()
ui:Ctor(uiName, uiProxy)
return ui
end
return nil
end
return XLaunchUiModule

View file

@ -0,0 +1,293 @@
local type = type
local pairs = pairs
local pcall = pcall
local select = select
local table = table
local string = string
local math = math
local utf8 = utf8
local tableConcat = table.concat
local tableInsert = table.insert
local tableUnpack = table.unpack
local stringPack = string.pack
local stringUnpack = string.unpack
local stringFormat = string.format
local mathType = math.type
local utf8Len = utf8.len
local decoderTable
local function Unpack(context, format)
local value, position = stringUnpack(format, context.input, context.position)
context.position = position
return value
end
local function DecodeNext(context)
return decoderTable[Unpack(context, ">B")](context)
end
local function DecodeArray(context, length)
local array = {}
for i = 1, length do
array[i] = DecodeNext(context)
end
return array
end
local function DecodeMap(context, length)
local map = {}
for _ = 1, length do
local k = DecodeNext(context)
local v = DecodeNext(context)
map[k] = v
end
return map
end
decoderTable = {
[192] = function() return nil end,
[194] = function() return false end,
[195] = function() return true end,
[196] = function(context) return Unpack(context, ">s1") end,
[197] = function(context) return Unpack(context, ">s2") end,
[198] = function(context) return Unpack(context, ">s4") end,
[202] = function(context) return Unpack(context, ">f") end,
[203] = function(context) return Unpack(context, ">d") end,
[204] = function(context) return Unpack(context, ">I1") end,
[205] = function(context) return Unpack(context, ">I2") end,
[206] = function(context) return Unpack(context, ">I4") end,
[207] = function(context) return Unpack(context, ">I8") end,
[208] = function(context) return Unpack(context, ">i1") end,
[209] = function(context) return Unpack(context, ">i2") end,
[210] = function(context) return Unpack(context, ">i4") end,
[211] = function(context) return Unpack(context, ">i8") end,
[217] = function(context) return Unpack(context, ">s1") end,
[218] = function(context) return Unpack(context, ">s2") end,
[219] = function(context) return Unpack(context, ">s4") end,
[220] = function(context) return DecodeArray(context, Unpack(context, ">I2")) end,
[221] = function(context) return DecodeArray(context, Unpack(context, ">I4")) end,
[222] = function(context) return DecodeMap(context, Unpack(context, ">I2")) end,
[223] = function(context) return DecodeMap(context, Unpack(context, ">I4")) end,
}
-- add single byte integers
for i = 0, 127 do
decoderTable[i] = function() return i end
end
for i = 224, 255 do
decoderTable[i] = function() return -32 + i - 224 end
end
-- add fixed maps
for i = 128, 143 do
decoderTable[i] = function(context) return DecodeMap(context, i - 128) end
end
-- add fixed arrays
for i = 144, 159 do
decoderTable[i] = function(context) return DecodeArray(context, i - 144) end
end
-- add fixed strings
for i = 160, 191 do
local format = stringFormat(">c%d", i - 160)
decoderTable[i] = function(context) return Unpack(context, format) end
end
local encoderTable
local function EncodeValue(value)
return encoderTable[type(value)](value)
end
local function CheckArray(value) -- simple function to verify a table is a proper array
local count = 0
for k in pairs(value) do
if type(k) ~= "number" then
return false
else
count = count + 1
end
end
for i = 1, count do
if not value[i] and type(value[i]) ~= "nil" then
return false
end
end
return true
end
encoderTable = {
["nil"] = function()
return stringPack(">B", 192)
end,
["boolean"] = function(value)
return stringPack(">B", value and 195 or 194)
end,
["string"] = function(value)
local length = #value
if utf8Len(value) then -- valid UTF-8 ... encode as string
if length < 32 then
return stringPack(">B", 160 + length) .. value
elseif length <= 255 then
return stringPack(">B s1", 217, value)
elseif length <= 65535 then
return stringPack(">B s2", 218, value)
else
return stringPack(">B s4", 219, value)
end
else -- encode as binary
if length <= 255 then
return stringPack(">B s1", 196, value)
elseif length <= 65535 then
return stringPack(">B s2", 197, value)
else
return stringPack(">B s4", 198, value)
end
end
end,
["number"] = function(value)
if mathType(value) == "integer" then
if value >= 0 then
if value <= 127 then
return stringPack(">B", value)
elseif value <= 255 then
return stringPack(">B I1", 204, value)
elseif value <= 65535 then
return stringPack(">B I2", 205, value)
elseif value <= 4294967295 then
return stringPack(">B I4", 206, value)
else
return stringPack(">B I8", 207, value)
end
else
if value >= -32 then
return stringPack(">B", 224 + value + 32)
elseif value >= -127 then
return stringPack(">B i1", 208, value)
elseif value >= -32767 then
return stringPack(">B i2", 209, value)
elseif value >= -2147483647 then
return stringPack(">B i4", 210, value)
else
return stringPack(">B i8", 211, value)
end
end
else
local converted = stringUnpack(">f", stringPack(">f", value))
if converted == value then
return stringPack(">B f", 202, value)
else
return stringPack(">B d", 203, value)
end
end
end,
["table"] = function(value)
local meta = getmetatable(value)
if CheckArray(value) and (meta == nil or not meta.IsTable) then
local elements = {}
for i, v in pairs(value) do
elements[i] = EncodeValue(v)
end
local length = #elements
if length == 0 then
return stringPack(">B", 192)
end
if length <= 15 then
return stringPack(">B", 144 + length) .. tableConcat(elements)
elseif length <= 65535 then
return stringPack(">B I2", 220, length) .. tableConcat(elements)
else
return stringPack(">B I4", 221, length) .. tableConcat(elements)
end
else
local elements = {}
for k, v in pairs(value) do
elements[#elements + 1] = EncodeValue(k)
elements[#elements + 1] = EncodeValue(v)
end
local length = #elements // 2
if length == 0 then
return stringPack(">B", 192)
end
if length <= 15 then
return stringPack(">B", 128 + length) .. tableConcat(elements)
elseif length <= 65535 then
return stringPack(">B I2", 222, length) .. tableConcat(elements)
else
return stringPack(">B I4", 223, length) .. tableConcat(elements)
end
end
end,
}
XMessagePack = XMessagePack or {}
function XMessagePack.Encode(value)
local ok, result = pcall(EncodeValue, value)
if ok then
return result
else
return nil, stringFormat("XMessagePack cannot encode type %s", type(value))
end
end
function XMessagePack.EncodeAll(...)
local result = {}
for i = 1, select("#", ...) do
local data, error = XMessagePack.Encode(select(i, ...))
if data then
tableInsert(result, data)
else
return nil, error
end
end
return tableConcat(result)
end
function XMessagePack.Decode(input, position)
local context = { input = input, position = position or 1 }
local ok, result = pcall(DecodeNext, context)
if ok then
return result, context.position
else
return nil, stringFormat("XMessagePack cannot decode position %d", context.position)
end
end
function XMessagePack.DecodeAll(input, position)
local context = { input = input, position = position or 1 }
local result = {}
while context.position <= #context.input do
local ok, value = pcall(DecodeNext, context)
if ok then
tableInsert(result, value)
else
return nil, stringFormat("XMessagePack cannot decode position %d", context.position)
end
end
return tableUnpack(result)
end
function XMessagePack.MarkAsTable(value)
if value == nil then
CS.XLog.Error("XMessagePack.MarkAsTable 函数错误, 参数value不能为空")
return
end
if type(value) ~= "table" then
local errorInfo = "XMessagePack.MarkAsTable 函数错误, 参数value的类型需要是table类型的, value的类型是" .. type(value)
CS.XLog.Error(errorInfo)
return
end
setmetatable(value, {IsTable = true})
end

View file

@ -0,0 +1,377 @@
local Creator = function()
local XUiLaunchUi = {}
function XUiLaunchUi:OnAwake()
--self.TxtProgressLoading.gameObject:SetActiveEx(true)
--CS.XLog.Error("new ui lua.")
self.UiLoading = self.UiLoading.gameObject
self.UiDownload = self.UiDownload.gameObject
self.UiVideoPlay = self.UiVideoPlay.gameObject
self.UiDownlosdTips = self.UiDownlosdTips.gameObject
self.UiLoading:SetActiveEx(false)
self.UiDownload:SetActiveEx(false)
self.UiVideoPlay:SetActiveEx(false)
self.UiDownlosdTips:SetActiveEx(false)
--self.BtnSkipVideo.CallBack = delegate(int i) { }
self.BtnMusicOn.CallBack = function()
self.BtnMusicOn.gameObject:SetActiveEx(false)
self.BtnMusicOff.gameObject:SetActiveEx(true)
end
self.BtnMusicOff.CallBack = function()
self.BtnMusicOn.gameObject:SetActiveEx(true)
self.BtnMusicOff.gameObject:SetActiveEx(false)
end
self.BtnBasic.CallBack = function() self:OnSelectBasic() end
self.BtnAll.CallBack = function() self:OnSelectAllDlc() end
self.BtnConfirmSelect.CallBack = function() self:OnConfirmSelect() end
--self.BtnVideo.CallBack = delegate (int i) { }
self.UpdateSize = 0
self.MBSize = 0
self.LastUpdateTime = 0
self.LastProgress = 0
self.CurrentDownloadSelect = 1
end
function XUiLaunchUi:OnStart()
self:HideHealthTip()
end
function XUiLaunchUi:HideHealthTip()
if self.UiLoading then -- 海外屏蔽健康提示十六字真言(不想改UI免得还得修改)
for i = 1, self.UiLoading.transform.childCount do
local child = self.UiLoading.transform:GetChild(i-1)
if child.name == "Text" then
child.gameObject:SetActiveEx(false)
end
end
end
end
function XUiLaunchUi:OnEnable()
CS.UnityEngine.Screen.sleepTimeout = CS.UnityEngine.SleepTimeout.NeverSleep
end
function XUiLaunchUi:OnDisable()
CS.UnityEngine.Screen.sleepTimeout = CS.UnityEngine.SleepTimeout.SystemSetting
end
function XUiLaunchUi:OnDestroy()
self.BtnMusicOn.CallBack = nil
self.BtnMusicOff.CallBack = nil
self.BtnBasic.CallBack = nil
self.BtnAll.CallBack = nil
self.BtnConfirmSelect.CallBack = nil
end
function XUiLaunchUi:OnGetEvents()
return { CS.XEventId.EVENT_LAUNCH_SETMESSAGE,
CS.XEventId.EVENT_LAUNCH_SETPROGRESS,
CS.XEventId.EVENT_LAUNCH_START_DOWNLOAD,
CS.XEventId.EVENT_LAUNCH_START_LOADING,
CS.XEventId.EVENT_LAUNCH_SHOW_DOWNLOAD_SELECT}
end
function XUiLaunchUi:OnNotify(evt, ...)
local args = { ... }
if evt == CS.XEventId.EVENT_LAUNCH_START_DOWNLOAD then
self.UiDownload:SetActiveEx(true)
self.UiLoading:SetActiveEx(false)
self.UpdateSize = args[1]
self.NeedUnit = (args[2] ~= false)
self.MBSize = self.NeedUnit and self.UpdateSize / 1024 / 1024 or self.UpdateSize
self.CustomFormat = args[3]
if self.NeedUnit then
self.TxtDownloadSize.text = string.format("(0MB/%dMB)", math.floor(self.MBSize))
else
self.TxtDownloadSize.text = string.format("(0/%d)", math.floor(self.MBSize))
self.TxtDownloadSpeed.text = ""
end
elseif evt == CS.XEventId.EVENT_LAUNCH_START_LOADING then
self.UiDownload:SetActiveEx(false)
self.UiLoading:SetActiveEx(true)
elseif evt == CS.XEventId.EVENT_LAUNCH_SETMESSAGE then
self.TxtMessageLoading.text = tostring(args[1])
elseif evt == CS.XEventId.EVENT_LAUNCH_SETPROGRESS then
self.VideoPlayer.targetCamera = CS.XUiManager.Instance.UiCamera
local progress = args[1]
if (self.UiLoading.activeInHierarchy) then
self.SliderLoading.value = progress
self.TxtProgressLoading.text = string.format("%d%%", math.floor(progress * 100))
elseif (self.UiDownload.activeInHierarchy) then
-- 版本
if (self.TxtAppVer ~= nil and self.TxtAppVer:Exist()) then
self.TxtAppVer.text = CS.XRemoteConfig.ApplicationVersion .. " (ApplicationVersion)"
end
if (self.TxtDocVer ~= nil and self.TxtDocVer:Exist()) then
self.TxtDocVer.text = CS.XRemoteConfig.DocumentVersion .. " (DocumentVersion)"
end
-- 速度
if self.NeedUnit and (CS.UnityEngine.Time.time - self.LastUpdateTime > 1) then
local kBSpeed = (progress - self.LastProgress) * (self.UpdateSize / 1024)
self.TxtDownloadSpeed.text = string.format("%dKB/S", math.floor(kBSpeed))
self.LastUpdateTime = CS.UnityEngine.Time.time
self.LastProgress = progress
end
self.SliderDownload.value = progress
self.TxtProgressDownload.text = string.format("%d%%", math.floor(progress * 100))
self.TxtDownloadSize.text = string.format("(%dMB/%dMB)", math.floor(self.MBSize * progress), math.floor(self.MBSize))
-- 进度
if self.NeedUnit then
self.TxtDownloadSize.text = string.format(self.CustomFormat or "(%dMB/%dMB)", math.floor(self.MBSize * progress), math.floor(self.MBSize))
else
self.TxtDownloadSize.text = string.format(self.CustomFormat or "(%d/%d)", math.floor(self.MBSize * progress), math.floor(self.MBSize))
end
elseif (self.UiVideoPlay.activeInHierarchy) then
self.TxtProgressVideoPlay.text = string.format("%d%%", math.floor(progress * 100))
end
elseif evt == CS.XEventId.EVENT_LAUNCH_SHOW_DOWNLOAD_SELECT then
self:SetupDownloadSelect(args)
end
end
function XUiLaunchUi:OnSelectBasic()
self.CurrentDownloadSelect = 1
self.BtnBasic:SetButtonState(CS.UiButtonState.Select)
self.BtnAll:SetButtonState(CS.UiButtonState.Normal)
--CS.XLog.Debug(" self.CurrentDownloadSelect == 1")
end
function XUiLaunchUi:OnSelectAllDlc()
self.CurrentDownloadSelect = 2
self.BtnBasic:SetButtonState(CS.UiButtonState.Normal)
self.BtnAll:SetButtonState(CS.UiButtonState.Select)
--CS.XLog.Debug(" self.CurrentDownloadSelect == 2")
end
function XUiLaunchUi:OnConfirmSelect()
self.UiDownlosdTips:SetActiveEx(false)
CS.XGameEventManager.Instance:Notify(CS.XEventId.EVENT_LAUNCH_DONE_DOWNLOAD_SELECT,self.CurrentDownloadSelect==2)
end
local GetSizeAndUnit = function(size)
local unit = "KB"
local num = size / 1024
if (num > 100) then
unit = "MB"
num = num / 1024
end
return num,unit
end
function XUiLaunchUi:SetupDownloadSelect(args)
self.UiDownlosdTips:SetActiveEx(true)
local baseUpdateSize = args[1]
local allUpdateSize = args[2]
if self.CurrentDownloadSelect == 1 then
self:OnSelectBasic()
else
self:OnSelectAllDlc()
end
local baseSize,baseUnit = GetSizeAndUnit(baseUpdateSize)
local allSize,allUnit = GetSizeAndUnit(allUpdateSize)
self.BtnBasic:SetNameByGroup(1,string.format("<b>%s%s</b>", tostring(math.ceil(baseSize)),baseUnit))
self.BtnAll:SetNameByGroup(1,string.format("<b>%s%s</b>", tostring(math.ceil(allSize)),allUnit))
end
function XUiLaunchUi:Ctor(name, uiProxy)
self.Name = name
self.UiProxy = uiProxy
self.Ui = uiProxy.Ui
end
function XUiLaunchUi:SetGameObject()
self.Transform = self.Ui.Transform
self.GameObject = self.Ui.GameObject
self.UiAnimation = self.Ui.UiAnimation
self:InitUiObjects()
end
--用于释放lua的内存
function XUiLaunchUi:OnRelease()
--self.Name = nil
self.UiProxy = nil
self.Ui = nil
self.Transform = nil
self.GameObject = nil
self.UiAnimation = nil
if self.Obj and self.Obj:Exist() then
local nameList = self.Obj.NameList
for _, v in pairs(nameList) do
self[v] = nil
end
self.Obj = nil
end
for k, v in pairs(self) do
local t = type(v)
if t == 'userdata' and CsXUiHelper.IsUnityObject(v) then
self[k] = nil
end
end
end
function XUiLaunchUi:SetUiSprite(image, spriteName, callBack)
self.UiProxy:SetUiSprite(image, spriteName, callBack)
end
--快捷隐藏界面(不建议使用)
function XUiLaunchUi:SetActive(active)
local temp = active and true or false
self.UiProxy:SetActive(temp)
end
--快捷关闭界面
function XUiLaunchUi:Close()
if self.UiProxy == nil then
XLog.Error(self.Name .. "重复Close")
else
self.UiProxy:Close()
end
end
--快捷移除UI,移除的UI不会播放进场、退场动画
function XUiLaunchUi:Remove()
if self.UiProxy then
self.UiProxy:Remove()
end
end
--注册点击事件
--function XUiLaunchUi:RegisterClickEvent(button, handle, clear)
--
-- clear = clear and true or false
-- self.UiProxy:RegisterClickEvent(button, function(eventData)
-- if handle then
-- handle(self, eventData)
-- end
-- end, clear)
--
--end
--返回指定名字的子节点的Component
--@name 子节点名称
--@type Component类型
function XUiLaunchUi:FindComponent(name, type)
return self.UiProxy:FindComponent(name, type)
end
--通过名字查找GameObject 例如:A/B/C
--@name 要查找的名字
function XUiLaunchUi:FindGameObject(name)
return self.UiProxy:FindGameObject(name)
end
--通过名字查找Transfrom 例如:A/B/C
--@name 要查找的名字
function XUiLaunchUi:FindTransform(name)
return self.UiProxy:FindTransform(name)
end
--打开一个子UI
--@childUIName 子UI名字
--@... 传到OnStart的参数
function XUiLaunchUi:OpenChildUi(childUIName, ...)
self.UiProxy:OpenChildUi(childUIName, ...)
end
--打开一个子UI,会关闭其他已显示的子UI
--@childUIName 子UI名字
--@... 传到OnStart的参数
function XUiLaunchUi:OpenOneChildUi(childUIName, ...)
self.UiProxy:OpenOneChildUi(childUIName, ...)
end
--关闭子UI
--@childUIName 子UI名字
function XUiLaunchUi:CloseChildUi(childUIName)
self.UiProxy:CloseChildUi(childUIName)
end
--查找子窗口对应的lua对象
--@childUiName 子窗口名字
function XUiLaunchUi:FindChildUiObj(childUiName)
local childUi = self.UiProxy:FindChildUi(childUiName)
if childUi then
return childUi.UiProxy.UiLuaTable
end
end
function XUiLaunchUi:InitChildUis()
if self.Ui == nil then
return
end
if not self.Ui.UiData.HasChildUi then
return
end
local childUis = self.Ui:GetAllChildUis()
if childUis == nil then
return
end
--子UI初始化完成后可在父UI通过【self.Child+子UI】名称的方式直接获取句柄
local childUiName
for k, v in pairs(childUis) do
childUiName = "Child" .. k
if self[childUiName] then
XLog.Error(string.format("%s该名字已被占用", childUiName))
else
self[childUiName] = v.UiProxy.UiLuaTable
end
end
end
function XUiLaunchUi:InitUiObjects()
self.Obj = self.Transform:GetComponent("UiObject")
if self.Obj ~= nil and self.Obj:Exist() then
for i = 0, self.Obj.NameList.Count - 1 do
self[self.Obj.NameList[i]] = self.Obj.ObjList[i]
end
end
end
--播放动画只支持Timeline模式
function XUiLaunchUi:PlayAnimation(animName, callback, beginCallback)
self.UiProxy:PlayAnimation(animName, callback, beginCallback)
end
--播放动画只支持Timeline模式, 增加Mask阻止操作打断动画
function XUiLaunchUi:PlayAnimationWithMask(animName, callback)
self.UiProxy:PlayAnimation(animName, function()
CS.XUiManager.Instance:SetMask(false)
if callback then
callback()
end
end, function()
CS.XUiManager.Instance:SetMask(true)
end)
end
return XUiLaunchUi
end
return Creator

1095
Script/matrix/UiRegistry.lua Normal file

File diff suppressed because it is too large Load diff

164
Script/matrix/XGame.lua Normal file
View file

@ -0,0 +1,164 @@
XGame = XGame or {}
local UI_LOGIN = "UiLogin"
XGame.Profiler = CS.XGame.Profiler:CreateChild("XGame")
XGame.Start1 = function()
XGame.Profiler:Start()
XConfigCenter.Init()
--打点
CS.XRecord.Record("23009", "LuaXGameStart")
CS.XApplication.SetProgress(0.86)
end
XGame.Start2 = function()
XLoginManager.Init()
XDataCenter.Init()
if XDataCenter.UiPcManager.IsPc() then
XDataCenter.UiPcManager.FullScreenableCheck()
end
CS.XApplication.SetProgress(0.88)
end
XGame.Start3 = function()
local playerProfiler = XGame.Profiler:CreateChild("XPlayerManager")
playerProfiler:Start()
XPlayerManager.Init()
playerProfiler:Stop()
local userProfiler = XGame.Profiler:CreateChild("XUserManager")
userProfiler:Start()
XUserManager.Init()
userProfiler:Stop()
local functionProfiler = XGame.Profiler:CreateChild("XFunctionManager")
functionProfiler:Start()
XFunctionManager.Init()
functionProfiler:Stop()
local resetProfiler = XGame.Profiler:CreateChild("XResetManager")
resetProfiler:Start()
XResetManager.Init()
resetProfiler:Stop()
CS.XApplication.SetProgress(0.89)
end
XGame.Start4 = function()
XAttribManager.Init()
CS.XApplication.SetProgress(0.95)
end
XGame.Start5 = function()
local magicProfiler = XGame.Profiler:CreateChild("XMagicSkillManager")
magicProfiler:Start()
XMagicSkillManager.Init()
magicProfiler:Stop()
local fightCharacterProfiler = XGame.Profiler:CreateChild("XFightCharacterManager")
fightCharacterProfiler:Start()
XFightCharacterManager.Init()
fightCharacterProfiler:Stop()
local fightEquipProfiler = XGame.Profiler:CreateChild("XFightEquipManager")
fightEquipProfiler:Start()
XFightEquipManager.Init()
fightEquipProfiler:Stop()
local fightPartnerProfiler = XGame.Profiler:CreateChild("XFightPartnerManager")
fightPartnerProfiler:Start()
XFightPartnerManager.Init()
fightPartnerProfiler:Stop()
local modelProfiler = XGame.Profiler:CreateChild("XModelManager")
modelProfiler:Start()
XModelManager.Init()
modelProfiler:Stop()
local conditionProfiler = XGame.Profiler:CreateChild("XConditionManager")
conditionProfiler:Start()
XConditionManager.Init()
conditionProfiler:Stop()
local rewardProfiler = XGame.Profiler:CreateChild("XRewardManager")
rewardProfiler:Start()
XRewardManager.Init()
rewardProfiler:Stop()
local roomSingleProfiler = XGame.Profiler:CreateChild("XRoomSingleManager")
roomSingleProfiler:Start()
XRoomSingleManager.Init()
roomSingleProfiler:Stop()
local robotProfiler = XGame.Profiler:CreateChild("XRobotManager")
robotProfiler:Start()
XRobotManager.Init()
robotProfiler:Stop()
local redPointProfiler = XGame.Profiler:CreateChild("XRedPointManager")
redPointProfiler:Start()
XRedPointManager.Init()
redPointProfiler:Stop()
--local hudProfiler = XGame.Profiler:CreateChild("XHudManager")
--hudProfiler:Start()
--XHudManager.Init()
--hudProfiler:Stop()
local permissionProfiler = XGame.Profiler:CreateChild("XPermissionManager")
permissionProfiler:Start()
XPermissionManager.Init()
permissionProfiler:Stop()
CS.XApplication.SetProgress(1, true)
end
XGame.Start6 = function()
local serverProfiler = XGame.Profiler:CreateChild("XServerManager")
serverProfiler:Start()
XServerManager.Init(function()
local UiLoginMovieId = CS.XGame.ClientConfig:GetInt("UiLoginMovieId")
local key = string.format("LoginVideo-%s", UiLoginMovieId)
local isPlayed = XSaveTool.GetData(key)
if isPlayed == 1 or UiLoginMovieId == 0 then
XLuaUiManager.PopAllThenOpen(UI_LOGIN)
return
end
XSaveTool.SaveData(key, 1)
XDataCenter.VideoManager.PlayMovie(UiLoginMovieId, function()
XLuaUiManager.PopAllThenOpen(UI_LOGIN)
end)
end)
serverProfiler:Stop()
XGame.Profiler:Stop()
XTableManager.ReleaseAll(true)
CS.BinaryManager.OnPreloadFight(true)
collectgarbage("collect")
--打点
CS.XRecord.Record("23014", "LuaXGameStartFinish")
LuaGC()
end
local BreakPointTimerId = nil
local BreakSocketHandle = nil
XGame.InitBreakPointTimer = function()
if CS.UnityEngine.Application.platform ~= CS.UnityEngine.RuntimePlatform.WindowsEditor then
return
end
-- if BreakPointTimerId then
-- XScheduleManager.UnSchedule(BreakPointTimerId)
-- BreakPointTimerId = nil
-- end
-- if not BreakSocketHandle then
-- local debugXpCall
-- BreakSocketHandle, debugXpCall = require("XDebug/LuaDebug")("localhost", 7003)
-- end
-- BreakPointTimerId = XScheduleManager.ScheduleForever(BreakSocketHandle, 0)
end
XGame.InitBreakPointTimer()

View file

@ -0,0 +1,129 @@
-- 用于运行时热重载LUA逻辑热键F3在XDataCenter中初始化的相关Manager文件中涉及数据的改动需要重登或断线重连后生效(仅editor + debug模式下生效)
XHotReload = XHotReload or {}
local function updateFunc(newFunc, oldFunc)
assert("function" == type(newFunc))
assert("function" == type(oldFunc))
local newUpvalueDic = {}
for i = 1, math.huge do
local name, newValue = debug.getupvalue(newFunc, i)
if not name then break end
newUpvalueDic[name] = newValue
end
for i = 1, math.huge do
local name = debug.getupvalue(oldFunc, i)
if not name then break end
local newValue = newUpvalueDic[name]
if newValue then
debug.setupvalue(oldFunc, i, newValue)
end
end
end
local updateTable
function updateTable(newTable, oldTable)
if "table" ~= type(oldTable) then return end
if "table" ~= type(newTable) then return end
for key, newValue in pairs(newTable) do
local oldValue = oldTable[key]
local typeValue = type(newValue)
if typeValue == "table" then
updateTable(newValue, oldValue)
elseif typeValue == "function" then
updateFunc(newValue, oldValue)
end
oldTable[key] = newValue--此处未处理newTable中值数量少于oldTable的情况
end
local oldMeta = debug.getmetatable(oldTable)
local newMeta = debug.getmetatable(newTable)
if type(oldMeta) == "table" and type(newMeta) == "table" then
updateTable(newMeta, oldMeta)
end
end
local function TryRunInitConfig(fileName)
local _, endPos = string.find(fileName, "XConfig/")
if not endPos or endPos < 0 then return end
local className = string.sub(fileName, endPos + 1)
local class = rawget(_G, className)
if not class then return end
if class.Init then class.Init() end
end
local function TryReplaceManager(filePath)
local _, endPos = string.find(filePath, "XManager/")
if not endPos or endPos < 0 then return end
local name = string.sub(filePath, endPos + 1)
local creatorName = string.format("%sCreator", name)
local managerVar = rawget(_G, creatorName) or rawget(_G, name)
if type(managerVar) == "function" then
local newManager = managerVar()
updateTable(newManager, XDataCenter[name])
elseif type(managerVar) == "table" and managerVar.Init then
managerVar.Init()
XLog.Debug(string.format("已重新运行%s的Init", name))
end
end
function XHotReload.Reload(fileName)
if not XMain.IsEditorDebug then return end
--local info = debug.getinfo(2)
if not package.loaded[fileName] then
XLog.Error("XHotReload.Reload reload file error: file never loaded, fileName is: ", fileName)
return
end
local oldModule = package.loaded[fileName]
package.loaded[fileName] = nil
local ok, err = pcall(require, fileName)
if not ok then
package.loaded[fileName] = oldModule
XLog.Error("XHotReload.Reload reload file error: ", err)
return
end
local newModule = package.loaded[fileName]
if "table" ~= type(newModule) then
TryRunInitConfig(fileName)--全局函数中只处理Config文件
end
updateTable(newModule, oldModule)
UpdateClassType(newModule, oldModule)
if "boolean" == type(newModule) then
TryReplaceManager(fileName) --改变XDataCenter所指向的Manager
end
package.loaded[fileName] = oldModule
XLog.Debug("kkkttt XHotReload.Reload suc, fileName is: ", fileName)
end
-- 部分表在Manager里读取
function XHotReload.InitMgrTab()
if not XMain.IsDebug then return end
XReadOnlyTable.HotLoad = true
XConditionManager.Init()
XFightUiManager.Init()
XLoginManager.Init()
XPlayerManager.Init()
XResetManager.Init()
XRobotManager.Init()
XRoomSingleManager.Init()
XFunctionManager.Init()
XModelManager.Init()
XRewardManager.Init()
XReadOnlyTable.HotLoad = false
CS.XGame.ClientConfig:Init("Client/Config/ClientConfig.tab")
CS.XGame.Config:Init("Share/Config/Config.tab")
end

215
Script/matrix/XMain.lua Normal file
View file

@ -0,0 +1,215 @@
XMain = XMain or {}
XMain.IsWindowsEditor = CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsEditor
local IsWindowsPlayer = CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsPlayer
XMain.IsDebug = CS.XRemoteConfig.Debug
XMain.IsEditorDebug = (XMain.IsWindowsEditor or IsWindowsPlayer) and XMain.IsDebug
local lockGMeta = {
__newindex = function(t, k)
XLog.Error("can't assign " .. k .. " in _G")
end,
__index = function(t, k)
XLog.Error("can't index " .. k .. " in _G, which is nil")
end
}
function LuaLockG()
setmetatable(_G, lockGMeta)
end
local import = CS.XLuaEngine.Import
import("XCommon/XLog.lua")
XMain.Step1 = function()
--打点
CS.XRecord.Record("23000", "LuaXMainStart")
if XMain.IsEditorDebug then
require("XHotReload")
end
require("XCommon/XRpc")
import("XCommon")
import("XConfig")
import("XOverseas/XConfig") -- 海外定制化目录
require("XGame")
import("XEntity")
import("XOverseas/XEntity") -- 海外定制化目录
-- import("XUi/XUiBase")
-- import("XUi/XUiCommon/XScrollView")
import("XBehavior")
import("XGuide")
require("XMovieActions/XMovieActionBase")
CS.XApplication.SetProgress(0.52)
end
XMain.Step2 = function()
import("XManager")
import("XOverseas/XManager") -- 海外定制化目录
import("XNotify")
CS.XApplication.SetProgress(0.54)
end
XMain.Step3 = function()
-- import("XUi/XUiDlcDownload")
-- import("XUi/XUiArena")
-- import("XUi/XUiArenaActivityResult")
-- import("XUi/XUiArenaFightResult")
-- import("XUi/XUiArenaLevelDetail")
-- import("XUi/XUiArenaStage")
-- import("XUi/XUiArenaTask")
-- import("XUi/XUiArenaTeam")
-- import("XUi/XUiArenaTeamRank")
-- import("XUi/XUiArenaWarZone")
-- import("XUi/XUiNewAutoFightDialog")
-- import("XUi/XUiAutoFightList")
-- import("XUi/XUiAutoFightReward")
-- import("XUi/XUiAutoFightTip")
-- import("XUi/XUiAwarenessTf")
-- import("XUi/XUiBag")
-- import("XUi/XUiBaseEquip")
-- import("XUi/XUiBfrt")
-- import("XUi/XUiBuyAsset")
-- import("XUi/XUiCharacter")
-- import("XUi/XUiCharacterDetail")
-- import("XUi/XUiChatServe")
-- import("XUi/XUiComeAcross")
-- import("XUi/XUiCommon")
-- import("XUi/XUiDialog")
-- import("XUi/XUiDorm")
-- import("XUi/XUiDraw")
CS.XApplication.SetProgress(0.56)
end
XMain.Step4 = function()
-- import("XUi/XUiEquip")
-- import("XUi/XUiEquipAwarenessReplace")
-- import("XUi/XUiEquipBreakThrough")
-- import("XUi/XUiEquipDetail")
-- import("XUi/XUiEquipReplace")
-- import("XUi/XUiEquipReplaceNew")
-- import("XUi/XUiEquipResonanceSelect")
-- import("XUi/XUiEquipResonanceSkill")
-- import("XUi/XUiEquipStrengthen")
-- import("XUi/XUiFashion")
-- import("XUi/XUiFavorability")
-- import("XUi/XUiFightLoading")
-- import("XUi/XUiFirstGetPopUp")
-- import("XUi/XUiFuben")
-- import("XUi/XUiFubenActivityBanner")
-- import("XUi/XUiFubenActivityChapter")
-- import("XUi/XUiFubenActivitySection")
-- import("XUi/XUiFubenChallengeBanner")
-- import("XUi/XUiFubenChallengeChapter")
CS.XApplication.SetProgress(0.58)
end
XMain.Step5 = function()
-- import("XUi/XUiFubenChallengeEMEX")
-- import("XUi/XUiFubenChallengeHSJYQZ")
-- import("XUi/XUiFubenChallengeMap")
-- import("XUi/XUiFubenBossSingle")
-- import("XUi/XUiFubenChallengeMapEmex")
-- import("XUi/XUiFubenChallengeSection")
-- import("XUi/XUiFubenChallengeUrgent")
-- import("XUi/XUiFubenChallengeYSHTX")
-- import("XUi/XUiFubenCoinSkill")
-- import("XUi/XUiFubenDailyBanner")
-- import("XUi/XUiFubenDailyChapter")
-- import("XUi/XUiFubenDialog")
-- import("XUi/XUiFubenFlopReward")
-- import("XUi/XUiFubenMainLineBanner")
-- import("XUi/XUiFubenMainLineChapter")
-- import("XUi/XUiFubenMainLineChapterBanner")
-- import("XUi/XUiFubenMainLineDetail")
-- import("XUi/XUiFubenResourceDetail")
-- import("XUi/XUiFubenStageDetail")
-- import("XUi/XUiFubenStory")
CS.XApplication.SetProgress(0.6)
end
XMain.Step6 = function()
-- import("XUi/XUiFubenUrgentEventTip")
-- import("XUi/XUiFunctionalOpen")
-- import("XUi/XUiGameNotice")
-- import("XUi/XUiGuide")
-- import("XUi/XUiHomeMain")
-- import("XUi/XUiHostelCharacterWork")
-- import("XUi/XUiHostelDelegate")
-- import("XUi/XUiHostelDelegateReporter")
-- import("XUi/XUiHostelDeviceDetail")
-- import("XUi/XUiHostelDeviceUpgradeResult")
-- import("XUi/XUiHostelDeviceUpgrading")
-- import("XUi/XUiHostelMissionComplete")
-- import("XUi/XUiHostelQte")
-- import("XUi/XUiHostelRest")
-- import("XUi/XUiHostelRoom")
-- import("XUi/XUiHud")
-- import("XUi/XUiLogin")
-- import("XUi/XUiLoginNotice")
-- import("XUi/XUiMail")
-- import("XUi/XUiMain")
CS.XApplication.SetProgress(0.62)
end
XMain.Step7 = function()
-- import("XUi/XUiMission")
-- import("XUi/XUiMoneyReward")
-- import("XUi/XUiMoneyRewardFightTipFind")
-- import("XUi/XUiNewPlayerTask")
-- import("XUi/XUiNewRoleShow")
-- import("XUi/XUiNewRoomSingle")
-- import("XUi/XUiNoticeTips")
-- import("XUi/XUiObtain")
-- import("XUi/XUiOnlineBoss")
-- import("XUi/XUiOnlineBossResult")
-- import("XUi/XUiOnLineTranscript")
-- import("XUi/XUiOnLineTranscriptRoom")
-- import("XUi/XUiPersonalInfo")
-- import("XUi/XUiPlayer")
-- import("XUi/XUiPlayerUp")
-- import("XUi/XUiPrequel")
-- import("XUi/XUiPrequelLineDetail")
-- import("XUi/XUiRegister")
-- import("XUi/XUiRoomCharacter")
-- import("XUi/XUiRoomMul")
CS.XApplication.SetProgress(0.65)
end
XMain.Step8 = function()
-- require("XUi/XUiSet/XUiDlcTest")
-- import("XUi/XUiRoomTeamPrefab")
-- import("XUi/XUiSet")
-- import("XUi/XUiSettleLose")
-- import("XUi/XUiSettleUrgentEvent")
-- import("XUi/XUiSettleWin")
-- import("XUi/XUiSettleWinMainLine")
-- import("XUi/XUiSettleWinSingleBoss")
-- import("XUi/XUiShop")
-- import("XUi/XUiSkip")
-- import("XUi/XUiSocial")
-- import("XUi/XUiStory")
-- import("XUi/XUiTask")
-- import("XUi/XUiTest")
-- import("XUi/XUiTip")
-- import("XUi/XUiTipReward")
-- import("XUi/XUiTower")
-- import("XUi/XUiTrial")
import("XHome")
import("XScene")
-- import("XUi")
require("XUi/XUiCommon/XUiCommon") --XUiGridCommon,
import("XOverseas/XUi") -- 海外定制化目录
import("XMerge")
CS.XApplication.SetProgress(0.68)
end
XMain.Step9 = function()
LuaLockG()
--打点
CS.XRecord.Record("23008", "LuaXMainStartFinish")
end

View file

@ -0,0 +1,115 @@
local Binary = {}
local Reader = require("Binary/Reader")
local OFFSET = 0
function Binary.New(path)
local temp = {}
setmetatable(temp, { __index = Binary })
local result = temp:Ctor(path)
if not result then
return nil
end
return temp
end
function Binary:Ctor(path)
local file, err = io.open(path, "rb")
if not file then
XLog.Error(string.format("Binary:Ctor 打开文件失败 %s ,%s", path, err))
return
end
local len = assert(file:seek("end"))
self.file = path
self.len = len
self.fileStream = file
return true
end
--读取int默认4字节其他类型暂时不管了
function Binary:ReadInt(position)
position = position or 0
if position >= self.len then
XLog.Error(string.format("Binary.ReadInt 超出长度 %sposition = %s", self.len, position))
return
end
local startPos = self:Seek("set", 0)
local bytes = self:Read(4)
if not bytes then
return 0
end
local b1, b2, b3, b4 = string.byte(bytes, 1, 4)
return b1 | b2 << 8 | b3 << 16 | b4 << 24
end
--读取字节
function Binary:Read(len)
local bytes, err = self.fileStream:read(len)
if not bytes then
XLog.Error(string.format("Binary.Read 读取二进制失败 len = %s,%s", len, err))
return
end
return bytes
end
--读取内存块
function Binary:GetReader(len, offset)
local bytes = self:ReadBytes(len, offset)
local reader = Reader.New(bytes, len)
return reader
end
--读取内存块
function Binary:ReadBytes(len, offset)
if not len then
XLog.Error(len)
end
if len >= self.len then
XLog.Error(string.format("Binary.ReadBytes 超出长度 %s, len = %s", self.len, len))
return
end
local startPos = self:Seek("set", offset)
local bytes = self:Read(len)
return bytes
end
--定位
function Binary:Seek(position, offset)
offset = offset and offset + OFFSET or OFFSET
local len, err = self.fileStream:seek(position, offset)
if not len then
XLog.Error(string.format("Binary.Seek 失败offset = %s ,position = %s,%s", offset, position, err))
return
end
return len
end
function Binary:ReadAll()
local startPos = self:Seek("set", 0)
local bytes = self:Read("*a")
return bytes
end
function Binary:Close()
self.fileStream:close()
self.fileStream = nil
end
return Binary

View file

@ -0,0 +1,528 @@
local BinaryTable = {}
local Binary = require("Binary/Binary")
local tableEmpty = {}
local BinaryPool = {}
local BINARY_LIMIT_COUNT = 10
local Reader = require("Binary/Reader")
local DefaultOfTypeNew = {
[1] = false,
[2] = nil,
[3] = fix.zero,
[4] = tableEmpty,
[5] = tableEmpty,
[6] = tableEmpty,
[7] = tableEmpty,
[8] = tableEmpty,
[9] = tableEmpty,
[10] = tableEmpty,
[11] = tableEmpty,
[12] = tableEmpty,
[13] = tableEmpty,
[14] = 0,
[15] = 0,
}
function BinaryTable.New(path)
local temp = {}
setmetatable(temp, { __index = BinaryTable })
temp:Ctor(path)
return temp
end
function BinaryTable:Ctor(path)
self.filePath = path
self.canRead = false
end
--读取全部
function BinaryTable.ReadAll(path, identifier)
local temp = BinaryTable.New(path)
if not temp or not temp:InitBinary() then
return
end
local tab = temp:ReadAllContent(identifier)
temp:Release(true)
temp = nil
return tab
end
--读取句柄
function BinaryTable.ReadHandle(path)
local temp = BinaryTable.New(path)
if not temp or not temp:InitBinary() then
return
end
return temp
end
function BinaryTable:InitBinary()
local bytes = CS.BinaryManager.LoadBytes(self.filePath)
if not bytes then
XLog.Error(string.format("BinaryTable.InitBinary 加载文件失败 %s", self.filePath))
return
end
self.len = string.len(bytes)
self.bytes = bytes
local result = self:Init()
CS.PrefProfiler.ProfilerCore.RecordTableBinaryLoad(self.filePath, self.len, self.row)
return result
end
--初始化基础信息
function BinaryTable:Init()
local reader = self:GetReader()
local len = reader:ReadIntFix()
self.col = reader:ReadInt()
self.infoTrunkLen = len
self.colTypes = {}
self.colNames = {}
for i = 1, self.col do
table.insert(self.colTypes, reader:ReadInt())
local name = reader:ReadString()
table.insert(self.colNames, name)
end
local hasPrimarykey = reader:ReadBool()
self.primarykeyCount = 0
if hasPrimarykey then
self.primarykeyCount = 1
self.primarykey = reader:ReadString()
self.primarykeyLen = reader:ReadInt()
end
for i = 1, #self.colNames do
local name = self.colNames[i]
if self.primarykey == name then
self.primarykeyType = self.colTypes[i]
end
end
self.rowTrunkLen = reader:ReadInt()
self.row = reader:ReadInt()
self.contentTrunkLen = reader:ReadInt()
if not self.contentTrunkLen then
if XMain.IsDebug then
XLog.Warning(string.format("BinaryTable:InitBinary,%s, 空表", self.filePath))
end
return
end
local position = self:GetContenTrunkPosition()
reader:Close()
reader = nil
self.canRead = true
self.caches = {}
self.cachesCount = 0
return true
end
--获取内容块
function BinaryTable:GetContentTrunkReader()
local position = self:GetContenTrunkPosition()
if position < 0 then
return
end
local reader = self:GetReader(position)
return reader
end
--获取内容块位置
function BinaryTable:GetContenTrunkPosition()
local position = self.infoTrunkLen + 4
local count = self.primarykeyCount
if count > 0 then
position = position + self.primarykeyLen
end
position = position + self.rowTrunkLen
return position
end
function BinaryTable:ReadAllContent(identifier)
local reader = self:GetContentTrunkReader()
if not reader then
XLog.Error(string.format("可能是空表 路径:%s 请检查", self.filePath))
return tableEmpty
end
local row = self.row
local col = self.col
local colType = self.colTypes
local colNames = self.colNames
local colNameIndex = {}
local index = 0
for i = 1, #colNames do
local name = colNames[i]
if name == identifier then
index = i
end
colNameIndex[name] = i
end
if index <= 0 then
XLog.Warning(string.format("找不到键值 Key:%s 请检查该键值和表头是否匹配", self.filePath))
end
---每一个表对应一个元表
local metaTable = {}
metaTable.__index = function(tbl, colName)
local idx = colNameIndex[colName]
if not idx or not tbl then
return nil
end
local result = rawget(tbl, idx)
if not result then
local resultType = colType[idx]
if not resultType then
XLog.Error(string.format("找不到键值 Key:%s 请检查该键值和表头是否匹配", colName))
end
result = DefaultOfTypeNew[resultType]
end
return result
end
metaTable.__newindex = function()
XLog.Error("attempt to update a readonly table")
end
metaTable.__metatable = "readonly table"
metaTable.__pairs = function(t)
local function stateless_iter(tbl, key)
local nk, v = next(tbl, key)
if nk and v then
local nv = t[v] or t[nk]
return nk, nv
end
end
return stateless_iter, colNameIndex, nil
end
local tab = {}
for i = 1, row do
local temp = {}
local keyValue = nil
for j = 1, col do
local type = colType[j]
local value = reader:Read(type)
temp[j] = value
if index > 0 and j == index then
keyValue = value or 0
end
end
if index == 0 then
keyValue = i
end
setmetatable(temp, metaTable)
tab[keyValue] = temp
self.caches[keyValue] = temp
CS.PrefProfiler.ProfilerCore.RecordGetTableBinaryItem(self.filePath)
end
self.cachesCount = self.row
reader:Close()
reader = nil
return tab
end
function BinaryTable:GetLength()
return self.row
end
function BinaryTable:Get(key)
local v = self.caches[key]
if v then
return v
end
local t = self:ReadElement(key)
self.caches[key] = t
if t ~= nil then
self.cachesCount = self.cachesCount + 1
end
CS.PrefProfiler.ProfilerCore.RecordGetTableBinaryItem(self.filePath)
return t
end
--读取内存块
function BinaryTable:GetReader(offset)
if not self.bytes then
self.bytes = CS.BinaryManager.LoadBytes(self.filePath)
CS.PrefProfiler.ProfilerCore.RecordTableBinaryLoad(self.filePath, self.len, self.row)
end
offset = offset or 0
local reader = Reader.New(self.bytes, self.len, offset + 1)
return reader
end
--读取索引块
function BinaryTable:ReadIndexTrunk()
local len = self.primarykeyLen
local position = self.infoTrunkLen + 4
if len <= 0 or position < 0 then
XLog.Error(string.format("%s,读取索引块失败!! primarykey = %s", self.filePath, self.primarykey))
return
end
self.primarykeyList = {}
local reader = self:GetReader(position)
for i = 1, self.row do
local temp = reader:Read(self.primarykeyType) or 0
self.primarykeyList[temp] = i
--table.insert(self.primarykeyList, temp)
end
reader:Close()
return true
end
-- 读取每行的位置和长度
function BinaryTable:ReadRowInfoTrunk()
local len = self.rowTrunkLen
local position = self.infoTrunkLen + 4
if self.primarykeyCount > 0 then
position = position + self.primarykeyLen
end
if len <= 0 or position < 0 then
XLog.Error(string.format("%s,BinaryTable:ReadRowInfoTrunk 读取行位置块失败!", self.filePath))
return
end
self.rowInfoArray = {}
local reader = self:GetReader(position)
for i = 1, self.row do
local rowInfo = {}
rowInfo.start = reader:ReadInt() or 0
rowInfo.tail = reader:ReadInt() or 0
table.insert(self.rowInfoArray, rowInfo)
end
reader:Close()
reader = nil
end
--获取某一行信息
function BinaryTable:TryGetRowInfo(index)
if not self.rowInfoArray then
self:ReadRowInfoTrunk()
end
if not self.rowInfoArray or #self.rowInfoArray <= 0 then
XLog.Error(string.format("%s,BinaryTable:TryGetRowInfo 读取行位置数据失败", self.filePath))
return
end
if index > #self.rowInfoArray then
XLog.Error(string.format("%s,BinaryTable:TryGetRowInfo 超出总行数长度 : %s 查询长度 : %s", self.filePath, #self.rowInfoArray, index))
return
end
return self.rowInfoArray[index]
end
--读取条目
function BinaryTable:ReadElement(value)
if not self.primarykey then
XLog.Error(string.format("%s,主键未初始化 ", self.filePath))
return nil
end
if not self.primarykeyList then
self:ReadIndexTrunk()
end
local element = nil
local index = self.primarykeyList[value]
if index then
local info = self:TryGetRowInfo(index)
element = self:ReadElementInner(info, index, value)
end
if not element then
-- XLog.Warning(string.format("%s,BinaryTable:ReadElement,查询失败,未找到条目 %s = %s", self.filePath, self.primarykey, value))
return
end
return element
end
function BinaryTable:ReadRow(info, offset)
if info.start < 0 or info.tail <= 0 then
XLog.Error(string.format("%s,BinaryTable:ReadRow,行数据异常 %s = %s", self.filePath, info.start, info.tail))
return
end
local len = info.tail - info.start
local startIndex = offset + info.start
local reader = self:GetReader(startIndex)
return reader
end
function BinaryTable:ReadElementInner(info, index, value)
local position = self:GetContenTrunkPosition()
local reader = self:ReadRow(info, position)
if not reader then
XLog.Warning(string.format("%s,BinaryTable:ReadElementInner,查询数据失败 %s = %s", self.filePath, self.primarykey, value))
return
end
local colType = self.colTypes
local colNames = self.colNames
self.colNameIndex = {}
for i = 1, #colNames do
local name = colNames[i]
self.colNameIndex[name] = i
end
---每一个表对应一个元表
local metaTable = {}
metaTable.__index = function(tbl, colName)
local idx = self.colNameIndex[colName]
if not idx or not tbl then
return nil
end
local result = rawget(tbl, idx)
if not result then
local resultType = colType[idx]
if not resultType then
XLog.Error(string.format("找不到键值 Key:%s 请检查该键值和表头是否匹配", colName))
end
result = DefaultOfTypeNew[resultType]
end
return result
end
metaTable.__newindex = function()
XLog.Error("attempt to update a readonly table")
end
metaTable.__metatable = "readonly table"
metaTable.__pairs = function(t)
local function stateless_iter(tbl, key)
local nk, v = next(tbl, key)
if nk and v then
local nv = t[v] or t[nk]
return nk, nv
end
end
return stateless_iter, self.colNameIndex, nil
end
local temp = {}
local keyValue = nil
for j = 1, self.col do
local type = colType[j]
local value = reader:Read(type)
temp[j] = value
end
setmetatable(temp, metaTable)
reader:Close()
reader = nil
return temp
end
function BinaryTable:Release(uload)
CS.PrefProfiler.ProfilerCore.RecordTableBinaryUnload(self.filePath, uload and true or false)
if uload then
self.bytes = nil
end
self.caches = {}
self.cachesCount = 0
end
function BinaryTable:Close()
self.bytes = nil
end
return BinaryTable

View file

@ -0,0 +1,333 @@
local Reader = XClass(nil, "Reader")
local ReadByType = {}
local MaxInt32 = 2147483647
local FloatToInt = 10000
function Reader:Ctor(bytes, len, index)
self.bytes = bytes
self.len = len
self.index = index or 1
end
function Reader:Close()
self.bytes = nil
end
function Reader:Read(type)
return ReadByType[type](self)
end
function Reader:ReadFloat()
local num = self:ReadInt()
if not num then
return nil
end
num = num / 10000
local a, b = math.modf(num) --拆分整数位和小数位
if b == 0 then
num = a
end
return num
--
-- if self.index + 3 > self.len then
-- return
-- end
-- local b1, b2, b3, b4 = string.byte(self.bytes, self.index, self.index + 3)
-- self.index = self.index + 4
-- local sign = b4 > 0x7F --最高位符号位
-- local expo = (b4 % 0x80) * 0x02 + math.floor(b3 / 0x80) --整数部分
-- local mant = ((b3 % 0x80) * 0x100 + b2) * 0x100 + b1 --小数部分
-- if sign then
-- sign = -1
-- else
-- sign = 1
-- end
-- local n
-- if mant == 0 and expo == 0 then
-- n = sign * 0
-- elseif expo == 0xFF then
-- if mant == 0 then
-- n = sign * math.huge
-- else
-- n = nil
-- end
-- else
-- if (expo > 0) and (expo < 0xFF) then
-- n = sign * (1 + mant / 8388608) * (1 << (expo - 0x7F))
-- else
-- n = sign * (mant / 8388608) * (1 << 0x7F)
-- end
-- end
-- return n
end
function Reader:ReadBool()
local value = string.byte(self.bytes, self.index, self.index)
self.index = self.index + 1
return value == 1 and true or nil
end
--读取string
function Reader:ReadString()
local postion = self.index
local ass = string.byte(self.bytes, postion, postion)
while ass > 0 do
postion = postion + 1
ass = string.byte(self.bytes, postion, postion)
if ass == nil then
XLog.Error(string.format("读取字符串异常 postion = %s,len = %s index =%s", postion, self.len, self.index))
end
end
if postion == self.index then
self.index = self.index + 1
return
end
local value = string.char(string.byte(self.bytes, self.index, postion - 1))
self.index = postion + 1
return value
end
function Reader:ReadIntFix()
self.index = self.index + 4
local b1, b2, b3, b4 = string.byte(self.bytes, 1, 4)
return b1 | b2 << 8 | b3 << 16 | b4 << 24
end
function Reader:ReadInt()
return self:ReadInt32Variant()
end
function Reader:ReadInt32Variant()
return self:ReadUInt32Variant()
end
function Reader:ReadUInt32Variant()
local value = 0
local tempByte
local index = 0
while not tempByte or ((tempByte >> 7) > 0) do
tempByte = string.byte(self.bytes, self.index, self.index)
local temp1 = (tempByte & 0x7F) << index
value = value | temp1
index = index + 7
self.index = self.index + 1
end
--负数,MaxInt32 = 2147483647 因为lua number是64bit 所以需要特殊处理负数
if value > MaxInt32 then
local newValue = 0
value = -(((~ value) & MaxInt32) + 1)
end
if value == 0 then
return nil
end
return value
end
function Reader:ReadListString()
local len = self:ReadInt()
if not len or len <= 0 then
return nil
end
local list = {}
for i = 1, len do
table.insert(list, self:ReadString())
end
return list
end
function Reader:ReadListBool()
local len = self:ReadInt()
if not len or len <= 0 then
return nil
end
local list = {}
for i = 1, len do
table.insert(list, self:ReadBool())
end
return list
end
function Reader:ReadListInt()
local len = self:ReadInt()
if not len or len <= 0 then
return nil
end
local list = {}
for i = 1, len do
table.insert(list, self:ReadInt() or 0)
end
return list
end
function Reader:ReadListFloat()
local len = self:ReadInt()
if not len or len <= 0 then
return nil
end
local list = {}
for i = 1, len do
table.insert(list, self:ReadFloat() or 0)
end
return list
end
function Reader:ReadDicStringString()
local len = self:ReadInt()
if not len or len <= 0 then
return nil
end
local dic = {}
for i = 1, len do
local key = self:ReadString()
local value = self:ReadString()
dic[key] = value
end
return dic
end
function Reader:ReadDicIntInt()
local len = self:ReadInt()
if not len or len <= 0 then
return nil
end
local dic = {}
for i = 1, len do
local key = self:ReadInt() or 0
local value = self:ReadInt() or 0
dic[key] = value
end
return dic
end
function Reader:ReadDicIntString()
local len = self:ReadInt()
if not len or len <= 0 then
return nil
end
local dic = {}
for i = 1, len do
local key = self:ReadInt() or 0
local value = self:ReadString()
dic[key] = value
end
return dic
end
function Reader:ReadDicStringInt()
local len = self:ReadInt() or 0
if not len or len <= 0 then
return nil
end
local dic = {}
for i = 1, len do
local key = self:ReadString()
local value = self:ReadInt()
dic[key] = value
end
return dic
end
function Reader:ReadDicIntFloat()
local len = self:ReadInt()
if not len or len <= 0 then
return nil
end
local dic = {}
for i = 1, len do
local key = self:ReadInt() or 0
local value = self:ReadFloat()
dic[key] = value
end
return dic
end
--读取Fix
function Reader:ReadFix()
local str = self:ReadString()
if not str then
return nil
end
return FixParse(str)
end
--读取Fix
function Reader:ReadListFix()
local len = self:ReadInt()
if not len or len <= 0 then
return nil
end
local list = {}
for i = 1, len do
table.insert(list, self:ReadFix())
end
return list
end
ReadByType = {
[1] = Reader.ReadBool,
[2] = Reader.ReadString,
[3] = Reader.ReadFix,
[4] = Reader.ReadListString,
[5] = Reader.ReadListBool,
[6] = Reader.ReadListInt,
[7] = Reader.ReadListFloat,
[8] = Reader.ReadListFix,
[9] = Reader.ReadDicStringString,
[10] = Reader.ReadDicIntInt,
[11] = Reader.ReadDicIntString,
[12] = Reader.ReadDicStringInt,
[13] = Reader.ReadDicIntFloat,
[14] = Reader.ReadInt,
[15] = Reader.ReadFloat,
}
return Reader

View file

@ -0,0 +1,34 @@
XLuaBehaviorAgent = XClass(nil, "XLuaBehaviorAgent")
function XLuaBehaviorAgent:Ctor(agentName, agentProxy)
self.Name = agentName
self.AgentProxy = agentProxy
self.Agent = agentProxy.BTAgent
end
function XLuaBehaviorAgent:OnAwake()
end
function XLuaBehaviorAgent:OnStart()
end
function XLuaBehaviorAgent:OnEnable()
end
function XLuaBehaviorAgent:OnDisable()
end
function XLuaBehaviorAgent:OnDestroy()
end
function XLuaBehaviorAgent:OnUpdate()
end
function XLuaBehaviorAgent:OnNotify()
end
function XLuaBehaviorAgent:OnGetEvents()
end

View file

@ -0,0 +1,61 @@
CsXBehaviorManager = CS.BehaviorTree.XBehaviorTreeManager
CsNodeStatus = CS.BehaviorTree.XNodeStatus
CsBehaviorNodeType = CS.BehaviorTree.XBehaviorNodeType
XLuaBehaviorManager = {}
local NodeClassType = {}
local AgentClassType = {}
--注册行为节点
function XLuaBehaviorManager.RegisterNode(super, classType, nodeType, islua, needUpdate)
super = XLuaBehaviorNode or super
CsXBehaviorManager.Instance:RegisterLuaNodeProxy(classType, nodeType, islua, needUpdate)
local behaviorNode = XClass(super, classType)
NodeClassType[classType] = behaviorNode
return behaviorNode
end
--创建行为节点实例
function XLuaBehaviorManager.NewLuaNodeProxy(className, nodeProxy)
local baseName = className
local class = NodeClassType[baseName]
if not class then
class = NodeClassType[baseName]
if not class then
XLog.Error("XLuaBehaviorManager.NewLuaNodeProxy error, class not exist, name: " .. className)
return nil
end
end
local obj = class.New(className, nodeProxy)
return obj
end
--注册行为主体
function XLuaBehaviorManager.RegisterAgent(super, classType)
super = XLuaBehaviorAgent or super
CsXBehaviorManager.Instance:RegisterLuaAgentProxy(classType)
local behaviorNode = XClass(super, classType)
AgentClassType[classType] = behaviorNode
return behaviorNode
end
--创建行为主体实例
function XLuaBehaviorManager.NewLuaAgentProxy(className, agentProxy)
local baseName = className
local class = AgentClassType[baseName]
if not class then
class = AgentClassType[baseName]
if not class then
XLog.Error("XLuaBehaviorManager.NewLuaAgentProxy error, class not exist, name: " .. className)
return nil
end
end
local obj = class.New(className, agentProxy)
return obj
end
function XLuaBehaviorManager.PlayId(id, agent)
agent:PlayBehavior(id)
end

View file

@ -0,0 +1,89 @@
XLuaBehaviorNode = XClass(nil, "XLuaBehaviorNode")
function XLuaBehaviorNode:Ctor(className, nodeProxy)
self.Name = className
self.NodeProxy = nodeProxy
self.Node = nodeProxy.Node
self.BehaviorTree = nodeProxy.Node.BTree
self:InitNodeData()
end
--初始化数据
function XLuaBehaviorNode:InitNodeData()
if not self.Node.Fields then
self.Fields = nil
return
end
self.Fields = {}
local fields = self.Node.Fields.Fields
for _, v in pairs(fields) do
self.Fields[v.FieldName] = v.Value
end
end
function XLuaBehaviorNode:OnAwake()
end
function XLuaBehaviorNode:SetAgent()
self.Agent = self.BehaviorTree.BTAgent
self.Proxy = self.Agent.Proxy
self.AgentProxy = self.Agent.Proxy.LuaAgentProxy
self:OnStart()
end
function XLuaBehaviorNode:OnEnable()
end
function XLuaBehaviorNode:OnStart()
end
function XLuaBehaviorNode:OnRecycle()
self.Agent = nil
self.Proxy = nil
self.AgentProxy = nil
end
function XLuaBehaviorNode:OnDisable()
end
function XLuaBehaviorNode:OnEnter()
end
function XLuaBehaviorNode:OnExit()
end
function XLuaBehaviorNode:OnReset()
end
function XLuaBehaviorNode:OnDestroy()
end
function XLuaBehaviorNode:OnUpdate(dt)
end
function XLuaBehaviorNode:OnFixedUpdate(dt)
end
function XLuaBehaviorNode:OnNotify(evt, ...)
end
function XLuaBehaviorNode:OnGetEvents()
end

View file

@ -0,0 +1,8 @@
fix = CS.Mathematics.fix
--fix.zero = CS.Mathematics.fix.zero
--fix.hundred = CS.Mathematics.fix.hundred
--fix.thousand = CS.Mathematics.fix.thousand
--fix.deg2rad = CS.Mathematics.fix.deg2rad
FixParse = CS.FixExtension.Parse
FixToInt = CS.FixExtension.FixToInt
FixToDouble = CS.FixExtension.FixToDouble

View file

@ -0,0 +1,397 @@
--
-- json.lua
--
-- Copyright (c) 2019 rxi
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy of
-- this software and associated documentation files (the "Software"), to deal in
-- the Software without restriction, including without limitation the rights to
-- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-- of the Software, and to permit persons to whom the Software is furnished to do
-- so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--
local json = { _version = "0.1.2" }
-------------------------------------------------------------------------------
-- Encode
-------------------------------------------------------------------------------
local encode
local escape_char_map = {
["\\"] = "\\\\",
["\""] = "\\\"",
["\b"] = "\\b",
["\f"] = "\\f",
["\n"] = "\\n",
["\r"] = "\\r",
["\t"] = "\\t",
}
local escape_char_map_inv = {["\\/"] = "/" }
for k, v in pairs(escape_char_map) do
escape_char_map_inv[v] = k
end
local function escape_char(c)
return escape_char_map[c] or string.format("\\u%04x", c:byte())
end
local function encode_nil()
return "null"
end
local function encode_table(val, stack)
local res = {}
stack = stack or {}
-- Circular reference?
if stack[val] then error("circular reference") end
stack[val] = true
if rawget(val, 1) ~= nil or next(val) == nil then
-- Treat as array -- check keys are valid and it is not sparse
local n = 0
for k in pairs(val) do
if type(k) ~= "number" then
error("invalid table: mixed or invalid key types")
end
n = n + 1
end
if n ~= #val then
error("invalid table: sparse array")
end
-- Encode
for _, v in ipairs(val) do
table.insert(res, encode(v, stack))
end
stack[val] = nil
return "[" .. table.concat(res, ",") .. "]"
else
-- Treat as an object
for k, v in pairs(val) do
if type(k) ~= "string" then
error("invalid table: mixed or invalid key types")
end
table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
end
stack[val] = nil
return "{" .. table.concat(res, ",") .. "}"
end
end
local function encode_string(val)
return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"'
end
local function encode_number(val)
-- Check for NaN, -inf and inf
if val ~= val or val <= -math.huge or val >= math.huge then
error("unexpected number value '" .. tostring(val) .. "'")
end
return string.format("%.14g", val)
end
local type_func_map = {
["nil" ] = encode_nil,
["table"] = encode_table,
["string"] = encode_string,
["number"] = encode_number,
["boolean"] = tostring,
}
encode = function(val, stack)
local t = type(val)
local f = type_func_map[t]
if f then
return f(val, stack)
end
error("unexpected type '" .. t .. "'")
end
function json.encode(val)
return (encode(val))
end
-------------------------------------------------------------------------------
-- Decode
-------------------------------------------------------------------------------
local parse
local function create_set(...)
local res = {}
for i = 1, select("#", ...) do
res[select(i, ...)] = true
end
return res
end
local space_chars = create_set(" ", "\t", "\r", "\n")
local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",")
local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u")
local literals = create_set("true", "false", "null")
local literal_map = {
["true"] = true,
["false"] = false,
["null"] = nil,
}
local function next_char(str, idx, set, negate)
for i = idx, #str do
if set[str:sub(i, i)] ~= negate then
return i
end
end
return #str + 1
end
local function decode_error(str, idx, msg)
local line_count = 1
local col_count = 1
for i = 1, idx - 1 do
col_count = col_count + 1
if str:sub(i, i) == "\n" then
line_count = line_count + 1
col_count = 1
end
end
error(string.format("%s at line %d col %d", msg, line_count, col_count))
end
local function codepoint_to_utf8(n)
-- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa
local f = math.floor
if n <= 0x7f then
return string.char(n)
elseif n <= 0x7ff then
return string.char(f(n / 64) + 192, n % 64 + 128)
elseif n <= 0xffff then
return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128)
elseif n <= 0x10ffff then
return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128,
f(n % 4096 / 64) + 128, n % 64 + 128)
end
error(string.format("invalid unicode codepoint '%x'", n))
end
local function parse_unicode_escape(s)
local n1 = tonumber(s:sub(3, 6), 16)
local n2 = tonumber(s:sub(9, 12), 16)
-- Surrogate pair?
if n2 then
return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000)
else
return codepoint_to_utf8(n1)
end
end
local function parse_string(str, i)
local has_unicode_escape = false
local has_surrogate_escape = false
local has_escape = false
local last
for j = i + 1, #str do
local x = str:byte(j)
if x < 32 then
decode_error(str, j, "control character in string")
end
if last == 92 then -- "\\" (escape char)
if x == 117 then -- "u" (unicode escape sequence)
local hex = str:sub(j + 1, j + 5)
if not hex:find("%x%x%x%x") then
decode_error(str, j, "invalid unicode escape in string")
end
if hex:find("^[dD][89aAbB]") then
has_surrogate_escape = true
else
has_unicode_escape = true
end
else
local c = string.char(x)
if not escape_chars[c] then
decode_error(str, j, "invalid escape char '" .. c .. "' in string")
end
has_escape = true
end
last = nil
elseif x == 34 then -- '"' (end of string)
local s = str:sub(i + 1, j - 1)
if has_surrogate_escape then
s = s:gsub("\\u[dD][89aAbB]..\\u....", parse_unicode_escape)
end
if has_unicode_escape then
s = s:gsub("\\u....", parse_unicode_escape)
end
if has_escape then
s = s:gsub("\\.", escape_char_map_inv)
end
return s, j + 1
else
last = x
end
end
decode_error(str, i, "expected closing quote for string")
end
local function parse_number(str, i)
local x = next_char(str, i, delim_chars)
local s = str:sub(i, x - 1)
local n = tonumber(s)
if not n then
decode_error(str, i, "invalid number '" .. s .. "'")
end
return n, x
end
local function parse_literal(str, i)
local x = next_char(str, i, delim_chars)
local word = str:sub(i, x - 1)
if not literals[word] then
decode_error(str, i, "invalid literal '" .. word .. "'")
end
return literal_map[word], x
end
local function parse_array(str, i)
local res = {}
local n = 1
i = i + 1
while 1 do
local x
i = next_char(str, i, space_chars, true)
-- Empty / end of array?
if str:sub(i, i) == "]" then
i = i + 1
break
end
-- Read token
x, i = parse(str, i)
res[n] = x
n = n + 1
-- Next token
i = next_char(str, i, space_chars, true)
local chr = str:sub(i, i)
i = i + 1
if chr == "]" then break end
if chr ~= "," then decode_error(str, i, "expected ']' or ','") end
end
return res, i
end
local function parse_object(str, i)
local res = {}
i = i + 1
while 1 do
local key, val
i = next_char(str, i, space_chars, true)
-- Empty / end of object?
if str:sub(i, i) == "}" then
i = i + 1
break
end
-- Read key
if str:sub(i, i) ~= '"' then
decode_error(str, i, "expected string for key")
end
key, i = parse(str, i)
-- Read ':' delimiter
i = next_char(str, i, space_chars, true)
if str:sub(i, i) ~= ":" then
decode_error(str, i, "expected ':' after key")
end
i = next_char(str, i + 1, space_chars, true)
-- Read value
val, i = parse(str, i)
-- Set
res[key] = val
-- Next token
i = next_char(str, i, space_chars, true)
local chr = str:sub(i, i)
i = i + 1
if chr == "}" then break end
if chr ~= "," then decode_error(str, i, "expected '}' or ','") end
end
return res, i
end
local char_func_map = {
['"'] = parse_string,
["0"] = parse_number,
["1"] = parse_number,
["2"] = parse_number,
["3"] = parse_number,
["4"] = parse_number,
["5"] = parse_number,
["6"] = parse_number,
["7"] = parse_number,
["8"] = parse_number,
["9"] = parse_number,
["-"] = parse_number,
["t"] = parse_literal,
["f"] = parse_literal,
["n"] = parse_literal,
["["] = parse_array,
["{"] = parse_object,
}
parse = function(str, idx)
local chr = str:sub(idx, idx)
local f = char_func_map[chr]
if f then
return f(str, idx)
end
decode_error(str, idx, "unexpected character '" .. chr .. "'")
end
function json.decode(str)
if type(str) ~= "string" then
error("expected argument of type string, got " .. type(str))
end
local res, idx = parse(str, next_char(str, 1, space_chars, true))
idx = next_char(str, idx, space_chars, true)
if idx <= #str then
decode_error(str, idx, "trailing garbage")
end
return res
end
return json

View file

@ -0,0 +1,35 @@
--==============================--
-- 通用数据收集事件
--==============================--
XAnalyticsEvent = XAnalyticsEvent or {}
local OnRoleCreate = function()
if XUserManager.IsUseSdk() then
XHeroSdkManager.CreateNewRole()
end
end
local OnLogin = function()
if XUserManager.IsUseSdk() then
XHeroSdkManager.EnterGame()
end
CS.BuglyAgent.SetUserId(tostring(XPlayer.Id))
end
local OnLevelUp = function()
if XUserManager.IsUseSdk() then
XHeroSdkManager.RoleLevelUp()
end
end
local OnLogout = function()
end
function XAnalyticsEvent.Init()
XEventManager.AddEventListener(XEventId.EVENT_NEW_PLAYER, OnRoleCreate)
XEventManager.AddEventListener(XEventId.EVENT_LOGIN_SUCCESS, OnLogin)
XEventManager.AddEventListener(XEventId.EVENT_PLAYER_LEVEL_CHANGE, OnLevelUp)
XEventManager.AddEventListener(XEventId.EVENT_USER_LOGOUT, OnLogout)
end

View file

@ -0,0 +1,171 @@
local rawget = rawget
local rawset = rawset
local getmetatable = getmetatable
local setmetatable = setmetatable
XBindTool = XBindTool or {}
local oldPairs = pairs
local pairs = function(arr)
local meta_t = getmetatable(arr)
if meta_t and meta_t.__pairs then
return meta_t.__pairs(arr)
end
return oldPairs(arr)
end
local function InitBind(obj)
if rawget(obj, "___isBinded") then return end
local store = {}
for key, _ in pairs(obj) do
local v = rawget(obj, key)
if v ~= nil then
store[key] = v
obj[key] = nil
end
end
local meta_t = getmetatable(obj)
if meta_t then setmetatable(store, meta_t) end
setmetatable(obj, {
__index = function(_, index)
local ret = rawget(obj, index)
if ret ~= nil then return ret end
return store[index]
end,
__newindex = function(_, index, v)
local event = rawget(obj, "___bind_event")
local old_v = store[index]
store[index] = v
if old_v ~= v then
if event and event[index] then
event[index].running = true
for key, func in pairs(event[index].callList) do
if not event[index].removeList[key] then
func(v, old_v)
end
end
event[index].running = nil
if next(event[index].removeList) then
for removeIndex, _ in pairs(event[index].removeList) do
event[index].callList[removeIndex] = nil
end
event[index].removeList = {}
end
end
end
end,
__pairs = function(_)
return oldPairs(store)
end
})
rawset(obj, "___isBinded", true)
rawset(obj, "___bind_store", store)
rawset(obj, "___bind_event", {})
rawset(obj, "___bind_id", 0)
end
function XBindTool.BindAttr(obj, attr, callback)
InitBind(obj)
local event = rawget(obj, "___bind_event")
local id = rawget(obj, "___bind_id")
event[attr] = event[attr] or { callList = {}, removeList = {} }
id = id + 1
rawset(obj, "___bind_id", id)
event[attr].callList[id] = callback
local value = obj[attr]
if value ~= nil then
callback(value)
end
return { obj = obj, attr = attr, id = id }
end
function XBindTool.GetBindInfo(val)
if type(val) ~= "table" then return val, false end
if not rawget(val, "___isBinded") then return val, false end
return rawget(val, "___bind_store"), true
end
function XBindTool.UnBind(handle)
local event = rawget(handle.obj, "___bind_event")
if event and event[handle.attr] then
if event[handle.attr].running then
event[handle.attr].removeList[handle.id] = true
else
event[handle.attr].callList[handle.id] = nil
end
end
end
function XBindTool.UnBindObj(obj)
local event = rawget(obj, "___bind_event")
if event then
for _, attrListener in pairs(event) do
if attrListener.running then
for key, _ in pairs(attrListener.callList) do
attrListener.removeList[key] = true
end
end
end
rawset(obj, "___bind_event", {})
end
end
local NodeBindInfoRecord = {}
function XBindTool.BindNode(node, obj, attr, func, unbindFunc)
if not NodeBindInfoRecord[node] then
NodeBindInfoRecord[node] = {}
end
local bindInfo = NodeBindInfoRecord[node]
bindInfo[obj] = bindInfo[obj] or { length = 0, record = {} }
local checkExist
if node.Exist then
checkExist = function() return node:Exist() end
else
local gameObject = node.GameObject or node.gameObject or node.Transform or node.transform
if gameObject and gameObject.Exist then
checkExist = function() return gameObject:Exist() end
end
end
local handle
if checkExist then
handle = XBindTool.BindAttr(obj, attr, function(...)
if not checkExist() then
XBindTool.UnBindNode(node)
if unbindFunc then
unbindFunc()
end
else
func(...)
end
end)
else
handle = XBindTool.BindAttr(obj, attr, func)
end
bindInfo[obj].record[handle.id] = handle
bindInfo[obj].length = bindInfo[obj].length + 1
return handle
end
function XBindTool.UnBindNode(node)
local bindInfo = NodeBindInfoRecord[node]
if bindInfo then
for key, val in pairs(bindInfo) do
for _, item in pairs(val.record) do
XBindTool.UnBind(item)
end
bindInfo[key] = nil
end
NodeBindInfoRecord[node] = nil
end
end

View file

@ -0,0 +1,115 @@
XCameraHelper = XCameraHelper or {}
function XCameraHelper.SetCameraTarget(cameraCtrl, targetTrans, distance)
if cameraCtrl and cameraCtrl:Exist() then
distance = distance or 0
cameraCtrl:SetLookAt(targetTrans, distance)
end
end
XCameraHelper.SCREEN_SHOT_WIDTH = 1920;
XCameraHelper.SCREEN_SHOT_HEIGHT = 1080;
XCameraHelper.DefaultRect = CS.UnityEngine.Rect(0, 0, XCameraHelper.SCREEN_SHOT_WIDTH, XCameraHelper.SCREEN_SHOT_HEIGHT);
XCameraHelper.ScreenRect = CS.UnityEngine.Rect(0, 0, CS.UnityEngine.Screen.width, CS.UnityEngine.Screen.height)
function XCameraHelper.ScreenShot(image, beginCb, cb)
if beginCb then
beginCb()
end
CS.XTool.WaitForEndOfFrame(function()
local screenShot = XCameraHelper.DoScreenShot(image)
if cb then
cb(screenShot)
end
end)
end
-- 截取屏幕画面到image中 (注意内存开销,需使用后及时释放)
-- image Image组件
-- cameraFar Camera组件
-- cameraNear Camera组件可选
function XCameraHelper.DoScreenShot(image)
if XTool.UObjIsNil(image) then
XLog.Error("ScreenShot image is nil")
return
end
-- if XTool.UObjIsNil(cameraFar) then
-- XLog.Error("ScreenShot cameraFar is nil")
-- return
-- end
local rect = XCameraHelper.ScreenRect
-- -- 创建一个rt对象
-- local rt = CS.UnityEngine.RenderTexture(rect.width, rect.height, 24)
-- rt.antiAliasing = 8
-- cameraFar.targetTexture = rt;
-- if not XTool.UObjIsNil(cameraNear) then
-- cameraNear.targetTexture = rt
-- end
-- cameraFar:Render();
-- if not XTool.UObjIsNil(cameraNear) then
-- cameraNear:Render()
-- end
-- local currentRT = CS.UnityEngine.RenderTexture.active
-- -- 激活rt 读取像素
-- CS.UnityEngine.RenderTexture.active = rt;
local screenShot = CS.UnityEngine.Texture2D(rect.width, rect.height, CS.UnityEngine.TextureFormat.RGB24, false);
screenShot:ReadPixels(rect, 0, 0);
screenShot:Apply();
-- 重置相关参数
-- cameraFar.targetTexture = nil;
-- if not XTool.UObjIsNil(cameraNear) then
-- cameraNear.targetTexture = nil;
-- end
-- CS.UnityEngine.RenderTexture.active = currentRT;
-- CS.UnityEngine.Object.Destroy(rt);
local sprite = CS.UnityEngine.Sprite.Create(screenShot, rect, CS.UnityEngine.Vector2.zero);
image.sprite = sprite
return screenShot
end
-- 调用该接口由ScreenCaptureWithCallBack回调函数传出的Texture用完后必须销毁
function XCameraHelper.ScreenShotNew(image, camera, cb, beginCb)
if not image then
XLog.Error("ScreenShot Call invalid parameter:image is nil")
return
end
if not camera then
XLog.Error("ScreenShot Call invalid parameter:camera is nil")
return
end
if not cb then
XLog.Error("The ScreenShot API Must Need CallBack")
return
end
-- if not XTool.UObjIsNil(image.mainTexture) and image.mainTexture.name ~= "UnityWhite" then -- 销毁texture2d (UnityWhite为默认的texture2d)
-- CS.UnityEngine.Object.Destroy(image.mainTexture)
-- end
if beginCb then
beginCb()
end
CS.XScreenCapture.ScreenCaptureWithCallBack(camera,function(texture)
local rect = CS.UnityEngine.Rect(0, 0, texture.width, texture.height)
local sprite = CS.UnityEngine.Sprite.Create(texture, rect, CS.UnityEngine.Vector2.zero);
image.sprite = sprite
if cb then
cb(texture)
end
end)
end
function XCameraHelper.GetBlendTime(cameraBrain, index)
return cameraBrain.m_CustomBlends.m_CustomBlends[index].m_Blend.m_Time
end

View file

@ -0,0 +1,153 @@
local getinfo = debug.getinfo
local type = type
local _class = {}
local _classNameDic = {}
function XClass(super, className)
local class
if XMain.IsEditorDebug then
local fullClassName = className .. getinfo(2, "S").source
class = _classNameDic[fullClassName]
if class then
class.Super = super
if _class[class] then
_class[class].Super = super
end
return class
end
class = {}
_classNameDic[fullClassName] = class
else
class = {}
end
class.Ctor = false
class.Super = super
class.New = function(...)
local obj = {}
obj.__cname = className
obj.__class = class --for typeof
setmetatable(obj, { __index = _class[class] })
do
local create
create = function(c, ...)
if c.Super then
create(c.Super, ...)
end
if c.Ctor then
c.Ctor(obj, ...)
end
end
create(class, ...)
end
return obj
end
local vtbl = {}
_class[class] = vtbl
setmetatable(class, {
__newindex = function(_, k, v)
vtbl[k] = v
end,
__index = function(_, k)
return vtbl[k]
end
})
if super then
vtbl.Super = super
setmetatable(vtbl, {
__index = function(_, k)
local ret = _class[super][k]
vtbl[k] = ret
return ret
end
})
end
return class
end
function GetClassVituralTable(class)
return _class[class]
end
function UpdateClassType(newClass, oldClass)
if "table" ~= type(newClass) then return end
if "table" ~= type(oldClass) then return end
if oldClass == newClass then return end
local new_vtbl = _class[newClass]
local old_vtbl = _class[oldClass]
if not new_vtbl or not old_vtbl then return end
_class[oldClass] = new_vtbl
_class[newClass] = nil
end
-- 检查obj是否从super中继承过来
function CheckClassSuper(obj, super)
if obj == nil or obj.Super == nil then
return false
end
local checkSuper = obj.Super
while checkSuper do
if checkSuper == super then
return true
end
checkSuper = checkSuper.Super
end
return false
end
function CheckIsClass(obj) -- hack
return obj.Ctor ~= nil and obj.New ~= nil
end
-- 创建匿名方法类
function CreateAnonClassInstance(funcDic, super, ...)
local result = super.New(...)
result.Super = super
for funcName, func in pairs(funcDic) do
result[funcName] = func
end
return result
end
function become_const(const_table, tipsError)
function Const(const_table)
local mt = {
__index = function(t, k)
if const_table[k] then
return const_table[k]
elseif tipsError then
XLog.Error(string.format("const or enum key = %s is nil", k))
end
end,
__newindex = function (t,k,v)
XLog.Error("can't set " .. tostring(const_table) .."." .. tostring(k) .." to " .. tostring(v))
end
}
return mt
end
local t = {}
setmetatable(t, Const(const_table))
return t
end
function enum(t, tipsError)
local ret = {}
for k, v in pairs(t) do
ret[k] = v
ret[v] = k
end
ret.dic = t
return become_const(ret, tipsError)
end

View file

@ -0,0 +1,30 @@
XCode = {}
local XCodeKeyMap = nil
local mt = {
__index = function(t, k)
local code = XCodeKeyMap[k]
if code then
t[k] = code
XCodeKeyMap[k] = nil
else
XLog.Error("XCode Key:" .. tostring(k) .. "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>XCodeText.tab<61><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD>ϸ<EFBFBD>Key<65>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ã<EFBFBD>XCode.cs<63>ж<EFBFBD><D0B6>")
end
return code
end
}
setmetatable(XCode, mt)
function XCode.Init()
if XCodeKeyMap then
return
end
XCodeKeyMap = {}
local TABLE_CODE_TEXT = "Share/Text/CodeText.tab"
local codeTextTemplates = XTableManager.ReadByStringKey(TABLE_CODE_TEXT, XTable.XTableCodeText, "Key")
for k, v in pairs(codeTextTemplates) do
XCodeKeyMap[k] = v.Id
end
end

View file

@ -0,0 +1,127 @@
XCountDown = XCountDown or {}
XCountDown.GTimerName = {
UrgentEvent = "UrgentEvent",
FubenInfestorExplore = "FubenInfestorExplore",
FubenInfestorExploreDaily = "FubenInfestorExploreDaily",
Stronghold = "Stronghold", --超级据点活动倒计时
KillZone = "KillZone", --杀戮无双活动倒计时
LivWarmSoundsActivity = "LivWarmSoundsActivity", --丽芙预热音频解密倒计时
LivWarmExActivity = "LivWarmExActivity", --丽芙预热宣发活动
AreaWar = "AreaWar", --全服决战
Doomsday = "Doomsday", --末日生存
}
-- 倒计时存储容器
-- bindCnt : 当前倒计时的总数
-- record : 倒计时
-- record[name] : 通过倒计时命名来记录
-- record[name].remainTime : 剩余时间
-- record[name].lastTime : 最后一次绑定时间
-- record[name].bindCnt : 单个命名绑定的倒计时的个数
-- record[name].nodeList : 记录当前名字存下的节点
-- timeHandle : 处理事件
local TimerRecord = { bindCnt = 0, record = {}, timeHandle = nil }
local function UpdateTimerRecord()
local now = XTime.GetServerNowTimestamp()
for _, v in pairs(TimerRecord.record) do
if v.bindCnt > 0 and v.remainTime > 0 then
v.remainTime = v.remainTime - (now - v.lastTime)
v.lastTime = now
if v.remainTime < 0 then
v.remainTime = 0
end
end
end
end
function XCountDown.CreateTimer(name, remainTime, now)
if not TimerRecord.record[name] then
TimerRecord.record[name] = {
bindCnt = 0,
}
end
now = now or XTime.GetServerNowTimestamp()
TimerRecord.record[name].remainTime = remainTime
TimerRecord.record[name].lastTime = now
end
function XCountDown.RemoveTimer(name)
local record = TimerRecord.record[name]
if record then
TimerRecord.bindCnt = TimerRecord.bindCnt - record.bindCnt
XBindTool.UnBindObj(record)
TimerRecord.record[name] = nil
if TimerRecord.bindCnt == 0 and TimerRecord.timeHandle then
XScheduleManager.UnSchedule(TimerRecord.timeHandle)
TimerRecord.timeHandle = nil
end
end
end
function XCountDown.GetRemainTime(name)
local record = TimerRecord.record[name]
if record then
local now = XTime.GetServerNowTimestamp()
if record.bindCnt > 0 and record.remainTime > 0 then
record.remainTime = record.remainTime - (now - record.lastTime)
record.lastTime = now
if record.remainTime < 0 then
record.remainTime = 0
end
end
return record.remainTime
else
return 0
end
end
function XCountDown.BindTimer(node, name, cb)
local record = TimerRecord.record[name]
if record then
if not record.nodeList then
record.nodeList = {}
end
table.insert(record.nodeList, node)
if not TimerRecord.timeHandle then
TimerRecord.timeHandle = XScheduleManager.ScheduleForever(function()
UpdateTimerRecord()
end, XScheduleManager.SECOND, 0)
UpdateTimerRecord()
end
TimerRecord.bindCnt = TimerRecord.bindCnt + 1
record.bindCnt = record.bindCnt + 1
XBindTool.BindNode(node, record, "remainTime", cb, function()
TimerRecord.bindCnt = TimerRecord.bindCnt - 1
record.bindCnt = record.bindCnt - 1
if TimerRecord.bindCnt == 0 then
XScheduleManager.UnSchedule(TimerRecord.timeHandle)
TimerRecord.timeHandle = nil
end
end)
end
end
function XCountDown.UnBindTimer(curNode, name)
XBindTool.UnBindNode(curNode)
local record = TimerRecord.record[name]
if not record or not record.nodeList then
return
end
for i = 1, #record.nodeList do
if record.nodeList[i] == curNode then
TimerRecord.bindCnt = TimerRecord.bindCnt - 1
record.bindCnt = record.bindCnt - 1
if TimerRecord.bindCnt == 0 then
XScheduleManager.UnSchedule(TimerRecord.timeHandle)
TimerRecord.timeHandle = nil
end
table.remove(record.nodeList, i)
end
end
end

View file

@ -0,0 +1,274 @@
XDynamicList = XClass(nil, "XDynamicList")
DLDelegateEvent = {
DYNAMIC_GRID_TOUCHED = 5,
DYNAMIC_GRID_ATINDEX = 6,
DYNAMIC_GRID_RECYCLE = 7,
}
DLInsertDataDir = {
None = 0,
Head = 1,
Tail = 2,
}
DLScrollDataDir = {
None = 0,
Head = 1,
Tail = 2
}
function XDynamicList:DebugLog(...)
if self.showLog then
XLog.Error(...)
end
end
function XDynamicList:Ctor(ui)
self.GameObject = ui.gameObject
self.Transform = ui.transform
self.ItemCache = {}
self.showLog = false
self:ResetData()
self:InitView()
end
function XDynamicList:ResetData()--重置数据
self.Data = {}
self.curDataMaxIndex = 0--当前数据最大的索引
self.dataHeadIndex = -1 --当前数据头索引
self.dataTailIndex = -1--当前数据尾索引
self.NodeListData = {}
self.curShowHeadIndex = -1--当前展示的头索引
self.curShowTailIndex = -1--当前展示的尾索引
end
function XDynamicList:InitView()
self.DynamicList = self.Transform:GetComponent("XVerticalDynamicList")
self.DynamicListBar = self.DynamicList.verticalScrollbar
if self.DynamicList == nil then
XLog.Error("Not Find XVerticalDynamicList Component!")
return
end
self.DynamicList:SetViewSize(self.Transform:GetComponent("RectTransform").rect.size)
end
function XDynamicList:SetData(data, cb, scrollCb)--设置数据
self:DebugLog("------数据初始化----", data)
self:ResetData()
self.CallBack = cb
self.ScrollCallBack = scrollCb --滑动回调
self.DynamicList.tableViewGridDelegate = function(evt, index, dir)
return self:GenerateItem(evt, dir, index)
end
self:FormatData(data)
end
function XDynamicList:FormatData(data)--格式化数据
if data == nil then
XLog.Error("------FormatData is error!------> data is nil! please check!")
return
end
self.dataHeadIndex = 1
self.dataTailIndex = #data
self.NodeListData = {}
for i = 1, self.dataTailIndex do
self.curDataMaxIndex = self.curDataMaxIndex + 1
local temp = {}
temp.data = data[i]
temp.index = self.curDataMaxIndex
temp.Pre = (i == 1) and -1 or self.curDataMaxIndex - 1
temp.Next = (i == #data) and -1 or self.curDataMaxIndex + 1
self.NodeListData[self.curDataMaxIndex] = temp
end
self:DebugLog("------FormatData------", self.NodeListData)
self:ReloadData()
end
function XDynamicList:ReloadData()
-- if #self.NodeListData <= 0 then
-- return
-- end
self.curShowTailIndex = -1
self.curShowHeadIndex = -1
self.DynamicList.TotalCount = #self.NodeListData
self.DynamicList:ReloadData(true)
self:DebugLog("------ReloadData------", self.NodeListData)
end
function XDynamicList:InsertData(insertData, dir, isReload)--插入数据
if #insertData == 0 then
XLog.Error("-----------insertData is null--------------")
return
end
local tempDataHeadIndex = self.dataHeadIndex
local tempDataTailIndex = self.dataTailIndex
for i = 1, #insertData do
self.curDataMaxIndex = self.curDataMaxIndex + 1
local temp = {}
temp.data = insertData[i]
temp.index = self.curDataMaxIndex
if dir == DLInsertDataDir.Head then
temp.Pre = (i == 1) and -1 or self.curDataMaxIndex - 1
if #self.NodeListData == 0 then
temp.Next = -1
else
temp.Next = (i == #insertData) and self.dataHeadIndex or self.curDataMaxIndex + 1
end
if i == 1 then
tempDataHeadIndex = self.curDataMaxIndex
end
if i == #insertData and #self.NodeListData > 0 then
self.NodeListData[self.dataHeadIndex].Pre = self.curDataMaxIndex
end
elseif dir == DLInsertDataDir.Tail then
if #self.NodeListData == 0 then
temp.Pre = -1
else
temp.Pre = (i == 1) and self.dataTailIndex or self.curDataMaxIndex - 1
end
temp.Next = (i == #insertData) and -1 or self.curDataMaxIndex + 1
if i == 1 and #self.NodeListData > 0 then
self.NodeListData[self.dataTailIndex].Next = self.curDataMaxIndex
end
if i == #insertData then
tempDataTailIndex = self.curDataMaxIndex
end
end
self.NodeListData[self.curDataMaxIndex] = temp
end
self.dataHeadIndex = tempDataHeadIndex
self.dataTailIndex = tempDataTailIndex
self:AddTotalCount(#insertData, dir)
if isReload then
self:ReloadData()
end
end
function XDynamicList:AddTotalCount(addCount, dir)
self.DynamicList.TotalCount = self.DynamicList.TotalCount + addCount;
if dir == DLInsertDataDir.Head then
self.DynamicList.StartIndex = self.DynamicList.StartIndex + addCount
-- self.DynamicList.EndIndex = self.DynamicList.EndIndex + addCount
end
end
function XDynamicList:GenerateItem(evt, dir, index)
if self.DynamicListBar then
if self:GetBarValue() <= 0 then--拉到底了
XEventManager.DispatchEvent(XEventId.EVENT_PULL_SCROLLVIEW_END, 0)
-- 添加新事件系统触发
CsXGameEventManager.Instance:Notify(XEventId.EVENT_PULL_SCROLLVIEW_END, 0)
elseif self:GetBarValue() >= 1 then--拉到顶了
XEventManager.DispatchEvent(XEventId.EVENT_PULL_SCROLLVIEW_UP, 0)
-- 添加新事件系统触发
CsXGameEventManager.Instance:Notify(XEventId.EVENT_PULL_SCROLLVIEW_UP, 0)
end
end
if self.ScrollCallBack then
self.ScrollCallBack()
end
if not self.CallBack then
XLog.Error("You must be set callBack......")
return
end
if evt == DLDelegateEvent.DYNAMIC_GRID_ATINDEX then
if #self.NodeListData == 0 then
return true
end
local curShowDataIndex = nil--下一个需要展示的数据index
if dir == DLScrollDataDir.Head then
if not self.NodeListData[self.curShowHeadIndex] then
return true
end
if self.NodeListData[self.curShowHeadIndex].Pre == -1 then
return true
end
self.curShowHeadIndex = self.NodeListData[self.curShowHeadIndex].Pre
curShowDataIndex = self.curShowHeadIndex
elseif dir == DLScrollDataDir.Tail then
if self.curShowTailIndex == -1 and self.curShowHeadIndex == -1 then
self.curShowHeadIndex = self.dataHeadIndex
self.curShowTailIndex = self.dataHeadIndex
else
if not self.NodeListData[self.curShowTailIndex] then
return true
end
if self.NodeListData[self.curShowTailIndex].Next == -1 then
return true
end
self.curShowTailIndex = self.NodeListData[self.curShowTailIndex].Next
end
curShowDataIndex = self.curShowTailIndex
end
self.CallBack(self.NodeListData[curShowDataIndex].data, function(poolName, ctor)
local item = self.DynamicList:PreDequeueGrid(poolName, index)
local xlayoutNode = item:GetComponent("XLayoutNode")
if self.DynamicList and xlayoutNode then
xlayoutNode.minSize = CS.UnityEngine.Vector2(self.DynamicList.transform:GetComponent("RectTransform").rect.width, 0)
end
if item == nil then
XLog.Error("GenerateItem is Fail......index = ", index)
return false
end
local key = item.gameObject:GetHashCode()
local itemScript = self.ItemCache[key]
if itemScript ~= nil then
return itemScript
else
local newItemScript = ctor(item.gameObject)
self.ItemCache[key] = newItemScript
return newItemScript
end
end)
return false
elseif evt == DLDelegateEvent.DYNAMIC_GRID_RECYCLE then
if dir == DLScrollDataDir.Head then
self.curShowHeadIndex = self.NodeListData[self.curShowHeadIndex].Next
elseif dir == DLScrollDataDir.Tail then
self.curShowTailIndex = self.NodeListData[self.curShowTailIndex].Pre
end
end
end
--------------------------Set-------------------
function XDynamicList:SetReverse(code)
self.DynamicList.Reverse = code
end
function XDynamicList:SetBarValue(value)
self.DynamicListBar.value = value
end
function XDynamicList:SetViewSize(rectSize, isReload)
self.DynamicList:SetViewSize(rectSize)
if isReload then
self:ReloadData()
end
end
---------------------------Get-----------------
function XDynamicList:GetBarValue()
if self.DynamicListBar then
return self.DynamicListBar.value
else
XLog.Error("------DynamicList Not ScrollBar Component!------")
return nil
end
end
function XDynamicList:GetCurDataCount()
return #self.NodeListData
end
function XDynamicList:AddObjectPools(poolName, prefab)
self.DynamicList.ObjectPool:Add(poolName, prefab)
end

View file

@ -0,0 +1,194 @@
XEntityHelper = XEntityHelper or {}
XEntityHelper.TEAM_MAX_ROLE_COUNT = 3
-- entityId : CharacterId or RobotId
function XEntityHelper.GetCharacterIdByEntityId(entityId)
if XRobotManager.CheckIsRobotId(entityId) then
return XRobotManager.GetRobotTemplate(entityId).CharacterId
else
return entityId
end
end
function XEntityHelper.GetIsRobot(entityId)
return XRobotManager.CheckIsRobotId(entityId)
end
function XEntityHelper.GetRobotCharacterType(robotId)
local characterId = XRobotManager.GetCharacterId(robotId)
return XCharacterConfigs.GetCharacterType(characterId)
end
function XEntityHelper.GetCharacterName(entityId)
local characterId = XEntityHelper.GetCharacterIdByEntityId(entityId)
local config = XCharacterConfigs.GetCharacterTemplate(characterId)
if not config then return "none" end
return config.Name
end
function XEntityHelper.GetCharacterTradeName(entityId)
local characterId = XEntityHelper.GetCharacterIdByEntityId(entityId)
local config = XCharacterConfigs.GetCharacterTemplate(characterId)
if not config then return "none" end
return config.TradeName
end
function XEntityHelper.GetCharacterLogName(entityId)
local characterId = XEntityHelper.GetCharacterIdByEntityId(entityId)
local config = XCharacterConfigs.GetCharacterTemplate(characterId)
if not config then return "none" end
return config.LogName
end
function XEntityHelper.GetCharacterSmallIcon(entityId)
local characterId = XEntityHelper.GetCharacterIdByEntityId(entityId)
return XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId, 0, true)
end
function XEntityHelper.GetCharacterType(entityId)
local characterId = XEntityHelper.GetCharacterIdByEntityId(entityId)
return XCharacterConfigs.GetCharacterType(characterId)
end
function XEntityHelper.GetCharacterAbility(entityId)
local ability = XEntityHelper.GetIsRobot(entityId) and XRobotManager.GetRobotAbility(entityId) or XDataCenter.CharacterManager.GetCharacterAbilityById(entityId)
return math.ceil(ability)
end
function XEntityHelper.GetCharBigRoundnessNotItemHeadIcon(entityId)
local characterId = XEntityHelper.GetCharacterIdByEntityId(entityId)
return XDataCenter.CharacterManager.GetCharBigRoundnessNotItemHeadIcon(characterId)
end
-- 根据奖励Id获取第一个奖励的图标
function XEntityHelper.GetRewardIcon(rewardId)
local rewardList = XRewardManager.GetRewardList(rewardId)
return XEntityHelper.GetItemIcon(rewardList[1].TemplateId)
end
function XEntityHelper.GetRewardItemId(rewardId, index)
if index == nil then index = 1 end
local rewardList = XRewardManager.GetRewardList(rewardId)
return rewardList[index]
end
function XEntityHelper.GetItemIcon(itemId)
local result = XGoodsCommonManager.GetGoodsIcon(itemId)
if result then return result end
local config = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(itemId)
return config.Icon
end
function XEntityHelper.GetItemName(itemId)
return XGoodsCommonManager.GetGoodsShowParamsByTemplateId(itemId).Name
end
function XEntityHelper.GetItemQuality(itemId)
local result = XGoodsCommonManager.GetGoodsDefaultQuality(itemId)
if result then return result end
local config = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(itemId)
return config.Quality or -1
end
function XEntityHelper.GetCharacterHalfBodyImage(entityId)
local characterId = XEntityHelper.GetCharacterIdByEntityId(entityId)
return XDataCenter.CharacterManager.GetCharHalfBodyImage(characterId)
end
-- 检查物品数量是否满足指定数量
function XEntityHelper.CheckItemCountIsEnough(itemId, count, showTip)
if showTip == nil then showTip = true end
if XDataCenter.ItemManager.GetCount(itemId) < count then
if showTip then
XUiManager.TipError(XUiHelper.GetText("AssetsBuyConsumeNotEnough", XDataCenter.ItemManager.GetItemName(itemId)))
end
return false
end
return true
end
-- 排序物品
--[[
itemData : {
TemplateId,
Count,
}
]]
function XEntityHelper.SortItemDatas(itemDatas)
table.sort(itemDatas, function(itemDataA, itemDataB)
local itemIdA = itemDataA.TemplateId
local itemIdB = itemDataB.TemplateId
local itemCountA = itemDataA.Count or 0
local itemCountB = itemDataB.Count or 0
local qualityA = XEntityHelper.GetItemQuality(itemIdA)
local qualityB = XEntityHelper.GetItemQuality(itemIdB)
-- 品质
if qualityA ~= qualityB then
return qualityA > qualityB
end
-- id
if itemIdA ~= itemIdB then
return itemIdA > itemIdB
end
-- 数量
return itemCountA > itemCountB
end)
end
function XEntityHelper.CheckIsNeedRoleLimit(stageId, viewModels)
local limitType = XFubenConfigs.GetStageCharacterLimitType(stageId)
if limitType == XFubenConfigs.CharacterLimitType.All then
return false
end
if #viewModels <= 0 then
return true
end
local characterType = XDataCenter.FubenManager.GetDefaultCharacterTypeByCharacterLimitType(limitType)
for _, viewModel in ipairs(viewModels) do
if viewModel:GetCharacterType() ~= characterType then
return true
end
end
return false
end
function XEntityHelper.CheckIsNeedCareerLimit(stageId, viewModels)
local careerLimitTypes = XFubenConfigs.GetStageCareerSuggestTypes(stageId)
if #careerLimitTypes <= 0 then
return false
end
local isContain, containIndex
local result = {}
for _, viewModel in pairs(viewModels) do
isContain, containIndex = table.contains(careerLimitTypes, viewModel:GetCareer())
if isContain then
result[containIndex] = true
end
end
if table.nums(result) == #careerLimitTypes then -- 都满足
return false
end
return true, careerLimitTypes, result
end
-- ids : 可包含机器人或角色Id返回对应的机器人或角色实体
function XEntityHelper.GetEntityByIds(ids)
local result = {}
for _, id in ipairs(ids) do
if XEntityHelper.GetIsRobot(id) then
table.insert(result, XRobotManager.GetRobotById(id))
else
table.insert(result, XDataCenter.CharacterManager.GetCharacter(id))
end
end
return result
end
function XEntityHelper.ClearErrorTeamEntityId(team, checkHasFunc)
for pos, entityId in pairs(team:GetEntityIds()) do
if entityId > 0 and not checkHasFunc(entityId) then
team:UpdateEntityTeamPos(entityId, pos, false)
end
end
end

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,28 @@
XFightNetwork = XFightNetwork or {}
function XFightNetwork.Send(handler, request)
local requestContent, error = XMessagePack.Encode(request)
if requestContent == nil then
XLog.Error("Lua.XFightNetwork.Send 函数错误, 客户端发送给服务端的数据编码处理失败, 失败原因:" .. error)
return
end
CS.XFightNetwork.Send(handler, requestContent);
end
function XFightNetwork.Call(handler, request, reply)
local requestContent, error = XMessagePack.Encode(request)
if requestContent == nil then
XLog.Error("Lua.XFightNetwork.Call 函数错误, 客户端发送给服务端的数据编码处理失败, 失败原因: " .. error)
return
end
CS.XFightNetwork.Call(handler, requestContent, function(responseContent)
local response, err = XMessagePack.Decode(responseContent)
if response == nil then
XLog.Error("Lua.XFightNetwork.Call 函数错误, 服务端返回的数据解码失败, 失败原因: " .. err)
return
end
reply(response)
end)
end

View file

@ -0,0 +1,187 @@
local coroutineRunning = coroutine.running
local coroutineResume = coroutine.resume
local coroutineYield = coroutine.yield
local coroutineWrap = coroutine.wrap
local tablePack = table.pack
local tableUnpack = table.unpack
local select = select
function Handler(target, func)
return function(...)
return func(target, ...)
end
end
handler = Handler
function LuaGC()
collectgarbage("collect")
end
--回调转异步任务需和RunAsyn配合使用
---@param func: 带回调的function类型, 示例:local testFunc = function(..., callback) end
---@param callbackPos: 回调在参数列表中的位置, 传nil默认为最后一位, 示例:local testFunc = function(p1, p2, callback) end-->callbackPos = 3
---@return asynTask不处理原函数返回值异步需求默认void原函数中的callback回调将不再可用必须传nil
---@Examplemple
--[[
local testFunc = function(str, cb)
XScheduleManager.ScheduleOnce(function()
XLog.Debug(str)
if cb then cb() end
end, XScheduleManager.SECOND)
end
--callback hell
XLog.Debug("test callback begin")
testFunc("test callback CallBack 1"
, function()
testFunc("test callback CallBack 2"
, function()
testFunc("test callback CallBack 3")
end)
end)
XLog.Debug("test callback end")
--asyn task
XLog.Debug("test asyn task begin")
local asynTest = asynTask(testFunc)
RunAsyn(function()
asynTest("test asyn CallBack 1")
XLog.Debug("test asyn after 1")
asynTest("test asyn CallBack 2")
asynTest("test asyn CallBack 3")
end)
XLog.Debug("test asyn task end")
]]
function asynTask(func, caller, callbackPos)
return function(...)
local results = {}
local isSync --同步方法,回调直接执行
local args = { ... }
local running = coroutineRunning()
callbackPos = callbackPos or select("#", ...) + 1
args[callbackPos] = function()
isSync = true
coroutineResume(running, tableUnpack(results))
end
results = caller and tablePack(func(caller, tableUnpack(args))) or tablePack(func(tableUnpack(args)))
return not isSync and coroutineYield() or nil
end
end
--异步等待second秒需和RunAsyn配合使用
function asynWaitSecond(second)
asynTask(
function(cb)
XScheduleManager.ScheduleOnce(cb, second * XScheduleManager.SECOND)
end
)()
end
--异步执行
function RunAsyn(func)
return coroutineWrap(func)()
end
function appendArray(dst, src)
if src == nil then return dst end
for i, v in ipairs(src) do
table.insert(dst, v)
end
return dst
end
-- 保留digit位小数
function getRoundingValue(value, digit)
return math.floor(value * math.pow(10, digit)) / math.pow(10, digit)
end
function math.pow(a, b)
return a ^ b
end
function math.round(value)
return math.floor(value + 0.5)
end
function table.indexof(array, value, begin)
for i = begin or 1, #array do
if array[i] == value then
return i
end
end
return false
end
function table.contains(tbl, ele)
for i, v in pairs(tbl) do
if v == ele then
return true, i
end
end
return false
end
function table.dicToArray(dic, keyName, valueName)
keyName = keyName or "key"
valueName = valueName or "value"
local array = {}
for k, v in pairs(dic) do
array[#array + 1] = {
[keyName] = k,
[valueName] = v
}
end
return array
end
function table.arrayToDic(array)
local dic = {}
for i, v in ipairs(array) do
dic[v] = i
end
return dic
end
function table.range(t, start, count)
local ret = {}
for i = start, start + count - 1 do
ret[#ret + 1] = t[i]
end
return ret
end
function table.nums(t)
return XTool.GetTableCount(t)
end
--[[
@desc:
--@t:需要去重的列表
--@bArray: true 更新列表的所有为新索引
false
@return:
]]
function table.unique(t, bArray)
local check = {}
local n = {}
local idx = 1
for k, v in ipairs(t) do
if not check[v] then
if bArray then
n[idx] = v
idx = idx + 1
else
n[k] = v
end
check[v] = true
end
end
return n
end
--程序暂停
function ApplicationPause(pause)
if XEventManager then
XEventManager.DispatchEvent(XEventId.EVENT_APPLICATION_PAUSE, pause)
end
end

View file

@ -0,0 +1,43 @@
local IncId = 0
XGlobalVar = {
ScrollViewScrollDir = {
ScrollDown = "ScrollDown", --从上往下滚
ScrollRight = "ScrollRight" --从左往右滚
},
UiDesignSize = { --ui设计尺寸
Width = 1920,
Height = 1080,
},
GetIncId = function()
IncId = IncId + 1
return IncId
end,
BtnBuriedSpotTypeLevelOne = {
BtnUiMainBtnRoleInfo = 1,
BtnUiMainBtnNotice = 2,
BtnUiMainPanelAd = 3,
BtnUiMainBtnChat = 4,
BtnUiMainBtnRole = 5,
BtnUiMainBtnSecond = 6,
BtnUiMainBtnActivityEntry1 = 7,
BtnUiMainBtnActivityEntry2 = 8,
BtnUiMainBtnActivityEntry3 = 9,
BtnUiMainBtnStore = 10,
BtnUiMainBtnRecharge = 11,
},
BtnBuriedSpotTypeLevelTwo = {
BtnUiPurchaseBtnTabSkip1 = 1,
BtnUiPurchaseBtnTabSkip2 = 2,
BtnUiPurchaseBtnTabSkip3 = 3,
BtnUiPurchaseBtnTabSkip4 = 4,
BtnUiPurchaseGroupTabSkip1 = 5,
BtnUiPurchaseGroupTabSkip2 = 6,
BtnUiPurchaseGroupTabSkip3 = 7,
BtnUiPurchaseGroupTabSkip4 = 8,
}
}

View file

@ -0,0 +1,188 @@
XLog = XLog or {}
local MAX_DEPTH = 15
local Type = type
local Tostring = tostring
local TableRemove = table.remove
local TableInsert = table.insert
local TableConcat = table.concat
local StringGub = string.gsub
local DebugTraceback = debug.traceback
local XLogDebug = CS.XLog.Debug
local XLogWarning = CS.XLog.Warning
local XLogError = CS.XLog.Error
local Pairs = function(arr)
local meta_t = getmetatable(arr)
if meta_t and meta_t.__pairs then
return meta_t.__pairs(arr)
end
return pairs(arr)
end
local indentCache = { "" }
local function GetIndent(depth)
if not indentCache[depth] then
indentCache[depth] = GetIndent(depth - 1) .. " "
end
return indentCache[depth]
end
local function Dump(target)
local content = {}
local stack = {
{
obj = target,
name = nil,
depth = 1,
symbol = nil,
}
}
while #stack > 0 do
local top = TableRemove(stack)
local obj = top.obj
local name = top.name
local depth = top.depth
local symbol = top.symbol
if Type(obj) == "table" then
if depth > MAX_DEPTH then
TableInsert(stack, {
obj = "too depth ...",
name = name,
depth = depth,
symbol = symbol,
})
else
TableInsert(stack, {
obj = "}",
name = nil,
depth = depth,
symbol = symbol,
})
local temp = {}
for k, v in Pairs(obj) do
TableInsert(temp, {
obj = v,
name = k,
depth = depth + 1,
symbol = ",",
})
end
local count = #temp
for i = 1, count do
TableInsert(stack, temp[count - i + 1])
end
TableInsert(stack, {
obj = "{",
name = name,
depth = depth,
symbol = nil,
})
end
else
TableInsert(content, GetIndent(depth))
if name then
if Type(name) == "string" then
TableInsert(content, "[\"")
TableInsert(content, name)
TableInsert(content, "\"]")
else
TableInsert(content, "[")
TableInsert(content, Tostring(name))
TableInsert(content, "]")
end
TableInsert(content, " = ")
end
if obj and Type(obj) == "string" then
if obj ~= "{" and obj ~= "}" then
TableInsert(content, "\"")
TableInsert(content, obj)
TableInsert(content, "\"")
else
TableInsert(content, obj)
end
else
TableInsert(content, Tostring(obj))
end
if symbol then
TableInsert(content, symbol)
end
TableInsert(content, "\n")
end
end
return TableConcat(content)
end
local Print = function(...)
local args = { ... }
local count = #args
if count <= 0 then
return
end
local content = {}
for i = 1, count do
if Type(args[i]) == "table" then
TableInsert(content, Dump(args[i]))
else
TableInsert(content, Tostring(args[i]))
TableInsert(content, "\n")
end
end
return TableConcat(content)
-- return StringGub(StringGub(TableConcat(content), "{", "/{"), "}", "/}")
end
XLog.Debug = function(...)
local content = Print(...)
if content then
XLogDebug(content .. "\n" .. DebugTraceback())
else
XLogDebug("nil\n" .. DebugTraceback())
end
end
XLog.Warning = function(...)
local content = Print(...)
if content then
XLogWarning(content .. "\n" .. DebugTraceback())
else
XLogWarning("nil\n" .. DebugTraceback())
end
end
XLog.Error = function(...)
local content = Print(...)
if content then
XLogError(content .. "\n" .. DebugTraceback())
else
XLogError("nil\n" .. DebugTraceback())
end
end
-- 表格找不到数据错误统一输出接口
XLog.ErrorTableDataNotFound = function(functionName, dataName, tablePath, paramName, paramValue)
XLog.Error(string.format("%s出错:找不到%s数据。搜索路径: %s 索引%s = %s", functionName, dataName, tablePath, paramName, paramValue))
end
XLog.Dump = function(value)
if type(value) ~= "table" then
return tostring(value)
end
return Dump(value)
end

View file

@ -0,0 +1,34 @@
XLuaBehaviour = XClass(nil, "XLuaBehaviour")
function XLuaBehaviour:Ctor(rootUi, ui)
self.Transform = ui.transform
self.GameObject = ui.gameObject
local behaviour = self.GameObject:GetComponent(typeof(CS.XLuaBehaviour))
if not behaviour then
behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour))
end
if self.Start then
behaviour.LuaStart = function() self:Start() end
end
if self.Update then
behaviour.LuaUpdate = function() self:Update() end
end
if self.LateUpdate then
behaviour.LuaLateUpdate = function() self:LateUpdate() end
end
if self.OnDestroy then
behaviour.LuaOnDestroy = function() self:OnDestroy() end
end
end
function XLuaBehaviour:Dispose()
local xLuaBehaviour = self.Transform:GetComponent(typeof(CS.XLuaBehaviour))
if (xLuaBehaviour) then
CS.UnityEngine.GameObject.Destroy(xLuaBehaviour)
end
end

View file

@ -0,0 +1,59 @@
local math = math
local mathFloor = math.floor
local mathRandom = math.random
XMath = XMath or {}
function XMath.RandByWeights(weights)
local weightSum = 0
for i = 1, #weights do
weightSum = weightSum + weights[i]
end
local rand = mathRandom(weightSum)
local curWeight = 0
for i = 1, #weights do
local weight = weights[i]
curWeight = curWeight + weight
if rand < curWeight then
return i
end
end
return #weights
end
function XMath.Clamp(value, min, max)
if value < min then
return min
end
if value > max then
return max
end
return value
end
--==============================--
--desc: 转换成整数,浮点数四舍五入
--==============================--
XMath.ToInt = function(val)
if not val then return end
return mathFloor(val + 0.5)
end
--==============================--
--desc: 转换成整数,浮点数向下取整数
--==============================--
XMath.ToMinInt = function(val)
if not val then return end
return mathFloor(val)
end
--==============================--
--desc: 最大整数与C#一致
--==============================--
XMath.IntMax = function()
return 2147483647
end

View file

@ -0,0 +1,280 @@
XNetwork = XNetwork or {}
local Ip
local Port
local LastIp
local LastPort
local XRpc = XRpc
local IsDebug = XMain.IsEditorDebug
local ShieldedProtocol = {}
local NeedShieldProtocol = false
XNetwork.NetworkMode = {
Auto = 1,
Ipv4 = 2,
Ipv6 = 3,
}
XNetwork.NetworkModeKey = "NETWORK_MODE_KEY"
local function GetIpAndPort()
return Ip, Port
end
function XNetwork.SetGateAddress(ip, port)
Ip = ip
Port = port
end
function XNetwork.CheckIsChangedGate()
return LastIp ~= Ip or LastPort ~= Port
end
local LogTableFunc = IsDebug and XLog.Debug or XLog.Error
local function TipTableDiff(sha1Table)
if not CS.XTableManager.NeedSha1 then -- 开发环境下不解析Sha1
return
end
XTool.LoopMap(CS.XTableManager.Sha1Table, function(k, v)
local sha1 = sha1Table[k]
if not sha1 then
LogTableFunc("多余表格: " .. k)
return
end
if v ~= sha1 then
LogTableFunc("差异表格: " .. k .. ", 客户端sha1: " .. v .. " , 服务端sha1: " .. sha1)
end
sha1Table[k] = nil
end)
for k, _ in pairs(sha1Table) do
LogTableFunc("缺少表格: " .. k)
end
end
XRpc.NotifyCheckTableSha1 = function(data)
TipTableDiff(data.Sha1Table)
end
function XNetwork.ConnectGateServer(args)
if not args then
return
end
if IsDebug then
XRpc.CheckLuaNetLogEnable()
end
CS.XNetwork.OnConnect = function()
if args.IsReconnect then
local request = { PlayerId = XPlayer.Id, Token = XUserManager.ReconnectedToken, LastMsgSeqNo = CS.XNetwork.ServerMsgSeqNo }
if CS.XNetwork.IsShowNetLog then
XLog.Debug("PlayerId=" .. request.PlayerId .. ", Token=" .. request.Token .. ", LastMsgSeqNo=" .. request.LastMsgSeqNo)
end
local request_func
request_func = function()
XNetwork.Call("ReconnectRequest", request, function(res)
if res.Code ~= XCode.Success then
if CS.XNetwork.IsShowNetLog then
XLog.Debug("服务器返回断线重连失败。" .. tostring(res.Code))
end
XLoginManager.DoDisconnect()
else
XNetwork.Send("ReconnectAck")
if CS.XNetwork.IsShowNetLog then
XLog.Debug("服务器返回断线重连成功。")
end
XUserManager.ReconnectedToken = res.ReconnectToken
if args.ConnectCb then
args.ConnectCb()
end
if res.OfflineMessages then
CS.XNetwork.ProcessReconnectMessageList(res.OfflineMessages)
end
CS.XNetwork.ReCall(res.RequestNo)
end
end)
end
request_func()
else
XNetwork.Call("HandshakeRequest", {
ApplicationVersion = CS.XRemoteConfig.ApplicationVersion,
DocumentVersion = CS.XRemoteConfig.DocumentVersion,
Sha1 = CS.XTableManager.Sha1
}, function(response)
if args.RemoveHandshakeTimerCb then
args.RemoveHandshakeTimerCb()
end
if response.Code ~= XCode.Success then
local msgTab = {}
msgTab.error_code = response.Code
CS.XRecord.Record(msgTab, "24019", "HandshakeRequest")
if response.Code == XCode.GateServerNotOpen then
local localTimeStr = XTime.TimestampToLocalDateTimeString(response.UtcOpenTime, "yyyy-MM-dd HH:mm(G'M'T z)")
local context = CS.XTextManager.GetCodeText(response.Code) .. localTimeStr
XUiManager.SystemDialogTip("", context, XUiManager.DialogType.OnlySure)
elseif response.Code == XCode.LoginApplicationVersionError then
-- 处于调试模式时进错服显示取消按钮,否则不显示
local cancelCb = XMain.IsDebug and function() end or nil
CS.XTool.WaitCoroutine(CS.XApplication.CoDialog(CS.XApplication.GetText("Tip"),
CS.XStringEx.Format(CS.XApplication.GetText("UpdateApplication"),
CS.XInfo.Version), cancelCb, function() CS.XTool.WaitCoroutine(CS.XApplication.GoToUpdateURL(GetAppUpgradeUrl()), nil) end))
else
XUiManager.DialogTip("", CS.XTextManager.GetCodeText(response.Code), XUiManager.DialogType.OnlySure)
end
if response.Code == XCode.LoginTableError then
XLog.Error("配置表客户端和服务端不一致")
TipTableDiff(response.Sha1Table)
end
CS.XNetwork.Disconnect()
return
end
CS.XRecord.Record("24020", "HandshakeRequestSuccess")
if args.ConnectCb then
args.ConnectCb()
end
end)
end
end
CS.XNetwork.OnDisconnect = function()
if args.DisconnectCb then
args.DisconnectCb()
end
end
CS.XNetwork.OnRemoteDisconnect = function()
if args.RemoteDisconnectCb then
args.RemoteDisconnectCb()
end
end
CS.XNetwork.OnError = function(error)
if args.ErrorCb then
args.ErrorCb(error)
end
end
CS.XNetwork.OnMessageError = function()
if args.MsgErrorCb then
args.MsgErrorCb()
end
end
CS.XNetwork.OnReconnectRequestFrequently = function()
if args.ReconnectRequestFrequentlyCb then
args.ReconnectRequestFrequentlyCb()
end
end
local ip, port
if args.IsReconnect then
ip, port = LastIp, LastPort
else
ip, port = GetIpAndPort()
end
XNetwork.ConnectServer(ip, port, args.IsReconnect)
end
function XNetwork.ConnectServer(ip, port, bReconnect)
if not ip or not port then
return
end
LastIp, LastPort = ip, port
local networkMode = XSaveTool.GetData(XNetwork.NetworkModeKey) or XNetwork.NetworkMode.Auto
if networkMode == XNetwork.NetworkMode.Auto then
CS.XNetwork.Connect(ip, tonumber(port), bReconnect, CS.XNetwork.NetworkMode.Auto)
elseif networkMode == XNetwork.NetworkMode.Ipv4 then
CS.XNetwork.Connect(ip, tonumber(port), bReconnect, CS.XNetwork.NetworkMode.Ipv4)
elseif networkMode == XNetwork.NetworkMode.Ipv6 then
CS.XNetwork.Connect(ip, tonumber(port), bReconnect, CS.XNetwork.NetworkMode.Ipv6)
else -- Auto保底
CS.XNetwork.Connect(ip, tonumber(port), bReconnect, CS.XNetwork.NetworkMode.Auto)
end
end
function XNetwork.Send(handler, request)
-- 检查是否是屏蔽协议
if NeedShieldProtocol and ShieldedProtocol[handler] then
XUiManager.TipMsg(CS.XGame.ClientConfig:GetString("ShieldedProtocol"))
return
end
local requestContent, error = XMessagePack.Encode(request)
if IsDebug then
XRpc.DebugPrint(XRpc.DEBUG_TYPE.Send, handler, requestContent)
end
if requestContent == nil then
XLog.Error("XNetwork.Send 函数错误, 客户端发送给服务端的数据编码处理失败, 失败原因:" .. error)
return
end
CS.XNetwork.Send(handler, requestContent);
end
function XNetwork.Call(handler, request, reply, isEncoded)
-- 检查是否是屏蔽协议
if NeedShieldProtocol and ShieldedProtocol[handler] then
XUiManager.TipMsg(CS.XGame.ClientConfig:GetString("ShieldedProtocol"))
return
end
if IsDebug then
XRpc.DebugPrint(XRpc.DEBUG_TYPE.Send_Call, handler, isEncoded and XMessagePack.Decode(request) or request)
end
local requestContent, error
if isEncoded == true then
requestContent = request
else
requestContent, error = XMessagePack.Encode(request)
if requestContent == nil then
XLog.Error("XNetwork.Call 函数错误, 客户端发送给服务端的数据编码处理失败, 失败原因: " .. error)
return
end
end
CS.XNetwork.Call(handler, requestContent, function(responseContent)
local response, err = XMessagePack.Decode(responseContent)
if response == nil then
XLog.Error("XNetwork.Call 函数错误, 服务端返回的数据解码失败, 失败原因: " .. err)
return
end
if IsDebug then
XRpc.DebugPrint(XRpc.DEBUG_TYPE.Recv_Call, handler, response)
end
reply(response)
end)
end
function XNetwork.CallWithAutoHandleErrorCode(handler, request, reply, isEncoded)
XNetwork.Call(handler, request, function(res)
if res.Code ~= XCode.Success then
XUiManager.TipCode(res.Code)
return
end
if reply then reply(res) end
end, isEncoded)
end
--================
--设置协议屏蔽列表
--@param protocolList:屏蔽协议名列表
--================
function XNetwork.SetShieldedProtocolList(protocolList)
if not protocolList then return end
ShieldedProtocol = {}
NeedShieldProtocol = false
for _, protocolName in pairs(protocolList) do
NeedShieldProtocol = true
ShieldedProtocol[protocolName] = true
end
end

View file

@ -0,0 +1,101 @@
-- auto export form enum
-- Automatic generation of code, forbid to edit or delete
XNpcAttribType = {
Life = 1, -- 生命
Energy = 2, -- 能量
RunSpeed = 3, -- 跑速度(逻辑单位/帧)
WalkSpeed = 4, -- 走速度(逻辑单位/帧)
TurnRoundSpeed = 5, -- 转身角速度(度/千帧)
BallInterval = 6, -- 出球间隔帧
DamageNormalImmunity = 7, -- 普通伤害免疫
DamageMagicImmunity = 8, -- 元素伤害免疫
AntiDamageNormalImmunity = 9, -- 反普通伤害免疫
AntiDamageMagicImmunity = 10, -- 反元素伤害免疫
AttackNormal = 11, -- 普通攻击
AttackMagicBegin = 11, -- 元素攻击起始
AttackMagic1 = 12, -- 元素1攻击
AttackMagic2 = 13, -- 元素2攻击
AttackMagic3 = 14, -- 元素3攻击
AttackMagic4 = 15, -- 元素4攻击
AttackMagicEnd = 16, -- 元素攻击结束
AntiAttackNormal = 17, -- 反普通攻击
AntiAttackMagicBegin = 17, -- 反元素攻击起始
AntiAttackMagic1 = 18, -- 反元素1攻击
AntiAttackMagic2 = 19, -- 反元素2攻击
AntiAttackMagic3 = 20, -- 反元素3攻击
AntiAttackMagic4 = 21, -- 反元素4攻击
AntiAttackMagicEnd = 22, -- 反元素攻击结束
DefenseNormal = 23, -- 普通防御
AntiDefenseNormal = 24, -- 反普通防御
DamageChangeP = 25, -- 总伤害加深率
DamageNormalChangeP = 26, -- 普通伤害加深率
DamageMagicChangePBegin = 26, -- 元素伤害加深率起始
DamageMagic1ChangeP = 27, -- 元素1伤害加深率
DamageMagic2ChangeP = 28, -- 元素2伤害加深率
DamageMagic3ChangeP = 29, -- 元素3伤害加深率
DamageMagic4ChangeP = 30, -- 元素4伤害加深率
DamageMagicChangePEnd = 31, -- 元素伤害加深率结束
AntiDamageChangeP = 32, -- 反总伤害加深率
AntiDamageNormalChangeP = 33, -- 反普通伤害加深率
AntiDamageMagicChangePBegin = 33, -- 反元素伤害加深率起始
AntiDamageMagic1ChangeP = 34, -- 反元素1伤害加深率
AntiDamageMagic2ChangeP = 35, -- 反元素2伤害加深率
AntiDamageMagic3ChangeP = 36, -- 反元素3伤害加深率
AntiDamageMagic4ChangeP = 37, -- 反元素4伤害加深率
AntiDamageMagicChangePEnd = 38, -- 反元素伤害加深率结束
DamagePBegin = 39, -- 类型伤害率起始
Damage1P = 40, -- 类型1伤害率
Damage2P = 41, -- 类型2伤害率
Damage3P = 42, -- 类型3伤害率
DamagePEnd = 43, -- 类型伤害率结束
Crit = 44, -- 暴击
CritP = 45, -- 暴击率
CritDamageP = 46, -- 暴击伤害率
AntiCritP = 47, -- 反暴击率
AntiCritDamageP = 48, -- 反暴击伤害率
Lifesteal = 49, -- 吸血
LifestealP = 50, -- 吸血率
CureChangeP = 51, -- 治疗加深率
AntiCureChangeP = 52, -- 反治疗加深率
Endure = 53, -- 霸体值
ThreatRateP = 54, -- 仇恨生成速率
DodgeEnergy = 55, -- 闪避能量值
DodgeEnergyAutoRecovery = 56, -- 闪避能量自动回复
CustomEnergy = 57, -- 自定义能量值
AccuResistance1 = 58, -- 积蓄抗性1
AccuResistance2 = 59, -- 积蓄抗性2
AccuResistance3 = 60, -- 积蓄抗性3
AccuResistance4 = 61, -- 积蓄抗性4
AccuResistance5 = 62, -- 积蓄抗性5
AccuResistance6 = 63, -- 积蓄抗性6
AccuResistance7 = 64, -- 积蓄抗性7
AccuResistance8 = 65, -- 积蓄抗性8
AccuResistance9 = 66, -- 积蓄抗性9
AccuResistance10 = 67, -- 积蓄抗性10
SquatSpeed = 68, -- 蹲走速度
NormalWeaknessP = 69, -- 物理弱点
MagicWeaknessPBegin = 69, -- 元素弱点起始
Magic1WeaknessP = 70, -- 元素弱点1
Magic2WeaknessP = 71, -- 元素弱点2
Magic3WeaknessP = 72, -- 元素弱点3
Magic4WeaknessP = 73, -- 元素弱点4
SprintSpeed = 74, -- 疾跑速度(逻辑单位/帧)
CustomEnergyGroup1 = 75, -- 自定义能量组1
CustomEnergyGroup2 = 76, -- 自定义能量组2
CustomEnergyGroup3 = 77, -- 自定义能量组3
CustomEnergyGroup4 = 78, -- 自定义能量组4
Hack = 79, -- 处决值
HackChangeP = 80, -- 处决加深率
AntiHackChangeP = 81, -- 处决抵抗率
HackAutoRecovery = 82, -- 处决值自动回复
SkillDamageChangeP = 83, -- 技能倍率加深率
ReduceHackDynamicScoringCoe = 84, -- 怪物处决值减少时的动态评分系数
BeExecutedDynamicScoringCoe = 85, -- 怪物受到处决的动态评分系数
DynamicScoringScoreChangeP = 86, -- 动态评分点数获取提升率
DynamicScoringScoreChangeV = 87, -- 动态评分点数获取提升值
ReduceDynamicScoringScorePerSecondChangeP = 88, -- 动态评分每秒固定点数下降提升率
ReduceDynamicScoringScorePerSecondChangeV = 89, -- 动态评分每秒固定点数下降提升值
ReduceDynamicScoringScoreWhenBeDamagedChangeP = 90, -- 受伤时动态评分点数下降提升率
ReduceDynamicScoringScoreWhenBeDamagedChangeV = 91, -- 受伤时动态评分点数下降提升值
End = 92, --
}

View file

@ -0,0 +1,82 @@
XPerformance = XPerformance or {}
local CsTime = CS.UnityEngine.Time
local IO = CS.System.IO
local collectgarbage = collectgarbage
local AutoSaveTime = 10
local LastSaveTime = 0
local TraceLevel = 5
XPerformance.SaveDataPath = XPerformance.SaveDataPath or string.format("Log/MemData_%s.tab", CS.System.DateTime.Now:ToString("MMddhhmm"))
XPerformance.SaveTimerId = XPerformance.SaveTimerId or 0
XPerformance.LuaMemData = XPerformance.LuaMemData or {}
-- 定期保存数据
function XPerformance.StartLuaMenCollect()
if CS.UnityEngine.Application.platform ~= CS.UnityEngine.RuntimePlatform.WindowsEditor then
return
end
if XPerformance.SaveTimerId then
XScheduleManager.UnSchedule(XPerformance.SaveTimerId)
XPerformance.SaveTimerId = 0
end
XPerformance.SaveTimerId = XScheduleManager.ScheduleForever(function()
if not next(XPerformance.LuaMemData) then
return
end
local nowTime = CsTime.realtimeSinceStartup
if nowTime - LastSaveTime > AutoSaveTime then
LastSaveTime = nowTime
XPerformance.SaveMemData()
end
end, AutoSaveTime * 1000)
end
-- 保存数据
function XPerformance.SaveMemData()
local sw
if not IO.File.Exists(XPerformance.SaveDataPath) then
sw = IO.File.CreateText(XPerformance.SaveDataPath)
sw:Write("traceName\tkey\tcostMem\tcurrentMem\n")
else
sw = IO.File.AppendText(XPerformance.SaveDataPath)
sw:Write("\n")
end
local tab = {}
for key, str in pairs(XPerformance.LuaMemData) do
table.insert(tab, str)
end
XPerformance.LuaMemData = {}
local content = table.concat(tab, '\n')
sw:Write(content)
sw:Flush()
sw:Close()
XLog.Debug("... save data:" .. content)
end
-- 记录一段代码消耗的lua内存
function XPerformance.RecordLuaMemData(name, func, isCollect)
if isCollect == nil then
isCollect = true
end
if isCollect then
collectgarbage("collect")
end
local beforeMem = collectgarbage("count")
func()
if isCollect then
collectgarbage("collect")
end
local currentMem = collectgarbage("count")
local costMem = currentMem - beforeMem
costMem = math.floor(costMem / 1024 * 10000) / 10000
currentMem = math.floor(beforeMem / 1024 * 10000) / 10000
-- 记录消耗
local traceName = XTool.GetStackTraceName(TraceLevel)
local str = string.format("%s\t%s\t%s\t%s", traceName, name, costMem, currentMem)
table.insert(XPerformance.LuaMemData, str)
end

View file

@ -0,0 +1,60 @@
XPool = XClass(nil, "XPool")
function XPool:Ctor(createFunc, onRelease)
if not createFunc then
XLog.Error("XPool:Ctor Error:createFunc is Empty.")
return
end
self.__Container = XStack.New()
self.__CreateFunc = createFunc
self.__OnRelease = onRelease
self.__TotalCount = 0
end
function XPool:Clear()
self.__TotalCount = 0
self.__Container:Clear()
end
function XPool:GetItemFromPool()
local item = self.__Container:Pop()
if not item then
item = self.__CreateFunc()
if not item then
XLog.Error("XPool:GetItemFromPool Error:createFunc return nil.")
return
end
self.__TotalCount = self.__TotalCount + 1
end
return item
end
function XPool:ReturnItemToPool(item)
if not item then return end
if self:UsingCount() < 1 then
return
end
if self.__OnRelease then
self.__OnRelease(item)
end
self.__Container:Push(item)
end
--池中剩余对象数量
function XPool:LeftCount()
return self.__Container:Count()
end
--使用中对象数量
function XPool:UsingCount()
return self.__TotalCount - self:LeftCount()
end
--已创建对象数量
function XPool:TotalCount()
return self.__TotalCount
end

View file

@ -0,0 +1,54 @@
XPrefs = XPrefs or {}
-- 登陆模块
XPrefs.UserId = "USER_ID"
XPrefs.UserName = "USER_NAME"
XPrefs.Channel = "CHANNEL"
XPrefs.Token = "TOKEN"
XPrefs.PasswordStatus = "PASSWORD_STATUS"
XPrefs.ServerId = "SERVER_ID"
XPrefs.User_ServerId = "USER_SERVER_ID"
XPrefs.CharacterStoryRecord = "CHARACTER_STORY_RECORD"
XPrefs.AssistSwitch = "ASSIST_SWITCH"
XPrefs.GuideTrigger = "GUIDE_DISABLE"
XPrefs.CommunicationTrigger = "COMMUNICATION_DISABLE"
XPrefs.FunctionEventTrigger = "FUNCTION_EVENT_DISABLE"
XPrefs.StoryTrigger = "STORY_DISABLE"
XPrefs.AccountHistory = "ACCOUNT_HISTORY"
XPrefs.LuaNetLog = "LUA_NET_LOG"
XPrefs.NoticeTrigger = "NOTICE_DISABLE"
XPrefs.TowerTip = "TOWER_TIP"
XPrefs.DormNewHint = "DORM_NEW_HINT_"
XPrefs.PayOrder = "PAY_ORDER_"
XPrefs.BaseEquip = "BASE_EQUIP"
XPrefs.AutoWindowEach = "AUTO_WINDOW_EACH"
XPrefs.AutoWindowPeriod = "AUTO_WINDOW_PERIOD"
XPrefs.YKLocalCache = "YK_LOCAL_CACHAE"
XPrefs.YKContinueBuy = "YK_CONTINUE_BUY"
XPrefs.ArenaTeamResult = "Arena_Team_Result"
XPrefs.ArenaOnlineInvit = "AreanOnline_Invit"
XPrefs.ArenaOnlineFirstOpen = "AreanOnline_First_Open"
-- 战斗设置
XPrefs.DynamicJoystick = "DYNAMIC_JOYSTICK"
XPrefs.FocusType = "FOCUS_TYPE"
XPrefs.FocusButton = "FOCUS_BUTTON"
XPrefs.InviteButton = "INVITE_BUTTON"
-- 武器显示设置
XPrefs.WeaponTransType = "WEAPON_TRANS_TYPE"
-- 累积充值显示设置
XPrefs.RechargeType = "RECHARGE_TYPE"

View file

@ -0,0 +1,51 @@
XQueue = XClass(nil, "XQueue")
function XQueue:Ctor()
self:Clear()
end
function XQueue:Clear()
self.__Container = {}
self.__StartIndex = 1
self.__EndIndex = 0
end
function XQueue:IsEmpty()
return self.__StartIndex > self.__EndIndex
end
function XQueue:Count()
return self.__EndIndex - self.__StartIndex + 1
end
function XQueue:Enqueue(element)
if not element then return end
local endIndex = self.__EndIndex + 1
self.__EndIndex = endIndex
self.__Container[endIndex] = element
end
function XQueue:EnqueueFront(element)
self.__Container[self.__StartIndex - 1] = element
self.__StartIndex = self.__StartIndex - 1
end
function XQueue:Dequeue()
if self:IsEmpty() then
self:Clear()
return
end
local startIndex = self.__StartIndex
local element = self.__Container[startIndex]
self.__StartIndex = startIndex + 1
self.__Container[startIndex] = nil
return element
end
function XQueue:Peek()
return self.__Container[self.__StartIndex]
end

View file

@ -0,0 +1,100 @@
XRpc = XRpc or {}
------- 方便调试协议的打印 ------
local IsPrintLuaRpc = false
if XMain.IsEditorDebug then
CS.XNetwork.IsShowNetLog = false
end
XRpc.IgnoreRpcNames = { ["HeartbeatRequest"] = true, ["HeartbeatResponse"] = true, ["KcpHeartbeatRequest"] = true, ["KcpHeartbeatResponse"] = true
, ["NotifyGuildDormSyncEntities"] = true, ["GuildDormHeartbeatRequest"] = true }
XRpc.DEBUG_TYPE = {
Send = "Send",
Send_Call = "Send_Call",
Recv = "Recv",
Recv_Call = "Recv_Call",
}
XRpc.DEBUG_TYPE_COLOR = {
Send = "#5bf54f",
Send_Call = "#5bf54f",
Recv = "#42a8fa",
Recv_Call = "#42a8fa",
}
-- 浅色主题用的字体颜色
-- XRpc.DEBUG_TYPE_COLOR = {
-- Send = "green",
-- Send_Call = "green",
-- Recv = "blue",
-- Recv_Call = "blue",
-- }
XRpc.DebugKeyWords = {"GuildBoss"} -- 【关键协议】
function XRpc.CheckLuaNetLogEnable()
IsPrintLuaRpc = XMain.IsEditorDebug and XSaveTool.GetData(XPrefs.LuaNetLog)
return IsPrintLuaRpc
end
function XRpc.SetLuaNetLogEnable(value)
IsPrintLuaRpc = value
XSaveTool.SaveData(XPrefs.LuaNetLog, IsPrintLuaRpc)
end
function XRpc.DebugPrint(debugType, rpcName, request)
if not IsPrintLuaRpc or XRpc.IgnoreRpcNames[rpcName] then
return
end
local color = XRpc.DEBUG_TYPE_COLOR[debugType]
if XRpc.DebugKeyWords then
for i, keyWord in ipairs(XRpc.DebugKeyWords) do
if (string.find(rpcName, keyWord)) then
rpcName = "<color=red>" .. rpcName .. "</color>" -- 【关键协议】显示为红色 可本地自定义
break
end
end
end
XLog.Debug("<color=" .. color .. "> " .. debugType .. ": " .. rpcName .. ", content: </color>" .. XLog.Dump(request))
end
-------------------------------
local handlers = {}
local IsHotReloadOpen = XMain.IsEditorDebug
function XRpc.Do(name, content)
local handler = handlers[name]
if handler == nil then
XLog.Error("XRpc.Do 函数错误, 没有定义相应的接收服务端数据的函数, 函数名是: " .. name)
return
end
local request, error = XMessagePack.Decode(content)
if request == nil then
XLog.Error("XRpc.Do 函数错误, 服务端返回的数据解码错误, 错误原因: " .. error)
return
end
XRpc.DebugPrint(XRpc.DEBUG_TYPE.Recv, name, request)
handler(request)
end
setmetatable(XRpc, {
__newindex = function(_, name, handler)
if type(name) ~= "string" then
XLog.Error("XRpc.register 函数错误, 参数name必须是string类型, type: " .. type(name))
return
end
if type(handler) ~= "function" then
XLog.Error("XRpc.register 函数错误, 注册的接收服务端数据的函数的值必须是函数类型, type: " .. type(handler))
return
end
if handlers[name] and not IsHotReloadOpen then
XLog.Error("XRpc.register 函数错误, 存在相同名字的接收服务端数据的函数, 名字是: " .. name)
return
end
handlers[name] = handler
end,
})
XRpc.TestRequest = function(request)
XLog.Warning(request);
end

View file

@ -0,0 +1,14 @@
-- auto export form enum
-- Automatic generation of code, forbid to edit or delete
XRpcExceptionCode = {
Success = 0,
DecodeError = 1,
ServerInternalError = 2,
RequestOutOfLimit = 3,
RpcTimeout = 4,
InvalidRequest = 5,
InvalidArgument = 6,
FeaturesNotOpen = 7,
RequestBlocked = 8,
ServiceUnavailable = 9,
}

View file

@ -0,0 +1,146 @@
local tostring = tostring
local load = load
local type = type
local ipairs = ipairs
local pairs = pairs
local string = string
local table = table
local stringDump = string.dump
local stringGmatch = string.gmatch
local tableUnpack = table.unpack
local tableInsert = table.insert
local tableSort = table.sort
local tableConcat = table.concat
XSaveTool = XSaveTool or {}
XSaveTool.LocalCache = {}
local function fret(...)
local args = { ... }
return function()
return tableUnpack(args)
end
end
--==============================--
--desc: 数据字符串化
--@val: 需要封装成字符串的数据
--@needSort: 是否需要排序
--@cache: 缓存处理table引用死锁判断
--@return 封装好的字符串
--==============================--
function XSaveTool.Stringify(val, needSort, cache)
cache = cache or {}
return (({
["nil"] = fret "nil",
["boolean"] = fret(tostring(val)),
["number"] = fret(val),
["function"] = function()
return "function(...)" ..
"return load(" ..
XSaveTool.Stringify(stringDump(val), needSort, cache) ..
")(...)" ..
"end"
end,
["string"] = function()
local s = "\""
for c in stringGmatch(val, ".") do
s = s .. "\\" .. c:byte()
end
return s .. "\""
end,
["table"] = function()
if cache[val] then
XLog.Error("loop Stringify")
return
end
cache[val] = true
local members = {}
if needSort then
local keys = {}
for k, _ in pairs(val) do
tableInsert(keys, k)
end
tableSort(keys)
for _, v in ipairs(keys) do
tableInsert(members, "[" .. XSaveTool.Stringify(v, needSort, cache) .. "]=" .. XSaveTool.Stringify(val[v], needSort, cache))
end
else
for k, v in pairs(val) do
tableInsert(members, "[" .. XSaveTool.Stringify(k, needSort, cache) .. "]=" .. XSaveTool.Stringify(v, needSort, cache))
end
end
return "{" .. tableConcat(members, ",") .. "}"
end,
})[type(val)] or function()
XLog.Error("cannot Stringify type:" .. type(val), 2)
end)()
end
--==============================--
--desc: 本地数据持久化
--@key: 存储key
--@value: 存储值
--==============================--
function XSaveTool.SaveData(key, value)
local k = XSaveTool.Stringify(key, true)
if value == false then
XSaveTool.LocalCache[k] = nil
else
XSaveTool.LocalCache[k] = value or XSaveTool.LocalCache[k]
end
CS.UnityEngine.PlayerPrefs.SetString("LuaData:" .. k, XSaveTool.Stringify(XSaveTool.LocalCache[k]))
CS.UnityEngine.PlayerPrefs.Save()
end
--==============================--
--desc: 持久化数据删除
--@key: 数据key
--==============================--
function XSaveTool.RemoveData(key)
local k = XSaveTool.Stringify(key, true)
XSaveTool.LocalCache[k] = nil
CS.UnityEngine.PlayerPrefs.DeleteKey("LuaData:" .. k)
end
--==============================--
--desc: 获取持久化数据
--@key: 存储key
--@return 存储值
--==============================--
function XSaveTool.GetData(key)
local k = XSaveTool.Stringify(key, true)
if XSaveTool.LocalCache[k] then
return XSaveTool.LocalCache[k]
end
local str = CS.UnityEngine.PlayerPrefs.GetString("LuaData:" .. k)
if str and str ~= "" then
local obj = load("return " .. str)()
XSaveTool.LocalCache[k] = obj
return obj
end
return nil
end
--==============================--
--desc: 移除所有持久化数据(调试)
--==============================--
function XSaveTool.RemoveAll()
local enable1 = XDataCenter.GuideManager.CheckFuncDisable()
local enable2 = XDataCenter.CommunicationManager.CheckFuncDisable()
local enable3 = XDataCenter.FunctionEventManager.CheckFuncDisable()
local enable4 = XRpc.CheckLuaNetLogEnable()
XSaveTool.LocalCache = {}
CS.UnityEngine.PlayerPrefs.DeleteAll()
XDataCenter.GuideManager.ChangeFuncDisable(enable1)
XDataCenter.CommunicationManager.ChangeFuncDisable(enable2)
XDataCenter.FunctionEventManager.ChangeFuncDisable(enable3)
XRpc.SetLuaNetLogEnable(enable4)
end

View file

@ -0,0 +1,86 @@
XScheduleManager = XScheduleManager or {}
local CSXScheduleManager = CS.XScheduleManager
XScheduleManager.SECOND = CSXScheduleManager.SECOND
require("XCommon/XTool")
local XTool = XTool
local IsEditor = XMain.IsEditorDebug
-- /// <summary>
-- /// 启动定时器
-- /// </summary>
-- /// <param name="handler">处理函数</param>
-- /// <param name="interval">间隔毫秒(第一次执行在间隔时间后)</param>
-- /// <param name="loop">循环次数</param>
-- /// <param name="delay">延迟毫秒</param>
-- /// <returns>定时器id</returns>
function XScheduleManager.Schedule(func, interval, loop, delay)
local name = IsEditor and XTool.GetStackTraceName() or nil
return CSXScheduleManager.Schedule(func, interval, loop, delay or 0, name)
end
-- /// <summary>
-- /// 启动单次定时器
-- /// </summary>
-- /// <param name="handler">处理函数</param>
-- /// <param name="delay">延迟毫秒</param>
-- /// <returns>定时器id</returns>
function XScheduleManager.ScheduleOnce(func, delay)
local name = IsEditor and XTool.GetStackTraceName() or nil
return CSXScheduleManager.ScheduleOnce(func, delay, name)
end
-- /// <summary>
-- /// 启动指定时间单次定时器
-- /// </summary>
-- /// <param name="handler">处理函数</param>
-- /// <param name="timeStamp">需要启动的时间</param>
-- /// <returns>定时器id</returns>
function XScheduleManager.ScheduleAtTimestamp(func, timeStamp)
local name = IsEditor and XTool.GetStackTraceName() or nil
local nowTime = XTime.GetServerNowTimestamp()
if timeStamp <= nowTime then
return
end
return CSXScheduleManager.ScheduleOnce(func, (timeStamp - nowTime) * XScheduleManager.SECOND, name)
end
-- /// <summary>
-- /// 启动永久定时器
-- /// </summary>
-- /// <param name="handler">处理函数</param>
-- /// <param name="interval">间隔毫秒</param>
-- /// <param name="delay">延迟毫秒</param>
-- /// <returns>定时器id</returns>
function XScheduleManager.ScheduleForever(func, interval, delay)
local name = IsEditor and XTool.GetStackTraceName() or nil
return CSXScheduleManager.ScheduleForever(func, interval, delay or 0, name)
end
-- /// <summary>
-- /// 启动永久定时器
-- /// </summary>
-- /// <param name="handler">处理函数</param>
-- /// <param name="interval">间隔毫秒</param>
-- /// <param name="delay">延迟毫秒</param>
-- /// <returns>定时器id</returns>
-- /// PS:去除了XScheduleManager.ScheduleForever里计算时间自动叠加多一次的Interval
function XScheduleManager.ScheduleForeverEx(func, interval, delay)
local name = IsEditor and XTool.GetStackTraceName() or nil
return CSXScheduleManager.ScheduleForever(func, interval, (delay or 0) - interval, name)
end
-- /// <summary>
-- /// 取消定时器
-- /// </summary>
-- /// <param name="id">定时器id</param>
function XScheduleManager.UnSchedule(id)
return CSXScheduleManager.UnSchedule(id)
end
-- 释放所有定时器
function XScheduleManager.UnScheduleAll()
XTool.ResetInitSchedule()
return CSXScheduleManager.UnScheduleAll()
end

View file

@ -0,0 +1,290 @@
local XSignBoardPlayer = {}
local PlayerState = {
IDLE = 0,
PLAYING = 1,
CHANGING = 2,
PAUSE = 3
}
--创建一个播放器
function XSignBoardPlayer.New(playUi, coolTime, delay)
if playUi == nil then
return nil
end
local player = {}
setmetatable(player, { __index = XSignBoardPlayer })
player:Init(playUi, coolTime, delay)
return player
end
--初始化
function XSignBoardPlayer:Init(playUi, coolTime, delay)
self.CoolTime = coolTime --冷却时间
self.PlayUi = playUi --执行Ui
self.Status = PlayerState.IDLE
self.DelayStart = XTime.GetServerNowTimestamp() + delay
self.LastPlayTime = -1
self.Delay = delay
self.Time = XTime.GetServerNowTimestamp()
self.AutoPlay = true
self.PlayOne = false
end
-- self.PlayerData.PlayerList = {} --播放列表
-- self.PlayerData..PlayingElement = nil --播放对象
-- self.PlayerData.PlayedList = {} --播放过的列表
-- self.LastPlayTime = -1 --上次播放时间
function XSignBoardPlayer:SetPlayerData(data)
self.PlayerData = data
end
--设置播放队列
function XSignBoardPlayer:SetPlayList(playList)
if not playList or #playList <= 0 then
return
end
self.PlayerData.PlayerList = {}
self.PlayerData.LastPlayTime = -1
self.DelayStart = self.Time + self.Delay
for _, element in ipairs(playList) do
table.insert(self.PlayerData.PlayerList, element)
end
end
--播放
function XSignBoardPlayer:Play(tab, cvType)
if not tab then
return false
end
if not self:IsActive() then
return false
end
if self.PlayerData.PlayingElement and self.PlayerData.PlayingElement.Id == tab.Id then
return false
end
local element = {}
element.Id = tab.Id --Id
element.AddTime = self.Time -- 添加事件
element.StartTime = -1 --开始播放的时间
element.EndTime = -1 --结束时间
-- 获取相应语言的动作持续时间
local duration
local defaultCvType = 1
local curElementCvType = cvType or CS.UnityEngine.PlayerPrefs.GetInt("CV_TYPE", defaultCvType)
if tab.Duration[curElementCvType] == nil then
if tab.Duration[defaultCvType] == nil then
XLog.Error(string.format("XSignBoardPlayer:Play函数错误配置表SignboardFeedback.tab没有配置Id:%s的Duration数据", tostring(element.Id)))
return false
end
duration = tab.Duration[defaultCvType]
else
duration = tab.Duration[curElementCvType]
end
element.Duration = duration
element.Validity = tab.Validity --有效期
element.CoolTime = 0--tab.CoolTime --冷却时间
element.Weight = tab.Weight --权重
element.SignBoardConfig = tab
element.CvType = cvType
table.insert(self.PlayerData.PlayerList, 1, element)
return true
end
--播放下一个
--isRecord决定是否要保存当前动作播放记录
function XSignBoardPlayer:PlayNext(isRecord)
if not self:IsActive() then
return
end
if not self.PlayerData.PlayerList or #self.PlayerData.PlayerList == 0 then
return
end
--获取第一个在有限期之类的动画
local head = nil
while #self.PlayerData.PlayerList > 0 and not head do
local temp = table.remove(self.PlayerData.PlayerList, 1)
-- local lastPlayTime = self.PlayerData.PlayedList[temp.Id]
-- --如果还在冷却中
-- if lastPlayTime and self.Time < lastPlayTime then
-- if #self.PlayerData.PlayerList <= 0 then
-- break
-- end
-- temp = table.remove(self.PlayerData.PlayerList, 1)
-- end
--检测是否过期
if temp.Validity < 0 then
head = temp
else
local validity = temp.Validity + temp.AddTime
if validity > self.Time then
head = temp
end
end
end
--如果找不到合适的动画
if not head then
return
end
head.StartTime = self.Time
self.PlayerData.PlayingElement = head
self.Status = PlayerState.PLAYING
self.PlayerData.LastPlayTime = head.StartTime + head.Duration
if isRecord then
-- 记录播放过的动作
XDataCenter.SignBoardManager.RecordSignBoard(head.SignBoardConfig)
end
self.PlayUi:Play(head)
if self.PlayOne then
-- 清空播放列表,只播放当前权重最高的动画(head)
self.PlayerData.PlayerList = {}
end
end
--停止
function XSignBoardPlayer:Stop()
if self.PlayerData.PlayingElement == nil then
return
end
self.PlayerData.PlayedList[self.PlayerData.PlayingElement.Id] = XTime.GetServerNowTimestamp() + self.PlayerData.PlayingElement.CoolTime
self.PlayUi:OnStop(self.PlayerData.PlayingElement)
self.PlayerData.PlayingElement = nil
self.Status = PlayerState.IDLE
self.LastPlayTime = XTime.GetServerNowTimestamp()
end
--暂停
function XSignBoardPlayer:Pause()
self.Status = PlayerState.PAUSE
end
function XSignBoardPlayer:Freeze()
self.Status = PlayerState.STOP
end
function XSignBoardPlayer:Resume()
self.LastPlayTime = XTime.GetServerNowTimestamp()
self.Status = PlayerState.IDLE
end
--更新
function XSignBoardPlayer:Update(deltaTime)
self.Time = self.Time + deltaTime
if self.Time < self.DelayStart then
return
end
if not self:IsActive() then
return
end
if (not self.PlayerData.PlayerList or #self.PlayerData.PlayerList == 0) and self.PlayerData.PlayingElement == nil then
return
end
if self.Status == PlayerState.STOP then
return
end
if self.Status == PlayerState.PAUSE then
return
end
local nextElementTime = self.PlayerData.LastPlayTime + self.CoolTime
--存在播放中的动作
if self.PlayerData.PlayingElement ~= nil and self.PlayerData.PlayingElement.Duration > 0 then
local deadline = self.PlayerData.PlayingElement.StartTime + self.PlayerData.PlayingElement.Duration
if deadline < self.Time then
if self.PlayUi.Parent.SetWhetherPlayChangeActionEffect then
--动作生命周期正常结束,不用播放打断特效
self.PlayUi.Parent:SetWhetherPlayChangeActionEffect(false)
end
self:SetInterruptDetection(false)
self:Stop()
return
end
end
--冷却时间
if nextElementTime < self.Time and self.Status ~= PlayerState.PLAYING and self.AutoPlay then
self:PlayNext(true)
end
end
function XSignBoardPlayer:SetInterruptDetection(boolValue)
self.IsInInterruptDetection = boolValue
end
function XSignBoardPlayer:GetInterruptDetection()
return self.IsInInterruptDetection
end
--强制运行
function XSignBoardPlayer:ForcePlay(tab, cvType, isRecord)
if self.Status == PlayerState.STOP then
return
end
if self:Play(tab, cvType) then
self:PlayNext(isRecord)
end
end
function XSignBoardPlayer:IsPlaying()
return self.Status == PlayerState.PLAYING
end
--设置自动播放
function XSignBoardPlayer:SetAutoPlay(bAutoPlay)
self.AutoPlay = bAutoPlay
end
-- 播放队列是否只播放权重最高的动画
function XSignBoardPlayer:SetPlayOne(bPlayOne)
self.PlayOne = bPlayOne
end
---生命周期----------------------------------------------
function XSignBoardPlayer:IsActive()
return self.Active
end
function XSignBoardPlayer:OnEnable()
self.Active = true
self:Resume()
end
function XSignBoardPlayer:OnDisable()
self.Active = false
self:Stop()
end
function XSignBoardPlayer:OnDestroy()
self:Stop()
end
return XSignBoardPlayer

View file

@ -0,0 +1,45 @@
XStack = XClass(nil, "XStack")
function XStack:Ctor()
self:Clear()
end
function XStack:Clear()
self.__Container = {}
self.__EndIndex = 0
end
function XStack:IsEmpty()
return self.__EndIndex < 1
end
function XStack:Count()
return self.__EndIndex
end
function XStack:Push(element)
if not element then return end
local endIndex = self.__EndIndex + 1
self.__EndIndex = endIndex
self.__Container[endIndex] = element
end
function XStack:Pop()
if self:IsEmpty() then
self:Clear()
return
end
local endIndex = self.__EndIndex
local element = self.__Container[endIndex]
self.__EndIndex = endIndex - 1
self.__Container[endIndex] = nil
return element
end
function XStack:Peek()
return self.__Container[self.__EndIndex]
end

View file

@ -0,0 +1,411 @@
--==============================--
-- 字符串相关扩展方法
--==============================--
local tonumber = tonumber
local next = next
local pairs = pairs
local string = string
local table = table
local math = math
local stringLen = string.len
local stringByte = string.byte
local stringSub = string.sub
local stringGsub = string.gsub
local stringFind = string.find
local stringMatch = string.match
local tableInsert = table.insert
local mathFloor = math.floor
--==============================--
--desc: 通过utf8获取字符串长度
--@str: 字符串
--@return 字符串长度
--==============================--
function string.Utf8Len(str)
local len = stringLen(str)
local left = len
local cnt = 0
local arr = { 0, 192, 224, 240, 248, 252 }
while left ~= 0 do
local tmp = stringByte(str, -left)
local i = #arr
while arr[i] do
if tmp >= arr[i] then
left = left - i
break
end
i = i - 1
end
cnt = cnt + 1
end
return cnt
end
--==============================--
--desc: 通过utf8获取单个字符长度
--@str: 单个字符
--@return 字符串长度
--==============================--
function string.Utf8Size(char)
if not char then
return 0
elseif char >= 252 then
return 6
elseif char >= 248 then
return 5
elseif char >= 240 then
return 4
elseif char >= 225 then
return 3
elseif char >= 192 then
return 2
else
return 1
end
end
--==============================--
--desc: 按utf8长度截取字符串
--@str: 字符串
--@return 字符串
--==============================--
function string.Utf8Sub(str, startChar, numChars)
local startIndex = 1
while startChar > 1 do
local char = stringByte(str, startIndex)
startIndex = startIndex + string.Utf8Size(char)
startChar = startChar - 1
end
local currentIndex = startIndex
while numChars > 0 and currentIndex <= #str do
local char = stringByte(str, currentIndex)
currentIndex = currentIndex + string.Utf8Size(char)
numChars = numChars - 1
end
return str:sub(startIndex, currentIndex - 1)
end
--==============================--
--desc: 将字符串分割成char table
--@str: 字符串
--@return char table
--==============================--
function string.SplitWordsToCharTab(str)
local len = stringLen(str)
local left = len
local chartab = {}
local arr = { 0, 192, 224, 240, 248, 252 }
while left ~= 0 do
local tmp = stringByte(str, -left)
local i = #arr
local value = left
while arr[i] do
if tmp >= arr[i] then
left = left - i
break
end
i = i - 1
end
local char = stringSub(str, -value, -left - 1)
if stringSub(str, -left, -left + 1) == "\\n" then
left = left - 2
char = char .. "\n"
end
tableInsert(chartab, char)
end
return chartab
end
--==============================--
--desc: 把有富文本格式的字符串变成char table
--@str: 富文本字符串
--@return char table
--==============================--
function string.CharsConvertToCharTab(str)
--str = "我只是用来{<color=#00ffffff><size=40>测一测</size></color>}别xiabibi{<size=25><color=#ff0000ff>红色试一试</color></size>}试玩啦"--
local leftindexs = {}
local rightindexs = {}
local startpos = 1
while true do
local pos = stringFind(str, "{", startpos)
if not pos then
break
end
tableInsert(leftindexs, pos)
pos = stringFind(str, "}", pos + 1)
if not pos then
break
end
tableInsert(rightindexs, pos)
startpos = pos + 1
end
local words = {}
if #leftindexs > 0 then
startpos = 1
for i = 1, #leftindexs do
tableInsert(words, stringSub(str, startpos, leftindexs[i] - 1))
tableInsert(words, stringSub(str, leftindexs[i] + 1, rightindexs[i] - 1))
startpos = rightindexs[i] + 1
end
if rightindexs[#rightindexs] ~= stringLen(str) then
tableInsert(words, stringSub(str, startpos))
end
else
tableInsert(words, str)
end
local result = {}
for i = 1, #words do
local tab
local IsRichText
local format
if stringSub(words[i], 1, 1) == "<" then
IsRichText = true
local pa = stringMatch(words[i], "%b></")
pa = stringMatch(pa, ">(.*)<")
format = stringGsub(words[i], "%b></", ">#$#</", 1)
tab = string.SplitWordsToCharTab(pa)
else
IsRichText = false
format = ""
tab = string.SplitWordsToCharTab(words[i])
end
for j = 1, #tab do
if IsRichText then
local char = stringGsub(format, "#$#", tab[j])
tableInsert(result, char)
else
tableInsert(result, tab[j])
end
end
end
return result
end
--==============================--
--desc: 检查字符串的开头是否与指定字符串匹配
--@str: 需要检查的字符串
--@value: 指定的字符串
--@return true匹配false不匹配
--==============================--
function string.StartsWith(str, value)
return stringSub(str, 1, stringLen(value)) == value
end
--==============================--
--desc: 检查字符串的结尾是否与指定字符串匹配
--@str: 需要检查的字符串
--@value: 指定的字符串
--@return true匹配false不匹配
--==============================--
function string.EndsWith(str, value)
return value == "" or stringSub(str, -stringLen(value)) == value
end
--==============================--
--desc: 字符串分割
--@str: 原字符串
--@separator: 分割符
--@return 字符串数组
--==============================--
function string.Split(str, separator)
if str == nil or str == "" then
return {}
end
if not separator then
separator = "|"
end
local result = {}
local startPos = 1
while true do
local endPos = str:find(separator, startPos)
if endPos == nil then
break
end
local elem = str:sub(startPos, endPos - 1)
tableInsert(result, elem)
startPos = endPos + #separator
end
tableInsert(result, str:sub(startPos))
return result
end
--==============================--
--desc: 将字符串分割成int数组
--@str: 原字符串
--@separator: 分割符
--@return int数组
--==============================--
function string.ToIntArray(str, separator)
local strs = string.Split(str, separator)
local array = {}
if next(strs) then
for _, v in pairs(strs) do
tableInsert(array, mathFloor(tonumber(v)))
end
end
return array
end
--==============================--
--desc: 从一个字符串中查找另一个字符串的第一次匹配的索引
--@str: 原字符串
--@separator: 需要匹配的字符串
--@return 索引号
--==============================--
function string.IndexOf(str, separator)
if not str or str == "" or not separator or separator == "" then
return -1
end
for i = 1, #str do
local success = true
for s = 1, #separator do
local strChar = stringByte(str, i + s - 1)
local sepChar = stringByte(separator, s)
if strChar ~= sepChar then
success = false
break
end
end
if success then
return i
end
end
return -1
end
--==============================--
--desc: 从一个字符串中查找另一个字符串的最后一次匹配的索引
--@str: 原字符串
--@separator: 需要匹配的字符串
--@return 索引号
--==============================--
function string.LastIndexOf(str, separator)
if not str or str == "" or not separator or separator == "" then
return -1
end
local strLen = #str
local sepLen = #separator
for i = 0, strLen - 1 do
local success = true
for s = 0, sepLen - 1 do
local strChar = stringByte(str, strLen - i - s)
local sepChar = stringByte(separator, sepLen - s)
if strChar ~= sepChar then
success = false
break
end
end
if success then
return strLen - i - sepLen + 1
end
end
return -1
end
--==============================--
--desc: 判断字符串是否为nil或者为空
--@str: 字符串对象
--@return 如果为nil或者为空返回true否则返回fale
--==============================--
function string.IsNilOrEmpty(str)
return str == nil or #str == 0
end
--==============================--
--desc: 过滤utf文本特殊屏蔽字干扰字符
--@str: 字符串对象
--@return 过滤后文本
--==============================--
local FilterSymbols = [[·~@#¥%……&*-=——+【】{}、|;‘’:“”,。、《》?[]{}""'';:./?,<>\|-_=+*()!@#$%^&*~` ]]
local FilterSymbolsTable = FilterSymbols:SplitWordsToCharTab()
function string.FilterWords(str)
local result = ""
for i = 1, string.Utf8Len(str) do
local nowStr = string.Utf8Sub(str, i, 1)
local isValid = true
for _, v in pairs(FilterSymbolsTable) do
if nowStr == v then
isValid = false
break
end
end
if isValid then
result = result .. nowStr
end
end
return result
end
--==============================--
--desc: 字符串每隔X个字符插入 需要的字符串
--@str: 字符串对象
--@interval: 间隔多少个字符
--@insertStr: 插入的字符串
--@return 过滤后文本
--==============================--
function string.InsertStr(str, interval, insertStr)
local index = 1
local worldCount = 0
local result = ""
while true do
local world = stringSub(str, index, index)
local byte = stringByte(world)
if byte > 128 then
world = stringSub(str, index, index + 2)
index = index + 3
else
index = index + 1
end
result = result .. world
worldCount = worldCount + 1
if worldCount >= interval then
result = result .. insertStr
worldCount = 0
end
if index > #str then
break
end
end
return result
end
--判断字符串是否为合法IP"[0-255].[0-255].[0-255].[0-255]"
function string.IsIp(ip)
if string.IsNilOrEmpty(ip) then return false end
local valueSet = table.pack(string.find(ip, "(%d+)%.(%d+)%.(%d+)%.(%d+)"))
local pureIpStr = table.concat(valueSet, '.', 3, 6)
if not valueSet[1] then return false end
local ipNum
for i = 3, 6 do
ipNum = tonumber(valueSet[i])
if not ipNum or ipNum < 0 or ipNum > 255 then
return false
end
end
return true, pureIpStr
end

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,360 @@
XTime = XTime or {}
local floor = math.floor
local CsTime = CS.UnityEngine.Time
local ServerTimeWhenStartupList = {} --客户端启动时,服务器的时间戳
local ServerTimeMaxCount = 10 --保存服务端时间的最大个数
local CurrentSaveIndex = 1 --当前保存到的下标
local ServerTimeWhenStartupAverage = 0 --客户端启动时,服务器的时间戳平局值
local PingTimeList = {}
local PingTimeIndex = 0
local PingTimeLength = 10
-- 一星期中的第几天 (3)[1 - 6 = 星期天 - 星期六]
local WeekOfDay = {
Sun = 0,
Mon = 1,
Tues = 2,
Wed = 3,
Thur = 4,
Fri = 5,
Sat = 6,
NorSun = 7
}
local WeekOfDayIndex = {
[WeekOfDay.Mon] = 1,
[WeekOfDay.Tues] = 2,
[WeekOfDay.Wed] = 3,
[WeekOfDay.Thur] = 4,
[WeekOfDay.Fri] = 5,
[WeekOfDay.Sat] = 6,
[WeekOfDay.Sun] = 7,
[WeekOfDay.NorSun] = 7
}
local WeekLength = 7
local sec_of_a_day = 24 * 60 * 60
local sec_of_one_hour = 60 * 60
local sec_of_refresh_time = 7 * 60 * 60
--==============================--
--desc: 获取服务器当前时间戳
--@return 长整型时间戳,单位(秒)
--==============================--
function XTime.GetServerNowTimestamp()
local sinceStartup = CsTime.realtimeSinceStartup
return floor(ServerTimeWhenStartupAverage + sinceStartup)
end
--==============================--
--desc: 同步时间
--@serverTime: 服务器时间
--@reqTime: 发起请求时间
--@resTime: 收到响应时间
--==============================--
function XTime.SyncTime(serverTime, reqTime, resTime)
local startup = (reqTime + resTime) * 0.5
local span = serverTime - startup
if CurrentSaveIndex > ServerTimeMaxCount then
CurrentSaveIndex = CurrentSaveIndex - ServerTimeMaxCount
end
ServerTimeWhenStartupList[CurrentSaveIndex] = span
CurrentSaveIndex = CurrentSaveIndex + 1
local count = #ServerTimeWhenStartupList
local total = 0
for _, v in ipairs(ServerTimeWhenStartupList) do
total = total + v
end
ServerTimeWhenStartupAverage = total / count
local gap = resTime - reqTime
PingTimeIndex = (PingTimeIndex % PingTimeLength) + 1
PingTimeList[PingTimeIndex] = gap
-- print(" ======= ping(ms) ... gap: " .. tostring(gap) .. ", avr:" .. tostring(XTime.GetPingTime()) .. ", i:" .. tostring(PingTimeIndex) .. ", t:" .. tostring(CS.UnityEngine.Time.realtimeSinceStartup))
end
-- 获取网络延时 单位: ms
function XTime.GetPingTime()
if #PingTimeList == 0 then
return 0
end
local total = 0
for _, v in ipairs(PingTimeList) do
total = total + v
end
return math.floor(total * 1000) / #PingTimeList
end
function XTime.ClearPingTime()
PingTimeList = {}
PingTimeIndex = 0
end
--==============================--
--desc: 时间字符串转服务器时区时间戳
--@dateTimeString: 时间字符串
--@return 转失败返回nil
--==============================--
function XTime.ParseToTimestamp(dateTimeString)
if dateTimeString == nil or dateTimeString == "" then
return
end
local success, timestamp = CS.XDateUtil.TryParseToTimestamp(dateTimeString)
if not success then
XLog.Error("XTime.TryParseToTimestamp parse to timestamp failed. try use ParseToTimestampMDY: " .. tostring(dateTimeString))
return XTime.ParseToTimestampMDY(dateTimeString)
end
return timestamp
end
function XTime.ParseToTimestampMDY(dateTimeString)
local arr = string.Split(dateTimeString, " ")
local date = arr[1]
local time = arr[2]
local dateArr = string.Split(date, "/")
local m = dateArr[1]
local d = dateArr[2]
local y = dateArr[3]
dateTimeString = y .. "/" .. m .. "/" .. d .. " " .. time
local success, timestamp = CS.XDateUtil.TryParseToTimestamp(dateTimeString)
if not success then
XLog.Error("XTime.TryParseToTimestamp parse to timestamp failed. invalid time argument: " .. tostring(dateTimeString))
return -- 该类在CS中不存在且在1.18版本出现时区格式问题
-- return CS.XDate.GetTime(dateTimeString)
end
return timestamp
end
--时间戳转utc时间字符串
function XTime.TimestampToUtcDateTimeString(timestamp, format)
format = format or "yyyy-MM-dd HH:mm:ss"
local dt = CS.XDateUtil.GetUtcDateTime(timestamp)
return dt:ToString(format)
end
--时间戳转设备本地时间字符串
function XTime.TimestampToLocalDateTimeString(timestamp, format)
format = format or "yyyy-MM-dd HH:mm:ss"
local dt = CS.XDateUtil.GetLocalDateTime(timestamp)
return dt:ToString(format)
end
--时间戳转游戏指定时区时间字符串
function XTime.TimestampToGameDateTimeString(timestamp, format)
format = format or "yyyy-MM-dd HH:mm:ss"
local dt = CS.XDateUtil.GetGameDateTime(timestamp)
return dt:ToString(format)
end
-- c#星期枚举转整形数
function XTime.DayOfWeekToInt(dayOfWeek, isNormlSunDay)
if dayOfWeek == CS.System.DayOfWeek.Sunday then
return isNormlSunDay and 7 or 0
elseif dayOfWeek == CS.System.DayOfWeek.Monday then
return 1
elseif dayOfWeek == CS.System.DayOfWeek.Tuesday then
return 2
elseif dayOfWeek == CS.System.DayOfWeek.Wednesday then
return 3
elseif dayOfWeek == CS.System.DayOfWeek.Thursday then
return 4
elseif dayOfWeek == CS.System.DayOfWeek.Friday then
return 5
else
return 6
end
end
--获取今天时间
function XTime.GetTodayTime(hour, min, sec)
hour = hour or 0
min = min or 0
sec = sec or 0
local nowTime = XTime.GetServerNowTimestamp()
local dt = CS.XDateUtil.GetGameDateTime(nowTime)
return dt.Date:AddHours(hour):AddMinutes(min):AddSeconds(sec):ToTimestamp()
end
function XTime.GeyServerTime(hour, min, sec)
hour = hour or 0
min = min or 0
sec = sec or 0
local nowTime = XTime.GetServerNowTimestamp()
local dt = CS.XDateUtil.GetGameDateTime(nowTime)
dt = dt.Date;
dt = dt:AddSeconds(sec)
dt = dt:AddMinutes(min)
dt = dt:AddHours(hour)
return dt:ToTimestamp()
end
-- 获取距离下一个星期x的时间,默认每周第一天为周一
function XTime.GetNextWeekOfDayStartWithMon(weekOfDay, offsetTime)
local needTime
local nowTime = XTime.GetServerNowTimestamp()
local dateTime = CS.XDateUtil.GetGameDateTime(nowTime)
local weekZero = CS.XDateUtil.GetFirstDayOfThisWeek(dateTime):ToTimestamp()
local resetTime = (WeekOfDayIndex[weekOfDay] - 1) * sec_of_a_day + offsetTime + weekZero
if nowTime < resetTime then
needTime = resetTime - nowTime
else
needTime = WeekLength * sec_of_a_day - (nowTime - resetTime)
end
return needTime
end
-- 获取最近一个未到达的星期X的服务器更新时间
function XTime.GetSeverNextWeekOfDayRefreshTime(weekOfDay)
local needTime = XTime.GetNextWeekOfDayStartWithMon(weekOfDay, sec_of_refresh_time)
local nowTime = XTime.GetServerNowTimestamp()
return nowTime + needTime
end
-- 获取服务器当天5点更新时间戳
function XTime.GetSeverTodayFreshTime()
local now = XTime.GetServerNowTimestamp()
local dateTime = CS.XDateUtil.GetGameDateTime(now)
local dayZero = dateTime.Date:ToTimestamp()
return dayZero + sec_of_refresh_time
end
--=========================
--获取服务器当天目标时间的时间戳
--oclock : 目标时间例如晚上8点为20 8点半为 20.5
--=========================
function XTime.GetServerTodayTargetTime(oclock)
local now = XTime.GetServerNowTimestamp()
local dateTime = CS.XDateUtil.GetGameDateTime(now)
local dayZero = dateTime.Date:ToTimestamp()
return dayZero + (oclock * sec_of_one_hour)
end
-- 获取服务器明天5点更新时间戳
function XTime.GetSeverTomorrowFreshTime()
local dayFreshTime = XTime.GetSeverTodayFreshTime()
return dayFreshTime + sec_of_a_day
end
--=========================
--获取服务器当天目标时间的时间戳
--oclock : 目标时间(例:晚上8点 = 20 晚上8点30分 = 20.5)
--=========================
function XTime.GetServerTomorrowTargetTime(oclock)
local dayFreshTime = XTime.GetServerTodayTargetTime(oclock)
return dayFreshTime + sec_of_a_day
end
-- 获取服务器昨天5点更新时间戳
function XTime.GetSeverYesterdayFreshTime()
local dayFreshTime = XTime.GetSeverTodayFreshTime()
return dayFreshTime - sec_of_a_day
end
--获取服务器下一次5点更新时间戳
function XTime.GetSeverNextRefreshTime()
local nextRefreshTime
local dayRefreshTime = XTime.GetSeverTodayFreshTime()
local nowTime = XTime.GetServerNowTimestamp()
nextRefreshTime = nowTime > dayRefreshTime and XTime.GetSeverTomorrowFreshTime() or dayRefreshTime
return nextRefreshTime
end
--=========================
--获取服务器下一次目标时间的时间戳
--oclock : 目标时间(例:晚上8点 = 20 晚上8点30分 = 20.5)
--=========================
function XTime.GetServerNextTargetTime(oclock)
local nextTargetTime
local dayTargetTime = XTime.GetServerTodayTargetTime(oclock)
local nowTime = XTime.GetServerNowTimestamp()
nextTargetTime = nowTime > dayTargetTime and XTime.GetServerTomorrowTargetTime(oclock) or dayTargetTime
return nextTargetTime
end
--=========================
--获取服务器到下一次目标时间的剩余时间(单位秒)
--oclock : 目标时间(例:晚上8点 = 20 晚上8点30分 = 20.5)
--=========================
function XTime.GetServerLeftTimeToTargetTime(oclock)
local nextTargetTime = XTime.GetServerNextTargetTime(oclock)
local now = XTime.GetServerNowTimestamp()
return nextTargetTime - now
end
-- 判断服务器当下是否是周末
function XTime.CheckWeekend()
local now = XTime.GetServerNowTimestamp()
local weekday = XTime.GetWeekDay(now, false)
if weekday == WeekOfDay.Sun then
return true
elseif weekday == WeekOfDay.Sat then
local todayFreshTime = XTime.GetSeverTodayFreshTime()
return now >= todayFreshTime
elseif weekday == WeekOfDay.Mon then
local todayFreshTime = XTime.GetSeverTodayFreshTime()
return now < todayFreshTime
else
return false
end
end
-- 判断时间戳是周几
function XTime.GetWeekDay(time, isNormlSunDay)
local dateTime = CS.XDateUtil.GetGameDateTime(time)
local weekday = XTime.DayOfWeekToInt(dateTime.DayOfWeek, isNormlSunDay)
return weekday
end
--获取一个时间戳的当天刷新的时间
function XTime.GetTimeDayFreshTime(time)
local todayRefreshTime
local dateTime = CS.XDateUtil.GetGameDateTime(time)
local dayZero = dateTime.Date:ToTimestamp()
todayRefreshTime = dayZero + sec_of_refresh_time
return todayRefreshTime
end
function XTime.GetWeekDayText(time)
local weekDay = XTime.GetWeekDay(time, true)
if weekDay == 1 then
return CSXTextManagerGetText("Monday")
elseif weekDay == 2 then
return CSXTextManagerGetText("Tuesday")
elseif weekDay == 3 then
return CSXTextManagerGetText("Wednesday")
elseif weekDay == 4 then
return CSXTextManagerGetText("Thursday")
elseif weekDay == 5 then
return CSXTextManagerGetText("Friday")
elseif weekDay == 6 then
return CSXTextManagerGetText("Saturday")
elseif weekDay == 7 then
return CSXTextManagerGetText("Sunday")
end
end
--判断两个时间戳是否在同一天
function XTime.IsToday(formTime, toTime)
local formDateTime = CS.XDateUtil.GetGameDateTime(formTime)
local toDateTime = CS.XDateUtil.GetGameDateTime(toTime)
local formDay = formDateTime.Day
local formMonth = formDateTime.Month
local formYear = formDateTime.Year
local toDay = toDateTime.Day
local toMonth = toDateTime.Month
local toYear = toDateTime.Year
return formDay == toDay and formMonth == toMonth and formYear == toYear
end

View file

@ -0,0 +1,655 @@
local Json = require("XCommon/Json")
local type = type
local table = table
local string = string
local math = math
local next = next
local debug = debug
local tostring = tostring
local tableInsert = table.insert
local stringMatch = string.match
local mathModf = math.modf
XTool =
XTool or
{
_IsAutoRefreshOnNextFrame = true
}
XTool.USENEWBATTLEROOM = true
XTool.UObjIsNil = function(uobj)
return uobj == nil or not uobj:Exist()
end
XTool.LoopMap = function(map, func)
if type(map) == "userdata" then
if not map then
return
end
local e = map:GetEnumerator()
while e:MoveNext() do
func(e.Current.Key, e.Current.Value)
end
e:Dispose()
elseif type(map) == "table" then
for key, value in pairs(map) do
func(key, value)
end
end
end
XTool.LoopCollection = function(collection, func)
if type(collection) == "table" then
for _, value in pairs(collection) do
func(value)
end
elseif type(collection) == "userdata" then
for i = 0, collection.Count - 1 do
func(collection[i])
end
end
end
XTool.LoopArray = function(collection, func)
for i = 0, collection.Length - 1 do
func(collection[i])
end
end
XTool.CsList2LuaTable = function(collection)
local ret = {}
for i = 0, collection.Count - 1 do
tableInsert(ret, collection[i])
end
return ret
end
XTool.CsMap2LuaTable = function(map)
local ret = {}
local e = map:GetEnumerator()
while e:MoveNext() do
ret[e.Current.Key] = e.Current.Value
end
e:Dispose()
return ret
end
XTool.CsObjectFields2LuaTable = function(CsObj)
if CsObj == nil or type(CsObj) ~= "userdata" then
return {}
end
local jsonStr = CS.XTool.SerializeObject(CsObj)
return Json.decode(jsonStr)
end
XTool.Clone = function(t)
local cache = {}
local function clone(o)
if type(o) ~= "table" then
return o
end
if cache[o] then
return cache[o]
end
local newO = {}
for k, v in pairs(o) do
newO[clone(k)] = clone(v)
end
local mTable = getmetatable(o)
if type(mTable) == "table" then
setmetatable(newO, mTable)
end
cache[o] = newO
return newO
end
return clone(t)
end
XTool.GetFileNameWithoutExtension = function(path)
return stringMatch(path, "[./]*([^/]*)%.%w+")
end
XTool.GetFileName = function(path)
return stringMatch(path, "[./]*([^/]*%.%w+)")
end
XTool.GetExtension = function(path)
return stringMatch(path, "[./]*(%.%w+)")
end
XTool.GetTableCount = function(list)
if type(list) ~= "table" then
return 0
end
local count = 0
for _, _ in pairs(list) do
count = count + 1
end
return count
end
local NumberText = {
[0] = "",
[1] = CS.XTextManager.GetText("One"),
[2] = CS.XTextManager.GetText("Two"),
[3] = CS.XTextManager.GetText("Three"),
[4] = CS.XTextManager.GetText("Four"),
[5] = CS.XTextManager.GetText("Five"),
[6] = CS.XTextManager.GetText("Six"),
[7] = CS.XTextManager.GetText("Seven"),
[8] = CS.XTextManager.GetText("Eight"),
[9] = CS.XTextManager.GetText("Nine"),
[10] = CS.XTextManager.GetText("Ten")
}
XTool.ParseNumberString = function(num)
return NumberText[mathModf(num / 10)] .. NumberText[num % 10]
end
XTool.ConvertNumberString = function(num)
return NumberText[num] or ""
end
XTool.MatchEmoji = function(text)
return stringMatch(text, "%[%d%d%d%d%d%]")
end
XTool.CopyToClipboard = function(text)
CS.XAppPlatBridge.CopyStringToClipboard(tostring(text))
XUiManager.TipText("Clipboard", XUiManager.UiTipType.Tip)
end
XTool.ToArray = function(t)
local array = {}
for _, v in pairs(t) do
table.insert(array, v)
end
return array
end
XTool.MergeArray = function(...)
local res = {}
for _, t in pairs({...}) do
if type(t) == "table" then
for _, v in pairs(t) do
table.insert(res, v)
end
end
end
return res
end
function XTool.ReverseList(list)
if not list then
return
end
local length = #list
local middle = math.floor(length * 0.5)
for i = 1, middle do
local reverseI = length - i + 1
local tmp = list[i]
list[i] = list[reverseI]
list[reverseI] = tmp
end
return list
end
XTool.Waterfall = function(cbList)
local last
for i = #cbList, 1, -1 do
if type(cbList[i]) == "function" then
local nextCb = last
local cb = function()
cbList[i](nextCb)
end
last = cb
else
XLog.Error("XTool.Waterfall error, unit is not function")
end
end
if last then
last()
end
end
XTool.InitUiObject = function(targetObj)
targetObj.Obj = targetObj.Transform:GetComponent("UiObject")
if targetObj.Obj ~= nil then
for i = 0, targetObj.Obj.NameList.Count - 1 do
targetObj[targetObj.Obj.NameList[i]] = targetObj.Obj.ObjList[i]
end
end
end
XTool.InitUiObjectByInstance = function(uiObject, instance)
for i = 0, uiObject.NameList.Count - 1 do
instance[uiObject.NameList[i]] = uiObject.ObjList[i]
end
end
XTool.InitUiObjectByUi = function(targetUi, uiPrefab)
targetUi.GameObject = uiPrefab.gameObject
targetUi.Transform = uiPrefab.transform
XTool.InitUiObject(targetUi)
return targetUi
end
XTool.DestroyChildren = function(gameObject)
if not gameObject then
return
end
if XTool.UObjIsNil(gameObject) then
return
end
local transform = gameObject.transform
for i = 0, transform.childCount - 1, 1 do
CS.UnityEngine.Object.Destroy(transform:GetChild(i).gameObject)
end
end
XTool.IsTableEmpty = function(tb)
return not tb or not next(tb)
end
XTool.IsNumberValid = function(number)
return number and number ~= 0 or false
end
XTool.GetStackTraceName = function(level)
level = level or 3
local info
for i = level, 2, -1 do
info = debug.getinfo(i)
if info then
break
end
end
local name = "lua:" .. tostring(info.source) .. "_" .. tostring(info.currentline)
return name
end
-- datas : 只接受数组
XTool.TableRemove = function(datas, removeValue)
local removePos = nil
for index, value in ipairs(datas) do
if value == removeValue then
removePos = index
break
end
end
if removePos then
table.remove(datas, removePos)
end
end
-- 直接使用getRoundingValue
-- 保留digit位小数
XTool.MathGetRoundingValue = function(value, digit)
return math.floor(value * XTool.MathPow(10, digit)) / XTool.MathPow(10, digit)
end
-- 直接使用math.pow
XTool.MathPow = function(a, b)
return a ^ b
end
--==================
--将utf8字符转换为unicode编码格式对应的十进制数值
--==================
XTool.Utf8_to_unicode = function(convertStr)
if type(convertStr) ~= "string" then
return convertStr
end
local resultDec = 0
local i = 1
local num1 = string.byte(convertStr, i)
if num1 ~= nil then
local tempVar1, tempVar2 = 0, 0
if num1 >= 0x00 and num1 <= 0x7f then
tempVar1 = num1
tempVar2 = 0
elseif num1 & 0xe0 == 0xc0 then
local t1 = 0
local t2 = 0
t1 = num1 & 0xff >> 3
i = i + 1
num1 = string.byte(convertStr, i)
t2 = num1 & 0xff >> 2
tempVar1 = t2 | ((t1 & (0xff >> 6)) << 6)
tempVar2 = t1 >> 2
elseif num1 & 0xf0 == 0xe0 then
local t1 = 0
local t2 = 0
local t3 = 0
t1 = num1 & (0xff >> 3)
i = i + 1
num1 = string.byte(convertStr, i)
t2 = num1 & (0xff >> 2)
i = i + 1
num1 = string.byte(convertStr, i)
t3 = num1 & (0xff >> 2)
tempVar1 = ((t2 & (0xff >> 6)) << 6) | t3
tempVar2 = (t1 << 4) | (t2 >> 2)
end
resultDec = tempVar2 * 256 + tempVar1
end
return resultDec
end
--==================
--提取字符串中的英文和汉字文本
--==================
XTool.GetPureStr = function(str)
if str == nil then
return nil
end
local resultChar = {}
for i = 1, #str do
local curByte = string.byte(str, i)
local byteCount = 1
if curByte > 239 then
byteCount = 4
elseif curByte > 223 then
byteCount = 3
elseif curByte > 128 then
byteCount = 2
else
byteCount = 1
end
local subStr = string.sub(str, i, i + byteCount - 1)
local charUnicodeNum = XTool.Utf8_to_unicode(subStr)
--
--[[if curByte == 32 or --空格
(curByte > 47 and curByte < 58) or --数字
(curByte > 96 and curByte < 123) or --小写字母
(curByte > 64 and curByte < 91) --大写字母
]] if
(curByte > 96 and curByte < 123) or (curByte > 64 and curByte < 91) or
(charUnicodeNum >= 19968 and charUnicodeNum <= 40891)
then --汉字/u4E00 -- /u9fbb
table.insert(resultChar, subStr)
end
i = i + byteCount
if i > #str then
return table.concat(resultChar)
end
end
return nil
end
--随机打乱
XTool.RandomBreakTableOrder = function(t)
local index
local temp
local total = #t
for i = 1, total, 1 do
for j = i + 1, total, 1 do
index = math.random(j, total)
temp = t[i]
t[i] = t[index]
t[index] = temp
break
end
end
return t
end
--权重随机算法输入带有Weight字段的元素组 输出:加权后的随机元素)
XTool.WeightRandomSelect = function(elements, isNotSetRandomseed)
local sum = 0
for _, v in ipairs(elements) do
sum = sum + v.Weight
end
if not isNotSetRandomseed then
math.randomseed(os.time())
end
local compareWeight = math.random(1, sum)
local index = 1
while sum > 0 do
sum = sum - elements[index].Weight
if sum < compareWeight then
return elements[index]
end
index = index + 1
end
XLog.Error("compare error, return nil")
return nil
end
-- 权重随机算法(输入:权重数组 输出加权后的随机index
XTool.RandomSelectByWeightArray = function(weights)
local sum = 0
for i = 1, #weights do
sum = sum + weights[i]
end
math.randomseed(os.time())
local compareWeight = math.random(1, sum)
local index = 1
while sum > 0 do
sum = sum - weights[index]
if sum < compareWeight then
return index
end
index = index + 1
end
XLog.Error("compare error, return nil")
return nil
end
--从1-limit之间获取指定count不重复随机数
function XTool.GetRandomNumbers(limit, count)
local result = {}
for i = 1, limit do
tableInsert(result, i)
end
local num, tmp
math.randomseed(os.time())
for i = 1, limit do
num = math.random(1, limit)
tmp = result[i]
result[i] = result[num]
result[num] = tmp
end
if count then
for i = count + 1, limit do
result[i] = nil
end
end
return result
end
XTool.ResetInitSchedule = function()
XTool.__InitSchedule = nil
end
--[[
使
1.,
2.使
]]
XTool.CallFunctionOnNextFrame = function(callback, caller, ...)
return XTool._RegisterFunctionOnNextFrame(callback, caller, ...)
end
XTool._RegisterFunctionOnNextFrame = function(callback, caller, ...)
if callback == nil then
return false
end
if not XTool._IsAutoRefreshOnNextFrame then
if caller then
callback(caller, ...)
else
callback(...)
end
return true
end
XTool._FunctionsOnNextFrame = XTool._FunctionsOnNextFrame or {}
local callerData
-- 分开处理避免两个不同的类调用同一个方法导致其中一个调用缺失
if caller then
callerData = XTool._FunctionsOnNextFrame[caller] or {}
callerData[callback] = {caller, ...}
XTool._FunctionsOnNextFrame[caller] = callerData
else
callerData = XTool._FunctionsOnNextFrame["STATIC"] or {}
callerData[callback] = {...}
XTool._FunctionsOnNextFrame["STATIC"] = callerData
end
if not XTool.__InitSchedule then
XTool.__InitSchedule = true
XScheduleManager.ScheduleForever(XTool._AutoRefreshOnNextFrame, 0, 0)
end
return true
end
XTool._AutoRefreshOnNextFrame = function()
if XTool.IsTableEmpty(XTool._FunctionsOnNextFrame) then
return
end
for key, callbackDic in pairs(XTool._FunctionsOnNextFrame) do
for callback, args in pairs(callbackDic) do
callback(table.unpack(args))
end
XTool._FunctionsOnNextFrame[key] = nil
end
end
XTool.ConnectSignal = function(source, path, event, callback, caller, returnArgKey)
local controlVar = XTool._CheckSignalPath(source, path, event, callback, caller)
if not controlVar then
return
end
if caller == nil then
caller = source
end
return XTool._ConnectSignal(controlVar, path, event, callback, caller, returnArgKey)
end
XTool.ConnectSignals = function(source, path, event, callback, caller)
local controlVar = XTool._CheckSignalPath(source, path, event, callback, caller)
if not controlVar then
return
end
if caller == nil then
caller = source
end
local result = {}
for _, var in ipairs(controlVar) do
table.insert(result, XTool._ConnectSignal(var, path, event, callback, caller))
end
return result
end
XTool._CheckSignalPath = function(source, path, event, callback, caller)
local varNames = string.Split(path, "/")
local controlVar = source
for _, v in ipairs(varNames) do
controlVar = controlVar[v]
if controlVar == nil then
XLog.Error("信号连接失败,请检查路径:", path)
return
end
end
return controlVar
end
XTool._ConnectSignal = function(controlVar, path, event, callback, caller, returnArgKey)
local signalData = controlVar.SignalData
if signalData == nil and CheckClassSuper(controlVar, XSignalData) then
signalData = controlVar
end
if not signalData then
XLog.Error("信号连接失败,查找对象不属于信号数据:", path)
return
end
signalData:ConnectSignal(event, caller, callback, returnArgKey)
return signalData
end
XTool.RegisterSignalWrap = function(source)
local wrapResult = {}
setmetatable(
wrapResult,
{
__index = function(_, k)
return source[k]
end
}
)
wrapResult.SignalData = XSignalData.New()
wrapResult.__Source = source
return wrapResult
end
XTool.GetTableNameByTablePath = function(tablePath)
local tableParts = string.Split(tablePath, "/")
return string.gsub(tableParts[#tableParts], ".tab", "")
end
--字符串转为Vector3 格式为 x|y|z
XTool.ConvertStringToVector3 = function(str)
local values = string.Split(str,"|")
local x = 0
local y = 0
local z = 0
if values[1] then
x = tonumber(values[1])
end
if values[2] then
y = tonumber(values[2])
end
if values[3] then
z = tonumber(values[3])
end
return CS.UnityEngine.Vector3(x, y, z)
end
XTool.Random = function(a, b)
if nil ~= a and nil ~= b then
if math.round(a) ~= a or math.round(b) ~= b then
return a + math.random() * (b - a)
end
if a > b then
XLog.Warning("math.random param b must be bigger than param a")
end
return math.random(a, b)
elseif nil ~= a then
return math.random(a)
end
return math.random()
end
-- 循坏分割字符串
XTool.LoopSplitStr = function(content, splitStr, splitLen)
local totalLenght = string.Utf8Len(content)
if totalLenght <= splitLen then
return content
end
local result = string.Utf8Sub(content, 1, splitLen)
local remaind = string.Utf8Sub(content, splitLen + 1, totalLenght - splitLen)
result = result .. splitStr .. XTool.LoopSplitStr(remaind, splitStr, splitLen)
return result
end

View file

@ -0,0 +1,56 @@
XUiGravity = XClass(XLuaBehaviour, "XUiGravity")
-- 范围(防止画面抖动)
local range = 0.01
function XUiGravity:Ctor(rootUi, ui, minX, maxX, minY, maxY)
self.minX = minX
self.maxX = maxX
self.minY = minY
self.maxY = maxY
self.lastAttitude = CS.UnityEngine.Vector3.zero
self.testV = 0
self.testSpeed = 0.01
end
function XUiGravity:Start()
CS.UnityEngine.Input.gyro.enabled = true
end
function XUiGravity:Update()
self.testV = self.testV + self.testSpeed
if self.testV > 1 then
self.testSpeed = -0.01
elseif self.testV < -1 then
self.testSpeed = 0.01
end
local transform = self.Transform
-- local attitude = CS.UnityEngine.Vector3(CS.UnityEngine.Input.gyro.attitude.x, CS.UnityEngine.Input.gyro.attitude.y, 0)
local attitude = CS.UnityEngine.Vector3(self.testV, 0, 0)
--使安全范围内 - 1之1
attitude.x = XMath.Clamp(attitude.x, -1, 1);
attitude.y = XMath.Clamp(attitude.y, -1, 1);
local x = transform.localPosition.x
local y = transform.localPosition.y
local isDirty = false
if math.abs(self.lastAttitude.x - attitude.x) >= range then
isDirty = true
local direction = attitude.x - self.lastAttitude.x
local position = direction * (self.maxX - self.minX) / 2
x = XMath.Clamp(transform.localPosition.x - position, self.minX, self.maxX);
self.lastAttitude = attitude
end
if math.abs(self.lastAttitude.y - attitude.y) >= range then
isDirty = true
local direction = attitude.y - self.lastAttitude.y
local position = direction * (self.maxY - self.minY) / 2
y = XMath.Clamp(transform.localPosition.y - position, self.minY, self.maxY);
self.lastAttitude = attitude
end
if isDirty then
transform.localPosition = CS.UnityEngine.Vector3(x, y, transform.localPosition.z);
end
end
return XUiGravity

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,140 @@
XAccumulatedConsumeConfig = XAccumulatedConsumeConfig or {}
local SHARE_CONSUME_DRAW_ACTIVITY = "Share/MiniActivity/AccumulatedConsumeDraw/AccumulatedConsumeDrawActivity.tab"
local SHARE_CONSUME_DRAW_REWARD = "Share/MiniActivity/AccumulatedConsumeDraw/AccumulatedConsumeDrawReward.tab"
local CLIENT_CONSUME_DRAW_ACTIVITY_DETAIL = "Client/MiniActivity/AccumulatedConsumeDraw/AccumulatedConsumeDrawActivityDetail.tab"
local CLIENT_CONSUME_DRAW_EXCHANGE_ICON = "Client/MiniActivity/AccumulatedConsumeDraw/AccumulatedConsumeDrawExchangeIcon.tab"
local CLIENT_CONSUME_DRAW_PROB_SHOW = "Client/MiniActivity/AccumulatedConsumeDraw/AccumulatedConsumeDrawProbShow.tab"
local CLIENT_CONSUME_DRAW_RULE = "Client/MiniActivity/AccumulatedConsumeDraw/AccumulatedConsumeDrawRule.tab"
local CLIENT_CONSUME_DRAW_REWARD_TYPE = "Client/MiniActivity/AccumulatedConsumeDraw/AccumulatedConsumeDrawRewardType.tab"
local ConsumeDrawActivity = {}
local ConsumeDrawReward = {}
local ConsumeDrawActivityDetail = {}
local ConsumeDrawProbShow = {}
local ConsumeDrawRule = {}
local ConsumeDrawRewardType = {}
function XAccumulatedConsumeConfig.Init()
ConsumeDrawActivity = XTableManager.ReadByIntKey(SHARE_CONSUME_DRAW_ACTIVITY, XTable.XTableAccumulatedConsumeDrawActivity, "Id")
ConsumeDrawReward = XTableManager.ReadByIntKey(SHARE_CONSUME_DRAW_REWARD, XTable.XTableAccumulatedConsumeDrawReward, "ActId")
ConsumeDrawActivityDetail = XTableManager.ReadByIntKey(CLIENT_CONSUME_DRAW_ACTIVITY_DETAIL, XTable.XTableAccumulatedConsumeDrawActivityDetail, "Id")
ConsumeDrawProbShow = XTableManager.ReadByIntKey(CLIENT_CONSUME_DRAW_PROB_SHOW, XTable.XTableAccumulatedConsumeDrawProbShow, "Id")
ConsumeDrawRule = XTableManager.ReadByIntKey(CLIENT_CONSUME_DRAW_RULE, XTable.XTableAccumulatedConsumeDrawRule, "DrawId")
ConsumeDrawRewardType = XTableManager.ReadByIntKey(CLIENT_CONSUME_DRAW_REWARD_TYPE, XTable.XTableAccumulatedConsumeDrawRewardType, "RewardType")
XConfigCenter.CreateGetPropertyByFunc(XAccumulatedConsumeConfig, "ConsumeDrawExchangeConfig", function()
return XTableManager.ReadByStringKey(CLIENT_CONSUME_DRAW_EXCHANGE_ICON, XTable.XTableAccumulatedConsumeDrawExchangeIcon, "Key")
end)
end
--region AccumulatedConsumeDrawActivity.tab
local function GetConsumeDrawActivity(id)
local config = ConsumeDrawActivity[id]
if not config then
XLog.Error("XAccumulatedConsumeConfig GetConsumeDrawActivity error:配置不存在Id:" .. id .. ",Path:" .. SHARE_CONSUME_DRAW_ACTIVITY)
return
end
return config
end
function XAccumulatedConsumeConfig.GetDrawActivity(id)
return GetConsumeDrawActivity(id)
end
--endregion
--region AccumulatedConsumeDrawReward.tab
local function GetConsumeDrawReward(actId)
local config = ConsumeDrawReward[actId]
if not config then
XLog.Error("XAccumulatedConsumeConfig GetConsumeDrawReward error:配置不存在ActId:" .. actId .. ",Path:" .. SHARE_CONSUME_DRAW_REWARD)
return
end
return config
end
function XAccumulatedConsumeConfig.GetDrawReward(actId)
return GetConsumeDrawReward(actId)
end
--endregion
--region AccumulatedConsumeDrawActivityDetail.tab
local function GetConsumeDrawActivityDetail(id)
local config = ConsumeDrawActivityDetail[id]
if not config then
XLog.Error("XAccumulatedConsumeConfig GetConsumeDrawActivityDetail error:配置不存在id:" .. id .. ",Path:" .. CLIENT_CONSUME_DRAW_ACTIVITY_DETAIL)
return
end
return config
end
function XAccumulatedConsumeConfig.GetDrawActivityDetail(id)
return GetConsumeDrawActivityDetail(id)
end
--endregion
--region AccumulatedConsumeDrawProbShow.tab
function XAccumulatedConsumeConfig.GetDrawProbShowByDrawId(drawId)
local config = {}
for _, pronShow in pairs(ConsumeDrawProbShow) do
if pronShow.DrawId == drawId then
table.insert(config, pronShow)
end
end
table.sort(config, function(a, b)
return a.Id < b.Id
end)
return config
end
--endregion
--region AccumulatedConsumeDrawRule.tab
local function GetConsumeDrawRule(drawId)
local config = ConsumeDrawRule[drawId]
if not config then
XLog.Error("XAccumulatedConsumeConfig GetConsumeDrawRule error:配置不存在drawId:" .. drawId .. ",Path:" .. CLIENT_CONSUME_DRAW_RULE)
return
end
return config
end
function XAccumulatedConsumeConfig.GetDrawRule(drawId)
return GetConsumeDrawRule(drawId)
end
--endregion
function XAccumulatedConsumeConfig.GetDrawRewardTypeConfig()
return ConsumeDrawRewardType
end
function XAccumulatedConsumeConfig.GetDefaultActivityId()
local defaultActivityId = 0
for activityId, config in pairs(ConsumeDrawActivity) do
defaultActivityId = activityId
if XTool.IsNumberValid(config.TimeId) and XFunctionManager.CheckInTimeByTimeId(config.TimeId) then
break
end
end
return defaultActivityId
end
function XAccumulatedConsumeConfig.GetConsumeSpecialIcons()
return XAccumulatedConsumeConfig.GetConsumeDrawExchangeConfig("ConsumeIcons").Values
end
function XAccumulatedConsumeConfig.GetTargetIcon()
return XAccumulatedConsumeConfig.GetConsumeDrawExchangeConfig("TargetIcon").Values[1]
end

View file

@ -0,0 +1,114 @@
--==================
--成就系统相关配置表
--模块负责:吕天元
--==================
XAchievementConfigs = XAchievementConfigs or {}
--================================================================
-- 配置表地址 --
--================================================================
local SHARE_TABLE_PATH = "Share/Achievement/"
local CLIENT_TABLE_PATH = "Client/Achievement/"
local TABLE_ACHIEVEMENT_BASETYPE = CLIENT_TABLE_PATH .. "AchievementBaseTypeInfo.tab"
local TABLE_ACHIEVEMENT_TYPE = CLIENT_TABLE_PATH .. "AchievementTypeInfo.tab"
--local TABLE_REVIEW_ACTIVITY_INFO = CLIENT_TABLE_PATH .. "ReviewActivityInfo.tab"
local TABLE_ACHIEVEMENT = SHARE_TABLE_PATH .. "Achievement.tab"
--local TABLE_REVIEW_ACTIVITY = SHARE_TABLE_PATH .. "ReviewActivity.tab"
--=================================================
--=================================================
local Configs = {}
--=============
--配置表枚举
--Id : 枚举Id
--Path : 关联的表地址 (日志中使用)
--Key : 要检查的字段名 (日志中使用)
--=============
XAchievementConfigs.TableKey = {
AchievementBaseType = {Id = 1, Path = TABLE_ACHIEVEMENT_BASETYPE}, --成就基础类型配置
AchievementType = {Id = 2, Path = TABLE_ACHIEVEMENT_TYPE}, --成就类型配置
--ReviewActivityInfo = {Id = 3, Path = TABLE_REVIEW_ACTIVITY_INFO}, --回顾活动文本信息
Achievement = {Id = 3, Path = TABLE_ACHIEVEMENT}, --成就表配置
--ReviewActivity = {Id = 5, Path = TABLE_REVIEW_ACTIVITY}, --回顾活动配置
Type2AchievementDic = {Id = 4, Path = TABLE_ACHIEVEMENT, Key = "AchievementTypeId"}, --
BaseId2AchievementTypeDic = {Id = 5, Path = TABLE_ACHIEVEMENT_TYPE, Key = "BaseTypeId"}
}
--=============
--初始化BaseTypeId -> 成就类型字典
--=============
local InitBaseId2AchievementTypeDic = function()
local tableId = XAchievementConfigs.TableKey.BaseId2AchievementTypeDic.Id
Configs[tableId] = {}
for _, cfg in pairs (XAchievementConfigs.GetAllConfigs(XAchievementConfigs.TableKey.AchievementType) or {}) do
local id = cfg.BaseTypeId
if not Configs[tableId][id] then Configs[tableId][id] = {} end
table.insert(Configs[tableId][id], cfg)
end
end
--=============
--初始化TypeId -> 成就类型字典
--=============
local InitType2AchievementDic = function()
local tableId = XAchievementConfigs.TableKey.Type2AchievementDic.Id
Configs[tableId] = {}
for _, cfg in pairs (XAchievementConfigs.GetAllConfigs(XAchievementConfigs.TableKey.Achievement) or {}) do
local id = cfg.AchievementTypeId
if not Configs[tableId][id] then Configs[tableId][id] = {} end
table.insert(Configs[tableId][id], cfg)
end
end
--=============
--初始化所有配置表和字典
--=============
function XAchievementConfigs.Init()
Configs[XAchievementConfigs.TableKey.AchievementBaseType.Id] = XTableManager.ReadByIntKey(TABLE_ACHIEVEMENT_BASETYPE, XTable.XTableAchievementBaseTypeInfo, "Id")
Configs[XAchievementConfigs.TableKey.AchievementType.Id] = XTableManager.ReadByIntKey(TABLE_ACHIEVEMENT_TYPE, XTable.XTableAchievementTypeInfo, "Id")
--Configs[XAchievementConfigs.TableKey.ReviewActivityInfo.Id] = XTableManager.ReadByStringKey(TABLE_REVIEW_ACTIVITY_INFO, XTable.XTableReviewActivityInfo, "Key")
Configs[XAchievementConfigs.TableKey.Achievement.Id] = XTableManager.ReadByIntKey(TABLE_ACHIEVEMENT, XTable.XTableAchievement, "Id")
--Configs[XAchievementConfigs.TableKey.ReviewActivity.Id] = XTableManager.ReadByIntKey(TABLE_REVIEW_ACTIVITY, XTable.XTableReviewActivity, "Id")
InitBaseId2AchievementTypeDic()
InitType2AchievementDic()
end
--=============
--给定配置表Key获取该配置表全部配置
--@tableKey : XAchievementConfigs.TableKey枚举项
--=============
function XAchievementConfigs.GetAllConfigs(tableKey)
if not tableKey or not tableKey.Id then
XLog.Error("The tableKey given is not exist. tableKey : " .. tostring(tableKey))
return {}
end
return Configs[tableKey.Id]
end
--=============
--给定配置表Key和Id获取该配置表指定Id的配置
--@params:
--tableKey : XAchievementConfigs.TableKey枚举项
--idKey : 该配置表的主键Id或Key
--noTips : 若没有查找到对应项,是否要打印错误日志
--=============
function XAchievementConfigs.GetCfgByIdKey(tableKey, idKey, noTips)
if not tableKey or not idKey then
if not noTips then
XLog.Error("XAchievementConfigs.GetCfgByIdKey error: tableKey or idKey is null!")
end
return {}
end
local allCfgs = XAchievementConfigs.GetAllConfigs(tableKey)
if not allCfgs then
return {}
end
local cfg = allCfgs[idKey]
if not cfg then
if not noTips then
XLog.ErrorTableDataNotFound(
"XAchievementConfigs.GetCfgByIdKey",
tableKey.Key or "唯一Id",
tableKey.Path,
tableKey.Key or "唯一Id",
tostring(idKey))
end
return {}
end
return cfg
end

View file

@ -0,0 +1,252 @@
local TABLE_ACTIVITY_PATH = "Client/ActivityBrief/ActivityBrief.tab"
local TABLE_ACTIVITY_SHOP = "Client/ActivityBrief/ActivityBriefShop.tab"
local TABLE_ACTIVITY_TASK = "Client/ActivityBrief/ActivityBriefTask.tab"
local TABLE_ACTIVITY_GROUP_PATH = "Client/ActivityBrief/ActivityBriefGroup.tab"
local TABLE_ACTIVITY_SPECIAL = "Client/ActivityBrief/SpecialActivity.tab"
local TABLE_ACTIVITY_Story = "Share/ActivityBrief/ActivityBriefStory.tab"
local ParseToTimestamp = XTime.ParseToTimestamp
local ActivityTemplates = {}
local ActivityShopTemplates = {}
local ActivityTaskTemplates = {}
local ActivityGroupTemplates = {}
local SpecialActivityTemplates = {}
local ActivityStoryTemplates = {}
local SkipIdToRedPointConditionsDic = {}
XActivityBriefConfigs = XActivityBriefConfigs or {}
-- 活动名称Id有需要新增勿删改
XActivityBriefConfigs.ActivityGroupId = {
MainLine = 1, --主线活动
Branch = 2, --支线活动
BossSingle = 3, --单机Boss活动
BossOnline = 4, --联机Boss活动
Prequel = 5, --间章故事-角色A
BabelTower = 6, --巴别塔
RougueLike = 7, --爬塔
RepeatChallenge = 8, --复刷关
ArenaOnline = 9, --区域联机
UnionKill = 10, --狙击战
ShortStories = 11, --短篇故事
Prequel2 = 12, --间章故事-角色B
Labyrinth = 13, --迷宫
Society = 14, --公会
Resource = 15, --资源
BigWar = 16, --大作战
Extra = 17, --番外-普通
WorldBoss = 18, --世界Boss
Expedition = 19, --自走棋
FubenBossSingle = 20, --幻痛囚笼
ActivityBriefShop = 21, --活动商店
Extra2 = 22, --番外-隐藏
MaintainerAction = 23, --大富翁
RpgTower = 24, --RPG玩法
ActivityDrawCard = 25, --活动抽卡
TRPGMainLine = 26, --终焉福音-主线跑团活动
NewCharActivity = 27, -- 新角色教学活动
FubenActivityTrial = 28, -- 试玩关
ShiTu = 29, -- 师徒系统
Nier = 30, -- 尼尔玩法
Pokemon = 31, -- 口袋战双
Pursuit = 32, -- 追击玩法
StrongHold = 33, --超级据点
Simulate = 34, -- 模拟战
Partner = 35, --伙伴系统
MoeWar = 38, --萌战
PetCard = 39, --宠物抽卡
PetTrial = 40, --新宠物活动
PokerGuessing = 41, --翻牌小游戏
Hack = 42, --骇客
RpgMaker = 43, --端午活动
Reform = 44, --改造玩法
CoupleCombat = 45, --双人同行
SuperTower = 46, --超级爬塔
SummerSeries = 47, --夏活系列关
KillZone = 48, --杀戮无双
Expedition = 49, --虚像地平线
SameColorGame = 50, --三消游戏
AreaWar = 51, --全服对决
SuperSmashBros = 52, --超限乱斗
TeachingSkin = 53, --教学关内涂装试玩
Maverick = 54, --射击玩法 异构阵线
MemorySave = 55, --意识营救战
Theatre = 56, --肉鸽玩法
DoomsDay = 57, --免疫之城
PivotCombat = 58, --Sp战力验证
Escape = 59, --大逃杀玩法
FubenShortStory = 60, --故事集
DoubleTowers = 61, --动作塔防
SecondActivityBriefShop = 62, --活动商店
SecondBriefPanel = 63, --副面板
GuildWar = 64, --工会战
GoldenMiner = 65, --黄金矿工
QiGuan = 66, --春节七关
TaikoMaster = 67, -- 音游小游戏
MultiDim = 68, -- 多维挑战
Festival = 69, -- 节日活动 v1.27:白色情人节
}
--跳转id
XActivityBriefConfigs.SkipId =
{
LivWarmExtActivity = 11767, --丽芙宣发活动
LivWarmRace = 20097, --二周年预热-赛跑小游戏
Doomsday = 82050, --免疫之城
NewYearLuck = 20112, --元旦奖券小游戏
BodyCombineGame = 20118, --接头霸王(哈卡玛预热小游戏)
AccumulateConsume = 20120, --累消活动
WhiteValentine = 20133, --白情活动
InvertCardGame = 20134, --翻牌小游戏(二期)
MineSweepingGame = 20140, --扫雷小游戏
}
local InitSkipIdToRedPointConditionsDic = function()
SkipIdToRedPointConditionsDic[11739] = {XRedPointConditions.Types.CONDITION_GUARD_CAMP_RED}
SkipIdToRedPointConditionsDic[80011] = {XRedPointConditions.Types.CONDITION_WHITEVALENTINE2021_ENTRYRED}
SkipIdToRedPointConditionsDic[11753] = {XRedPointConditions.Types.CONDITION_FINGERGUESSING_TASK}
SkipIdToRedPointConditionsDic[11757] = {XRedPointConditions.Types.CONDITION_MOVIE_ASSEMBLE_01}
SkipIdToRedPointConditionsDic[11761] = {XRedPointConditions.Types.CONDITION_FASHION_STORY_HAVE_STAGE}
SkipIdToRedPointConditionsDic[81103] = {XRedPointConditions.Types.CONDITION_RPG_MAKER_GAME_RED}
SkipIdToRedPointConditionsDic[20091] = {XRedPointConditions.Types.CONDITION_LIV_WARM_ACTIVITY}
SkipIdToRedPointConditionsDic[20107] = {XRedPointConditions.Types.CONDITION_DICEGAME_RED}
SkipIdToRedPointConditionsDic[XActivityBriefConfigs.SkipId.LivWarmExtActivity] = {XRedPointConditions.Types.CONDITION_LIV_WARM_EXT_ACTIVITY}
SkipIdToRedPointConditionsDic[XActivityBriefConfigs.SkipId.LivWarmRace] = {XRedPointConditions.Types.CONDITION_LIV_WARM_RACE_REWARD}
SkipIdToRedPointConditionsDic[XActivityBriefConfigs.SkipId.Doomsday] = {XRedPointConditions.Types.XRedPointConditionDoomsdayActivity}
SkipIdToRedPointConditionsDic[XActivityBriefConfigs.SkipId.NewYearLuck] = {XRedPointConditions.Types.CONDITION_NEW_YEAR_LUCK_RULE_RED}
SkipIdToRedPointConditionsDic[XActivityBriefConfigs.SkipId.BodyCombineGame] = {XRedPointConditions.Types.CONDITION_BODYCOMBINEGAME_MAIN}
SkipIdToRedPointConditionsDic[XActivityBriefConfigs.SkipId.AccumulateConsume] = {XRedPointConditions.Types.CONDITION_CONSUME_ACTIVITY}
SkipIdToRedPointConditionsDic[XActivityBriefConfigs.SkipId.WhiteValentine] = {XRedPointConditions.Types.CONDITION_ACTIVITY_WHITE_VALENTINE}
SkipIdToRedPointConditionsDic[XActivityBriefConfigs.SkipId.InvertCardGame] = {XRedPointConditions.Types.CONDITION_INVERTCARDGAME_RED}
SkipIdToRedPointConditionsDic[XActivityBriefConfigs.SkipId.MineSweepingGame] = {XRedPointConditions.Types.CONDITION_MINSWEEPING_RED}
SkipIdToRedPointConditionsDic[1400008] = {XRedPointConditions.Types.CONDITION_SLOTMACHINE_RED}
SkipIdToRedPointConditionsDic[1400009] = {XRedPointConditions.Types.CONDITION_SLOTMACHINE_REDL}
end
function XActivityBriefConfigs.Init()
ActivityTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_PATH, XTable.XTableBriefActivity, "Id")
ActivityShopTemplates= XTableManager.ReadByIntKey(TABLE_ACTIVITY_SHOP, XTable.XTableActivityBriefShop, "Id")
ActivityTaskTemplates= XTableManager.ReadByIntKey(TABLE_ACTIVITY_TASK, XTable.XTableActivityBriefTask, "Id")
ActivityGroupTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_GROUP_PATH, XTable.XTableActivityBriefGroup, "Id")
SpecialActivityTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_SPECIAL, XTable.XTableSpecialActivity, "Id")
ActivityStoryTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_Story, XTable.XTableActivityBriefStory, "Id")
InitSkipIdToRedPointConditionsDic()
end
function XActivityBriefConfigs.GetActivityBeginTime()
local config = XActivityBriefConfigs.GetActivityConfig()
return XFunctionManager.GetStartTimeByTimeId(config.TimeId)
end
function XActivityBriefConfigs.GetActivityEndTime()
local config = XActivityBriefConfigs.GetActivityConfig()
return XFunctionManager.GetEndTimeByTimeId(config.TimeId)
end
function XActivityBriefConfigs.GetActivityConfig()
return ActivityTemplates[1]
end
function XActivityBriefConfigs.GetActivityModels()
local config = XActivityBriefConfigs.GetActivityConfig()
return config.UIModelId or {}
end
function XActivityBriefConfigs.GetSpinePath(index)
local config = XActivityBriefConfigs.GetActivityConfig()
return config.SpinePath[index] or ""
end
--===========================================================================
--v1.27 活动面板优化根据活动主题主副面板Id和SpineIndex获取SpinePath
--===========================================================================
function XActivityBriefConfigs.GetSpinePathByType(panelType, index)
local config = ActivityTemplates[panelType]
return config.SpinePath[index] or ""
end
--===========================================================================
--v1.27 活动面板优化根据活动主题主副面板Id获取当前的 SpinePath List
--===========================================================================
function XActivityBriefConfigs.GetSpinePathList(panelType)
local config = ActivityTemplates[panelType]
return config.SpinePath or {}
end
--===========================================================================
--v1.27 活动面板优化根据活动主题主副面板Id获取当前的 GroupId List
--===========================================================================
function XActivityBriefConfigs.GetGroupIdList(panelType)
local config = ActivityTemplates[panelType]
return config.GroupIdList or ""
end
function XActivityBriefConfigs.GetActivityEntrySkipId(id)
return SpecialActivityTemplates[id].SkipId
end
function XActivityBriefConfigs.GetAllActivityEntryConfig()
return SpecialActivityTemplates
end
function XActivityBriefConfigs.GetActivityShopByInfoId(id)
return ActivityShopTemplates[id]
end
function XActivityBriefConfigs.GetActivityTaskByInfoId(id)
return ActivityTaskTemplates[id]
end
function XActivityBriefConfigs.GetActivityGroupConfig(groupId)
local groupConfig = ActivityGroupTemplates[groupId]
if not groupConfig then
XLog.ErrorTableDataNotFound("XActivityBriefConfigs.GetActivityGroupConfig",
"根据groupId获取的配置表项", TABLE_ACTIVITY_GROUP_PATH, "groupId", tostring(groupId))
return
end
return groupConfig
end
--===========================================================================
--v1.27 活动面板优化根据活动GroupId获取该Btn点击事件绑定函数名
--===========================================================================
function XActivityBriefConfigs.GetActivityGroupBtnInitMethodName(groupId)
local groupConfig = ActivityGroupTemplates[groupId]
if not groupConfig then
XLog.ErrorTableDataNotFound("XActivityBriefConfigs.GetActivityGroupBtnInitMethodName",
"根据groupId获取的配置表项", TABLE_ACTIVITY_GROUP_PATH, "groupId", tostring(groupId))
return
end
return groupConfig.BtnInitMethodName or nil
end
function XActivityBriefConfigs.TestOpenActivity()
local newTemplate = {}
for id, template in pairs(ActivityTemplates) do
if id ~= 1 then
newTemplate[id] = template
else
newTemplate[id] = XTool.Clone(template)
newTemplate[id].TimeId = 24
end
end
ActivityTemplates = newTemplate
end
function XActivityBriefConfigs.GetTableActivityPath()
return TABLE_ACTIVITY_PATH
end
function XActivityBriefConfigs.GetActivityStoryConfig()
return ActivityStoryTemplates
end
function XActivityBriefConfigs.GetActivityBriefGroup(id)
local config = XActivityBriefConfigs.GetActivityGroupConfig(id)
return config.Name
end
function XActivityBriefConfigs.GetRedPointConditionsBySkipId(skipId)
return skipId and SkipIdToRedPointConditionsDic[skipId]
end

View file

@ -0,0 +1,19 @@
XActivityCalendarConfigs = XActivityCalendarConfigs or {}
local ACTIVITY_CALENDAR_PATH = "Client/Calendar/ActivityCalendar.tab"
XActivityCalendarConfigs.ActivityState = {
Lock = 1,
Active = 2,
End = 3
}
local ActivityCalendarConfigs = {}
function XActivityCalendarConfigs.Init()
ActivityCalendarConfigs = XTableManager.ReadByIntKey(ACTIVITY_CALENDAR_PATH,XTable.XTableActivityCalendar,"Id")
end
function XActivityCalendarConfigs.GetActivityConfigs()
return ActivityCalendarConfigs
end

View file

@ -0,0 +1,112 @@
local ParseToTimestamp = XTime.ParseToTimestamp
local TimestampToGameDateTimeString = XTime.TimestampToGameDateTimeString
local TABLE_ACTIVITY_PATH = "Client/Activity/Activity.tab"
local TABLE_ACTIVITY_GROUP_PATH = "Client/Activity/ActivityGroup.tab"
local TABLE_ACTIVITY_LINK_PATH = "Client/Activity/ActivityLink.tab"
local ActivityTemplates = {}
local ActivityGroupTemplates = {}
local ActivityLinkTemplates = {}
XActivityConfigs = XActivityConfigs or {}
--活动类型
XActivityConfigs.ActivityType = {
Task = 1, --任务
Shop = 2, --商店
Skip = 3, --跳转
SendInvitation = 4, --邀请他人
AcceptInvitation = 5, -- 接受邀请
JigsawPuzzle = 6, -- 拼图
Link = 7, --活动外链类型
ConsumeReward = 8, -- 累消奖励
ScratchTicket = 9, -- 普通刮刮乐
ScratchTicketGolden = 10, -- 黄金刮刮乐
}
-- 活动背景类型
XActivityConfigs.ActivityBgType = {
Image = 1, -- 普通图片
Spine = 2, -- Spine动画
}
-- 任务面板跳转类型
XActivityConfigs.TaskPanelSkipType = {
CanZhangHeMing_Qu = 20031, -- 拼图游戏(曲版本预热)
CanZhangHeMing_LuNa = 20036, -- 拼图游戏(露娜预热)
ChrismasTree_Dress = 20048, -- 装点圣诞树小游戏
Couplet_Game = 20064, -- 春节对联游戏
CanZhangHeMing_SP = 20070, -- 拼图游戏(SP角色预热)
InvertCard_Game = 20076, -- 翻牌小游戏
LivWarmPop_Game = 20091, -- 消消乐
DiceGame = 20107,
BodyCombineGame = 20118, -- 接头霸王(哈卡玛预热)
InvertCardGame2 = 20134, --翻牌小游戏(二期)
}
function XActivityConfigs.Init()
ActivityTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_PATH, XTable.XTableActivity, "Id")
ActivityGroupTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_GROUP_PATH, XTable.XTableActivityGroup, "Id")
ActivityLinkTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_LINK_PATH, XTable.XTableActivityLink, "Id")
end
function XActivityConfigs.GetActivityTemplates()
return ActivityTemplates
end
function XActivityConfigs.GetActivityGroupTemplates()
return ActivityGroupTemplates
end
function XActivityConfigs.GetActivityTemplate(activityId)
return ActivityTemplates[activityId]
end
function XActivityConfigs.GetActivityTimeStr(activityId, beginTime, endTime)
local activityCfg = XActivityConfigs.GetActivityTemplate(activityId)
local format = "yyyy-MM-dd HH:mm"
local beginTimeStr = ""
local endTimeStr = ""
if not string.IsNilOrEmpty(activityCfg.ShowBeginTime) then
beginTimeStr = activityCfg.ShowBeginTime
else
if beginTime and beginTime ~= 0 then
beginTimeStr = TimestampToGameDateTimeString(beginTime, format)
else
beginTimeStr = TimestampToGameDateTimeString(XFunctionManager.GetStartTimeByTimeId(activityCfg.TimeId), format)
end
end
if not string.IsNilOrEmpty(activityCfg.ShowEndTime) then
endTimeStr = activityCfg.ShowEndTime
else
if endTime and endTime ~= 0 then
endTimeStr = TimestampToGameDateTimeString(endTime, format)
else
endTimeStr = TimestampToGameDateTimeString(XFunctionManager.GetEndTimeByTimeId(activityCfg.TimeId), format)
end
end
if not string.IsNilOrEmpty(beginTimeStr) and not string.IsNilOrEmpty(endTimeStr) then
return beginTimeStr .. "~" .. endTimeStr
else
if not string.IsNilOrEmpty(beginTimeStr) then
return beginTimeStr
elseif not string.IsNilOrEmpty(endTimeStr) then
return endTimeStr
else
return ""
end
end
end
function XActivityConfigs.GetActivityLinkCfg(id)
return ActivityLinkTemplates[id]
end
function XActivityConfigs.GetActivityLinkTemplate()
return ActivityLinkTemplates
end

View file

@ -0,0 +1,9 @@
--
-- Author: wujie
-- Note: app lua层配置相关
XAppConfigs = XAppConfigs or {}
XAppConfigs.PackageName = {
Hero = "com.kurogame.haru.hero",
}

View file

@ -0,0 +1,919 @@
--
-- Author: zhangshuang、wujie
-- Note: 图鉴配置相关
XArchiveConfigs = XArchiveConfigs or {}
XArchiveConfigs.SubSystemType = {
Monster = 1,
Weapon = 2,
Awareness = 3,
Story = 4,
CG = 5,
NPC = 6,
Email = 7,
Partner = 8,
PV = 9,
}
XArchiveConfigs.SettingType = {
All = 0,
Setting = 1,
Story = 2,
}
-- 设定位置
XArchiveConfigs.SettingIndex = {
First = 1,
}
XArchiveConfigs.WeaponCamera = {
Main = 1, -- 武器详情默认是主镜头
Setting = 2,
}
XArchiveConfigs.MonsterType = {
Pawn = 1,
Elite = 2,
Boss = 3,
}
XArchiveConfigs.MonsterInfoType = {
Short = 1,
Long = 2,
}
XArchiveConfigs.MonsterSettingType = {
Setting = 1,
Story = 2,
}
XArchiveConfigs.MonsterDetailType = {
Synopsis = 1,
Info = 2,
Setting = 3,
Skill = 4,
Zoom = 5,
ScreenShot = 6,
}
XArchiveConfigs.EquipStarType = {
All = 0,
One = 1,
Two = 2,
Three = 3,
Four = 4,
Five = 5,
Six = 6,
}
XArchiveConfigs.EquipLikeType = {
NULL = 0,
Dis = 1,
Like = 2,
}
XArchiveConfigs.StarToQualityName = {
[XArchiveConfigs.EquipStarType.All] = CS.XTextManager.GetText("ArchiveAwarenessFliterAll"),
[XArchiveConfigs.EquipStarType.Two] = CS.XTextManager.GetText("ArchiveAwarenessFliterTwoStar"),
[XArchiveConfigs.EquipStarType.Three] = CS.XTextManager.GetText("ArchiveAwarenessFliterThreeStar"),
[XArchiveConfigs.EquipStarType.Four] = CS.XTextManager.GetText("ArchiveAwarenessFliterFourStar"),
[XArchiveConfigs.EquipStarType.Five] = CS.XTextManager.GetText("ArchiveAwarenessFliterFiveStar"),
[XArchiveConfigs.EquipStarType.Six] = CS.XTextManager.GetText("ArchiveAwarenessFliterSixStar"),
}
XArchiveConfigs.EvaluateOnForAll = CS.XGame.ClientConfig:GetInt("ArchiveEvaluateOnForAll")
XArchiveConfigs.OnForAllState = {
Off = 0,
On = 1,
}
XArchiveConfigs.NpcGridState = {
Open = 0,
Close = 1,
}
XArchiveConfigs.EmailType = {
Email = 1,
Communication = 2,
}
XArchiveConfigs.PartnerSettingType = {
Setting = 1,
Story = 2,
}
XArchiveConfigs.MonsterDetailUiType = {
Default = 1, -- 默认图鉴打开
Show = 2, -- 只负责显示,屏蔽玩家操作
}
XArchiveConfigs.SpecialData = { --特判数据(仅武器天狼星使用)
PayRewardId = 5,
Equip = {--天狼星
ResonanceCount = 0,
Level = 1,
Breakthrough = 0,
Id = 2026003,
},
}
local TABLE_TAG = "Share/Archive/Tag.tab"
local TABLE_ARCHIVE = "Share/Archive/Archive.tab"
local TABLE_MONSTER = "Share/Archive/Monster.tab"
local TABLE_MONSTERINFO = "Share/Archive/MonsterInfo.tab"
local TABLE_MONSTERSKILL = "Share/Archive/MonsterSkill.tab"
local TABLE_MONSTERSETTING = "Share/Archive/MonsterSetting.tab"
local TABLE_SAMENPCGROUP = "Share/Archive/SameNpcGroup.tab"
local TABLE_MONSTERNPCDATA = "Client/Archive/MonsterNpcData.tab"
local TABLE_AWARENESSSETTING = "Share/Archive/AwarenessSetting.tab"
local TABLE_WEAPONSETTING = "Share/Archive/WeaponSetting.tab"
local TABLE_MONSTERMODEL_TRANS = "Client/Archive/MonsterModelTrans.tab"
local TABLE_MONSTER_EFFECT = "Client/Archive/MonsterEffect.tab"
local TABLE_STORYGROUP = "Share/Archive/StoryGroup.tab"
local TABLE_STORYCHAPTER = "Share/Archive/StoryChapter.tab"
local TABLE_STORYDETAIL = "Share/Archive/StoryDetail.tab"
local TABLE_STORYNPC = "Share/Archive/StoryNpc.tab"
local TABLE_STORYNPCSETTING = "Share/Archive/StoryNpcSetting.tab"
local TABLE_CGDETAIL = "Share/Archive/CGDetail.tab"
local TABLE_CGGROUP = "Share/Archive/CGGroup.tab"
local TABLE_ARCHIVEMAIL = "Share/Archive/ArchiveMail.tab"
local TABLE_COMMUNICATION = "Share/Archive/Communication.tab"
local TABLE_EVENTDATEGROUP = "Share/Archive/EventDateGroup.tab"
local TABLE_ARCHIVE_WEAPON_GROUP_PATH = "Client/Archive/ArchiveWeaponGroup.tab"
local TABLE_ARCHIVE_AWARENESS_GROUP_PATH = "Client/Archive/ArchiveAwarenessGroup.tab"
local TABLE_ARCHIVE_AWARENESS_GROUPTYPE_PATH = "Client/Archive/ArchiveAwarenessGroupType.tab"
local TABLE_ARCHIVE_PARTNER_SETTING = "Share/Archive/PartnerSetting.tab"
local TABLE_ARCHIVE_PARTNER = "Client/Archive/ArchivePartner.tab"
local TABLE_ARCHIVE_PARTNER_GROUP = "Client/Archive/ArchivePartnerGroup.tab"
local TABLE_PVDETAIL = "Share/Archive/PVDetail.tab"
local TABLE_PVGROUP = "Client/Archive/PVGroup.tab"
local TABLE_BIRTHDAYPLOT = "Share/BirthdayPlot/BirthdayPlot.tab"
local tableSort = table.sort
local Tags = {}
local Archives = {}
local Monsters = {}
local MonsterInfos = {}
local MonsterSkills = {}
local MonsterSettings = {}
local AwarenessSettings = {}
local WeaponSettings = {}
local SameNpcGroups = {}
local MonsterNpcDatas = {}
local MonsterModelTrans = {}
local MonsterEffects = {}
local StoryGroups = {}
local StoryChapters = {}
local StoryDetails = {}
local StoryNpc = {}
local StoryNpcSetting = {}
local CGGroups = {}
local CGDetails = {}
local ArchiveMails = {}
local ArchiveCommunications = {}
local EventDateGroups = {}
local WeaponGroup = {}
local WeaponTemplateIdToSettingListDic = {}
local ShowedWeaponTypeList = {}
local WeaponTypeToIdsDic = {}
local WeaponSumCollectNum = 0
local AwarenessGroup = {}
local AwarenessGroupType = {}
local AwarenessShowedStatusDic = {}
local AwarenessSumCollectNum = 0
local AwarenessTypeToGroupDatasDic = {}
local AwarenessSuitIdToSettingListDic = {}
local ArchiveTagAllList = {}
local ArchiveStoryGroupAllList = {}
local ArchiveSameNpc = {}
local ArchiveMonsterTransDic = {}
local ArchiveMonsterEffectDatasDic = {}
local ArchivePartnerSettings = {}
local ArchivePartners = {}
local ArchivePartnerGroups = {}
local PVGroups = {}
local PVDetails = {}
local BirthdayPlot = {}
function XArchiveConfigs.Init()
Tags = XTableManager.ReadByIntKey(TABLE_TAG, XTable.XTableArchiveTag, "Id")
Archives = XTableManager.ReadByIntKey(TABLE_ARCHIVE, XTable.XTableArchive, "Id")
Monsters = XTableManager.ReadAllByIntKey(TABLE_MONSTER, XTable.XTableArchiveMonster, "Id")
MonsterInfos = XTableManager.ReadAllByIntKey(TABLE_MONSTERINFO, XTable.XTableArchiveMonsterInfo, "Id")
MonsterSkills = XTableManager.ReadAllByIntKey(TABLE_MONSTERSKILL, XTable.XTableArchiveMonsterSkill, "Id")
MonsterSettings = XTableManager.ReadAllByIntKey(TABLE_MONSTERSETTING, XTable.XTableMonsterSetting, "Id")
SameNpcGroups = XTableManager.ReadByIntKey(TABLE_SAMENPCGROUP, XTable.XTableSameNpcGroup, "Id")
MonsterNpcDatas = XTableManager.ReadByIntKey(TABLE_MONSTERNPCDATA, XTable.XTableMonsterNpcData, "Id")
MonsterModelTrans = XTableManager.ReadByIntKey(TABLE_MONSTERMODEL_TRANS, XTable.XTableMonsterModelTrans, "Id")
MonsterEffects = XTableManager.ReadByIntKey(TABLE_MONSTER_EFFECT, XTable.XTableMonsterEffect, "Id")
StoryGroups = XTableManager.ReadByIntKey(TABLE_STORYGROUP, XTable.XTableArchiveStoryGroup, "Id")
StoryChapters = XTableManager.ReadByIntKey(TABLE_STORYCHAPTER, XTable.XTableArchiveStoryChapter, "Id")
StoryDetails = XTableManager.ReadByIntKey(TABLE_STORYDETAIL, XTable.XTableArchiveStoryDetail, "Id")
StoryNpc = XTableManager.ReadByIntKey(TABLE_STORYNPC, XTable.XTableArchiveStoryNpc, "Id")
StoryNpcSetting = XTableManager.ReadByIntKey(TABLE_STORYNPCSETTING, XTable.XTableArchiveStoryNpcSetting, "Id")
CGGroups = XTableManager.ReadByIntKey(TABLE_CGGROUP, XTable.XTableArchiveCGGroup, "Id")
CGDetails = XTableManager.ReadByIntKey(TABLE_CGDETAIL, XTable.XTableArchiveCGDetail, "Id")
ArchiveMails = XTableManager.ReadByIntKey(TABLE_ARCHIVEMAIL, XTable.XTableArchiveMail, "Id")
ArchiveCommunications = XTableManager.ReadByIntKey(TABLE_COMMUNICATION, XTable.XTableArchiveCommunication, "Id")
EventDateGroups = XTableManager.ReadByIntKey(TABLE_EVENTDATEGROUP, XTable.XTableArchiveEventDateGroup, "Id")
WeaponGroup = XTableManager.ReadByIntKey(TABLE_ARCHIVE_WEAPON_GROUP_PATH, XTable.XTableArchiveWeaponGroup, "Id")
WeaponSettings = XTableManager.ReadByIntKey(TABLE_WEAPONSETTING, XTable.XTableWeaponSetting, "Id")
AwarenessGroup = XTableManager.ReadByIntKey(TABLE_ARCHIVE_AWARENESS_GROUP_PATH, XTable.XTableArchiveAwarenessGroup, "Id")
AwarenessGroupType = XTableManager.ReadByIntKey(TABLE_ARCHIVE_AWARENESS_GROUPTYPE_PATH, XTable.XTableArchiveAwarenessGroupType, "GroupId")
AwarenessSettings = XTableManager.ReadByIntKey(TABLE_AWARENESSSETTING, XTable.XTableAwarenessSetting, "Id")
ArchivePartnerSettings = XTableManager.ReadByIntKey(TABLE_ARCHIVE_PARTNER_SETTING, XTable.XTablePartnerSetting, "Id")
ArchivePartners = XTableManager.ReadByIntKey(TABLE_ARCHIVE_PARTNER, XTable.XTableArchivePartner, "Id")
ArchivePartnerGroups = XTableManager.ReadByIntKey(TABLE_ARCHIVE_PARTNER_GROUP, XTable.XTableArchivePartnerGroup, "Id")
PVGroups = XTableManager.ReadByIntKey(TABLE_PVGROUP, XTable.XTableArchivePVGroup, "Id")
PVDetails = XTableManager.ReadByIntKey(TABLE_PVDETAIL, XTable.XTableArchivePVDetail, "Id")
BirthdayPlot = XTableManager.ReadByIntKey(TABLE_BIRTHDAYPLOT, XTable.XTableBirthdayPlot, "Id")
XArchiveConfigs.SetArchiveTagAllList()
XArchiveConfigs.SetArchiveSameNpc()
XArchiveConfigs.SetArchiveMonsterModelTransDic()
XArchiveConfigs.SetArchiveMonsterEffectsDic()
XArchiveConfigs.CreateShowedWeaponTypeList()
XArchiveConfigs.CreateWeaponTemplateIdToSettingDataListDic()
XArchiveConfigs.SetWeaponSumCollectNum()
XArchiveConfigs.CreateWeaponTypeToIdsDic()
XArchiveConfigs.CreateAwarenessShowedStatusDic()
XArchiveConfigs.SetAwarenessSumCollectNum()
XArchiveConfigs.CreateAwarenessTypeToGroupDatasDic()
XArchiveConfigs.CreateAwarenessSiteToBgPathDic()
XArchiveConfigs.CreateAwarenessSuitIdToSettingDataListDic()
XArchiveConfigs.SetArchiveStoryGroupAllList()
end
function XArchiveConfigs.GetArchiveConfigById(Id)
return Archives[Id]
end
function XArchiveConfigs.GetArchiveConfigs()
return Archives
end
function XArchiveConfigs.GetArchiveMonsterConfigs()
return Monsters
end
function XArchiveConfigs.GetArchiveMonsterConfigById(id)
return Monsters[id]
end
function XArchiveConfigs.GetArchiveMonsterInfoConfigs()
return MonsterInfos
end
function XArchiveConfigs.GetArchiveMonsterInfoConfigById(id)
return MonsterInfos[id]
end
function XArchiveConfigs.GetArchiveMonsterSkillConfigs()
return MonsterSkills
end
function XArchiveConfigs.GetArchiveMonsterSkillConfigById(id)
return MonsterSkills[id]
end
function XArchiveConfigs.GetArchiveMonsterSettingConfigs()
return MonsterSettings
end
function XArchiveConfigs.GetArchiveMonsterSettingConfigById(id)
return MonsterSettings[id]
end
function XArchiveConfigs.GetArchiveTagCfgById(id)
return Tags[id]
end
function XArchiveConfigs.GetArchiveTagAllList()
return ArchiveTagAllList
end
function XArchiveConfigs.GetSameNpcId(npcId)
return ArchiveSameNpc[npcId] and ArchiveSameNpc[npcId] or npcId
end
function XArchiveConfigs.GetMonsterTransDataGroup(npcId)
return ArchiveMonsterTransDic[npcId]
end
function XArchiveConfigs.GetMonsterTransDatas(npcId, npcState)
local archiveMonsterTransData = ArchiveMonsterTransDic[npcId]
return archiveMonsterTransData and archiveMonsterTransData[npcState]
end
function XArchiveConfigs.GetMonsterEffectDatas(npcId, npcState)
local archiveMonsterEffectData = ArchiveMonsterEffectDatasDic[npcId]
return archiveMonsterEffectData and archiveMonsterEffectData[npcState]
end
-------------------------------------------------------------
function XArchiveConfigs.GetAwarenessSettingById(Id)
return AwarenessSettings[Id]
end
function XArchiveConfigs.GetAwarenessSettings()
return AwarenessSettings
end
function XArchiveConfigs.GetAwarenessGroupTypes()
local list = {}
for _, type in pairs(AwarenessGroupType) do
table.insert(list, type)
end
return XArchiveConfigs.SortByOrder(list)
end
function XArchiveConfigs.GetWeaponSettingById(Id)
return WeaponSettings[Id]
end
function XArchiveConfigs.GetWeaponSettings()
return WeaponSettings
end
function XArchiveConfigs.GetMonsterNpcDataById(Id)
if not MonsterNpcDatas[Id] then
XLog.ErrorTableDataNotFound("XArchiveConfigs.GetMonsterNpcDataById", "配置表项", TABLE_MONSTERNPCDATA, "Id", tostring(Id))
end
return MonsterNpcDatas[Id] or {}
end
-----------------------------怪物图鉴----------------------------
function XArchiveConfigs.SetArchiveTagAllList()
ArchiveTagAllList = {}
for _, tag in pairs(Tags or {}) do
for _, groupId in pairs(tag.TagGroupId) do
if not ArchiveTagAllList[groupId] then
ArchiveTagAllList[groupId] = {}
end
if tag.IsNotShow == 0 then
table.insert(ArchiveTagAllList[groupId], tag)
end
end
end
for _, v in pairs(ArchiveTagAllList) do
XArchiveConfigs.SortByOrder(v)
end
end
function XArchiveConfigs.SetArchiveSameNpc()
for _, group in pairs(SameNpcGroups or {}) do
for _, npcId in pairs(group.NpcId) do
ArchiveSameNpc[npcId] = group.Id
end
end
end
function XArchiveConfigs.SetArchiveMonsterModelTransDic()
for _, transData in pairs(MonsterModelTrans or {}) do
local archiveMonsterTransData = ArchiveMonsterTransDic[transData.NpcId]
if not archiveMonsterTransData then
archiveMonsterTransData = {}
ArchiveMonsterTransDic[transData.NpcId] = archiveMonsterTransData
end
archiveMonsterTransData[transData.NpcState] = transData
end
end
function XArchiveConfigs.SetArchiveMonsterEffectsDic()
for _, transData in pairs(MonsterEffects or {}) do
local archiveMonsterEffectData = ArchiveMonsterEffectDatasDic[transData.NpcId]
if not archiveMonsterEffectData then
archiveMonsterEffectData = {}
ArchiveMonsterEffectDatasDic[transData.NpcId] = archiveMonsterEffectData
end
local archiveMonsterEffect = archiveMonsterEffectData[transData.NpcState]
if not archiveMonsterEffect then
archiveMonsterEffect = {}
archiveMonsterEffectData[transData.NpcState] = archiveMonsterEffect
end
archiveMonsterEffect[transData.EffectNodeName] = transData.EffectPath
end
end
function XArchiveConfigs.SortByOrder(list)
tableSort(list, function(a, b)
if a.Order then
if a.Order == b.Order then
return a.Id > b.Id
else
return a.Order < b.Order
end
else
if a:GetOrder() == b:GetOrder() then
return a:GetId() > b:GetId()
else
return a:GetOrder() < b:GetOrder()
end
end
end)
return list
end
function XArchiveConfigs.GetMonsterRealName(id)
local name = XArchiveConfigs.GetMonsterNpcDataById(id).Name
if not name then
XLog.ErrorTableDataNotFound("XArchiveConfigs.GetMonsterRealName", "配置表项中的Name字段", TABLE_MONSTERNPCDATA, "id", tostring(id))
return ""
end
return name
end
function XArchiveConfigs.GetMonsterModel(id)
return XArchiveConfigs.GetMonsterNpcDataById(id).ModelId
end
function XArchiveConfigs.GetCountUnitChange(count)
local newCount = count
if count >= 1000 then
newCount = count / 1000
else
return newCount
end
local a, b = math.modf(newCount)
return b >= 0.05 and string.format("%.1fk", newCount) or string.format("%dk", a)
end
-- 武器、意识相关------------->>>
function XArchiveConfigs.CreateShowedWeaponTypeList()
for _, group in pairs(WeaponGroup) do
table.insert(ShowedWeaponTypeList, group.Id)
end
table.sort(ShowedWeaponTypeList, function(aType, bType)
local aData = XArchiveConfigs.GetWeaponGroupByType(aType)
local bData = XArchiveConfigs.GetWeaponGroupByType(bType)
return aData.Order < bData.Order
end)
end
function XArchiveConfigs.CreateWeaponTemplateIdToSettingDataListDic()
local equipId
for _, settingData in pairs(WeaponSettings) do
equipId = settingData.EquipId
WeaponTemplateIdToSettingListDic[equipId] = WeaponTemplateIdToSettingListDic[equipId] or {}
table.insert(WeaponTemplateIdToSettingListDic[equipId], settingData)
end
end
function XArchiveConfigs.SetWeaponSumCollectNum()
for _, _ in pairs(WeaponTemplateIdToSettingListDic) do
WeaponSumCollectNum = WeaponSumCollectNum + 1
end
end
function XArchiveConfigs.CreateWeaponTypeToIdsDic()
for type, _ in pairs(WeaponGroup) do
WeaponTypeToIdsDic[type] = {}
end
local templateData
local equipType
for templateId, _ in pairs(WeaponTemplateIdToSettingListDic) do
templateData = XEquipConfig.GetEquipCfg(templateId)
equipType = templateData.Type
if WeaponTypeToIdsDic[equipType] then
table.insert(WeaponTypeToIdsDic[equipType], templateId)
end
end
end
function XArchiveConfigs.CreateAwarenessShowedStatusDic()
local templateIdList
for suitId, _ in pairs(AwarenessGroup) do
templateIdList = XEquipConfig.GetEquipTemplateIdsBySuitId(suitId)
for _, templateId in ipairs(templateIdList) do
AwarenessShowedStatusDic[templateId] = true
end
end
end
function XArchiveConfigs.SetAwarenessSumCollectNum()
for _, _ in pairs(AwarenessShowedStatusDic) do
AwarenessSumCollectNum = AwarenessSumCollectNum + 1
end
end
function XArchiveConfigs.CreateAwarenessTypeToGroupDatasDic()
for _, type in pairs(AwarenessGroupType) do
AwarenessTypeToGroupDatasDic[type.GroupId] = {}
end
local groupType
for _, groupData in pairs(AwarenessGroup) do
groupType = groupData.Type
if AwarenessTypeToGroupDatasDic[groupType] then
table.insert(AwarenessTypeToGroupDatasDic[groupType], groupData)
end
end
end
function XArchiveConfigs.CreateAwarenessSiteToBgPathDic()
XArchiveConfigs.SiteToBgPath = {
[XEquipConfig.EquipSite.Awareness.One] = CS.XGame.ClientConfig:GetString("ArchiveAwarenessSiteBgPath1"),
[XEquipConfig.EquipSite.Awareness.Two] = CS.XGame.ClientConfig:GetString("ArchiveAwarenessSiteBgPath2"),
[XEquipConfig.EquipSite.Awareness.Three] = CS.XGame.ClientConfig:GetString("ArchiveAwarenessSiteBgPath3"),
[XEquipConfig.EquipSite.Awareness.Four] = CS.XGame.ClientConfig:GetString("ArchiveAwarenessSiteBgPath4"),
[XEquipConfig.EquipSite.Awareness.Five] = CS.XGame.ClientConfig:GetString("ArchiveAwarenessSiteBgPath5"),
[XEquipConfig.EquipSite.Awareness.Six] = CS.XGame.ClientConfig:GetString("ArchiveAwarenessSiteBgPath6"),
}
end
function XArchiveConfigs.CreateAwarenessSuitIdToSettingDataListDic()
local suitId
for _, settingData in pairs(AwarenessSettings) do
suitId = settingData.SuitId
AwarenessSuitIdToSettingListDic[suitId] = AwarenessSuitIdToSettingListDic[suitId] or {}
table.insert(AwarenessSuitIdToSettingListDic[suitId], settingData)
end
end
function XArchiveConfigs.GetWeaponSumCollectNum()
return WeaponSumCollectNum
end
function XArchiveConfigs.GetWeaponGroup()
return WeaponGroup
end
function XArchiveConfigs.GetWeaponGroupByType(type)
return WeaponGroup[type]
end
function XArchiveConfigs.GetWeaponGroupName(type)
return WeaponGroup[type].GroupName
end
function XArchiveConfigs.GetShowedWeaponTypeList()
return ShowedWeaponTypeList
end
function XArchiveConfigs.GetWeaponTypeToIdsDic()
return WeaponTypeToIdsDic
end
function XArchiveConfigs.GetWeaponTemplateIdListByType(type)
return WeaponTypeToIdsDic[type]
end
function XArchiveConfigs.GetAwarenessSumCollectNum()
return AwarenessSumCollectNum
end
function XArchiveConfigs.GetAwarenessGroup()
return AwarenessGroup
end
function XArchiveConfigs.GetAwarenessTypeToGroupDatasDic()
return AwarenessTypeToGroupDatasDic
end
function XArchiveConfigs.GetAwarenessShowedStatusDic()
return AwarenessShowedStatusDic
end
function XArchiveConfigs.GetAwarenessSuitInfoTemplate(suitId)
return AwarenessGroup[suitId]
end
function XArchiveConfigs.GetAwarenessSuitInfoGetType(suitId)
return AwarenessGroup[suitId].Type
end
function XArchiveConfigs.GetAwarenessSuitInfoIconPath(suitId)
return AwarenessGroup[suitId].IconPath
end
function XArchiveConfigs.GetWeaponTemplateIdToSettingListDic()
return WeaponTemplateIdToSettingListDic
end
-- 武器设定或故事
function XArchiveConfigs.GetWeaponSettingList(id, settingType)
local list = {}
local settingDataList = WeaponTemplateIdToSettingListDic[id]
if settingDataList then
if not settingType or settingType == XArchiveConfigs.SettingType.All then
list = settingDataList
else
for _, settingData in pairs(settingDataList) do
if settingData.Type == settingType then
table.insert(list, settingData)
end
end
end
end
return XArchiveConfigs.SortByOrder(list)
end
function XArchiveConfigs.GetWeaponSettingType(id)
return WeaponSettings[id].Type
end
function XArchiveConfigs.GetWeaponTemplateIdBySettingId(id)
return WeaponSettings[id].EquipId
end
-- 意识设定或故事
function XArchiveConfigs.GetAwarenessSettingList(id, settingType)
local list = {}
local settingDataList = AwarenessSuitIdToSettingListDic[id]
if settingDataList then
if not settingType or settingType == XArchiveConfigs.SettingType.All then
list = settingDataList
else
for _, settingData in pairs(settingDataList) do
if settingData.Type == settingType then
table.insert(list, settingData)
end
end
end
else
XLog.ErrorTableDataNotFound("XArchiveConfigs.GetAwarenessSettingList", "配置表项", TABLE_AWARENESSSETTING, "id", tostring(id))
end
return XArchiveConfigs.SortByOrder(list)
end
function XArchiveConfigs.GetAwarenessSettingType(id)
return AwarenessSettings[id].Type
end
function XArchiveConfigs.GetAwarenessSuitIdBySettingId(id)
return AwarenessSettings[id].SuitId
end
-- 武器、意识相关-------------<<<
-- 剧情相关------------->>>
function XArchiveConfigs.GetArchiveStoryGroupAllList()
return ArchiveStoryGroupAllList
end
function XArchiveConfigs.GetArchiveStoryChapterConfigs()
return StoryChapters
end
function XArchiveConfigs.GetArchiveStoryChapterConfigById(id)
return StoryChapters[id]
end
function XArchiveConfigs.GetArchiveStoryDetailConfigs()
return StoryDetails
end
function XArchiveConfigs.GetArchiveStoryDetailConfigById(id)
return StoryDetails[id]
end
function XArchiveConfigs.SetArchiveStoryGroupAllList()
for _, group in pairs(StoryGroups or {}) do
table.insert(ArchiveStoryGroupAllList, group)
end
XArchiveConfigs.SortByOrder(ArchiveStoryGroupAllList)
end
-- 剧情相关-------------<<<
-- NPC相关------------->>>
function XArchiveConfigs.GetArchiveStoryNpcConfigs()
return StoryNpc
end
function XArchiveConfigs.GetArchiveStoryNpcConfigById(id)
return StoryNpc[id]
end
function XArchiveConfigs.GetArchiveStoryNpcSettingConfigs()
return StoryNpcSetting
end
function XArchiveConfigs.GetArchiveStoryNpcSettingConfigById(id)
return StoryNpcSetting[id]
end
-- NPC相关-------------<<<
-- CG相关------------->>>
function XArchiveConfigs.GetArchiveCGGroupConfigs()
return CGGroups
end
function XArchiveConfigs.GetArchiveCGDetailConfigs()
return CGDetails
end
function XArchiveConfigs.GetArchiveCGDetailConfigById(id)
return CGDetails[id]
end
-- CG相关-------------<<<
-- 邮件通讯相关------------->>>
function XArchiveConfigs.GetArchiveMailsConfigs()
return ArchiveMails
end
function XArchiveConfigs.GetArchiveMailsConfigById(id)
return ArchiveMails[id]
end
function XArchiveConfigs.GetArchiveCommunicationsConfigs()
return ArchiveCommunications
end
function XArchiveConfigs.GetArchiveCommunicationsConfigById(id)
return ArchiveCommunications[id]
end
function XArchiveConfigs.GetEventDateGroupsConfigs()
return EventDateGroups
end
-- 邮件通讯相关-------------<<<
-- 伙伴相关------------->>>
function XArchiveConfigs.GetPartnerSettingConfigs()
return ArchivePartnerSettings
end
function XArchiveConfigs.GetPartnerSettingConfigById(id)
if not ArchivePartnerSettings[id] then
XLog.Error("Id is not exist in " .. TABLE_ARCHIVE_PARTNER_SETTING .. " id = " .. id)
return
end
return ArchivePartnerSettings[id]
end
function XArchiveConfigs.GetPartnerConfigs()
return ArchivePartners
end
function XArchiveConfigs.GetPartnerConfigById(id)
if not ArchivePartners[id] then
XLog.Error("Id is not exist in " .. TABLE_ARCHIVE_PARTNER .. " id = " .. id)
return
end
return ArchivePartners[id]
end
function XArchiveConfigs.GetPartnerGroupConfigs()
return ArchivePartnerGroups
end
function XArchiveConfigs.GetPartnerGroupConfigById(id)
if not ArchivePartnerGroups[id] then
XLog.Error("Id is not exist in " .. TABLE_ARCHIVE_PARTNER_GROUP .. " id = " .. id)
return
end
return ArchivePartnerGroups[id]
end
function XArchiveConfigs.GetBirthdayPlotConfigById(id)
if not BirthdayPlot[id] then
XLog.Error("Id is not exist in " .. TABLE_BIRTHDAYPLOT .. " id = " .. id)
return
end
return BirthdayPlot[id]
end
-- 伙伴相关-------------<<<
function XArchiveConfigs.GetWeaponSettingPath()
return TABLE_WEAPONSETTING
end
-- PV相关------------->>>
function XArchiveConfigs.GetPVGroups()
local list = {}
for _, group in pairs(PVGroups) do
table.insert(list, group)
end
return XArchiveConfigs.SortByOrder(list)
end
local IsInitPVDetail = false
local PVGroupIdToDetailIdList = {}
local PVDetailIdList = {}
local InitPVDetail = function()
if IsInitPVDetail then
return
end
for id, v in pairs(PVDetails) do
if not PVGroupIdToDetailIdList[v.GroupId] then
PVGroupIdToDetailIdList[v.GroupId] = {}
end
table.insert(PVGroupIdToDetailIdList[v.GroupId], id)
table.insert(PVDetailIdList, id)
end
for _, idList in pairs(PVGroupIdToDetailIdList) do
tableSort(idList, function(a, b)
return a < b
end)
end
IsInitPVDetail = true
end
local GetPVDetailConfig = function(id)
if not PVDetails[id] then
XLog.Error("Id is not exist in " .. TABLE_PVDETAIL .. " id = " .. id)
return
end
return PVDetails[id]
end
function XArchiveConfigs.GetPVDetailIdList(groupId)
InitPVDetail()
return groupId and PVGroupIdToDetailIdList[groupId] or PVDetailIdList
end
function XArchiveConfigs.GetPVDetailName(id)
local config = GetPVDetailConfig(id)
return config.Name
end
function XArchiveConfigs.GetPVDetailBg(id)
local config = GetPVDetailConfig(id)
return config.Bg
end
function XArchiveConfigs.GetPVDetailLockBg(id)
local config = GetPVDetailConfig(id)
return config.LockBg
end
function XArchiveConfigs.GetPVDetailUnLockTime(id)
local config = GetPVDetailConfig(id)
return config.UnLockTime
end
function XArchiveConfigs.GetPVDetailCondition(id)
local config = GetPVDetailConfig(id)
return config.Condition
end
function XArchiveConfigs.GetPVDetailPv(id)
local config = GetPVDetailConfig(id)
return config.Pv
end
function XArchiveConfigs.GetPVDetailIsShowRedPoint(id)
local config = GetPVDetailConfig(id)
return config.IsShowRed
end
function XArchiveConfigs.GetPVDetailBgWidth(id)
local config = GetPVDetailConfig(id)
return config.BgWidth
end
function XArchiveConfigs.GetPVDetailBgHigh(id)
local config = GetPVDetailConfig(id)
return config.BgHigh
end
function XArchiveConfigs.GetPVDetailBgOffSetX(id)
local config = GetPVDetailConfig(id)
return config.BgOffSetX
end
function XArchiveConfigs.GetPVDetailBgOffSetY(id)
local config = GetPVDetailConfig(id)
return config.BgOffSetY
end
-- PV相关-------------<<<

View file

@ -0,0 +1,866 @@
local tonumber = tonumber
local tableInsert = table.insert
local tableSort = table.sort
local ipairs = ipairs
local pairs = pairs
local CSXTextManagerGetText = CS.XTextManager.GetText
XAreaWarConfigs = XAreaWarConfigs or {}
-----------------活动相关 begin-----------------
local TABLE_ACITIVTY_PATH = "Share/AreaWar/AreaWarActivity.tab"
local ActivityConfig = {}
local function InitActivityConfig()
ActivityConfig = XTableManager.ReadByIntKey(TABLE_ACITIVTY_PATH, XTable.XTableAreaWarActivity, "Id")
end
local function GetActivityConfig(activityId)
local config = ActivityConfig[activityId]
if not config then
XLog.Error(
"XAreaWarConfigs GetActivityConfig error:配置不存在, activityId:" ..
activityId .. ",path: " .. TABLE_ACITIVTY_PATH
)
return
end
return config
end
local function GetActivityTimeId(activityId)
local config = GetActivityConfig(activityId)
return config.TimeId
end
function XAreaWarConfigs.GetDefaultActivityId()
local defaultActivityId = 0
for activityId, config in pairs(ActivityConfig) do
defaultActivityId = activityId
if XTool.IsNumberValid(config.TimeId) and XFunctionManager.CheckInTimeByTimeId(config.TimeId) then
break
end
end
return defaultActivityId
end
function XAreaWarConfigs.GetActivityStartTime(activityId)
local config = GetActivityConfig(activityId)
return XFunctionManager.GetStartTimeByTimeId(GetActivityTimeId(activityId))
end
function XAreaWarConfigs.GetActivityEndTime(activityId)
return XFunctionManager.GetEndTimeByTimeId(GetActivityTimeId(activityId))
end
function XAreaWarConfigs.GetActivityTimeLimitTaskIds(activityId)
local taskIds = {}
local config = GetActivityConfig(activityId)
for _, taskId in ipairs(config.TimeLimitTaskId) do
if XTool.IsNumberValid(taskId) then
tableInsert(taskIds, taskId)
end
end
return taskIds
end
function XAreaWarConfigs.GetActivityShopIds(activityId)
local shopIds = {}
local config = GetActivityConfig(activityId)
for _, shopId in ipairs(config.ShopId) do
if XTool.IsNumberValid(shopId) then
tableInsert(shopIds, shopId)
end
end
return shopIds
end
function XAreaWarConfigs.GetActivityTimeLimitTaskId(activityId, index)
local config = GetActivityConfig(activityId)
return config.TimeLimitTaskId[index] or 0
end
function XAreaWarConfigs.GetActivityBanner(activityId)
local config = GetActivityConfig(activityId)
return config.ActivityBanner or ""
end
function XAreaWarConfigs.GetActivityName(activityId)
local config = GetActivityConfig(activityId)
return config.Name or ""
end
-----------------活动相关 end-------------------
-----------------区域相关 begin-------------------
local TABLE_AREA_PATH = "Client/AreaWar/AreaWarArea.tab"
local AreaConfig = {}
XAreaWarConfigs.Difficult = {
Normal = 1,
Hard = 2
}
local function InitAreaConfig()
AreaConfig = XTableManager.ReadByIntKey(TABLE_AREA_PATH, XTable.XTableAreaWarArea, "Id")
end
local function GetAreaConfig(areaId)
local config = AreaConfig[areaId]
if not config then
XLog.Error("XAreaWarConfigs GetAreaConfig error:配置不存在, areaId:" .. areaId .. ",path: " .. TABLE_AREA_PATH)
return
end
return config
end
function XAreaWarConfigs.GetAllAreaIds()
local areaIds = {}
for areaId in ipairs(AreaConfig) do
tableInsert(areaIds, areaId)
end
return areaIds
end
function XAreaWarConfigs.GetAreaUnlockBlockId(areaId)
local config = GetAreaConfig(areaId)
return config.UnlockBlockId
end
function XAreaWarConfigs.GetAreaName(areaId)
local config = GetAreaConfig(areaId)
return config.Name
end
function XAreaWarConfigs.GetAreaBlockIds(areaId)
local blockIds = {}
local config = GetAreaConfig(areaId)
for _, blockId in ipairs(config.BlockId) do
if XTool.IsNumberValid(blockId) then
tableInsert(blockIds, blockId)
end
end
return blockIds
end
--获取指定区块所属区域Id
function XAreaWarConfigs.GetBlockAreaId(blockId)
for areaId, config in pairs(AreaConfig) do
for _, inBlockId in pairs(config.BlockId) do
if inBlockId == blockId then
return areaId
end
end
end
return 0
end
--获取指定区域内世界Boss的Ui类型不同区域使用不同的UI
function XAreaWarConfigs.GetAreaWorldBossUiType(areaId)
local config = GetAreaConfig(areaId)
return config.WorldBossUiType
end
-----------------区域相关 end-------------------
-----------------区块相关 begin-------------------
local TABLE_BLOCK_PATH = "Share/AreaWar/AreaWarBlock.tab"
local TABLE_BLOCK_SHOW_TYPE_PATH = "Client/AreaWar/AreaWarBlockShowType.tab"
local TABLE_WORLD_BOSS_UI_PATH = "Client/AreaWar/AreaWarWorldBossUi.tab"
local BlockConfig = {}
local BlockShowTypeConfig = {}
local WorldBossUiConfig = {}
--区块类型
XAreaWarConfigs.BlockType = {
Init = 1, --初始区块
Normal = 2, --常规区块
WorldBoss = 3, --世界BOSS区块
Mystery = 4 --神秘区块
}
--区块展示类型
XAreaWarConfigs.BlockShowType = {
Init = 1, --初始区块
NormalExplore = 2, --常规区块(探索)
WorldBoss = 3, --世界Boss区块
Mystery = 4, --神秘区块
NormalBox = 5, --常规区块(宝箱)
NormalCharacter = 6, --常规区块(角色特攻)
NormalPurify = 7, --常规区块(净化加成)
NormalBeacon = 8, --常规区块(灯塔)
NormalBoss = 9 --常规区块Boss
}
--世界BossUI类型
XAreaWarConfigs.WorldBossUiType = {
Normal = 1,
Special = 2
}
local function InitBlockConfig()
BlockConfig = XTableManager.ReadByIntKey(TABLE_BLOCK_PATH, XTable.XTableAreaWarBlock, "Id")
BlockShowTypeConfig =
XTableManager.ReadByIntKey(TABLE_BLOCK_SHOW_TYPE_PATH, XTable.XTableAreaWarBlockShowType, "Id")
WorldBossUiConfig = XTableManager.ReadByIntKey(TABLE_WORLD_BOSS_UI_PATH, XTable.XTableAreaWarWorldBossUi, "Id")
end
local function GetBlockConfig(blockId)
local config = BlockConfig[blockId]
if not config then
XLog.Error("XAreaWarConfigs GetBlockConfig error:配置不存在, blockId:" .. blockId .. ",path: " .. TABLE_BLOCK_PATH)
return
end
return config
end
local function GetBlockShowTypeConfig(showType)
local config = BlockShowTypeConfig[showType]
if not config then
XLog.Error(
"XAreaWarConfigs GetBlockShowTypeConfig error:配置不存在, showType:" ..
showType .. ",path: " .. TABLE_BLOCK_SHOW_TYPE_PATH
)
return
end
return config
end
local function GetWorldBossUiConfig(uiType)
local config = WorldBossUiConfig[uiType]
if not config then
XLog.Error(
"XAreaWarConfigs GetWorldBossUiConfig error:配置不存在, uiType:" ..
uiType .. ",path: " .. TABLE_WORLD_BOSS_UI_PATH
)
return
end
return config
end
function XAreaWarConfigs.GetAllBlockIds()
local blockIds = {}
for blockId in pairs(BlockConfig) do
if XTool.IsNumberValid(blockId) then
tableInsert(blockIds, blockId)
end
end
return blockIds
end
function XAreaWarConfigs.GetBlockIdByStageId(stageId)
for blockId, config in pairs(BlockConfig) do
if config.StageId == stageId then
return blockId
end
end
return 0
end
function XAreaWarConfigs.GetAllBlockStageIds()
local stageIds = {}
for _, config in pairs(BlockConfig) do
if XTool.IsNumberValid(config.StageId) then
tableInsert(stageIds, config.StageId)
end
end
return stageIds
end
function XAreaWarConfigs.GetBlockRequirePurification(blockId)
local config = GetBlockConfig(blockId)
return config.CleanNeed
end
--获取前置区块Ids可选列表
function XAreaWarConfigs.GetBlockPreBlockIdsAlternativeList(blockId)
local alternativeList = {}
local config = GetBlockConfig(blockId)
for _, preBlockIdStr in pairs(config.PreBlockId) do
local result = string.Split(preBlockIdStr)
for index, str in pairs(result) do
result[index] = tonumber(str)
end
tableInsert(alternativeList, result)
end
return alternativeList
end
function XAreaWarConfigs.GetBlockName(blockId)
local config = GetBlockConfig(blockId)
return config.Name or ""
end
function XAreaWarConfigs.GetBlockNameEn(blockId)
local config = GetBlockConfig(blockId)
return config.NameEn or ""
end
--是否是初始区块
function XAreaWarConfigs.IsInitBlock(blockId)
return XAreaWarConfigs.GetBlockType(blockId) == XAreaWarConfigs.BlockType.Init
end
--获取区块实际类型(服务端)
function XAreaWarConfigs.GetBlockType(blockId)
local config = GetBlockConfig(blockId)
return config.Type
end
--获取区块展示类型
function XAreaWarConfigs.GetBlockShowType(blockId)
local config = GetBlockConfig(blockId)
return config.ShowType
end
function XAreaWarConfigs.CheckBlockShowType(blockId, showType)
return XAreaWarConfigs.GetBlockShowType(blockId) == showType
end
--活动开启后多少秒区块开启
function XAreaWarConfigs.GetBlockOpenSeconds(blockId)
local config = GetBlockConfig(blockId)
return config.OpenHour * 3600
end
--世界Boss在区块开放后一天几点开启/关闭
function XAreaWarConfigs.GetBlockWorldBossHour(blockId)
local config = GetBlockConfig(blockId)
return config.WorldBossStartHour, config.WorldBossEndHour
end
function XAreaWarConfigs.GetBlockShowRewardId(blockId)
local config = GetBlockConfig(blockId)
return config.ShowRewardId
end
--获取区块作战消耗活动体力
function XAreaWarConfigs.GetBlockActionPoint(blockId)
local config = GetBlockConfig(blockId)
return config.ActionPoint
end
--获取区块派遣消耗活动体力
function XAreaWarConfigs.GetBlockDetachActionPoint(blockId)
local config = GetBlockConfig(blockId)
return config.DetachActionPoint
end
function XAreaWarConfigs.GetBlockStageId(blockId)
local config = GetBlockConfig(blockId)
return config.StageId
end
function XAreaWarConfigs.GetBlockMovieId(blockId)
local config = GetBlockConfig(blockId)
return config.MovieId
end
--派遣基础奖励
function XAreaWarConfigs.GetBlockDetachBasicRewardItems(blockId)
local rewardItems = {}
local config = GetBlockConfig(blockId)
local rewardId = config.DetachBasicRewardId
if XTool.IsNumberValid(rewardId) then
rewardItems = XRewardManager.GetRewardList(rewardId)
end
return XRewardManager.MergeAndSortRewardGoodsList(rewardItems)
end
--派遣满足条件额外奖励
function XAreaWarConfigs.GetBlockDetachDetachExtraRewardItems(blockId, index)
local rewardItems = {}
local config = GetBlockConfig(blockId)
local rewardId = config.DetachExtraRewardId[index]
if XTool.IsNumberValid(rewardId) then
rewardItems = XRewardManager.GetRewardList(rewardId)
end
return XRewardManager.MergeAndSortRewardGoodsList(rewardItems)
end
function XAreaWarConfigs.GetAllBlockShowTypes()
local showTypes = {}
for showType in pairs(BlockShowTypeConfig) do
tableInsert(showTypes, showType)
end
return showTypes
end
function XAreaWarConfigs.GetBlockShowTypeName(showType)
local config = GetBlockShowTypeConfig(showType)
return config.Name
end
--获取区块类型小图标
function XAreaWarConfigs.GetBlockShowTypeIconByBlockId(blockId)
local showType = XAreaWarConfigs.GetBlockShowType(blockId)
return XAreaWarConfigs.GetBlockShowTypeIcon(showType)
end
--获取区块类型关卡详情背景
function XAreaWarConfigs.GetBlockShowTypeStageBgByBlockId(blockId)
local showType = XAreaWarConfigs.GetBlockShowType(blockId)
return XAreaWarConfigs.GetBlockShowTypeStageBg(showType)
end
--获取区块类型格子预制体路径
function XAreaWarConfigs.GetBlockShowTypePrefab(blockId)
local showType = XAreaWarConfigs.GetBlockShowType(blockId)
local config = GetBlockShowTypeConfig(showType)
return config.Prefab
end
--获取区块类型为常规区块(角色特攻)时对应的特攻角色小头像图标
function XAreaWarConfigs.GetRoleBlockIcon(blockId)
local roleId = XAreaWarConfigs.GetUnlockSpecialRoleIdByBlockId(blockId)
return XAreaWarConfigs.GetBlockSpecialRoleIcon(roleId)
end
function XAreaWarConfigs.GetWorldBossUiName(uiType)
local config = GetWorldBossUiConfig(uiType)
return config.UiName
end
function XAreaWarConfigs.GetBlockShowTypeIcon(showType)
local config = GetBlockShowTypeConfig(showType)
return config.Icon
end
function XAreaWarConfigs.GetBlockShowTypeStageBg(showType)
local config = GetBlockShowTypeConfig(showType)
return config.StageDetailBg
end
function XAreaWarConfigs.GetWorldBossUiTitleIcon(uiType)
local config = GetWorldBossUiConfig(uiType)
return config.TitleIcon
end
function XAreaWarConfigs.GetWorldBossUiHeadName(uiType)
local config = GetWorldBossUiConfig(uiType)
return config.HeadName
end
function XAreaWarConfigs.GetWorldBossUiHeadIcon(uiType)
local config = GetWorldBossUiConfig(uiType)
return config.HeadIcon
end
function XAreaWarConfigs.GetWorldBossRankTitle(uiType)
local config = GetWorldBossUiConfig(uiType)
return config.RankTitle
end
function XAreaWarConfigs.GetWorldBossUiModelIdDic(uiType)
local modelIds = {}
local config = GetWorldBossUiConfig(uiType)
for index, modelId in pairs(config.ModelId) do
if XTool.IsNumberValid(modelId) then
modelIds[index] = modelId
end
end
return modelIds
end
--获取世界Boss区块Ui名称
function XAreaWarConfigs.GetBlockWorldBossUiName(blockId)
local areaId = XAreaWarConfigs.GetBlockAreaId(blockId)
local uiType = XAreaWarConfigs.GetAreaWorldBossUiType(areaId)
return XAreaWarConfigs.GetWorldBossUiName(uiType)
end
--获取世界Boss区块排行榜
function XAreaWarConfigs.GetBlockWorldBossRankTitle(blockId)
local areaId = XAreaWarConfigs.GetBlockAreaId(blockId)
local uiType = XAreaWarConfigs.GetAreaWorldBossUiType(areaId)
return XAreaWarConfigs.GetWorldBossRankTitle(uiType)
end
-----------------区块相关 end-------------------
-----------------派遣相关 begin-------------------
local TABLE_DISPATCH_CHARACTER_PATH = "Share/AreaWar/AreaWarDetachRole.tab"
local TABLE_DISPATCH_CONDITION_PATH = "Share/AreaWar/AreaWarDetachCondition.tab"
local DispatchCharacterConfig = {}
local DispatchConditionConfig = {}
local function InitDispatchConfig()
DispatchCharacterConfig =
XTableManager.ReadByIntKey(TABLE_DISPATCH_CHARACTER_PATH, XTable.XTableAreaWarDetachRole, "Id")
DispatchConditionConfig =
XTableManager.ReadByIntKey(TABLE_DISPATCH_CONDITION_PATH, XTable.XTableAreaWarDetachCondition, "Id")
end
local function GetDispatchCharacterConfig(characterId)
local config = DispatchCharacterConfig[characterId]
if not config then
XLog.Error(
"XAreaWarConfigs GetDispatchCharacterConfig error:配置不存在, characterId:" ..
characterId .. ",path: " .. TABLE_DISPATCH_CHARACTER_PATH
)
return
end
return config
end
local function GetDispatchConditionConfig(conditionId)
local config = DispatchConditionConfig[conditionId]
if not config then
XLog.Error(
"XAreaWarConfigs GetDispatchConditionConfig error:配置不存在, conditionId:" ..
conditionId .. ",path: " .. TABLE_DISPATCH_CONDITION_PATH
)
return
end
return config
end
--获取指定派遣成员/机器人Id列表对应满足的所有条件检查表
function XAreaWarConfigs.GetDispatchCharacterCondtionIdCheckDic(entityIds)
local conditionIdCheckDic = {}
for _, entityId in pairs(entityIds or {}) do
local characterId = XEntityHelper.GetCharacterIdByEntityId(entityId)
if XTool.IsNumberValid(characterId) then
local config = GetDispatchCharacterConfig(characterId)
for _, conditionId in pairs(config.DetachCondition) do
conditionIdCheckDic[conditionId] = conditionId
end
end
end
return conditionIdCheckDic
end
--获取指定派遣成员/机器人Id列表对应满足的所有条件检查表
function XAreaWarConfigs.GetDispatchCharacterCondtionIds(entityId)
local conditionIds = {}
local characterId = XEntityHelper.GetCharacterIdByEntityId(entityId)
if XTool.IsNumberValid(characterId) then
local config = GetDispatchCharacterConfig(characterId)
for _, conditionId in ipairs(config.DetachCondition) do
tableInsert(conditionIds, conditionId)
end
end
return conditionIds
end
function XAreaWarConfigs.GetDispatchConditionDesc(conditionId)
local config = GetDispatchConditionConfig(conditionId)
return config.Desc
end
-----------------派遣相关 end-------------------
-----------------BUFF相关 begin-------------------
local TABLE_BUFF_PATH = "Share/AreaWar/AreaWarBuff.tab"
local BuffConfig = {}
local function InitBuffConfig()
BuffConfig = XTableManager.ReadByIntKey(TABLE_BUFF_PATH, XTable.XTableAreaWarBuff, "Id")
end
local function GetBuffConfig(buffId)
local config = BuffConfig[buffId]
if not config then
XLog.Error("XAreaWarConfigs GetBuffConfig error:配置不存在, buffId:" .. buffId .. ",path: " .. TABLE_BUFF_PATH)
return
end
return config
end
function XAreaWarConfigs.GetBuffName(buffId)
local config = GetBuffConfig(buffId)
return config.Name
end
function XAreaWarConfigs.GetBuffDesc(buffId)
local config = GetBuffConfig(buffId)
return config.Desc
end
function XAreaWarConfigs.GetBuffIcon(buffId)
local config = GetBuffConfig(buffId)
return config.Icon
end
-----------------BUFF相关 end-------------------
-----------------特攻角色 begin-------------------
local TABLE_SPECIAL_ROLE_PATH = "Share/AreaWar/AreaWarSpecialRole.tab"
local TABLE_SPECIAL_ROLE_REWARD_PATH = "Share/AreaWar/AreaWarSpecialRoleReward.tab"
local SpecialRoleConfig = {}
local SpecialRoleRewardConfig = {}
local function InitSpecialRoleConfig()
SpecialRoleConfig = XTableManager.ReadByIntKey(TABLE_SPECIAL_ROLE_PATH, XTable.XTableAreaWarSpecialRole, "Id")
SpecialRoleRewardConfig =
XTableManager.ReadByIntKey(TABLE_SPECIAL_ROLE_REWARD_PATH, XTable.XTableAreaWarSpecialRoleReward, "Id")
end
local function GetSpecialRoleConfig(roleId)
local config = SpecialRoleConfig[roleId]
if not config then
XLog.Error(
"XAreaWarConfigs GetSpecialRoleConfig error:配置不存在, roleId:" ..
roleId .. ",path: " .. TABLE_SPECIAL_ROLE_PATH
)
return
end
return config
end
local function GetSpecialRoleRewardConfig(rewardId)
local config = SpecialRoleRewardConfig[rewardId]
if not config then
XLog.Error(
"XAreaWarConfigs GetSpecialRoleRewardConfig error:配置不存在, rewardId:" ..
rewardId .. ",path: " .. TABLE_SPECIAL_ROLE_REWARD_PATH
)
return
end
return config
end
function XAreaWarConfigs.GetAllSpecialRoleIds()
local roleIds = {}
for roleId in pairs(SpecialRoleConfig) do
if XTool.IsNumberValid(roleId) then
tableInsert(roleIds, roleId)
end
end
tableSort(
roleIds,
function(a, b)
return GetSpecialRoleConfig(a).OrderId < GetSpecialRoleConfig(b).OrderId
end
)
return roleIds
end
function XAreaWarConfigs.GetSpecialRoleUnlockBlockId(roleId)
local config = GetSpecialRoleConfig(roleId)
return config.UnlockBlockId
end
function XAreaWarConfigs.GetSpecialRoleRobotId(roleId)
local config = GetSpecialRoleConfig(roleId)
return config.RobotId
end
function XAreaWarConfigs.GetSpecialRoleName(roleId)
local config = GetSpecialRoleConfig(roleId)
return config.Name
end
function XAreaWarConfigs.GetSpecialRoleIcon(roleId)
local config = GetSpecialRoleConfig(roleId)
return config.Icon
end
--获取小地图上用的头像图标
function XAreaWarConfigs.GetBlockSpecialRoleIcon(roleId)
local config = GetSpecialRoleConfig(roleId)
return config.HeadIcon
end
function XAreaWarConfigs.GetSpecialRoleBuffId(roleId)
local config = GetSpecialRoleConfig(roleId)
return config.BuffId
end
function XAreaWarConfigs.GetSpecialRoleLihui(roleId)
local config = GetSpecialRoleConfig(roleId)
return config.Lihui
end
function XAreaWarConfigs.GetUnlockSpecialRoleIdByBlockId(blockId)
if not XTool.IsNumberValid(blockId) then
return 0
end
for roleId, config in pairs(SpecialRoleConfig) do
if blockId == config.UnlockBlockId then
return roleId
end
end
return 0
end
--获取所有角色解锁奖励Id
function XAreaWarConfigs.GetAllSpecialRoleUnlockRewardIds()
local rewardIds = {}
for rewardId, config in ipairs(SpecialRoleRewardConfig) do
if XTool.IsNumberValid(config.RewardId) then
tableInsert(rewardIds, rewardId)
end
end
return rewardIds
end
function XAreaWarConfigs.GetSpecialRoleRewardRewardId(rewardId)
local config = GetSpecialRoleRewardConfig(rewardId)
return config.RewardId
end
function XAreaWarConfigs.GetSpecialRoleRewardUnlockCount(rewardId)
local config = GetSpecialRoleRewardConfig(rewardId)
return config.UnlockCount
end
--获取指定奖励Id的上一个奖励解锁需要的区块净化数量
function XAreaWarConfigs.GetSpecialRoleRewardLastUnlockCount(rewardId)
local targetRewardId = rewardId - 1
if SpecialRoleRewardConfig[targetRewardId] then
return SpecialRoleRewardConfig[targetRewardId].UnlockCount
end
return 0
end
--获取指定区域所有特攻角色Id
function XAreaWarConfigs.GetAreaSpecialRoleIds(areaId)
local roleIds = {}
local blockIds = XAreaWarConfigs.GetAreaBlockIds(areaId)
for _, blockId in ipairs(blockIds) do
local roleId = XAreaWarConfigs.GetUnlockSpecialRoleIdByBlockId(blockId)
if XTool.IsNumberValid(roleId) then
tableInsert(roleIds, roleId)
end
end
return roleIds
end
-----------------特攻角色 end-------------------
-----------------挂机收益 begin-------------------
local TABLE_HANG_UP_PATH = "Share/AreaWar/AreaWarHangUpReward.tab"
local HangUpConfig = {}
local function InitHangUpConfig()
HangUpConfig = XTableManager.ReadByIntKey(TABLE_HANG_UP_PATH, XTable.XTableAreaWarHangUpReward, "Id")
end
local function GetHangUpConfig(id)
local config = HangUpConfig[id]
if not config then
XLog.Error("XAreaWarConfigs GetHangUpConfig error:配置不存在, id:" .. id .. ",path: " .. TABLE_HANG_UP_PATH)
return
end
return config
end
function XAreaWarConfigs.GetAllHangUpIds()
local ids = {}
for roleId in ipairs(HangUpConfig) do
if XTool.IsNumberValid(roleId) then
tableInsert(ids, roleId)
end
end
return ids
end
function XAreaWarConfigs.GetHangUpUnlockBlockId(id)
local config = GetHangUpConfig(id)
return config.UnlockBlockId
end
function XAreaWarConfigs.GetHangUpUnlockAmount(id)
local config = GetHangUpConfig(id)
return config.ProductionAmount
end
-----------------挂机收益 end-------------------
-----------------净化加成/插件相关 begin-------------------
local TABLE_PURIFICATION_LEVEL_PATH = "Share/AreaWar/AreaWarPurificationLevel.tab"
local PurificationLevelConfig = {}
XAreaWarConfigs.PluginSlotCount = 3 --插件槽数量
local function InitPurificationConfig()
PurificationLevelConfig =
XTableManager.ReadByIntKey(TABLE_PURIFICATION_LEVEL_PATH, XTable.XTableAreaWarPurificationLevel, "Id")
end
local function GetPurificationLevelConfig(level, ignoreError)
local config = PurificationLevelConfig[level]
if not config then
if not ignoreError then
XLog.Error(
"XAreaWarConfigs GetPurificationLevelConfig error:配置不存在, level:" ..
level .. ",path: " .. TABLE_PURIFICATION_LEVEL_PATH
)
end
return
end
return config
end
--获取指定净化等级解锁插件槽数量
function XAreaWarConfigs.GetPfLevelUnlockSlot(level)
if not XTool.IsNumberValid(level) then
return 0
end
local config = GetPurificationLevelConfig(level)
return config.HoleCount
end
--获取解锁指定插件槽需要净化等级
function XAreaWarConfigs.GetUnlockSlotPfLevel(slot)
for level in ipairs(PurificationLevelConfig) do
if XAreaWarConfigs.GetPfLevelUnlockSlot(level) == slot then
return level
end
end
return 0
end
--获取指定净化等级升到下一级所需经验
function XAreaWarConfigs.GetPfLevelNextLevelExp(level)
local config = GetPurificationLevelConfig(level + 1, true)
return config and config.Exp or 0
end
--获取指定插件解锁等级
function XAreaWarConfigs.GetPfLevelByPluginId(pluginId)
for level, config in pairs(PurificationLevelConfig) do
if config.BuffId == pluginId then
return level
end
end
return 0
end
--获取指定净化等级固定加成属性值
function XAreaWarConfigs.GetPfLevelAddAttrs(level)
if level < 1 then
return {0, 0, 0, 0}
end
local config = GetPurificationLevelConfig(level)
return config.AddAttr
end
function XAreaWarConfigs.GetAllPluginIds()
local pluginIds = {}
for _, config in pairs(PurificationLevelConfig) do
if XTool.IsNumberValid(config.BuffId) then
tableInsert(pluginIds, config.BuffId)
end
end
return pluginIds
end
--获取从0级升到指定净化等级总共需要经验
function XAreaWarConfigs.GetAccumulatedPfExp(targetLevel)
local totalExp = 0
for level = 0, targetLevel - 1 do
totalExp = totalExp + XAreaWarConfigs.GetPfLevelNextLevelExp(level)
end
return totalExp
end
--获取最大净化等级
function XAreaWarConfigs.GetMaxPfLevel()
return #PurificationLevelConfig
end
-----------------净化加成/插件相关 end-------------------
function XAreaWarConfigs.Init()
InitActivityConfig()
InitAreaConfig()
InitBlockConfig()
InitBuffConfig()
InitSpecialRoleConfig()
InitHangUpConfig()
InitPurificationConfig()
InitDispatchConfig()
end

View file

@ -0,0 +1,333 @@
---
--- 竞技副本配置表
---
XArenaConfigs = XArenaConfigs or {}
--战区贡献道具的id
XArenaConfigs.CONTRIBUTESCORE_ID = 54
XArenaActivityStatus = {
--game服和竞技服等待数据的时候用
Loading = -1,
--默认状态
Default = 0,
--休息状态
Rest = 1,
--战斗状态
Fight = 2,
--结束
Over = 3,
}
--个人排行区域
XArenaPlayerRankRegion = {
UpRegion = 1, --晋级区
KeepRegion = 2, --保级区
DownRegion = 3, --降级区
}
--竞技副本通关评级
XArenaAppraiseType = {
S = 1,
A = 2,
B = 3,
C = 4,
D = 5,
}
XArenaConfigs.ArenaTimerName = "FubenArenaActivityTimer"
XArenaConfigs.SHOP_ID = CS.XGame.ClientConfig:GetInt("AreanShopId")
local TABLE_ARENA_BUFF_DETAIL = "Client/Fuben/Arena/ArenaAreaBuffDetails.tab"
local TABLE_ARENA_STAGE = "Client/Fuben/Arena/ArenaStage.tab"
local TABLE_ARENA_LEVEL = "Share/Fuben/Arena/ArenaLevel.tab"
local TABLE_CHALLENGE_AREA = "Share/Fuben/Arena/ChallengeArea.tab"
local TABLE_AREA_STAGE = "Share/Fuben/Arena/AreaStage.tab"
local TABLE_TEAM_RANK_REWARD = "Share/Fuben/Arena/TeamRankReward.tab"
local TABLE_MARK = "Share/Fuben/Arena/Mark.tab"
local ArenaRankBottomCount --竞技排行基数
local ArenaClientStageTemplate --競技客户端关卡表
local ArenaLevelTemplate --竞技段位表
local ChallengeAreaTemplate --挑战区域表
local AreaStageTemplate --战区关卡配置表
local TeamRankRewardTemplate --队伍排行奖励表
local MarkTemplate --结算分数表
local BuffDetail --Buff展示信息配置表
local MaxArenaLevel = 0 --最大竞技段位
local PlayerLevelRangeToChallengeIds --玩家等级段索引挑战配置列表
local MaxArenaStageCountPerArea = 0 --竞技战区最大关卡数
local MaxChallengeId = 0 --最大挑战区域Id
--私有方法定义
local InitChallengeAreaCfg
local InitArenaLevelCfg
local InitAreaStageTemplate
function XArenaConfigs.Init()
ArenaRankBottomCount = CS.XGame.Config:GetInt("ArenaTeamRankShow")
ArenaClientStageTemplate = XTableManager.ReadByIntKey(TABLE_ARENA_STAGE, XTable.XTableArenaStage, "StageId")
ArenaLevelTemplate = XTableManager.ReadByIntKey(TABLE_ARENA_LEVEL, XTable.XTableArenaLevel, "Id")
ChallengeAreaTemplate = XTableManager.ReadByIntKey(TABLE_CHALLENGE_AREA, XTable.XTableChallengeArea, "ChallengeId")
AreaStageTemplate = XTableManager.ReadByIntKey(TABLE_AREA_STAGE, XTable.XTableAreaStage, "Id")
TeamRankRewardTemplate = XTableManager.ReadByIntKey(TABLE_TEAM_RANK_REWARD, XTable.XTableTeamRankReward, "Id")
MarkTemplate = XTableManager.ReadByIntKey(TABLE_MARK, XTable.XTableMark, "MarkId")
BuffDetail = XTableManager.ReadByIntKey(TABLE_ARENA_BUFF_DETAIL,XTable.XTableArenaAreaBuffDetails,"Id")
InitArenaLevelCfg()
InitChallengeAreaCfg()
InitAreaStageTemplate()
end
InitArenaLevelCfg = function()
for _, cfg in pairs(ArenaLevelTemplate) do
if MaxArenaLevel < cfg.Id then
MaxArenaLevel = cfg.Id
end
end
end
InitChallengeAreaCfg = function()
PlayerLevelRangeToChallengeIds = {}
local tempMap = {}
local tempTypeId = 0
for id, cfg in pairs(ChallengeAreaTemplate) do
if id > MaxChallengeId then
MaxChallengeId = id
end
local typeId = tempMap[cfg.MinLv]
if not typeId then
typeId = tempTypeId + 1
tempMap[cfg.MinLv] = typeId
tempTypeId = typeId
end
local map = PlayerLevelRangeToChallengeIds[typeId]
if not map then
map = {}
PlayerLevelRangeToChallengeIds[typeId] = map
end
map[id] = cfg
end
end
InitAreaStageTemplate = function()
for _, cfg in pairs(AreaStageTemplate) do
if MaxArenaStageCountPerArea < #cfg.StageId then
MaxArenaStageCountPerArea = #cfg.StageId
end
end
end
local GetChallengeCfgMapById = function(challengeId)
for _, map in ipairs(PlayerLevelRangeToChallengeIds) do
local cfg = map[challengeId]
if cfg then
return map
end
end
return nil
end
local SortChallenge = function(a, b)
return a.ArenaLv < b.ArenaLv
end
local SorTeamRankReward = function(a, b)
return a.MinRank < b.MinRank
end
-- 获取个人排行区文字
function XArenaConfigs.GetRankRegionText(rankRegion)
if rankRegion == XArenaPlayerRankRegion.UpRegion then
return CS.XTextManager.GetText("ArenaActivityUpRegion")
elseif rankRegion == XArenaPlayerRankRegion.DownRegion then
return CS.XTextManager.GetText("ArenaActivityDownRegion")
else
return CS.XTextManager.GetText("ArenaActivityKeepRegion")
end
end
-- 获取个人排行区文字带颜色
function XArenaConfigs.GetRankRegionColorText(rankRegion)
if rankRegion == XArenaPlayerRankRegion.UpRegion then
return CS.XTextManager.GetText("ArenaActivityUpRegionColor")
elseif rankRegion == XArenaPlayerRankRegion.DownRegion then
return CS.XTextManager.GetText("ArenaActivityDownRegionColor")
else
return CS.XTextManager.GetText("ArenaActivityKeepRegionColor")
end
end
-- 获取个人排行区描述
function XArenaConfigs.GetRankRegionDescText(rankRegion, challengeCfg)
if rankRegion == XArenaPlayerRankRegion.UpRegion then
return CS.XTextManager.GetText("ArenaActivityUpRegionDesc", 1, challengeCfg.DanUpRank)
elseif rankRegion == XArenaPlayerRankRegion.DownRegion then
return CS.XTextManager.GetText("ArenaActivityDownRegionDesc", challengeCfg.DanKeepRank + 1, challengeCfg.DanDownRank)
else
return CS.XTextManager.GetText("ArenaActivityKeepRegionDesc", challengeCfg.DanUpRank + 1, challengeCfg.DanKeepRank)
end
end
-- 获取个人排行不升段位描述
function XArenaConfigs.GetRankNotRegionDescText(rankRegion)
if rankRegion == XArenaPlayerRankRegion.UpRegion then
return CS.XTextManager.GetText("ArenaActivityNotUpRegionDesc")
elseif rankRegion == XArenaPlayerRankRegion.DownRegion then
return CS.XTextManager.GetText("ArenaActivityNotDownRegionDesc")
else
return CS.XTextManager.GetText("ArenaActivityNotKeepRegionDesc")
end
end
-- 获取个人排行区奖励id
function XArenaConfigs.GetRankRegionRewardId(rankRegion, challengeCfg)
if rankRegion == XArenaPlayerRankRegion.UpRegion then
return challengeCfg.UpRewardId
elseif rankRegion == XArenaPlayerRankRegion.DownRegion then
return challengeCfg.DownRewardId
else
return challengeCfg.KeepRewardId
end
end
-- 是否是最大竞技段位
function XArenaConfigs.IsMaxArenaLevel(level)
return level >= MaxArenaLevel
end
function XArenaConfigs.GetMaxChallengeCfg()
return XArenaConfigs.GetChallengeArenaCfgById(MaxChallengeId)
end
-- 获取竞技副本评级文字
function XArenaConfigs.GetArenaFightAppraiseText(appraiseType)
if appraiseType == XArenaAppraiseType.S then
return "S"
elseif appraiseType == XArenaAppraiseType.A then
return "A"
elseif appraiseType == XArenaAppraiseType.B then
return "B"
elseif appraiseType == XArenaAppraiseType.C then
return "C"
elseif appraiseType == XArenaAppraiseType.D then
return "D"
end
end
-- 获取竞技队伍排行榜统计基数
function XArenaConfigs.GetArenaRankBottomCount()
return ArenaRankBottomCount
end
-- 获取竞技段位配置表
function XArenaConfigs.GetArenaLevelCfgByLevel(level)
return ArenaLevelTemplate[level]
end
-- 获取竞技段位配置表
function XArenaConfigs.GetArenaStageConfig(stageId)
local t = ArenaClientStageTemplate[stageId]
if not t then
XLog.ErrorTableDataNotFound("XArenaConfigs.GetArenaStageConfig", "根据stageId获取的配置表项", TABLE_ARENA_STAGE, "stageId", tostring(stageId))
return nil
end
return t
end
-- 获取竞技挑战配置表
function XArenaConfigs.GetChallengeArenaCfgById(challengeId)
return ChallengeAreaTemplate[challengeId]
end
-- 获取竞技挑战配置列表
function XArenaConfigs.GetChallengeCfgListById(challengeId)
local list = {}
local map = GetChallengeCfgMapById(challengeId)
if map then
for _, cfg in pairs(map) do
table.insert(list, cfg)
end
table.sort(list, SortChallenge)
end
return list
end
-- 获取竞技挑战最高等级
function XArenaConfigs.GetChallengeMaxArenaLevel(challengeId)
local maxArenalLevel = 0
local map = GetChallengeCfgMapById(challengeId)
if map then
for _, cfg in pairs(map) do
if cfg.ArenaLv > maxArenalLevel then
maxArenalLevel = cfg.ArenaLv
end
end
end
return maxArenalLevel
end
function XArenaConfigs.GetArenaStageCfg()
return AreaStageTemplate
end
-- 获取竞技区域关卡配置
function XArenaConfigs.GetArenaAreaStageCfgByAreaId(areaId)
return AreaStageTemplate[areaId]
end
-- 获取竞技战区最大关卡数量
function XArenaConfigs.GetTheMaxStageCountOfArenaArea()
return MaxArenaStageCountPerArea
end
-- 获取竞技队伍排行奖励配置列表
function XArenaConfigs.GetTeamRankRewardCfgList(challengeId)
local list = {}
for _, cfg in pairs(TeamRankRewardTemplate) do
if cfg.ChallengeId == challengeId then
table.insert(list, cfg)
end
end
if #list > 2 then
table.sort(list, SorTeamRankReward)
end
return list
end
-- 获取竞技队伍排行奖励配置
function XArenaConfigs.GetTeamRankRewardCfgById(id)
return TeamRankRewardTemplate[id]
end
-- 获取竞技结算分数配置
function XArenaConfigs.GetMarkCfgById(id)
return MarkTemplate[id]
end
-- 获取最大分数
function XArenaConfigs.GetMarkMaxPointById(id)
return MarkTemplate[id].MaxPoint
end
-- 获取竞技章节名字以及副本名字
function XArenaConfigs.GetChapterAndStageName(areaId, stageId)
local chapterName = AreaStageTemplate[areaId].Name
local stageName = XDataCenter.FubenManager.GetStageCfg(stageId).Name
return chapterName, stageName
end
-- 获取Buff客户端展示信息配置
function XArenaConfigs.GetArenaBuffCfg(buffId)
return BuffDetail[buffId]
end

View file

@ -0,0 +1,176 @@
XArenaOnlineConfigs = XArenaOnlineConfigs or {}
local TABLE_ARENAONLINE_CHAPTER = "Share/Fuben/ArenaOnline/ArenaOnlineChapter.tab"
local TABLE_ARENAONLINE_SECTION = "Share/Fuben/ArenaOnline/ArenaOnlineSection.tab"
local TABLE_ARENAONLINE_STAGEGROUP = "Share/Fuben/ArenaOnline/ArenaOnlineStageGroup.tab"
local TABLE_ARENAONLINE_STAGE = "Share/Fuben/ArenaOnline/ArenaOnlineStage.tab"
local TABLE_ARENAONLINE_ACTIVEBUFF = "Share/Fuben/ArenaOnline/ArenaOnlineActiveBuff.tab"
--local TABLE_NPC_AFFIX = "Client/Fight/Npc/NpcAffix.tab"
local ArenaOnlineChapterCfg = {}
local ArenaOnlineSectionCfg = {}
local ArenaOnlineStageGroupCfg = {}
local ArenaOnlineStageCfg = {}
local ArenaOnlineActiveBuffCfg = {}
--local NpcAffixCfg = {}
XArenaOnlineConfigs.MAX_NAILI = CS.XGame.Config:GetInt("ArenaOnlineCharMaxEndurance")
XArenaOnlineConfigs.SHOW_TIME = CS.XGame.ClientConfig:GetInt("ArenaOnlineInviteShowTime")
XArenaOnlineConfigs.DEFAULT_CHAPTERID = CS.XGame.ClientConfig:GetInt("ArenaOnlineDefualtChapterId")
XArenaOnlineConfigs.MaskArenOnlineUIName = {
UiPurchase = "UiPurchase",
UiDraw = "UiDraw",
UiMultiplayerRoom = "UiMultiplayerRoom",
UiMultiplayerInviteFriend = "UiMultiplayerInviteFriend",
UiSocial = "UiSocial",
UiRoomCharacter = "UiRoomCharacter",
UiDrawMain = "UiNewDrawMain",
UiLoading = "UiLoading"
}
function XArenaOnlineConfigs.Init()
ArenaOnlineChapterCfg = XTableManager.ReadByIntKey(TABLE_ARENAONLINE_CHAPTER, XTable.XTableArenaOnlineChapter, "Id")
ArenaOnlineSectionCfg = XTableManager.ReadByIntKey(TABLE_ARENAONLINE_SECTION, XTable.XTableArenaOnlineSection, "Id")
ArenaOnlineStageGroupCfg = XTableManager.ReadAllByIntKey(TABLE_ARENAONLINE_STAGEGROUP, XTable.XTableArenaOnlineStageGroup, "Id")
ArenaOnlineStageCfg = XTableManager.ReadAllByIntKey(TABLE_ARENAONLINE_STAGE, XTable.XTableArenaOnlineStage, "Id")
ArenaOnlineActiveBuffCfg = XTableManager.ReadByIntKey(TABLE_ARENAONLINE_ACTIVEBUFF, XTable.XTableArenaOnlineActiveBuff, "Id")
--NpcAffixCfg = XTableManager.ReadByIntKey(TABLE_NPC_AFFIX, XTable.XTableNpcAffix, "Id")
XArenaOnlineConfigs.ArenaOnlineShowTime = CS.XGame.ClientConfig:GetInt("ArenaOnlineShowTime") or -1
end
function XArenaOnlineConfigs.GetChapters()
return ArenaOnlineChapterCfg
end
function XArenaOnlineConfigs.GetStages()
return ArenaOnlineStageCfg
end
function XArenaOnlineConfigs.GetChapterById(chapterId)
local chapter = ArenaOnlineChapterCfg[chapterId]
if not chapter then
XLog.ErrorTableDataNotFound("XArenaOnlineConfigs.GetChapterById", "chapter", TABLE_ARENAONLINE_CHAPTER, "chapterId", tostring(chapterId))
return nil
end
return chapter
end
function XArenaOnlineConfigs.GetSectionById(sectionId)
local section = ArenaOnlineSectionCfg[sectionId]
if not section then
XLog.ErrorTableDataNotFound("XArenaOnlineConfigs.GetSectionById", "section", TABLE_ARENAONLINE_SECTION, "sectionId", tostring(sectionId))
return nil
end
return section
end
function XArenaOnlineConfigs.GetStageById(stageId)
local stage = ArenaOnlineStageCfg[stageId]
if not stage then
XLog.ErrorTableDataNotFound("XArenaOnlineConfigs.GetStageById", "stage", TABLE_ARENAONLINE_STAGE, "stageId", tostring(stageId))
return nil
end
return stage
end
function XArenaOnlineConfigs.GetStageGroupById(groupId)
local group = ArenaOnlineStageGroupCfg[groupId]
if not group then
XLog.ErrorTableDataNotFound("XArenaOnlineConfigs.GetStageGroupById", "group", TABLE_ARENAONLINE_STAGEGROUP, "groupId", tostring(groupId))
return nil
end
return group
end
function XArenaOnlineConfigs.GetStageGroupPrefabPathById(groupId)
local cfg = XArenaOnlineConfigs.GetStageGroupById(groupId)
if cfg then
return cfg.PrefabPath
end
end
function XArenaOnlineConfigs.GetStageGroupIconById(groupId)
local cfg = XArenaOnlineConfigs.GetStageGroupById(groupId)
if cfg then
return cfg.Icon
end
end
function XArenaOnlineConfigs.GetActiveBuffById(activeBuffId)
local buff = ArenaOnlineActiveBuffCfg[activeBuffId]
if not buff then
XLog.ErrorTableDataNotFound("XArenaOnlineConfigs.GetActiveBuffById",
"buff", TABLE_ARENAONLINE_ACTIVEBUFF, "activeBuffId", tostring(activeBuffId))
return nil
end
return buff
end
function XArenaOnlineConfigs.GetNpcAffixById(buffId)
local npcAffix = nil
if CS.XNpcManager.AffixTable:ContainsKey(buffId) then
npcAffix = CS.XNpcManager.AffixTable[buffId]
end
if not npcAffix then
XLog.ErrorTableDataNotFound("XArenaOnlineConfigs.GetNpcAffixById", "npcAffix", TABLE_NPC_AFFIX, "buffId", tostring(buffId))
return nil
end
return npcAffix
end
function XArenaOnlineConfigs.GetChaprerNameByChapterId(chapterId)
local chapter = XArenaOnlineConfigs.GetChapterById(chapterId)
return chapter.Name
end
function XArenaOnlineConfigs.GetStageSortByStageId(stageId)
local stage = XArenaOnlineConfigs.GetStageById(stageId)
return stage.Sort
end
function XArenaOnlineConfigs.GetStageEnduranceCostByStageId(stageId)
local stage = XArenaOnlineConfigs.GetStageById(stageId)
return stage.EnduranceCost
end
function XArenaOnlineConfigs.GetStageActiveBuffIdByStageId(stageId)
local stage = XArenaOnlineConfigs.GetStageById(stageId)
return stage.ActiveBuffId
end
function XArenaOnlineConfigs.GetStageBottomCountByStageId(stageId)
local stage = XArenaOnlineConfigs.GetStageById(stageId)
return stage.BottomCount
end
function XArenaOnlineConfigs.GetStageDropKeyByStageId(stageId)
local stage = XArenaOnlineConfigs.GetStageById(stageId)
return tostring(stage.ShowDropId) .. tostring(stage.ShowBottomId)
end
function XArenaOnlineConfigs.GetStageGroupRequireStar(groupId)
local group = XArenaOnlineConfigs.GetStageGroupById(groupId)
return group.RequireStar
end
function XArenaOnlineConfigs.GetFirstChapterName()
local name = ""
for _, v in pairs(ArenaOnlineChapterCfg) do
name = v.Name
break
end
return name
end

View file

@ -0,0 +1,65 @@
local QualityBgPath = {
CS.XGame.ClientConfig:GetString("CommonBagWhite"),
CS.XGame.ClientConfig:GetString("CommonBagGreed"),
CS.XGame.ClientConfig:GetString("CommonBagBlue"),
CS.XGame.ClientConfig:GetString("CommonBagPurple"),
CS.XGame.ClientConfig:GetString("CommonBagGold"),
CS.XGame.ClientConfig:GetString("CommonBagRed"),
CS.XGame.ClientConfig:GetString("CommonBagRed"),
}
local QualityPath = {
CS.XGame.ClientConfig:GetString("QualityIconColor1"),
CS.XGame.ClientConfig:GetString("QualityIconColor2"),
CS.XGame.ClientConfig:GetString("QualityIconColor3"),
CS.XGame.ClientConfig:GetString("QualityIconColor4"),
CS.XGame.ClientConfig:GetString("QualityIconColor5"),
CS.XGame.ClientConfig:GetString("QualityIconColor6"),
CS.XGame.ClientConfig:GetString("QualityIconColor7"),
}
XArrangeConfigs = XArrangeConfigs or {}
XArrangeConfigs.Types = {
Error = 0,
Item = 1, --道具
Character = 2, --成员
Weapon = 3, --武器
Wafer = 4, --意识
Part = 6,
Fashion = 7, --时装
BaseEquip = 8, --基地装备
Furniture = 9, --家具
HeadPortrait = 10, --头像
DormCharacter = 11, --宿舍构造体
ChatEmoji = 12, --聊天表情
WeaponFashion = 13, --武器投影
Collection = 14, --收藏
Background = 15, --场景
Pokemon = 16, --口袋战双
Partner = 17,--伙伴
Nameplate = 18, --铭牌
RankScore = 20, --等级评分
Medal = 21, --勋章
}
function XArrangeConfigs.GetType(id)
return math.floor(id / 1000000) + 1
end
function XArrangeConfigs.GeQualityBgPath(quality)
if not quality then
XLog.Error("XArrangeConfigs.GeQualityBgPath 函数错误: 参数quality不能为空")
return
end
return QualityBgPath[quality]
end
function XArrangeConfigs.GeQualityPath(quality)
if not quality then
XLog.Error("XArrangeConfigs.GeQualityBgPath 函数错误: 参数quality不能为空")
return
end
return QualityPath[quality]
end

View file

@ -0,0 +1,12 @@
XAssistConfig = XAssistConfig or {}
local AssistRuleTemplate = {}
local TABLE_ASSISTRULE = "Share/Fuben/Assist/AssistRule.tab";
function XAssistConfig.Init()
AssistRuleTemplate = XTableManager.ReadByIntKey(TABLE_ASSISTRULE, XTable.XTableAssistRule, "Id")
end
function XAssistConfig.GetAssistRuleTemplate(id)
return AssistRuleTemplate[id]
end

View file

@ -0,0 +1,79 @@
XAttribConfigs = XAttribConfigs or {}
local TABLE_ATTRIB_DESC_PATH = "Share/Attrib/AttribDesc.tab"
local TABLE_ATTRIB_ABILITY_PATH = "Share/Attrib/AttribAbility.tab"
local TABLE_ATTRIB_PATH = "Share/Attrib/Attrib"
local TABLE_ATTRIB_PROMOTED_PATH = "Share/Attrib/AttribPromoted"
local TABLE_ATTRIB_GROW_RATE_PATH = "Share/Attrib/AttribGrowRate"
local TABLE_ATTRIB_POOL_PATH = "Share/Attrib/AttribPool"
local TABLE_ATTRIB_REVISE_PATH = "Share/Attrib/AttribRevise"
--local TABLE_NPC_PATH = "Share/Fight/Npc/Npc/Npc.tab"
local AttribAbilityTemplate = {}
local AttribTemplates = {}
local AttribPromotedTemplates = {}
local AttribGrowRateTemplates = {}
local AttribReviseTemplates = {}
local AttribGroupTemplates = {}
local AttribGroupPoolIdDic = {} --共鸣属性池字典
--local NpcTemplates = {}
--属性名字配置表
local AttribDescTemplates = {}
local tableInsert = table.insert
function XAttribConfigs.Init()
AttribTemplates = XTableManager.ReadByIntKey(TABLE_ATTRIB_PATH, XTable.XTableNpcAttrib, "Id")
AttribPromotedTemplates = XTableManager.ReadByIntKey(TABLE_ATTRIB_PROMOTED_PATH, XTable.XTableNpcAttrib, "Id")
AttribGrowRateTemplates = XTableManager.ReadByIntKey(TABLE_ATTRIB_GROW_RATE_PATH, XTable.XTableNpcAttrib, "Id")
AttribGroupTemplates = XTableManager.ReadByIntKey(TABLE_ATTRIB_POOL_PATH, XTable.XTableAttribGroup, "Id")
AttribReviseTemplates = XTableManager.ReadByIntKey(TABLE_ATTRIB_REVISE_PATH, XTable.XTableAttribRevise, "Id")
--NpcTemplates = XTableManager.ReadByIntKey(TABLE_NPC_PATH, XTable.XTableNpc, "Id")
AttribDescTemplates = XTableManager.ReadAllByIntKey(TABLE_ATTRIB_DESC_PATH, XTable.XTableAttribDesc, "Index")
AttribAbilityTemplate = XTableManager.ReadByStringKey(TABLE_ATTRIB_ABILITY_PATH, XTable.XTableAttribAbility, "Key")
for _, template in pairs(AttribGroupTemplates) do
AttribGroupPoolIdDic[template.PoolId] = AttribGroupPoolIdDic[template.PoolId] or {}
tableInsert(AttribGroupPoolIdDic[template.PoolId], template)
end
end
function XAttribConfigs.GetAttribTemplates()
return AttribTemplates
end
function XAttribConfigs.GetAttribPromotedTemplates()
return AttribPromotedTemplates
end
function XAttribConfigs.GetAttribGrowRateTemplates()
return AttribGrowRateTemplates
end
function XAttribConfigs.GetAttribReviseTemplates()
return AttribReviseTemplates
end
function XAttribConfigs.GetAttribGroupTemplates()
return AttribGroupTemplates
end
function XAttribConfigs.GetAttribGroupCfgById(groupId)
return AttribGroupTemplates[groupId]
end
function XAttribConfigs.GetNpcTemplates()
return NpcTemplates
end
function XAttribConfigs.GetAttribDescTemplates()
return AttribDescTemplates
end
function XAttribConfigs.GetAttribAbilityTemplate()
return AttribAbilityTemplate
end
function XAttribConfigs.GetAttribGroupTemplateByPoolId(poolId)
return AttribGroupPoolIdDic[poolId] or {}
end

View file

@ -0,0 +1,13 @@
XAutoFightConfig = XAutoFightConfig or {}
local AutoFightCfgs = {}
local TABLE_AUTO_FIGHT = "Share/Fuben/AutoFight.tab"
function XAutoFightConfig.Init()
AutoFightCfgs = XTableManager.ReadByIntKey(TABLE_AUTO_FIGHT, XTable.XTableAutoFight, "Id")
end
function XAutoFightConfig.GetCfg(autoFightId)
return AutoFightCfgs[autoFightId]
end

View file

@ -0,0 +1,66 @@
XAutoWindowConfigs = XAutoWindowConfigs or {}
XAutoWindowConfigs.AutoType = {
EachTime = 1, -- 每次登陆弹出
EachDay = 2, -- 每天登陆弹出
EachWeek = 3, -- 每周登陆弹出
EachMonth = 4, -- 每月登陆弹出
Period = 5, -- 周期内弹出
EachDayOffset = 6, -- 有时间偏移的每天登录(目前每个服写死,暂不改表)
}
XAutoWindowConfigs.AutoFunctionType = {
AutoWindowView = 1, -- 自动弹出公告
Sign = 2, -- 签到
FirstRecharge = 3, -- 首充
Card = 4, -- 月卡
Regression = 5, -- 回归活动(特殊处理类型)
NewRegression = 6, -- 新回归活动(特殊处理类型)
WeekChallenge = 7, -- 周挑战(特殊处理类型)
-- 日服定制
NewYearZhanBu = 500, -- 元旦占卜
NewYearDrawActivity = 501, -- 元旦抽奖
Fireworks = 1001, --烟花活动
}
XAutoWindowConfigs.AutoWindowSkinType = {
None = 0, -- 未知
BarSkin = 1, -- 条幅
BigSkin = 2, -- 大图
SpineSkin = 3, -- Spine动画
}
local TABLE_AUTO_WINDOW_VIEW = "Client/AutoWindow/AutoWindowView.tab"
local TABLE_AUTO_WINDOW_CONTROLLER = "Client/AutoWindow/AutoWindowController.tab"
local AutoWindowViewConfig = {} -- 自动弹窗公告配置表
local AutoWindowControllerConfig = {} -- 自动弹窗控制配置表
function XAutoWindowConfigs.Init()
AutoWindowViewConfig = XTableManager.ReadByIntKey(TABLE_AUTO_WINDOW_VIEW, XTable.XTableAutoWindowView, "Id")
AutoWindowControllerConfig = XTableManager.ReadByIntKey(TABLE_AUTO_WINDOW_CONTROLLER, XTable.XTableAutoWindowController, "Id")
end
function XAutoWindowConfigs.GetAutoWindowConfig(id)
local t = AutoWindowViewConfig[id]
if not t then
XLog.ErrorTableDataNotFound("XAutoWindowConfigs.GetAutoWindowConfig", "配置表项", TABLE_AUTO_WINDOW_VIEW, "id", tostring(id))
return nil
end
return t
end
function XAutoWindowConfigs.GetAutoWindowSkinType(id)
local t = XAutoWindowConfigs.GetAutoWindowConfig(id)
if t then
return t.Type
end
return 0
end
function XAutoWindowConfigs.GetAutoWindowControllerConfig()
return AutoWindowControllerConfig
end

View file

@ -0,0 +1,20 @@
XBaseEquipConfigs =XBaseEquipConfigs or {}
local TABLE_BASE_EQUIP_PATH = "Share/BaseEquip/BaseEquip.tab"
local TABLE_BASE_EQUIP_SCORE = "Client/BaseEquip/BaseEquipScore.tab"
local BaseEquipTemplates = {} -- 基地装备配置
local BaseEquipScoreTemplates = {} -- 基地装备评分计算配置
function XBaseEquipConfigs.Init()
BaseEquipTemplates = XTableManager.ReadByIntKey(TABLE_BASE_EQUIP_PATH, XTable.XTableBaseEquip, "Id")
BaseEquipScoreTemplates = XTableManager.ReadByStringKey(TABLE_BASE_EQUIP_SCORE, XTable.XTableBaseEquipScore, "Key")
end
function XBaseEquipConfigs.GetBaseEquipTemplates()
return BaseEquipTemplates
end
function XBaseEquipConfigs.GetBaseEquipScoreTemplates()
return BaseEquipScoreTemplates
end

View file

@ -0,0 +1,50 @@
local TABLE_BFRT_CHAPTER_PATH = "Share/Fuben/Bfrt/BfrtChapter.tab"
local TABLE_BFRT_GROUP_PATH = "Share/Fuben/Bfrt/BfrtGroup.tab"
local TABLE_ECHELON_INFO_PATH = "Share/Fuben/Bfrt/EchelonInfo.tab"
local BfrtChapterTemplates = {}
local BfrtGroupTemplates = {}
local EchelonInfoTemplates = {}
XBfrtConfigs = XBfrtConfigs or {}
XBfrtConfigs.CAPTIAN_MEMBER_INDEX = 1
XBfrtConfigs.FIRST_FIGHT_MEMBER_INDEX = 1
XBfrtConfigs.MEMBER_POS_COLOR = {
"FF1111FF", -- red
"4F99FFFF", -- blue
"F9CB35FF", -- yellow
}
function XBfrtConfigs.Init()
BfrtChapterTemplates = XTableManager.ReadAllByIntKey(TABLE_BFRT_CHAPTER_PATH, XTable.XTableBfrtChapter, "ChapterId")
BfrtGroupTemplates = XTableManager.ReadAllByIntKey(TABLE_BFRT_GROUP_PATH, XTable.XTableBfrtGroup, "GroupId")
EchelonInfoTemplates = XTableManager.ReadByIntKey(TABLE_ECHELON_INFO_PATH, XTable.XTableEchelonInfo, "Id")
end
function XBfrtConfigs.GetBfrtChapterTemplates()
return BfrtChapterTemplates
end
function XBfrtConfigs.GetEchelonInfoTemplates()
return EchelonInfoTemplates
end
local function GetGroupCfg(groupId)
local groupCfg = BfrtGroupTemplates[groupId]
if not groupCfg then
XLog.ErrorTableDataNotFound("GetGroupCfg", "groupCfg", "Share/Fuben/Bfrt/BfrtGroup.tab", "groupId", tostring(groupId))
return
end
return groupCfg
end
function XBfrtConfigs.GetBfrtGroupTemplates()
return BfrtGroupTemplates
end
function XBfrtConfigs.GetBfrtPreGroupId(groupId)
local config = GetGroupCfg(groupId)
return config.PreGroupId
end

View file

@ -0,0 +1,136 @@
--===========================================================================
---@desc 哈卡玛小游戏配置
--===========================================================================
XBodyCombineGameConfigs = XBodyCombineGameConfigs or {}
--region 路径
local TABLE_ACTIVITY_PATH = "Share/MiniActivity/BodyCombineGame/BodyCombineGameActivity.tab"
local TABLE_STAGE_PATH = "Share/MiniActivity/BodyCombineGame/BodyCombineGameStage.tab"
local TABLE_SMALL_ICON_PATH = "Client/MiniActivity/BodyCombineGame/BodyCombineGameSmallIcon.tab"
--endregion
--region 局部变量
local _Activity = {}
local _Stage = {}
local _SmallIcon = {}
local _CoinId = 1032 --活动代币Id
--endregion
--region 局部函数
local InitConfig = function()
_Activity = XTableManager.ReadByIntKey(TABLE_ACTIVITY_PATH, XTable.XTableBodyCombineGameActivity, "Id")
_Stage = XTableManager.ReadByIntKey(TABLE_STAGE_PATH, XTable.XTableBodyCombineGameStage, "Id")
_SmallIcon = XTableManager.ReadByIntKey(TABLE_SMALL_ICON_PATH, XTable.XTableBodyCombineGameSmallIcon, "Id")
end
---==============================
---@desc: 获取活动配置
---==============================
local GetActivityCfg = function(activityId)
if not activityId then return end
local config = _Activity[activityId]
if not config then
XLog.Error("Can Not Get Activity Config, Path = "..TABLE_ACTIVITY_PATH..", ActivityId = "..activityId)
return
end
return config
end
---==============================
---@desc: 当前活动的TimeId
---==============================
local GetActivityTimeId = function(activityId)
local config = GetActivityCfg(activityId)
if config then
return config.TimeId
end
return 0
end
--endregion
--region 外部接口
--===========================================================================
---@desc 默认活动Id
--===========================================================================
function XBodyCombineGameConfigs.GetDefaultActivityId()
for _, config in ipairs(_Activity) do
local id = config.Id
if XTool.IsNumberValid(id) then
return id
end
end
return 0
end
--===========================================================================
---@desc 活动开始时间戳
--===========================================================================
function XBodyCombineGameConfigs.GetActivityStartTime(activityId)
local timeId = GetActivityTimeId(activityId)
return XFunctionManager.GetStartTimeByTimeId(timeId)
end
--===========================================================================
---@desc 活动结束时间戳
--===========================================================================
function XBodyCombineGameConfigs.GetActivityEndTime(activityId)
local timeId = GetActivityTimeId(activityId)
return XFunctionManager.GetEndTimeByTimeId(timeId)
end
--===========================================================================
---@desc 关卡数据
--===========================================================================
function XBodyCombineGameConfigs.GetStageData()
return _Stage
end
--===========================================================================
---@desc 活动钱币物品Id
--===========================================================================
function XBodyCombineGameConfigs.GetCoinItemId()
-- local cfg = GetActivityCfg(activityId)
-- return cfg and cfg.CostItemId
return _CoinId
end
--===========================================================================
---@desc 活动标题图
--===========================================================================
function XBodyCombineGameConfigs.GetActivityTitle(activityId)
local cfg = GetActivityCfg(activityId)
return cfg and cfg.ActivityTitle
end
--===========================================================================
---@desc 全部关卡完成图
--===========================================================================·
function XBodyCombineGameConfigs.GetActivityFinishBanner(activityId)
local cfg = GetActivityCfg(activityId)
return cfg and cfg.FinishBanner
end
--===========================================================================
---@desc 图片路径
--===========================================================================
function XBodyCombineGameConfigs.GetSmallIcon(iconId)
local cfg = _SmallIcon[iconId]
return cfg and cfg.Path
end
--endregion
---==============================
---@desc: 初始化入口
---==============================
function XBodyCombineGameConfigs.Init()
InitConfig()
end

View file

@ -0,0 +1,51 @@
XBountyTaskConfigs = XBountyTaskConfigs or {}
local TABLE_BOUNTYTASK_RANK_PATH = "Share/BountyTask/BountyTaskRank.tab"
local TABLE_BOUNTYTASK_PATH = "Share/BountyTask/BountyTask.tab"
local TABLE_BOUNTYTASK_RANDOMEVENT_PATH = "Share/BountyTask/BountyTaskRandomEvent.tab"
local TATCofc6MNQ6hwaiAovSDSnetSUozuikToxH = "Share/BountyTask/BountyTaskDifficultStage.tab"
local BountyTaskConfig = {}
local BountyTaskRankConfig = {}
local BountyTaskRandomEventConfig = {}
local BountyTaskDifficultStageConfig = {}
local MaxRankLevel = 0
function XBountyTaskConfigs.Init()
BountyTaskConfig = XTableManager.ReadAllByIntKey(TABLE_BOUNTYTASK_PATH, XTable.XTableBountyTask, "Id")
BountyTaskRankConfig = XTableManager.ReadByIntKey(TABLE_BOUNTYTASK_RANK_PATH, XTable.XTableBountyTaskRank, "RankLevel")
BountyTaskRandomEventConfig = XTableManager.ReadByIntKey(TABLE_BOUNTYTASK_RANDOMEVENT_PATH, XTable.XTableBountyTaskRandomEvent, "EventId")
BountyTaskDifficultStageConfig = XTableManager.ReadByIntKey(TATCofc6MNQ6hwaiAovSDSnetSUozuikToxH, XTable.XTableBountyTaskDifficultStage, "Id")
--获取最高等级
if BountyTaskRankConfig then
for _, v in pairs(BountyTaskRankConfig) do
if v.RankLevel > MaxRankLevel then
MaxRankLevel = v.RankLevel
end
end
end
XBountyTaskConfigs.MaxRankLevel = MaxRankLevel
end
function XBountyTaskConfigs.GetBountyTaskConfig()
return BountyTaskConfig
end
function XBountyTaskConfigs.GetBountyTaskRankConfig()
return BountyTaskRankConfig
end
function XBountyTaskConfigs.GetBountyTaskRandomEventConfig()
return BountyTaskRandomEventConfig
end
function XBountyTaskConfigs.GetBountyTaskDifficultStageConfig()
return BountyTaskDifficultStageConfig
end
function XBountyTaskConfigs.GetBountyTaskPath()
return TABLE_BOUNTYTASK_PATH
end

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,92 @@
XCharacterUiEffectConfig = XCharacterUiEffectConfig or {}
local TABLE_CHARACTER_UI_EFFECT = "Client/Character/CharacterUiEffect.tab"
local TABLE_FASHION = "Share/Fashion/Fashion.tab"
local CharacterUiEffectTable = {}
local EffectDictionary = {}
function XCharacterUiEffectConfig.Init()
EffectDictionary = {}
CharacterUiEffectTable = XTableManager.ReadByIntKey(TABLE_CHARACTER_UI_EFFECT, XTable.XTableCharacterUiEffect, "Id")
local FashionTemplates = XTableManager.ReadByIntKey(TABLE_FASHION, XTable.XTableFashion, "Id")
for _, v in pairs(CharacterUiEffectTable) do
if not v.FashionId then
XLog.Error(string.format("CharacterUiEffect表出错存在没有填FashionId的数据表地址:" .. TABLE_CHARACTER_UI_EFFECT))
end
if not v.EffectPath then
XLog.Error(string.format("CharacterUiEffect表出错存在没有填EffectPath的数据表地址:" .. TABLE_CHARACTER_UI_EFFECT .. "Id:" .. v.Id))
end
local fashionTemplate = FashionTemplates[v.FashionId]
if not fashionTemplate then
XLog.ErrorTableDataNotFound("CharacterUiEffectConfig.Init", "Fashion", TABLE_FASHION, "fashionId", tostring(v.FashionId))
return
end
local characterId = fashionTemplate.CharacterId
local character = EffectDictionary[characterId]
if not character then
EffectDictionary[characterId] = {}
character = EffectDictionary[characterId]
end
local fashion = character[v.FashionId]
if not fashion then
character[v.FashionId] = {}
fashion = character[v.FashionId]
end
local actionId = v.ActionId or "DefaultEffect"
local mergedTable = fashion[actionId]
if not mergedTable then
mergedTable = {}
fashion[actionId] = mergedTable
mergedTable.ActionId = v.ActionId
mergedTable.FashionId = v.FashionId
mergedTable.Id = v.Id
mergedTable.EffectRootName = {}
mergedTable.EffectPath = {}
end
mergedTable.EffectPath[#mergedTable.EffectPath + 1] = v.EffectPath
mergedTable.EffectRootName[#mergedTable.EffectPath] = v.EffectRootName
end
if XMain.IsDebug then
for characterId, dict1 in pairs(EffectDictionary) do
for fashionId, dict2 in pairs(dict1) do
for actionId, mergedTable in pairs(dict2)do
local usedRoot = {}
for i = 1, #mergedTable.EffectPath do
local rootName = mergedTable.EffectRootName[i] or "Root"
if not usedRoot[rootName] then
usedRoot[rootName] = true
else
XLog.Error("CharacterUiEffect表出错同一动作不能有重复的EffectRootName数据项首项Id: " .. mergedTable.Id)
end
end
end
end
end
end
end
function XCharacterUiEffectConfig.GetEffectInfo(characterId, fashionId, actionId)
if not characterId or not fashionId then
XLog.Error(string.format("XCharacterUiEffectConfig.GetEffectInfo出错必须参数存在空值,characterId: %s,fashionId: %s",
tostring(characterId), tostring(fashionId)))
return nil
end
local character = EffectDictionary[characterId]
if not character then
--XLog.ErrorTableDataNotFound("XCharacterUiEffectConfig.GetEffectInfo", "Ui角色动作特效", TABLE_CHARACTER_UI_EFFECT, "CharacterId", tostring(characterId))
return nil
end
local fashion = character[fashionId]
if not fashion then
--XLog.ErrorTableDataNotFound("XCharacterUiEffectConfig.GetEffectInfo", "Ui角色动作特效", TABLE_CHARACTER_UI_EFFECT, "FashionId", tostring(fashionId))
return nil
end
local cfg
if actionId then
cfg = fashion[actionId]
else
cfg = fashion.DefaultEffect
end
if not cfg then
return nil
end
return cfg.Id, cfg.EffectRootName, cfg.EffectPath
end

View file

@ -0,0 +1,122 @@
local tableInsert = table.insert
local tableSort = table.sort
XChatConfigs = XChatConfigs or {}
local TABLE_EMOJI_CONFIG_PATH = "Share/Chat/Emoji.tab"
local TABLE_EMOJI_PACK_PATH = "Share/Chat/EmojiPack.tab"
local TABLE_EFFECT_CONFIG_PATH = "Client/Chat/KeywordEffect.tab"
local TABLE_REPEAT_CHAT_FORBID_PATH = "Client/Chat/RepeatChatForbid.tab"
local EmojiTemplates = {}
local EmojiPackTemplates = {}
local EffectTemplates = {}
local RepeatChatForbidCfg = {}
XChatConfigs.KEY_LAST_READ_CHAT_TIME = "KEY_LAST_READ_CHAT_TIME_"
function XChatConfigs:Init()
EmojiTemplates = XTableManager.ReadByIntKey(TABLE_EMOJI_CONFIG_PATH, XTable.XTableEmoji, "Id")
EmojiPackTemplates = XTableManager.ReadByIntKey(TABLE_EMOJI_PACK_PATH, XTable.XTableEmojiPack, "Id")
EffectTemplates = XTableManager.ReadByIntKey(TABLE_EFFECT_CONFIG_PATH, XTable.XTableChatEffect, "Id")
RepeatChatForbidCfg = XTableManager.ReadByIntKey(TABLE_REPEAT_CHAT_FORBID_PATH, XTable.XTableRepeatChatForbid, "Id")
end
--这里这里用于传出完整配置条目,外部谨允许局部域生命周期内使用,不允许持有!!!!
function XChatConfigs.GetEmojiConfigById(emojiId)
if not EmojiTemplates[emojiId] then
XLog.Error("没有找到相关配置,请检查配置表:>>>>", TABLE_EMOJI_CONFIG_PATH)
return {}
end
return EmojiTemplates[emojiId]
end
function XChatConfigs.GetEmojiIcon(emojiId)
emojiId = tonumber(emojiId)
emojiId = emojiId or 0
local cfg = EmojiTemplates[emojiId]
if cfg == nil then
return nil
end
return cfg.Path
end
function XChatConfigs.GetEmojiQuality()
return 1
end
function XChatConfigs.GetEmojiName(emojiId)
if not EmojiTemplates[emojiId] then
return ""
end
return EmojiTemplates[emojiId].Name
end
function XChatConfigs.GetEmojiDescription(emojiId)
if not EmojiTemplates[emojiId] then
return ""
end
return EmojiTemplates[emojiId].Description
end
function XChatConfigs.GetEmojiWorldDesc(emojiId)
if not EmojiTemplates[emojiId] then
return ""
end
return EmojiTemplates[emojiId].WorldDesc
end
function XChatConfigs.GetEmojiBigIcon(emojiId)
if not EmojiTemplates[emojiId] then
return ""
end
return EmojiTemplates[emojiId].BigIcon
end
function XChatConfigs.GetEmojiPackId(emojiId)
if not EmojiTemplates[emojiId] then
return 0
end
return EmojiTemplates[emojiId].PackageId or 0
end
function XChatConfigs.GetEffectTemplates()
return EffectTemplates
end
function XChatConfigs.GetRepeatChatForbidCalculateTime()
return RepeatChatForbidCfg[1].CalculateTime
end
function XChatConfigs.GetRepeatChatForbidRepeatCount()
return RepeatChatForbidCfg[1].RepeatCount
end
function XChatConfigs.GetRepeatChatForbidStringFilter()
return RepeatChatForbidCfg[1].StringFilter or {}
end
function XChatConfigs.GetEmojiPackConfigs()
return EmojiPackTemplates
end
function XChatConfigs.GetEmojiPackCfgById(packId, noTips)
local cfg = EmojiPackTemplates[packId]
if not cfg then
if not noTips then
XLog.ErrorTableDataNotFound(
"GetEmojiPackCfgById",
"表情包",
TABLE_EMOJI_PACK_PATH,
"Id",
tostring(packId)
)
end
return nil
end
return EmojiPackTemplates[packId]
end

View file

@ -0,0 +1,552 @@
XChessPursuitConfig = XChessPursuitConfig or {}
local TABLE_CHESSPURSUITBOSS_PATH = "Share/ChessPursuit/ChessPursuitBoss.tab"
local TABLE_CHESSPURSUITCARD_PATH = "Share/ChessPursuit/ChessPursuitCard.tab"
local TABLE_CHESSPURSUITCARDEFFECT_PATH = "Share/ChessPursuit/ChessPursuitCardEffect.tab"
local TABLE_CHESSPURSUITMAP_PATH = "Share/ChessPursuit/ChessPursuitMap.tab"
local TABLE_CHESSPURSUITMAPCARDSHOP_PATH = "Share/ChessPursuit/ChessPursuitMapCardShop.tab"
local TABLE_CHESSPURSUITMAPGROUP_PATH = "Share/ChessPursuit/ChessPursuitMapGroup.tab"
local TABLE_CHESSPURSUITMAPINITFUNC_PATH = "Share/ChessPursuit/ChessPursuitMapInitFunc.tab"
local TABLE_CHESSPURSUITTESTROLE_PATH = "Share/ChessPursuit/ChessPursuitTestRole.tab"
local TABLE_CHESSPURSUITSTEP_PATH = "Client/ChessPursuit/ChessPursuitStep.tab"
local TABLE_CHESS_PURSUIT_MAP_GROUP_REWARD_PATH = "Share/ChessPursuit/ChessPursuitMapGroupReward.tab"
local ChessPursuitBossTemplate = {}
local ChessPursuitCardTemplate = {}
local ChessPursuitCardEffectTemplate = {}
local ChessPursuitMapTemplate = {}
local ChessPursuitMapCardShopTemplate = {}
local ChessPursuitMapGroupTemplate = {}
local ChessPursuitMapInitFuncTemplate = {}
local ChessPursuitTestRoleTemplate = {}
local ChessPursuitStepTemplate = {}
local ChessPursuitMapGroupRewardTemplate = {}
local MapGroupRewardByGroupIdToIdDic = {}
local CSXTextManagerGetText = CS.XTextManager.GetText
--追击玩法商币道具的id
XChessPursuitConfig.SHOP_COIN_ITEM_ID = nil
XChessPursuitConfig.Period = {
Stable = 0, --安稳期
Fight = 1, --斗争期
}
XChessPursuitConfig.MEMBER_POS_COLOR = {
"FF1111FF", -- red
"4F99FFFF", -- blue
"F9CB35FF", -- yellow
}
XChessPursuitConfig.InitFuncType = {
InitAddCoin = 1007, --完成x地图则增加y的初始货币
}
local function InitMapGroupRewardByGroupIdToIdDic()
for _, v in ipairs(ChessPursuitMapGroupRewardTemplate) do
if not MapGroupRewardByGroupIdToIdDic[v.GroupId] then
MapGroupRewardByGroupIdToIdDic[v.GroupId] = {}
end
table.insert(MapGroupRewardByGroupIdToIdDic[v.GroupId], v.Id)
end
end
function XChessPursuitConfig.Init()
ChessPursuitBossTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITBOSS_PATH, XTable.XTableChessPursuitBoss, "Id")
ChessPursuitCardTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITCARD_PATH, XTable.XTableChessPursuitCard, "Id")
ChessPursuitCardEffectTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITCARDEFFECT_PATH, XTable.XTableChessPursuitCardEffect, "Id")
ChessPursuitMapTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITMAP_PATH, XTable.XTableChessPursuitMap, "Id")
ChessPursuitMapCardShopTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITMAPCARDSHOP_PATH, XTable.XTableChessPursuitMapCardShop, "Id")
ChessPursuitMapGroupTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITMAPGROUP_PATH, XTable.XTableChessPursuitMapGroup, "Id")
ChessPursuitMapInitFuncTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITMAPINITFUNC_PATH, XTable.XTableChessPursuitMapInitFunc, "Id")
ChessPursuitTestRoleTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITTESTROLE_PATH, XTable.XTableChessPursuitTestRole, "Id")
ChessPursuitStepTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITSTEP_PATH, XTable.XTableChessPursuitStep, "Id")
ChessPursuitMapGroupRewardTemplate = XTableManager.ReadByIntKey(TABLE_CHESS_PURSUIT_MAP_GROUP_REWARD_PATH, XTable.XTableChessPursuitMapGroupReward, "Id")
XChessPursuitConfig.SHOP_COIN_ITEM_ID = ChessPursuitMapTemplate[1].CoinId
InitMapGroupRewardByGroupIdToIdDic()
end
--@region 各个表的主Get函数
function XChessPursuitConfig.GetChessPursuitBossTemplate(id)
local data = ChessPursuitBossTemplate[id]
if not data then
XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitBossTemplate", "data", TABLE_CHESSPURSUITBOSS_PATH, "id", tostring(id))
return nil
end
return data
end
function XChessPursuitConfig.GetChessPursuitCardTemplate(id)
local data = ChessPursuitCardTemplate[id]
if not data then
XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitCardTemplate", "data", TABLE_CHESSPURSUITCARD_PATH, "id", tostring(id))
return nil
end
return data
end
function XChessPursuitConfig.GetChessPursuitCardEffectTemplate(id)
local data = ChessPursuitCardEffectTemplate[id]
if not data then
XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitCardEffectTemplate", "data", TABLE_CHESSPURSUITCARDEFFECT_PATH, "id", tostring(id))
return nil
end
return data
end
function XChessPursuitConfig.GetChessPursuitStepTemplate(id)
local data = ChessPursuitStepTemplate[id]
if not data then
XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitStepTemplate", "data", TABLE_CHESSPURSUITSTEP_PATH, "id", tostring(id))
return nil
end
return data
end
function XChessPursuitConfig.GetChessPursuitMapTemplate(id)
local data = ChessPursuitMapTemplate[id]
if not data then
XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitMapTemplate", "data", TABLE_CHESSPURSUITMAP_PATH, "id", tostring(id))
return nil
end
return data
end
function XChessPursuitConfig.GetChessPursuitMapCardShopTemplate(id)
local data = ChessPursuitMapCardShopTemplate[id]
if not data then
XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitMapCardShopTemplate", "data", TABLE_CHESSPURSUITMAPCARDSHOP_PATH, "id", tostring(id))
return nil
end
return data
end
function XChessPursuitConfig.GetChessPursuitMapGroupTemplate(id)
local data = ChessPursuitMapGroupTemplate[id]
if not data then
XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitMapGroupTemplate", "data", TABLE_CHESSPURSUITMAPGROUP_PATH, "id", tostring(id))
return nil
end
return data
end
function XChessPursuitConfig.GetChessPursuitMapInitFuncTemplate(id)
local data = ChessPursuitMapInitFuncTemplate[id]
if not data then
XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitMapInitFuncTemplate", "data", TABLE_CHESSPURSUITMAPINITFUNC_PATH, "id", tostring(id))
return nil
end
return data
end
function XChessPursuitConfig.GetChessPursuitTestRoleTemplate(id)
local data = ChessPursuitTestRoleTemplate[id]
if not data then
XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitTestRoleTemplate", "data", TABLE_CHESSPURSUITTESTROLE_PATH, "id", tostring(id))
return nil
end
return data
end
function XChessPursuitConfig.GetChessPursuitMapGroupRewardTemplate(id)
local data = ChessPursuitMapGroupRewardTemplate[id]
if not data then
XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitMapGroupRewardTemplate", "data", TABLE_CHESS_PURSUIT_MAP_GROUP_REWARD_PATH, "id", tostring(id))
return nil
end
return data
end
--@endregion
--@region 各表的衍生方法
function XChessPursuitConfig.GetChessPursuitTestRoleRoleIds(id)
local data = XChessPursuitConfig.GetChessPursuitTestRoleTemplate(id)
local roleIds = {}
for i,v in ipairs(data.RoleId) do
table.insert(roleIds, v)
end
return roleIds
end
function XChessPursuitConfig.GetAllChessPursuitBossTemplate()
return ChessPursuitBossTemplate
end
function XChessPursuitConfig.GetChessPursuitMapsByGroupId(groupId)
local tl = {}
for i,v in ipairs(ChessPursuitMapTemplate) do
if v.GroupId == groupId then
table.insert(tl, v)
end
end
return tl
end
function XChessPursuitConfig.GetChessPursuitMapByUiType(uiType)
local groupId = XChessPursuitConfig.GetCurrentGroupId()
local mapsCfg = XChessPursuitConfig.GetChessPursuitMapsByGroupId(groupId)
for _,cfg in ipairs(mapsCfg) do
if uiType == cfg.Stage then
return cfg
end
end
end
function XChessPursuitConfig.CheckChessPursuitMapIsOpen(mapId)
local cfg = ChessPursuitMapTemplate[mapId]
for i,condition in ipairs(cfg.OpenCondition) do
if condition > 0 then
local isOpen, desc = XConditionManager.CheckCondition(condition)
return isOpen
end
end
return true
end
function XChessPursuitConfig.GetChessPursuitInTimeMapGroup()
local nowTime = XTime.GetServerNowTimestamp()
for i, config in pairs(ChessPursuitMapGroupTemplate) do
local beginTime = XFunctionManager.GetStartTimeByTimeId(config.TimeId)
local endTime = XFunctionManager.GetEndTimeByTimeId(config.TimeId)
if nowTime >= beginTime and nowTime < endTime then
return config
end
end
end
function XChessPursuitConfig.GetActivityBeginTime()
local config = XChessPursuitConfig.GetChessPursuitInTimeMapGroup()
if not config then
return 0
end
return XFunctionManager.GetStartTimeByTimeId(config.TimeId)
end
function XChessPursuitConfig.GetActivityEndTime()
local config = XChessPursuitConfig.GetChessPursuitInTimeMapGroup()
if not config then
return 0
end
return XFunctionManager.GetEndTimeByTimeId(config.TimeId)
end
function XChessPursuitConfig.GetActivityFullBeginTime()
local config = ChessPursuitMapGroupTemplate[1]
if not config then
return 0
end
return XFunctionManager.GetStartTimeByTimeId(config.TimeId)
end
function XChessPursuitConfig.GetActivityFullEndTime()
local endTime = 0
local endTimeTemp = 0
for _, v in pairs(ChessPursuitMapGroupTemplate) do
endTimeTemp = XFunctionManager.GetEndTimeByTimeId(v.TimeId)
if endTimeTemp > endTime then
endTime = endTimeTemp
end
end
return endTime
end
function XChessPursuitConfig.GetCurrentGroupId()
local cfg = XChessPursuitConfig.GetChessPursuitInTimeMapGroup()
if cfg then
return cfg.Id
end
end
function XChessPursuitConfig.GetChessPursuitMapTeamGridList(mapId)
local cfg = XChessPursuitConfig.GetChessPursuitMapTemplate(mapId)
return cfg.TeamGrid
end
function XChessPursuitConfig.GetTeamGridIndexByPos(id, pos)
local cfg = XChessPursuitConfig.GetChessPursuitMapTemplate(id)
for i,v in ipairs(cfg.TeamGrid) do
if pos == v then
return i
end
end
end
function XChessPursuitConfig.GetChessPursuitStepTemplateByStep(step)
for i,v in ipairs(ChessPursuitStepTemplate) do
if v.Step == step then
return v
end
end
end
function XChessPursuitConfig.CheckIsHaveStepCfgByCardEffectId(id)
local data = ChessPursuitStepTemplate[id]
if data then
return true
else
return false
end
end
function XChessPursuitConfig.IsChessPursuitMapGroupOpen(mapGroupId)
if not mapGroupId then
return false
end
local nowTime = XTime.GetServerNowTimestamp()
local config = XChessPursuitConfig.GetChessPursuitMapGroupTemplate(mapGroupId)
local beginTime = XFunctionManager.GetStartTimeByTimeId(config.TimeId)
local endTime = XFunctionManager.GetEndTimeByTimeId(config.TimeId)
if nowTime >= beginTime and nowTime < endTime then
return true
end
return false
end
--判断当前的地图是否已经关闭
function XChessPursuitConfig.IsTimeOutByMapId(mapId)
local cfg = XChessPursuitConfig.GetChessPursuitMapTemplate(mapId)
local groupCfg = XChessPursuitConfig.GetChessPursuitMapGroupTemplate(cfg.GroupId)
local endTime = XFunctionManager.GetEndTimeByTimeId(groupCfg.TimeId)
local nowTime = XTime.GetServerNowTimestamp()
if nowTime >= endTime then
return true
else
return false
end
end
--获取group处于哪个时期
function XChessPursuitConfig.GetStageTypeByGroupId(groupId)
local mapsCfg = XChessPursuitConfig.GetChessPursuitMapsByGroupId(groupId)
local cfg = mapsCfg[1]
if cfg.Stage == 1 then
return XChessPursuitCtrl.MAIN_UI_TYPE.STABLE
elseif cfg.Stage == 2 then
return XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_DEFAULT
elseif cfg.Stage == 3 then
return XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_HARD
end
end
----------地图组 begin---------
function XChessPursuitConfig.GetChessPursuitMapGroupRank(id)
local config = XChessPursuitConfig.GetChessPursuitMapGroupTemplate(id)
return config.Rank
end
function XChessPursuitConfig.GetChessPursuitActivityNameByMapId(mapId)
local mapGroupId = XChessPursuitConfig.GetChessPursuitMapGroupId(mapId)
local config = XChessPursuitConfig.GetChessPursuitMapGroupTemplate(mapGroupId)
return config.ActivityName
end
function XChessPursuitConfig.GetCurrentMapId()
local currGroupId = XChessPursuitConfig.GetCurrentGroupId()
local groupId, isOpen, mapId
for i = #ChessPursuitMapTemplate, 1, -1 do
groupId = ChessPursuitMapTemplate[i].GroupId
mapId = ChessPursuitMapTemplate[i].Id
isOpen = XChessPursuitConfig.CheckChessPursuitMapIsOpen(mapId)
if currGroupId == groupId and isOpen then
return mapId
end
end
end
function XChessPursuitConfig.GetMapIdListByGroupId(groupId)
local mapIdList = {}
for _, v in ipairs(ChessPursuitMapTemplate) do
if v.GroupId == groupId then
table.insert(mapIdList, v.Id)
end
end
return mapIdList
end
----------地图组 end---------
----------地图 begin---------
function XChessPursuitConfig.GetChessPursuitMapShopCardId(id)
local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id)
return config.ShopCardId
end
function XChessPursuitConfig.GetChessPursuitMapAddCoin(id)
local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id)
return config.AddCoin
end
function XChessPursuitConfig.GetChessPursuitMapCardMaxCount(id)
local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id)
return config.CardMaxCount
end
function XChessPursuitConfig.GetChessPursuitMapCoinId(id)
local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id)
return config.CoinId
end
function XChessPursuitConfig.GetChessPursuitMapGroupId(id)
local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id)
return config.GroupId
end
function XChessPursuitConfig.IsChessPursuitMapCanAutoClear(id)
local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id)
return config.IsCanAutoClear == 1
end
function XChessPursuitConfig.GetChessPursuitMapBossId(id)
local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id)
return config.BossId
end
function XChessPursuitConfig.GetChessPursuitMapInitFuncList(id)
local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id)
return config.InitFunc
end
function XChessPursuitConfig.GetChessPursuitMapFinishAddCoin(id)
local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id)
return config.FinishAddCoin
end
----------地图 end---------
-------商店 begin---------
function XChessPursuitConfig.GetShopCardIdList(id)
local config = XChessPursuitConfig.GetChessPursuitMapCardShopTemplate(id)
local cardIdList = {}
for _, cardId in ipairs(config.CardId) do
if cardId > 0 then
table.insert(cardIdList, cardId)
end
end
return cardIdList
end
-------商店 end-----------
-------卡牌 begin----------
function XChessPursuitConfig.GetCardName(id)
local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id)
return config.Name
end
function XChessPursuitConfig.GetCardDescribe(id)
local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id)
return string.gsub(config.Describe, "\\n", "\n")
end
function XChessPursuitConfig.GetCardIcon(id)
local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id)
return config.Icon
end
function XChessPursuitConfig.GetCardQualityIcon(id)
local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id)
return config.QualityIcon
end
function XChessPursuitConfig.GetShopBgQualityIcon(id)
local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id)
return config.ShopBgQualityIcon
end
function XChessPursuitConfig.GetCardSubCoin(id)
local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id)
return config.SubCoin
end
function XChessPursuitConfig.GetCardQuality(id)
local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id)
return config.Quality
end
function XChessPursuitConfig.GetCardEffect(id)
local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id)
return config.Effect
end
function XChessPursuitConfig.GetCardTipsQualityIconBg(id)
local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id)
return config.TipsQualityIconBg
end
-------卡牌 end----------
-------奖励 begin---------
function XChessPursuitConfig.GetMapGroupRewardByGroupIdToIdDic(groupId)
return MapGroupRewardByGroupIdToIdDic[groupId]
end
function XChessPursuitConfig.GetMapGroupRewardStartRange(id)
local config = XChessPursuitConfig.GetChessPursuitMapGroupRewardTemplate(id)
return config.StartRange
end
function XChessPursuitConfig.GetMapGroupRewardEndRange(id)
local config = XChessPursuitConfig.GetChessPursuitMapGroupRewardTemplate(id)
return config.EndRange
end
function XChessPursuitConfig.GetMapGroupRewardRewardShowId(id)
local config = XChessPursuitConfig.GetChessPursuitMapGroupRewardTemplate(id)
return config.RewardShowId
end
-------奖励 end-----------
-------Boss begin---------
function XChessPursuitConfig.GetChessPursuitBossStageIdByMapId(mapId)
local bossId = XChessPursuitConfig.GetChessPursuitMapBossId(mapId)
local config = XChessPursuitConfig.GetChessPursuitBossTemplate(bossId)
return config.StageId
end
function XChessPursuitConfig.GetChessPursuitBossHeadIconByMapId(mapId)
local bossId = XChessPursuitConfig.GetChessPursuitMapBossId(mapId)
local config = XChessPursuitConfig.GetChessPursuitBossTemplate(bossId)
return config.HeadIcon
end
-------Boss end-----------
------ChessPursuitMapInitFunc begin-------
function XChessPursuitConfig.GetMapInitFuncMapId(id)
local config = XChessPursuitConfig.GetChessPursuitMapInitFuncTemplate(id)
return config.Param[1]
end
function XChessPursuitConfig.GetMapInitFuncType(id)
local config = XChessPursuitConfig.GetChessPursuitMapInitFuncTemplate(id)
return config.Type
end
function XChessPursuitConfig.IsMapInitFuncAddCoinType(id)
local initFuncType = XChessPursuitConfig.GetMapInitFuncType(id)
return initFuncType == XChessPursuitConfig.InitFuncType.InitAddCoin
end
------ChessPursuitMapInitFunc end-------
function XChessPursuitConfig.GetBabelRankIcon(num)
return CS.XGame.ClientConfig:GetString("BabelTowerRankIcon" .. num)
end
--@endregion

View file

@ -0,0 +1,91 @@
local tableInsert = table.insert
XChristmasTreeConfig = XChristmasTreeConfig or {}
local CHRISTMAS_TREE_ACTIVITY_PATH = "Share/MiniActivity/ChristmasTree/ChristmasTree.tab"
local CHRISTMAS_TREE_ACTIVITY_ORNAMENT_PATH = "Share/MiniActivity/ChristmasTree/ChristmasTreeOrnaments.tab"
local CHRISTMAS_TREE_ACTIVITY_PART_PATH = "Share/MiniActivity/ChristmasTree/ChristmasTreePart.tab"
local ActivityTemplates = {}
local ChristmasTreeOrnament = {}
local ChristmasTreeOrnamentGroup = {}
local ChristmasTreePart = {}
local ChristmasTreePartGroup = {}
local OrnamentAttrCount = {}
local PartCount, PartGrpCount
function XChristmasTreeConfig.Init()
ActivityTemplates = XTableManager.ReadByIntKey(CHRISTMAS_TREE_ACTIVITY_PATH, XTable.XTableChristmasTreeActivity, "Id")
ChristmasTreePart = XTableManager.ReadByIntKey(CHRISTMAS_TREE_ACTIVITY_PART_PATH, XTable.XTableChristmasTreeActivityPart, "Id")
PartCount, PartGrpCount = 0, 0
for _, item in ipairs(ChristmasTreePart) do
if not ChristmasTreePartGroup[item.GroupId] then
PartGrpCount = PartGrpCount + 1
ChristmasTreePartGroup[item.GroupId] = {}
end
tableInsert(ChristmasTreePartGroup[item.GroupId], item)
PartCount = PartCount + 1
end
ChristmasTreeOrnament = XTableManager.ReadByIntKey(CHRISTMAS_TREE_ACTIVITY_ORNAMENT_PATH, XTable.XTableChristmasTreeActivityOrnament, "Id")
for _, item in ipairs(ChristmasTreeOrnament) do
OrnamentAttrCount[item.Id] = 0
for _, value in ipairs(item.Attr) do
OrnamentAttrCount[item.Id] = OrnamentAttrCount[item.Id] + value
end
for _, partId in ipairs(item.PartId) do
local groupId = XChristmasTreeConfig.GetGrpIdByTreePart(partId)
if not ChristmasTreeOrnamentGroup[groupId] then
ChristmasTreeOrnamentGroup[groupId] = {}
end
if not ChristmasTreeOrnamentGroup[groupId][item.Id] then
ChristmasTreeOrnamentGroup[groupId][item.Id] = item
end
end
end
end
function XChristmasTreeConfig.GetActivityTemplates()
return ActivityTemplates
end
function XChristmasTreeConfig.GetActivityTemplateById(Id)
if not ActivityTemplates then
return nil
end
return ActivityTemplates[Id]
end
function XChristmasTreeConfig.GetOrnamentCfg()
return ChristmasTreeOrnament
end
function XChristmasTreeConfig.GetOrnamentById(id)
return ChristmasTreeOrnament[id]
end
function XChristmasTreeConfig.GetOrnamentByGroup(grpId)
return ChristmasTreeOrnamentGroup[grpId]
end
function XChristmasTreeConfig.GetTreePartCount()
return PartCount, PartGrpCount
end
function XChristmasTreeConfig.GetAttrCount(id)
return OrnamentAttrCount[id]
end
function XChristmasTreeConfig.GetTreePartById(id)
return ChristmasTreePart[id]
end
function XChristmasTreeConfig.GetGrpIdByTreePart(id)
return ChristmasTreePart[id].GroupId
end
function XChristmasTreeConfig.GetTreePartByGroup(grpId)
return ChristmasTreePartGroup[grpId]
end

View file

@ -0,0 +1,81 @@
local tableInsert = table.insert
local TABLE_CLICKCLEAR_GAME_PATH = "Share/ClickClearGame/ClickClearGame.tab"
local TABLE_CLICKCLEAR_GAME_STAGE_PATH = "Share/ClickClearGame/ClickClearGameStage.tab"
local TABLE_CLICKCLEAR_PAGE_PATH = "Client/ClickClearGame/ClickClearPage.tab"
local TABLE_CLICKCLEAR_ROW_PATH = "Client/ClickClearGame/ClickClearRow.tab"
local TABLE_CLICKCLEAR_HEAD_PATH = "Client/ClickClearGame/ClickClearHead.tab"
local GameTemplates = {}
local GameStageTemplates = {}
local PageTemplates = {}
local RowTemplates = {}
local HeadTemplates = {}
local HeadTypeList = {}
XClickClearGameConfigs = XClickClearGameConfigs or {}
function XClickClearGameConfigs.Init()
GameTemplates = XTableManager.ReadByIntKey(TABLE_CLICKCLEAR_GAME_PATH, XTable.XTableClickClearGame, "Id")
GameStageTemplates = XTableManager.ReadByIntKey(TABLE_CLICKCLEAR_GAME_STAGE_PATH, XTable.XTableClickClearGameStage, "Id")
PageTemplates = XTableManager.ReadByIntKey(TABLE_CLICKCLEAR_PAGE_PATH, XTable.XTableClickClearPage, "Id")
RowTemplates = XTableManager.ReadByIntKey(TABLE_CLICKCLEAR_ROW_PATH, XTable.XTableClickClearRow, "Id")
HeadTemplates = XTableManager.ReadByIntKey(TABLE_CLICKCLEAR_HEAD_PATH, XTable.XTableClickClearHead, "Id")
for i,v in pairs(HeadTemplates) do
local type = v.Type
if not HeadTypeList[type] then
HeadTypeList[type] = {}
end
tableInsert(HeadTypeList[type], i)
end
end
function XClickClearGameConfigs.GetGameTemplates()
return GameTemplates
end
function XClickClearGameConfigs.GetGameStageTemplates()
return GameStageTemplates
end
function XClickClearGameConfigs.GetGameStageTemplateById(id)
if not GameStageTemplates or #GameStageTemplates <= 0 then
return nil
end
return GameStageTemplates[id]
end
function XClickClearGameConfigs.GetPageTemplateById(id)
if not PageTemplates or #PageTemplates <= 0 then
return nil
end
return PageTemplates[id]
end
function XClickClearGameConfigs.GetRowTemplateById(id)
if not RowTemplates or #RowTemplates <= 0 then
return nil
end
return RowTemplates[id]
end
function XClickClearGameConfigs.GetHeadTemplateById(id)
if not HeadTemplates or #HeadTemplates <= 0 then
return nil
end
return HeadTemplates[id]
end
function XClickClearGameConfigs.GetHeadTypeListByType(type)
if not HeadTypeList or #HeadTypeList <= 0 or not HeadTypeList[type] then
return nil
end
return HeadTypeList[type]
end

View file

@ -0,0 +1,236 @@
XCollectionWallConfigs = XCollectionWallConfigs or {}
local TABLE_COLLECTION_WALL = "Share/ScoreTitle/CollectionWall.tab"
local TABLE_COLLECTION_WALL_DECORATION = "Share/ScoreTitle/CollectionWallDecoration.tab"
local TABLE_COLLECTION_SIZE = "Client/CollectionWall/CollectionSize.tab"
-- 装饰品种类
XCollectionWallConfigs.EnumDecorationType = {
Background = 1, -- 背景
Pedestal = 2, -- 底座
}
-- 收藏品墙的状态
XCollectionWallConfigs.EnumWallState = {
Lock = 1, -- 未解锁
None = 2, -- 空白
Normal = 3, -- 正常
}
-- 收藏品墙格子的使用的种类
XCollectionWallConfigs.EnumWallGridOpenType = {
Overview = 1, -- 管理界面
Setting = 2, -- 设置界面
}
-- 收藏品墙装饰品的解锁类型
XCollectionWallConfigs.EnumDecorationUnlockType = {
Condition = 1, -- 条件解锁
Reward = 2, -- 奖励解锁
}
-- 编辑模式选择的种类
XCollectionWallConfigs.EnumSelectType = {
BACKGROUND = 1, -- 墙面
PEDESTAL = 2, -- 底座
LITTL = 3, -- 模型小
MIDDLE = 4, -- 模型中
BIG = 5, -- 模型大
}
-- 墙面单元格尺寸为90*90
XCollectionWallConfigs.CellSize = 90
local CollectionWallCfg = {}
local CollectionWallDecorationCfg = {}
local CollectionSizeCfg = {}
function XCollectionWallConfigs.Init()
CollectionWallCfg = XTableManager.ReadByIntKey(TABLE_COLLECTION_WALL, XTable.XTableCollectionWall, "Id")
CollectionWallDecorationCfg = XTableManager.ReadByIntKey(TABLE_COLLECTION_WALL_DECORATION, XTable.XTableCollectionWallDecoration, "Id")
CollectionSizeCfg = XTableManager.ReadByIntKey(TABLE_COLLECTION_SIZE, XTable.XTableCollectionSize, "Id")
end
------------------------------------------------------------------ CollectionWall.tab数据读取 -------------------------------------------------------
---
--- 根据'id'获取收藏品墙的配置
--- 建议使用XCollectionWall.lua的接口来获取需要的数据
---@param id number
---@return table
function XCollectionWallConfigs.GetCollectionWallCfg(id)
local config = CollectionWallCfg[id]
if not config then
XLog.ErrorTableDataNotFound("XCollectionWallConfigs.GetCollectionWallCfg",
"收藏品墙配置", TABLE_COLLECTION_WALL, "Id", tostring(id))
return {}
end
return config
end
---
--- 获取所有收藏品墙的Id数组
---@return table
function XCollectionWallConfigs.GetCollectionWallIdList()
local idList = {}
for id, _ in pairs(CollectionWallCfg) do
table.insert(idList, id)
end
return idList
end
------------------------------------------------------------------ CollectionWallDecoration.tab数据读取 -------------------------------------------------------
---
--- 根据'id'获取收藏品墙饰品配置
---@param id number
---@return table
local function GetColDecCfgList(id)
local config = CollectionWallDecorationCfg[id]
if not config then
XLog.ErrorTableDataNotFound("XCollectionWallConfigs.GetColDecCfgList",
"收藏品墙饰品配置", TABLE_COLLECTION_WALL_DECORATION, "Id", tostring(id))
return {}
end
return config
end
---
--- 获取全部type种类的收藏品墙饰品配置数组
---@param type number
---@return table
function XCollectionWallConfigs.GetColDecCfgListByType(type)
local result = {}
for _,data in pairs(CollectionWallDecorationCfg) do
if data.Type == type then
table.insert(result,data)
end
end
return result
end
---
--- 根据'id'获取收藏品墙饰品的种类
---@param id number
---@return number
function XCollectionWallConfigs.GetColDecType(id)
local cfg = GetColDecCfgList(id)
return cfg.Type
end
---
--- 根据'id'获取收藏品墙饰品的名称
---@param id number
---@return string
function XCollectionWallConfigs.GetColDecName(id)
local cfg = GetColDecCfgList(id)
return cfg.Name
end
---
--- 根据'id'获取收藏品墙饰品的图标
---@param id number
---@return string
function XCollectionWallConfigs.GetColDecIcon(id)
local cfg = GetColDecCfgList(id)
return cfg.Icon
end
---
--- 根据'id'获取收藏品墙饰品的路径
---@param id number
---@return string
function XCollectionWallConfigs.GetColDecPath(id)
local cfg = GetColDecCfgList(id)
return cfg.Path
end
---
--- 根据'id'获取收藏品墙饰品的解锁类型
---@param id number
---@return number
function XCollectionWallConfigs.GetColDecUnlockType(id)
local cfg = GetColDecCfgList(id)
return cfg.UnlockType
end
---
--- 根据'id'获取收藏品墙饰品的解锁条件
---@param id number
---@return number
function XCollectionWallConfigs.GetColDecCondition(id)
local cfg = GetColDecCfgList(id)
return cfg.Condition
end
---
--- 根据'id'获取收藏品墙饰品的解锁描述
---@param id number
---@return string
function XCollectionWallConfigs.GetColDecLockDesc(id)
local cfg = GetColDecCfgList(id)
return cfg.LockDesc
end
---
--- 根据'id'获取收藏品墙饰品的排序值
---@param id number
---@return string
function XCollectionWallConfigs.GetColDecRank(id)
local cfg = GetColDecCfgList(id)
return cfg.Rank
end
------------------------------------------------------------------ CollectionSize.tab数据读取 -------------------------------------------------------
---
--- 根据'id'获取收藏品尺寸数据
---@param id number
---@return number
local function GetCollectionSizeCfg(id)
local config = CollectionSizeCfg[id]
if not config then
XLog.ErrorTableDataNotFound("XCollectionWallConfigs.GetColDecCfgList",
"收藏品尺寸配置", TABLE_COLLECTION_SIZE, "Id", tostring(id))
return {}
end
return config
end
---
--- 根据'id'获取收藏品尺寸
---@param id number
---@return number
function XCollectionWallConfigs.GetCollectionSize(id)
local cfg = GetCollectionSizeCfg(id)
return cfg.Size
end
---
--- 根据'id'获取收藏品缩放系数
---@param id number
---@return number
function XCollectionWallConfigs.GetCollectionScale(id)
local cfg = GetCollectionSizeCfg(id)
return cfg.Scale
end
---
--- 根据'id'获取收藏品占用的格子
---@param id number
---@return number
function XCollectionWallConfigs.GetCollectionGridNum(id)
local cfg = GetCollectionSizeCfg(id)
return cfg.GridNum
end

View file

@ -0,0 +1,184 @@
XComeAcrossConfig = XComeAcrossConfig or {}
ComeAcrossGameType = {
GAME_CLICK = 1,
GAME_ELIMINATE = 2,
}
local TABLE_COMEACROSS = "Share/Trust/TrustGameConfig.tab";
local TABLE_COMEACROSS_CLICK_POOL = "Share/Trust/TrustGameClickPool.tab";
local TABLE_COMEACROSS_ELIMINATE_POOL = "Share/Trust/TrustGameEliminatePool.tab";
local TABLE_COMEACROSS_REWARD = "Share/Trust/TrustGameReward.tab";
local TABLE_COMEACROSS_POSITION = "Share/Trust/TrustGamePosition.tab";
local TABLE_COMEACROSS_GRID = "Share/Trust/TrustGameGrid.tab";
local TABLE_COMEACROSS_GAMETYPE = "Share/Trust/TrustGameTypeConfig.tab";
local ComeAcrossConfig = {}
local ComeAcrossClickPoolConfig = {}
local ComeAcrossEliminatePoolConfig = {}
local ComeAcrossRewardConfig = {}
local ComeAcrossPositionConfig = {}
local ComeAcrossGridConfig = {}
local ComeAcrossGameTypeConfig = {}
local GameTypePools = {}
function XComeAcrossConfig.Init()
ComeAcrossConfig = XTableManager.ReadByIntKey(TABLE_COMEACROSS, XTable.XTableTrustGameConfig, "Id")
ComeAcrossRewardConfig = XTableManager.ReadByIntKey(TABLE_COMEACROSS_REWARD, XTable.XTableTrustGameReward, "Id")
ComeAcrossClickPoolConfig = XTableManager.ReadByIntKey(TABLE_COMEACROSS_CLICK_POOL, XTable.XTableTrustGameClickPool, "Id")
ComeAcrossEliminatePoolConfig = XTableManager.ReadByIntKey(TABLE_COMEACROSS_ELIMINATE_POOL, XTable.XTableTrustGameEliminatePool, "Id")
ComeAcrossPositionConfig = XTableManager.ReadByIntKey(TABLE_COMEACROSS_POSITION, XTable.XTableTrustGamePosition, "Id")
ComeAcrossGridConfig = XTableManager.ReadByIntKey(TABLE_COMEACROSS_GRID, XTable.XTableTrustGameGrid, "Id")
ComeAcrossGameTypeConfig = XTableManager.ReadByIntKey(TABLE_COMEACROSS_GAMETYPE, XTable.XTableTrustGameTypeConfig, "Id")
GameTypePools[ComeAcrossGameType.GAME_CLICK] = ComeAcrossClickPoolConfig
GameTypePools[ComeAcrossGameType.GAME_ELIMINATE] = ComeAcrossEliminatePoolConfig
end
--获取小游戏关卡表
function XComeAcrossConfig.GetComeAcrossConfig()
return ComeAcrossConfig
end
--获取小游戏关卡
function XComeAcrossConfig.GetComeAcrossConfigById(id)
if not ComeAcrossConfig then
return
end
return ComeAcrossConfig[id]
end
--获取小游戏内容
function XComeAcrossConfig.GetComeAcrossTypeConfigById(id)
if not ComeAcrossGameTypeConfig then
return
end
return ComeAcrossGameTypeConfig[id]
end
--获取小游戏位置
function XComeAcrossConfig.GetComeAcrossPositionConfigById(id)
if not ComeAcrossPositionConfig then
return
end
return ComeAcrossPositionConfig[id]
end
--获得奖励
function XComeAcrossConfig.GetComeAcrossRewardConfigById(id)
if not ComeAcrossRewardConfig then
return
end
return ComeAcrossRewardConfig[id]
end
--根据类型获取小游戏消除元素
function XComeAcrossConfig.GetComeAcrossGridConfigById(gridType)
if not ComeAcrossGridConfig then
return
end
for _,v in ipairs(ComeAcrossGridConfig) do
if v.Type == gridType then
return v
end
end
return nil
end
--随机获取N个小游戏
function XComeAcrossConfig.RandomNumberGetGameConfig(count)
if not ComeAcrossConfig then
return
end
local length = #ComeAcrossConfig
if length <= count then
return ComeAcrossConfig
end
local temp = {}
for _, v in ipairs(ComeAcrossConfig) do
table.insert(temp, v)
end
local games = {}
for i = 1, count, 1 do
local sum = #temp
local rand = math.random(1, sum)
local gameTable = {}
gameTable.GameConfig = table.remove(temp, rand)
gameTable.TypeOfGames = XComeAcrossConfig.RandomNumberGetGameConfigFormPoolByType(gameTable.GameConfig.Count, gameTable.GameConfig.Type,gameTable.GameConfig.Difficult)
gameTable.Position = ComeAcrossPositionConfig[i]
table.insert(games, gameTable)
end
return games
end
--从游戏类型池随出特定类型和数量的游戏关卡
function XComeAcrossConfig.RandomNumberGetGameConfigFormPoolByType(count, gameType,difficult)
local pools = GameTypePools[gameType]
if not pools or #pools <= count then
return pools
end
--筛选难度
local pool = {}
for _,v in ipairs(pools) do
if v.Difficult == difficult then
table.insert(pool,v)
end
end
if not pool or #pool <= count then
return pool
end
--获取权重总和
local sum = 0
for _, v in ipairs(pool) do
sum = sum + v.Weight
end
--设置随机数种子
math.randomseed(os.time())
--随机数加上权重,越大的权重,数值越大
local weightList = {}
for i, v in ipairs(pool) do
local rand = math.random(0, sum)
local seed = {}
seed.Index = i
seed.Weight = rand + v.Weight
table.insert(weightList, seed)
end
--排序
table.sort(weightList, function(x, y)
return x.Weight > y.Weight
end)
--返回最大的权重值的前几个
local typeOfGames = {}
for i = 1, count, 1 do
local index = weightList[i].Index
if pool[index] then
table.insert(typeOfGames,pool[index] )
end
end
return typeOfGames
end

View file

@ -0,0 +1,97 @@
XCommunicationConfig = XCommunicationConfig or {}
local TABLE_FUNCTION_COMMUNICATION_PATH = "Share/Functional/FunctionalCommunication.tab"
local TABLE_FUNCTION_FESTIVAL_COMMUNICATION_PATH = "Share/Functional/FunctionalFestivalCommunication.tab"
local TABLE_FUNCTION_INITIATIVE_COMMUNICATION_PATH = "Share/Functional/FunctionalInitiativeCommunication.tab"
local TABLE_FUNCTION_INITIATIVE_CONTENTS_PATH = "Client/Functional/FunctionalContents.tab"
local FunctionCommunicationConfig = {}
local FunctionFestivalCommunicationConfig = {}
local FunctionInitiativeCommunicationConfig = {}
local FunctionFestivalCommunicationDic = {}
local FunctionalContentsConfig = {}
local FunctionalContentsGroupIdDic = {}
XCommunicationConfig.ComminictionType = {
NormalType = 1,
OptionType = 2,
}
function XCommunicationConfig.Init()
FunctionCommunicationConfig = XTableManager.ReadByIntKey(TABLE_FUNCTION_COMMUNICATION_PATH, XTable.XTableFunctionalCommunication, "Id")
FunctionFestivalCommunicationConfig = XTableManager.ReadByIntKey(TABLE_FUNCTION_FESTIVAL_COMMUNICATION_PATH, XTable.XTableFunctionalFestivalCommunication, "Id")
FunctionInitiativeCommunicationConfig = XTableManager.ReadByIntKey(TABLE_FUNCTION_INITIATIVE_COMMUNICATION_PATH, XTable.XTableFunctionalCommunication, "Id")
FunctionalContentsConfig = XTableManager.ReadByIntKey(TABLE_FUNCTION_INITIATIVE_CONTENTS_PATH, XTable.XTableFunctionalContents, "Id")
XCommunicationConfig.SetFunctionFestivalCommunicationDic()
XCommunicationConfig.InitFunctionalContentsGroup()
end
function XCommunicationConfig.GetFunctionCommunicationConfig()
return FunctionCommunicationConfig
end
function XCommunicationConfig.GetFunctionFestivalCommunicationConfig()
return FunctionFestivalCommunicationConfig
end
function XCommunicationConfig.GetFunctionFestivalCommunicationDicByType(type)
return FunctionFestivalCommunicationDic[type]
end
function XCommunicationConfig.GetFunctionInitiativeCommunicationConfig()
return FunctionInitiativeCommunicationConfig
end
function XCommunicationConfig.GetFunctionInitiativeCommunicationConfigById(commuId)
return FunctionInitiativeCommunicationConfig[commuId]
end
function XCommunicationConfig.SetFunctionFestivalCommunicationDic()
for _, communication in pairs(FunctionFestivalCommunicationConfig) do
local functionFestivalCommunicationType = FunctionFestivalCommunicationDic[communication.Type]
if not functionFestivalCommunicationType then
functionFestivalCommunicationType = {}
FunctionFestivalCommunicationDic[communication.Type] = functionFestivalCommunicationType
end
table.insert(functionFestivalCommunicationType, communication)
end
end
function XCommunicationConfig.InitFunctionalContentsGroup()
for _, communication in pairs(FunctionalContentsConfig) do
local functionalComList = FunctionalContentsGroupIdDic[communication.GroupId]
if not functionalComList then
functionalComList = {}
FunctionalContentsGroupIdDic[communication.GroupId] = functionalComList
end
if communication.Type == XCommunicationConfig.ComminictionType.NormalType and #communication.OptionTitle > 0 then
XLog.Error("XCommunicationConfig.InitFunctionalContentsGroup".."配置表项"..TABLE_FUNCTION_INITIATIVE_CONTENTS_PATH.."不应该配置按钮,ID:"..tostring(communication.Id))
end
table.insert(functionalComList, communication)
end
for _, communicationList in pairs(FunctionalContentsGroupIdDic) do
table.sort(communicationList,function(a, b)
return a.Id < b.Id
end)
end
end
function XCommunicationConfig.GetFunctionalContentsInfoById(id)
if not FunctionalContentsConfig[id] then
XLog.ErrorTableDataNotFound("XCommunicationConfig.GetFunctionalContentsInfoById", "配置表项", TABLE_FUNCTION_INITIATIVE_CONTENTS_PATH, "Id", tostring(id))
end
return FunctionalContentsConfig[id]
end
function XCommunicationConfig.GetFunctionalContentsGroupFirstInfoByGroupId(groupId)
if not FunctionalContentsGroupIdDic[groupId] or not FunctionalContentsGroupIdDic[groupId][1] then
XLog.ErrorTableDataNotFound("XCommunicationConfig.GetFunctionalContentsGroupListByGroupId", "配置表项", TABLE_FUNCTION_INITIATIVE_CONTENTS_PATH, "GroupId", tostring(groupId))
end
return FunctionalContentsGroupIdDic[groupId][1]
end

View file

@ -0,0 +1,145 @@
-- 组合小游戏Config
XComposeGameConfig = XComposeGameConfig or {}
-- ===================表地址====================
local SHARE_TABLE_PATH = "Share/MiniActivity/ComposeGame/"
local CLIENT_TABLE_PATH = "Client/MiniActivity/ComposeGame/"
local TABLE_GAMECONFIGS = SHARE_TABLE_PATH .. "ComposeGame.tab"
local TABLE_GOODS = SHARE_TABLE_PATH .. "ComposeGoods.tab"
local TABLE_CLIENT_CONFIG = CLIENT_TABLE_PATH .. "ComposeClientConfig.tab"
--=================================================
-- ===================原表数据===================
local GameConfigs = {}
local GoodsConfigs = {}
local ClientConfig = {}
--=================================================
-- ================构建搜索用字典================
local GameId2GoodsDic = {}
local GameId2ClientConfigDic = {}
--=================================================
--==================初始化方法======================
--===============
--构建活动ID<-->活动道具列表字典
--===============
local CreateGameId2GoodsDic = function()
for _, good in pairs(GoodsConfigs) do
if not GameId2GoodsDic[good.ActId] then GameId2GoodsDic[good.ActId] = {} end
table.insert(GameId2GoodsDic[good.ActId], good)
end
end
--===============
--构建活动ID<-->活动客户端配置字典
--===============
local CreateGameId2ClientConfigDic = function()
for id, config in pairs(ClientConfig) do
-- 通用配置不进入构建字典
if id > 0 then GameId2ClientConfigDic[config.ActId] = config end
end
end
--===============
--初始化表配置
--===============
function XComposeGameConfig.Init()
GameConfigs = XTableManager.ReadByIntKey(TABLE_GAMECONFIGS, XTable.XTableComposeGame, "Id")
GoodsConfigs = XTableManager.ReadByIntKey(TABLE_GOODS, XTable.XTableComposeGoods, "Id")
ClientConfig = XTableManager.ReadByIntKey(TABLE_CLIENT_CONFIG, XTable.XTableComposeClientConfig, "Id")
CreateGameId2GoodsDic()
CreateGameId2ClientConfigDic()
end
--==================================================
--==================读表方法======================
--===============
--获取所有组合小游戏活动基础配置
--===============
function XComposeGameConfig.GetGameConfigs()
return GameConfigs
end
--===============
--根据Id获取组合小游戏活动基础配置
--@param gameId:活动ID
--===============
function XComposeGameConfig.GetGameConfigsByGameId(gameId)
local config = GameConfigs[gameId]
if not config then
XLog.ErrorTableDataNotFound(
"XComposeGameConfig.GetGameConfigsByGameId",
"组合小游戏活动基础配置数据",
TABLE_GAMECONFIGS,
"Id",
tostring(gameId)
)
return nil
end
return config
end
--===============
--获取所有组合小游戏物品配置
--===============
function XComposeGameConfig.GetGoodsConfigs()
return GoodsConfigs
end
--===============
--根据Id获取组合小游戏物品配置
--@param itemId:物品ID
--===============
function XComposeGameConfig.GetItemConfigByItemId(itemId)
local config = GoodsConfigs[itemId]
if not config then
XLog.ErrorTableDataNotFound(
"XComposeGameConfig.GetItemConfigByItemId",
"组合小游戏物品配置数据",
TABLE_GOODS,
"Id",
tostring(itemId)
)
return nil
end
return config
end
--===============
--根据活动Id获取活动对应的所有物品配置
--@param gameId:活动ID
--===============
function XComposeGameConfig.GetItemListConfigByGameId(gameId)
local itemCfgsList = GameId2GoodsDic[gameId]
if not itemCfgsList then
XLog.ErrorTableDataNotFound(
"XComposeGameConfig.GetItemListConfigByGameId",
"组合小游戏物品配置数据",
TABLE_GOODS,
"ActId",
tostring(gameId)
)
return nil
end
return itemCfgsList
end
--===============
--根据活动ID获取组合小游戏客户端配置(对个别组合小游戏的客户端配置)
--@param gameId:活动ID
--===============
function XComposeGameConfig.GetClientConfigByGameId(gameId)
local config = GameId2ClientConfigDic[gameId]
if not config then
XLog.ErrorTableDataNotFound(
"XComposeGameConfig.GetClientConfigByGameId",
"组合小游戏活动客户端配置",
TABLE_CLIENT_CONFIG,
"ActId",
tostring(gameId)
)
return nil
end
return config
end
--===============
--获取组合小游戏默认客户端配置(全组合小游戏通用配置)
--===============
function XComposeGameConfig.GetDefaultConfig()
return ClientConfig[0]
end
--==================================================

View file

@ -0,0 +1,23 @@
XComposeMiniGameConfig = XComposeMiniGameConfig or {}
-- ===================表地址
local SHARE_TABLE_PATH = "Share/MiniActivity/ComposeGame/"
local CLIENT_TABLE_PATH = "Client/MiniActivity/ComposeGame/"
local TABLE_COMPOSE_GAME = SHARE_TABLE_PATH .. "ComposeGame.tab"
local TABLE_COMPOSE_GOODS = SHARE_TABLE_PATH .. "ComposeGoods.tab"
-- ===================原表数据
local ComposeGameConfig = {}
local ComposeGoodsConfig = {}
--================
--初始化Config
--================
function XComposeMiniGameConfig.Init()
XComposeMiniGameConfig.InitConfig()
end
function XComposeMiniGameConfig.InitConfig()
end

View file

@ -0,0 +1,38 @@
local type = type
--配置基类(存储通用方法)
XConfig = XClass(nil, "XConfig")
function XConfig:Ctor(path, xTable, primaryKey)
primaryKey = primaryKey or "Id"
self.Path = path
self.XTable = xTable
self.Configs = XTableManager.ReadByIntKey(path, xTable, primaryKey)
end
function XConfig:GetPath()
return self.Path or ""
end
function XConfig:GetConfigs()
return self.Configs
end
function XConfig:GetConfig(key)
local config = self.Configs[key]
if not config then
XLog.Error(string.format("配置不存在, Id: %s, 配置路径:%s ", key, self.Path))
return
end
return config
end
function XConfig:GetProperty(key, name)
local config = self:GetConfig(key)
local property = config[name]
if nil == property and XTableManager.GetTypeDefaultValue(self.XTable[name].ValueType) ~= property then
XLog.Error(string.format("配置字段未定义, 配置路径: %s, 配置Id:%s, 字段名称: %s", self.Path, key, name))
return
end
return property
end

View file

@ -0,0 +1,306 @@
XConfigCenter = XConfigCenter or {}
XConfigCenter.DirectoryType = {
Share = 1,
Client = 2,
}
local IsWindowsEditor = XMain.IsWindowsEditor
local ConfigCenterProfiler = nil
local function InitConfig(config, key)
if IsWindowsEditor then
local profiler = ConfigCenterProfiler:CreateChild(key)
profiler:Start()
-- XPerformance.RecordLuaMemData(key, function()
config.Init()
-- end)
profiler:Stop()
else
config.Init()
end
end
function XConfigCenter.Init()
ConfigCenterProfiler = XGame.Profiler:CreateChild("XConfigCenter")
ConfigCenterProfiler:Start()
InitConfig(XDlcConfig,"XDlcConfig")
-- 新拆分出的Config
InitConfig(XAssistConfig, "XAssistConfig")
InitConfig(XAutoFightConfig, "XAutoFightConfig")
InitConfig(XFubenBossOnlineConfig, "XFubenBossOnlineConfig")
InitConfig(XFubenUrgentEventConfig, "XFubenUrgentEventConfig")
InitConfig(XLoadingConfig, "XLoadingConfig")
InitConfig(XTeamConfig, "XTeamConfig")
InitConfig(XFunctionConfig, "XFunctionConfig")
InitConfig(XAttribConfigs, "XAttribConfigs")
InitConfig(XUiConfigs, "XUiConfigs")
InitConfig(XGuideConfig, "XGuideConfig")
InitConfig(XItemConfigs, "XItemConfigs")
InitConfig(XCharacterConfigs, "XCharacterConfigs")
InitConfig(XSignBoardConfigs, "XSignBoardConfigs")
InitConfig(XEquipConfig, "XEquipConfig")
InitConfig(XComeAcrossConfig, "XComeAcrossConfig")
InitConfig(XFavorabilityConfigs, "XFavorabilityConfigs")
InitConfig(XArenaConfigs, "XArenaConfigs")
InitConfig(XArenaOnlineConfigs, "XArenaOnlineConfigs")
InitConfig(XTrialConfigs, "XTrialConfigs")
InitConfig(XCommunicationConfig, "XCommunicationConfig")
InitConfig(XPrequelConfigs, "XPrequelConfigs")
InitConfig(XTaskConfig, "XTaskConfig")
InitConfig(XFubenConfigs, "XFubenConfigs")
InitConfig(XTaskForceConfigs, "XTaskForceConfigs")
InitConfig(XDrawConfigs, "XDrawConfigs")
InitConfig(XGachaConfigs, "XGachaConfigs")
InitConfig(XFubenMainLineConfigs, "XFubenMainLineConfigs")
InitConfig(XFubenBossSingleConfigs, "XFubenBossSingleConfigs")
InitConfig(XFubenExperimentConfigs, "XFubenExperimentConfigs")
InitConfig(XMailConfigs, "XMailConfigs")
InitConfig(XBfrtConfigs, "XBfrtConfigs")
InitConfig(XBountyTaskConfigs, "XBountyTaskConfigs")
--InitConfig(XHostelConfigs, "XHostelConfigs")
InitConfig(XBaseEquipConfigs, "XBaseEquipConfigs")
InitConfig(XFurnitureConfigs, "XFurnitureConfigs")
InitConfig(XPayConfigs, "XPayConfigs")
InitConfig(XFubenExploreConfigs, "XFubenExploreConfigs")
InitConfig(XFubenActivityBranchConfigs, "XFubenActivityBranchConfigs")
InitConfig(XFubenActivityBossSingleConfigs, "XFubenActivityBossSingleConfigs")
InitConfig(XFubenRepeatChallengeConfigs, "XFubenRepeatChallengeConfigs")
InitConfig(XDormConfig, "XDormConfig")
InitConfig(XMovieConfigs, "XMovieConfigs")
InitConfig(XExhibitionConfigs, "XExhibitionConfigs")
InitConfig(XAutoWindowConfigs, "XAutoWindowConfigs")
InitConfig(XPlayerInfoConfigs, "XPlayerInfoConfigs")
InitConfig(XSignInConfigs, "XSignInConfigs")
InitConfig(XReportConfigs, "XReportConfigs")
InitConfig(XPracticeConfigs, "XPracticeConfigs")
InitConfig(XFubenUnionKillConfigs, "XFubenUnionKillConfigs")
InitConfig(XFubenSpecialTrainConfig, "XFubenSpecialTrainConfig")
InitConfig(XShopConfigs, "XShopConfigs")
InitConfig(XHelpCourseConfig, "XHelpCourseConfig")
InitConfig(XMedalConfigs, "XMedalConfigs")
InitConfig(XArchiveConfigs, "XArchiveConfigs")
InitConfig(XGuildConfig, "XGuildConfig")
InitConfig(XFestivalActivityConfig, "XFestivalActivityConfig")
InitConfig(XFubenBabelTowerConfigs, "XFubenBabelTowerConfigs")
InitConfig(XFubenRogueLikeConfig, "XFubenRogueLikeConfig")
InitConfig(XMarketingActivityConfigs, "XMarketingActivityConfigs")
InitConfig(XFubenAssignConfigs, "XFubenAssignConfigs")
InitConfig(XRegressionConfigs, "XRegressionConfigs")
InitConfig(XPlatformShareConfigs, "XPlatformShareConfigs")
InitConfig(XRewardConfigs, "XRewardConfigs")
InitConfig(XMusicPlayerConfigs, "XMusicPlayerConfigs")
InitConfig(XFubenExtraChapterConfigs, "XFubenExtraChapterConfigs")
InitConfig(XFubenShortStoryChapterConfigs, "XFubenShortStoryChapterConfigs")
InitConfig(XDailyDungeonConfigs, "XDailyDungeonConfigs")
InitConfig(XCharacterUiEffectConfig, "XCharacterUiEffectConfig")
InitConfig(XHeadPortraitConfigs, "XHeadPortraitConfigs")
InitConfig(XGuildBossConfig, "XGuildBossConfig")
InitConfig(XEliminateGameConfig, "XEliminateGameConfig")
InitConfig(XWorldBossConfigs, "XWorldBossConfigs")
InitConfig(XMaintainerActionConfigs, "XMaintainerActionConfigs")
InitConfig(XExpeditionConfig, "XExpeditionConfig")
InitConfig(XRpgTowerConfig, "XRpgTowerConfig")
InitConfig(XClickClearGameConfigs, "XClickClearGameConfigs")
InitConfig(XFubenZhouMuConfigs, "XFubenZhouMuConfigs")
InitConfig(XNieRConfigs, "XNieRConfigs")
InitConfig(XMentorSystemConfigs, "XMentorSystemConfigs")
InitConfig(XCollectionWallConfigs, "XCollectionWallConfigs")
InitConfig(XActivityConfigs, "XActivityConfigs")
InitConfig(XPurchaseConfigs, "XPurchaseConfigs")
InitConfig(XActivityBriefConfigs, "XActivityBriefConfigs")
InitConfig(XSetConfigs, "XSetConfigs")
InitConfig(XRedEnvelopeConfigs, "XRedEnvelopeConfigs")
InitConfig(XVideoConfig, "XVideoConfig")
InitConfig(XWeaponFashionConfigs, "XWeaponFashionConfigs")
InitConfig(XFubenInfestorExploreConfigs, "XFubenInfestorExploreConfigs")
InitConfig(XPuzzleActivityConfigs, "XPuzzleActivityConfigs")
InitConfig(XChatConfigs, "XChatConfigs")
InitConfig(XPhotographConfigs, "XPhotographConfigs")
InitConfig(XTRPGConfigs, "XTRPGConfigs")
InitConfig(XPokemonConfigs, "XPokemonConfigs")
InitConfig(XSpringFestivalActivityConfigs, "XSpringFestivalActivityConfigs")
InitConfig(XFubenActivityPuzzleConfigs, "XFubenActivityPuzzleConfigs")
InitConfig(XFubenNewCharConfig, "XFubenNewCharConfig")
InitConfig(XSceneModelConfigs, "XSceneModelConfigs")
InitConfig(XRoomCharFilterTipsConfigs, "XRoomCharFilterTipsConfigs")
InitConfig(XChessPursuitConfig, "XChessPursuitConfig")
InitConfig(XComposeGameConfig, "XComposeGameConfig")
InitConfig(XLottoConfigs, "XLottoConfigs")
InitConfig(XPartnerConfigs, "XPartnerConfigs")
InitConfig(XWhiteValentineConfig, "XWhiteValentineConfig")
InitConfig(XSpecialShopConfigs, "XSpecialShopConfigs")
InitConfig(XFashionConfigs, "XFashionConfigs")
InitConfig(XFingerGuessingConfig, "XFingerGuessingConfig")
InitConfig(XReformConfigs, "XReformConfigs")
InitConfig(XPartnerTeachingConfigs, "XPartnerTeachingConfigs")
InitConfig(XScratchTicketConfig, "XScratchTicketConfig")
InitConfig(XRpgMakerGameConfigs, "XRpgMakerGameConfigs")
InitConfig(XInvertCardGameConfig, "XInvertCardGameConfig")
InitConfig(XMineSweepingConfigs, "XMineSweepingConfigs")
InitConfig(XSuperTowerConfigs, "XSuperTowerConfigs")
InitConfig(XFashionStoryConfigs, "XFashionStoryConfigs")
InitConfig(XPassportConfigs, "XPassportConfigs")
InitConfig(XGuardCampConfig, "XGuardCampConfig")
InitConfig(XFubenSimulatedCombatConfig, "XFubenSimulatedCombatConfig")
InitConfig(XChristmasTreeConfig, "XChristmasTreeConfig")
InitConfig(XCoupletGameConfigs, "XCoupletGameConfigs")
InitConfig(XStrongholdConfigs, "XStrongholdConfigs")
InitConfig(XMoeWarConfig, "XMoeWarConfig")
InitConfig(XMovieAssembleConfig, "XMovieAssembleConfig")
InitConfig(XFubenHackConfig, "XFubenHackConfig")
InitConfig(XFubenCoupleCombatConfig, "XFubenCoupleCombatConfig")
InitConfig(XPokerGuessingConfig, "XPokerGuessingConfig")
InitConfig(XKillZoneConfigs, "XKillZoneConfigs")
InitConfig(XAreaWarConfigs, "XAreaWarConfigs")
InitConfig(XSameColorGameConfigs, "XSameColorGameConfigs")
InitConfig(XActivityCalendarConfigs, "XActivityCalendarConfigs")
InitConfig(XMouthAnimeConfigs, "XMouthAnimeConfigs")
InitConfig(XLivWarmActivityConfigs, "XLivWarmActivityConfigs")
InitConfig(XLivWarmSoundsActivityConfig, "XLivWarmSoundsActivityConfig")
InitConfig(XLivWarmExtActivityConfig, "XLivWarmSoundsActivityConfig")
InitConfig(XLivWarmRaceConfigs, "XLivWarmRaceConfigs")
InitConfig(XSuperSmashBrosConfig, "XSuperSmashBrosConfig")
InitConfig(XPickFlipConfigs, "XPickFlipConfigs")
InitConfig(XNewRegressionConfigs, "XNewRegressionConfigs")
InitConfig(XMemorySaveConfig, "XMemorySaveConfig")
InitConfig(XDiceGameConfigs, "XDiceGameConfigs")
InitConfig(XTheatreConfigs, "XTheatreConfigs")
InitConfig(XMaverickConfigs, "XMaverickConfigs")
InitConfig(XAchievementConfigs, "XAchievementConfigs")
InitConfig(XReviewActivityConfigs, "XReviewActivityConfigs")
InitConfig(XDoomsdayConfigs, "XDoomsdayConfigs")
InitConfig(XPivotCombatConfigs, "XPivotCombatConfigs")
InitConfig(XNewYearLuckConfigs, "XNewYearLuckConfigs")
InitConfig(XHitMouseConfigs, "XHitMouseConfigs")
InitConfig(XEscapeConfigs, "XEscapeConfigs")
InitConfig(XBodyCombineGameConfigs, "XBodyCombineGameConfigs")
InitConfig(XGuildWarConfig, "XGuildWarConfig")
InitConfig(XGoldenMinerConfigs, "XGoldenMinerConfigs")
InitConfig(XDoubleTowersConfigs, "XDoubleTowersConfigs")
InitConfig(XAccumulatedConsumeConfig, "XAccumulatedConsumeConfig")
InitConfig(XMultiDimConfig, "XMultiDimConfig")
InitConfig(XTaikoMasterConfigs, "XTaikoMasterConfigs")
InitConfig(XGuildDormConfig, "XGuildDormConfig")
InitConfig(XSlotMachineConfigs, "XSlotMachineConfigs")
ConfigCenterProfiler:Stop()
end
-- 创建配置表属性,主要是为了封装方法延时调用加载表
function XConfigCenter.CreateGetPropertyByFunc(config, name, readFunc)
config["Get" .. name] = function(key, showTip)
if config[name] == nil then
config[name] = readFunc()
end
if key then
return XConfigCenter.GetValueByKey(key, showTip, config, name)
end
return config[name]
end
end
function XConfigCenter.CreateGetPropertyByArgs(config, name, funcName, path, tableConfig, readId)
config[name] = nil
config["Get" .. name] = function(key, showTip)
if config[name] == nil then
config[name] = XTableManager[funcName](path, tableConfig, readId)
end
if key then
return XConfigCenter.GetValueByKey(key, showTip, config, name, path, readId)
end
return config[name]
end
end
function XConfigCenter.GetValueByKey(key, showTip, config, name, path, readId)
local result = config[name][key]
if not result and showTip then
XLog.ErrorTableDataNotFound(
string.format("XConfigCenter.Get%s", name) ,
string.format("配置%s_%s", name, readId),
path or "",
readId or "",
tostring(key))
end
return result
end
function XConfigCenter.CreateGetProperties(config, names, args)
local beginIndex = 1
for i, name in ipairs(names) do
beginIndex = i + 3 * (i - 1)
XConfigCenter.CreateGetPropertyByArgs(config, name, args[beginIndex], args[beginIndex + 1], args[beginIndex + 2], args[beginIndex + 3])
end
end
function XConfigCenter.ReadTableByTableConfig(tableConfig, directoryName, tableName)
local readFuncName = tableConfig.ReadFuncName or "ReadByIntKey"
local readKeyName = tableConfig.ReadKeyName or "Id"
local tablePath = "Share"
if tableConfig.DirType == XConfigCenter.DirectoryType.Client then
tablePath = "Client"
end
tablePath = string.format("%s/%s/%s.tab", tablePath, directoryName, tableName)
return XTableManager[readFuncName](tablePath, XTable["XTable" .. tableName], readKeyName)
end
function XConfigCenter.CreateTableConfig(value, name)
if value then return value end
local config = {}
setmetatable(config, {
__index = {
--=============
--给定配置表Key获取该配置表全部配置
--=============
GetAllConfigs = function(tableKey)
if not tableKey then
XLog.Error("The tableKey given is not exist. tableKey : " .. tostring(tableKey))
return {}
end
config.__Configs = config.__Configs or {}
local result = config.__Configs[tableKey]
if result == nil then
result = XConfigCenter.ReadTableByTableConfig(tableKey, config.DirectoryName
, tableKey.TableName or config.TableKey[tableKey])
config.__Configs[tableKey] = result
end
return result
end,
--=============
--给定配置表Key和Id获取该配置表指定Id的配置
--tableKey : 配置表的Key
--idKey : 该配置表的主键Id或Key
--noTips : 若没有查找到对应项,是否要打印错误日志
--=============
GetCfgByIdKey = function(tableKey, idKey, noTips)
if not tableKey or not idKey then
XLog.Error(string.format("%s.GetCfgByIdKey error: tableKey or idKey is null!", name))
return {}
end
local allCfgs = config.GetAllConfigs(tableKey)
if not allCfgs then
return {}
end
local cfg = allCfgs[idKey]
if not cfg then
if not noTips then
XLog.ErrorTableDataNotFound(
string.format( "%s.GetCfgByIdKey", name),
tableKey.LogKey or "唯一Id",
tableKey.TableName or config.TableKey[tableKey],
tableKey.LogKey or "唯一Id",
tostring(idKey))
end
return {}
end
return cfg
end
}
})
return config
end

View file

@ -0,0 +1,148 @@
local tableInsert = table.insert
XCoupletGameConfigs = XCoupletGameConfigs or {}
XCoupletGameConfigs.CouPletStatus = {
Incomplete = 0,
Complete = 1,
}
XCoupletGameConfigs.PlayVideoState = {
UnPlay = 0,
Played = 1,
}
XCoupletGameConfigs.HitFaceHelpState = {
NotHit = 0,
Hited = 1,
}
XCoupletGameConfigs.HitFaceVideoState = {
UnPlay = 0,
Played = 1,
}
-- XCoupletGameConfigs.COUPLET_GAME_DATA_KEY = "COUPLET_GAME_DATA_KEY" -- 对联游戏本地数据键
XCoupletGameConfigs.COUPLET_GAME_HELP_HIT_KEY = "COUPLET_GAME_HELP_HIT_KEY" -- 对联游戏帮助打脸键
XCoupletGameConfigs.COUPLET_GAME_VIDEO_HIT_KEY = "COUPLET_GAME_VIDEO_HIT_KEY" -- 对联游戏打脸剧情键
XCoupletGameConfigs.PLAY_VIDEO_STATE_KEY = "COUPLET_PLAY_VIDEO_STATE_KEY" -- 剧情播放信息键
local COUPLET_ACTIVITY_BASE_PATH = "Share/MiniActivity/CoupletGame/CoupletActivityBase.tab"
local COUPLET_PATH = "Share/MiniActivity/CoupletGame/Couplet.tab"
local COUPLET_WORD_PATH = "Share/MiniActivity/CoupletGame/CoupletWord.tab"
local ActivityBaseTemplates = {}
local CoupletTemplates = {}
local CoupletTemplatesWithAct = {}
local CoupletWordTemplates = {}
local DownWordArrList = {}
function XCoupletGameConfigs.Init()
ActivityBaseTemplates = XTableManager.ReadByIntKey(COUPLET_ACTIVITY_BASE_PATH, XTable.XTableCoupletActivityBase, "Id")
CoupletTemplates = XTableManager.ReadByIntKey(COUPLET_PATH, XTable.XTableCouplet, "Id")
CoupletWordTemplates = XTableManager.ReadByIntKey(COUPLET_WORD_PATH, XTable.XTabelCoupletWord, "Id")
for _, coupletTemplet in ipairs(CoupletTemplates) do
if coupletTemplet.ActivityId then
if not CoupletTemplatesWithAct[coupletTemplet.ActivityId] then
CoupletTemplatesWithAct[coupletTemplet.ActivityId] = {}
end
end
if CoupletTemplatesWithAct[coupletTemplet.ActivityId] then
tableInsert(CoupletTemplatesWithAct[coupletTemplet.ActivityId], coupletTemplet)
end
end
for _, coupletTemplate in pairs(CoupletTemplates) do
if DownWordArrList[coupletTemplate.Id] == nil then
DownWordArrList[coupletTemplate.Id] = {}
end
local downWordIdStrList = coupletTemplate.DownWordId
for _, downWordIdStr in ipairs(downWordIdStrList) do
local downWordIdArr = string.ToIntArray(downWordIdStr)
tableInsert(DownWordArrList[coupletTemplate.Id], downWordIdArr)
end
end
end
function XCoupletGameConfigs.GetCoupletBaseActivityById(id)
if not ActivityBaseTemplates or not next(ActivityBaseTemplates) or not ActivityBaseTemplates[id] then
return
end
return ActivityBaseTemplates[id]
end
function XCoupletGameConfigs.GetCoupletTemplatesByActId(actId)
if not CoupletTemplatesWithAct or not next(CoupletTemplatesWithAct) or not CoupletTemplatesWithAct[actId] then
return
end
return CoupletTemplatesWithAct[actId]
end
function XCoupletGameConfigs.GetCoupletTemplateById(id)
if not CoupletTemplates or not next(CoupletTemplates) or not CoupletTemplates[id] then
return
end
return CoupletTemplates[id]
end
function XCoupletGameConfigs.GetCoupletWordImageById(wordId)
if not CoupletWordTemplates or not next(CoupletWordTemplates) or not CoupletWordTemplates[wordId] then
return
end
return CoupletWordTemplates[wordId].WordImageUrl
end
function XCoupletGameConfigs.GetCoupletUpWordsId(coupletId)
if not CoupletTemplates or not next(CoupletTemplates) or not CoupletTemplates[coupletId] then
return
end
return CoupletTemplates[coupletId].UpWordId
end
function XCoupletGameConfigs.GetCoupletBatch(coupletId)
if not CoupletTemplates or not CoupletTemplates[coupletId] then
return
end
return CoupletTemplates[coupletId].BatchUrl
end
function XCoupletGameConfigs.GetCoupletDefaultBatch(coupletId)
if not CoupletTemplates or not CoupletTemplates[coupletId] then
return
end
return CoupletTemplates[coupletId].DefaultBatchUrl
end
function XCoupletGameConfigs.GetCoupletUpImgUrl(coupletId)
if not CoupletTemplates or not CoupletTemplates[coupletId] then
return
end
return CoupletTemplates[coupletId].UpImgUrl
end
function XCoupletGameConfigs.GetCoupletDownImgUrl(coupletId)
if not CoupletTemplates or not CoupletTemplates[coupletId] then
return
end
return CoupletTemplates[coupletId].DownImgUrl
end
function XCoupletGameConfigs.GetCoupletDownIdArr(coupletId, Index)
if not DownWordArrList or not DownWordArrList[coupletId] then
return
end
local coupletDownWordArr = DownWordArrList[coupletId]
if coupletDownWordArr and next(coupletDownWordArr) then
return coupletDownWordArr[Index]
end
end

View file

@ -0,0 +1,66 @@
XDailyDungeonConfigs = {}
local TABLE_DAILY_DROP_GROUP = "Client/Fuben/Daily/DailyDropGroup.tab"
local TABLE_DAILT_DUNGEON_RULES = "Share/Fuben/Daily/DailyDungeonRules.tab"
local TABLE_DAILY_DUNGEON_DATA = "Share/Fuben/Daily/DailyDungeonData.tab"
local TABLE_DAILY_SPECOAL_CONDITION = "Share/Fuben/Daily/DailySpecialCondition.tab"
local DailyDungeonRulesTemplates = {}
local DailyDungeonDataTemplates = {}
local DailySpecialConditionTemplates = {}
local DailyDropGroupTemplates = {}
function XDailyDungeonConfigs.Init()
DailyDungeonRulesTemplates = XTableManager.ReadByIntKey(TABLE_DAILT_DUNGEON_RULES, XTable.XTableDailyDungeonRules, "Id")
DailyDungeonDataTemplates = XTableManager.ReadByIntKey(TABLE_DAILY_DUNGEON_DATA, XTable.XTableDailyDungeonData, "Id")
DailySpecialConditionTemplates = XTableManager.ReadByIntKey(TABLE_DAILY_SPECOAL_CONDITION, XTable.XTableDailySpecialCondition, "Id")
DailyDropGroupTemplates = XTableManager.ReadByIntKey(TABLE_DAILY_DROP_GROUP, XTable.XTableDailyDropGroup, "Id")
end
function XDailyDungeonConfigs.GetDailyDungeonRulesList()
return DailyDungeonRulesTemplates
end
function XDailyDungeonConfigs.GetDailyDungeonRulesById(id)
return DailyDungeonRulesTemplates[id]
end
function XDailyDungeonConfigs.GetDailyDungeonDayOfWeek(Id)
local tmpTab = {}
for _, v in pairs(DailyDungeonRulesTemplates[Id].OpenDayOfWeek) do
table.insert(tmpTab, v)
end
return tmpTab
end
function XDailyDungeonConfigs.GetDailyDungeonDataList()
return DailyDungeonDataTemplates
end
function XDailyDungeonConfigs.GetDailyDungeonData(Id)
return DailyDungeonDataTemplates[Id]
end
function XDailyDungeonConfigs.GetDailySpecialConditionList()
return DailySpecialConditionTemplates
end
function XDailyDungeonConfigs.GetDailyDungeonIdByStageId(stageId)
for _, v in pairs(DailyDungeonDataTemplates) do
for _, v2 in pairs(v.StageId) do
if v2 == stageId then
return v.Id
end
end
end
return nil
end
function XDailyDungeonConfigs.GetDailyDropGroupList()
return DailyDropGroupTemplates
end
function XDailyDungeonConfigs.GetFubenDailyShopId(id)
local data = DailyDungeonDataTemplates[id]
return data and data.ShopId
end

View file

@ -0,0 +1,103 @@
XDiceGameConfigs = XDiceGameConfigs or {}
local TABLE_DICEGAME_ACTIVITY = "Share/MiniActivity/DiceGameActivity/DiceGameActivity.tab"
local TABLE_DICEGAME_OPERATION = "Share/MiniActivity/DiceGameActivity/DiceGameOperation.tab"
local TABLE_DICEGAME_REWARD = "Share/MiniActivity/DiceGameActivity/DiceGameReward.tab"
local TABLE_DICEGAME_EASTEREGG = "Share/MiniActivity/DiceGameActivity/DiceGameEasterEgg.tab"
local TABLE_DICEGAME_POINT = "Share/MiniActivity/DiceGameActivity/DiceGamePoint.tab"
local TABLE_DICE_ANIMATION = "Client/MiniActivity/DiceGameActivity/DiceAnimation.tab"
local DiceGameActivityCfgs = {}
local DiceGameOperationCfgs = {}
local DiceGameRewardCfgs = {}
local DiceGameEasterEggCfgs = {}
local DiceGamePointCfgs = {}
local DiceAnimationCfgs = {}
XDiceGameConfigs.OperationType = {
None = 0,
A = 1,
B = 2,
C = 3,
}
function XDiceGameConfigs.Init()
DiceGameActivityCfgs = XTableManager.ReadByIntKey(TABLE_DICEGAME_ACTIVITY, XTable.XTableDiceGameActivity, "Id")
DiceGameOperationCfgs = XTableManager.ReadByIntKey(TABLE_DICEGAME_OPERATION, XTable.XTableDiceGameOperation, "Id")
DiceGameRewardCfgs = XTableManager.ReadByIntKey(TABLE_DICEGAME_REWARD, XTable.XTableDiceGameReward, "Id")
DiceGameEasterEggCfgs = XTableManager.ReadByIntKey(TABLE_DICEGAME_EASTEREGG, XTable.XTableDiceGameEasterEgg, "Id")
DiceGamePointCfgs = XTableManager.ReadByIntKey(TABLE_DICEGAME_POINT, XTable.XTableDiceGamePoint, "Id")
DiceAnimationCfgs = XTableManager.ReadByIntKey(TABLE_DICE_ANIMATION, XTable.XTableDiceAnimation, "Id")
end
function XDiceGameConfigs.GetDiceGameActivityById(id)
local cfg = DiceGameActivityCfgs[id]
if not cfg then
XLog.Error("GetDiceGameActivityById error: no cfg of id:" .. id)
end
return cfg
end
function XDiceGameConfigs.GetDiceGameOperationById(id)
local cfg = DiceGameOperationCfgs[id]
if not cfg then
XLog.Error("GetDiceGameOperationById error: no cfg of id:" .. id)
end
return cfg
end
function XDiceGameConfigs.GetDiceGameRewardById(id)
local cfg = DiceGameRewardCfgs[id]
if not cfg then
XLog.Error("GetDiceGameRewardById error: no cfg of id:" .. id)
end
return cfg
end
function XDiceGameConfigs.GetDiceGameEasterEggById(id)
local cfg = DiceGameEasterEggCfgs[id]
if not cfg then
XLog.Error("GetDiceGameEasterEggById error: no cfg of id:" .. id)
end
return cfg
end
function XDiceGameConfigs.GetDiceGamePointById(id)
local cfg = DiceGamePointCfgs[id]
if not cfg then
XLog.Error("GetDiceGamePointById error: no cfg of id:" .. id)
end
return cfg
end
function XDiceGameConfigs.GetDiceAnimationById(id)
local cfg = DiceAnimationCfgs[id]
if not cfg then
XLog.Error("GetDiceAnimationById error: no cfg of id:" .. id)
end
return cfg
end
function XDiceGameConfigs.GetActivityCfgs()
return DiceGameActivityCfgs
end
function XDiceGameConfigs.GetOperationCfgs()
return DiceGameOperationCfgs
end
function XDiceGameConfigs.GetRewardCfgs()
return DiceGameRewardCfgs
end
function XDiceGameConfigs.GetEasterEggCfgs()
return DiceGameEasterEggCfgs
end
function XDiceGameConfigs.GetPointCfgs()
return DiceGamePointCfgs
end
function XDiceGameConfigs.GetRewardCount()
return #DiceGameRewardCfgs
end

View file

@ -0,0 +1,40 @@
XDisplayConfigs = XDisplayConfigs or {}
local tableInsert = table.insert
local TABLE_DISPLAY_PATH = "Client/Display/Display.tab"
local TABLE_CONTENT_PATH = "Client/Display/DisplayContent.tab"
local DisplayTable = {}
local ContentTable = {}
local Groups = {}
function XDisplayConfigs.Init()
DisplayTable = XTableManager.ReadByIntKey(TABLE_DISPLAY_PATH, XTable.XTableDisplay, "Id")
if not DisplayTable then
XLog.Error("XDisplayConfigs.Init 函数错误, 根据键值Id读取表 " .. TABLE_DISPLAY_PATH .. " 的时候出错")
end
ContentTable = XTableManager.ReadByIntKey(TABLE_CONTENT_PATH, XTable.XTableDisplayContent, "Id")
for _, tab in pairs(DisplayTable) do
local group = Groups[tab.Model]
if not group then
group = { Ids = {}, Weights = {} }
Groups[tab.Model] = group
end
tableInsert(group.Ids, tab.Id)
tableInsert(group.Weights, tab.Weight)
end
end
function XDisplayConfigs.GetDisplayTable()
return DisplayTable
end
function XDisplayConfigs.GetContentTable()
return ContentTable
end
function XDisplayConfigs.GetGroups()
return Groups
end

View file

@ -0,0 +1,85 @@
XDlcConfig = XDlcConfig or {}
local TABLE_DLC_LIST_PATH = "Client/DlcRes/DlcList.tab"
local TABLE_PATHC_CONFIG_PATH = "Client/DlcRes/PatchConfig.tab"
local TABLE_UNPATCH_CONFIG_PATH = "Client/DlcRes/UnPatchConfig.tab"
local DlcListConfig = nil
local PatchConfig = nil
local UnPatchConfig = nil
local EntryDlcIdMap = nil
local StageIdMap = nil
local EntryType = {
MainChapter = 1, -- 主线参数章节idchapterMain.Id配置在 Share/Fuben/MainLine/ChapterMain.tab
ExtraChapter = 2, -- 外篇参数章节idchapterId配置在 Share/Fuben/ExtraChapter/ChapterExtra.tab
Chanllenge = 3, -- 挑战参数挑战类型XFubenManager.ChapterType定义在 Share/Fuben/FubenChallengeBanner.tab
Bfrt = 4, -- 据点参数章节idchapterId配置在 Share/Fuben/Bfrt/BfrtChapter.tab
}
XDlcConfig.EntryType = EntryType
function XDlcConfig.Init()
DlcListConfig = XTableManager.ReadByIntKey(TABLE_DLC_LIST_PATH, XTable.XTableDlcList, "Id")
PatchConfig = XTableManager.ReadByIntKey(TABLE_PATHC_CONFIG_PATH, XTable.XTablePatchConfig, "Id")
UnPatchConfig = XTableManager.ReadByIntKey(TABLE_UNPATCH_CONFIG_PATH, XTable.XTableUnPatchConfig, "Id")
EntryDlcIdMap = {}
for id, config in pairs(DlcListConfig) do
if not EntryDlcIdMap[config.EntryType] then
EntryDlcIdMap[config.EntryType] = {}
end
EntryDlcIdMap[config.EntryType][config.EntryParam] = id
end
StageIdMap = {}
end
function XDlcConfig.GetDlcListConfig()
return DlcListConfig
end
function XDlcConfig.GetPatchConfig()
return PatchConfig
end
function XDlcConfig.GetUnPatchConfig()
return UnPatchConfig
end
function XDlcConfig.GetListConfigById(id)
local config = DlcListConfig[id]
if not config then
XLog.ErrorTableDataNotFound("XDlcConfig.GetListConfigById",
"DlcList", TABLE_DLC_LIST_PATH, "Id", tostring(id))
end
return config
end
-- 根据功能入口获取分包id
function XDlcConfig.GetDlcIdsByEntry(entryType, entryParam)
if EntryDlcIdMap[entryType] then
local dlcId = EntryDlcIdMap[entryType][entryParam]
if dlcId then
return DlcListConfig[dlcId].PatchConfigIds
end
end
XLog.Debug("尝试根据[功能入口]或取分包id, 失败: entryType:" .. tostring(entryType) .. ", entryParam:" .. tostring(entryParam))
end
-- 根据关卡id获取分包id
function XDlcConfig.GetDlcIdsByStageId(stageId)
local dlcId = StageIdMap[stageId]
if not StageIdMap[stageId] then
for id, config in pairs(DlcListConfig) do
-- 主线和外篇入口参数使用stageId
if config.EntryType == EntryType.MainChapter or config.EntryType == EntryType.ExtraChapter and stageId == config.EntryParam then
dlcId = id
StageIdMap[stageId] = id
end
end
end
if dlcId then
return DlcListConfig[dlcId].PatchConfigIds
end
XLog.Debug("尝试根据[stageId]获取分包id, 失败: stageId:" .. tostring(stageId))
end

View file

@ -0,0 +1,368 @@
local tonumber = tonumber
local tableInsert = table.insert
local tableSort = table.sort
local ipairs = ipairs
local pairs = pairs
XDoomsdayConfigs = XDoomsdayConfigs or {}
function XDoomsdayConfigs.Init()
XDoomsdayConfigs.ActivityConfig =
XConfig.New("Share/MiniActivity/Doomsday/DoomsdayActivity.tab", XTable.XTableDoomsdayActivity) --活动配置
XDoomsdayConfigs.StageConfig =
XConfig.New("Share/MiniActivity/Doomsday/DoomsdayStage.tab", XTable.XTableDoomsdayStage) --关卡配置
XDoomsdayConfigs.PlaceConfig =
XConfig.New("Share/MiniActivity/Doomsday/DoomsdayStagePlace.tab", XTable.XTableDoomsdayStagePlace) --探索地点配置
XDoomsdayConfigs.ResourceConfig =
XConfig.New("Share/MiniActivity/Doomsday/DoomsdayResource.tab", XTable.XTableDoomsdayResource) --资源配置
XDoomsdayConfigs.EventConfig =
XConfig.New("Share/MiniActivity/Doomsday/DoomsdayEvent.tab", XTable.XTableDoomsdayEvent) --关卡事件配置
XDoomsdayConfigs.CreatTeamConfig =
XConfig.New("Share/MiniActivity/Doomsday/DoomsdayCreateTeam.tab", XTable.XTableDoomsdayCreateTeam) --探索队伍创建消耗配置
XDoomsdayConfigs.BuildingConfig =
XConfig.New("Share/MiniActivity/Doomsday/DoomsdayBuilding.tab", XTable.XTableDoomsdayBuilding) --建筑配置
XDoomsdayConfigs.AttributeConfig =
XConfig.New("Share/MiniActivity/Doomsday/DoomsdayAttribute.tab", XTable.XTableDoomsdayAttribute) --属性配置
XDoomsdayConfigs.TargetConfig =
XConfig.New("Share/MiniActivity/Doomsday/DoomsdayTask.tab", XTable.XTableDoomsdayTask) --关卡目标配置
XDoomsdayConfigs.AttributeTypeConfig =
XConfig.New("Share/MiniActivity/Doomsday/DoomsdayAttributeType.tab", XTable.XTableDoomsdayAttributeType) --属性类型配置
XDoomsdayConfigs.ReportConfig =
XConfig.New("Client/MiniActivity/Doomsday/DoomsdayReportText.tab", XTable.XTableDoomsdayReportText) --报告内容随机文本库配置
XDoomsdayConfigs.ResourceAllotConfig =
XConfig.New("Client/MiniActivity/Doomsday/DoomsdayResourceAllot.tab", XTable.XTableDoomsdayResourceAllot) --资源分配方式配置
XDoomsdayConfigs.InitText()
end
-----------------活动相关 begin-----------------
function XDoomsdayConfigs.GetDefaultActivityId()
local defaultActivityId = 0
for activityId, config in pairs(XDoomsdayConfigs.ActivityConfig:GetConfigs()) do
defaultActivityId = activityId
if XTool.IsNumberValid(config.TimeId) and XFunctionManager.CheckInTimeByTimeId(config.TimeId) then
break
end
end
return defaultActivityId
end
--获取后置关卡Id
function XDoomsdayConfigs.GetAfterStageId(activityId, stageId)
for _, inStageId in pairs(XDoomsdayConfigs.ActivityConfig:GetProperty(activityId, "StageId") or {}) do
if XDoomsdayConfigs.StageConfig:GetProperty(inStageId, "PreStage") == stageId then
return inStageId
end
end
return 0
end
---------------活动相关 end-------------------
--居民属性类型
XDoomsdayConfigs.ATTRUBUTE_TYPE = {
HEALTH = 1, --健康值
HUNGER = 2, --饱腹值
SAN = 3 --精神值
}
XDoomsdayConfigs.HOMELESS_ATTR_TYPE = 4 --无家可归属性类型(策划要放到其他居民属性一起展示)
function XDoomsdayConfigs.GetSortedAttrTypes()
return {
XDoomsdayConfigs.ATTRUBUTE_TYPE.HEALTH,
XDoomsdayConfigs.ATTRUBUTE_TYPE.HUNGER,
XDoomsdayConfigs.ATTRUBUTE_TYPE.SAN
}
end
--获取关卡每日单居民需求资源数量(仅分配资源使用)
function XDoomsdayConfigs.GetStageDailyRequireResourceCount(stageId, resourceId)
for index, inResourceId in pairs(XDoomsdayConfigs.StageConfig:GetProperty(stageId, "DailyConsumeResouceId")) do
if inResourceId == resourceId then
return XDoomsdayConfigs.StageConfig:GetProperty(stageId, "DailyConsumeResouceCount")[index] or 0
end
end
return 0
end
--根据资源Id获取关联的居民属性Type
function XDoomsdayConfigs.GetRelatedAttrIdByResourceId(stageId, resourceId)
for _, attrId in pairs(XDoomsdayConfigs.StageConfig:GetProperty(stageId, "AttributeId")) do
if XDoomsdayConfigs.AttributeConfig:GetProperty(attrId, "ResourceId") == resourceId then
return attrId
end
end
return 0
end
--关卡事件类型
XDoomsdayConfigs.EVENT_TYPE = {
MAIN = 1, --主要事件
NORMAL = 2, --普通事件
EXPLORE = 3 --探索事件
}
function XDoomsdayConfigs.GetEventTypeRemindDesc(eventType)
if eventType == XDoomsdayConfigs.EVENT_TYPE.MAIN then
return CsXTextManagerGetText("DoomsdayEventTypeRemindDescMain")
elseif eventType == XDoomsdayConfigs.EVENT_TYPE.EXPLORE then
return CsXTextManagerGetText("DoomsdayEventTypeRemindDescExplore")
end
return CsXTextManagerGetText("DoomsdayEventTypeRemindDescNormal")
end
--获取资源Id列表brief简明模式只显示前两种资源
function XDoomsdayConfigs.GetResourceIds(brief)
local ids = {}
local limitCount = brief and 2 or XMath.IntMax()
for id in ipairs(XDoomsdayConfigs.ResourceConfig:GetConfigs()) do
if id > limitCount then
break
end
tableInsert(ids, id)
end
return ids
end
local function CreateReourceList(ids, counts, daily)
local resources = {}
for index, id in ipairs(ids) do
if XTool.IsNumberValid(id) then
tableInsert(
resources,
{
Id = id,
Count = counts[index],
Daily = daily
}
)
end
end
return resources
end
--获取建筑建造消耗资源列表
function XDoomsdayConfigs.GetBuildingConstructResourceInfos(buildingId)
return CreateReourceList(
XDoomsdayConfigs.BuildingConfig:GetProperty(buildingId, "SpendResourceType"),
XDoomsdayConfigs.BuildingConfig:GetProperty(buildingId, "SpendResourceCount")
)
end
--获取建筑工作中每日消耗资源列表
function XDoomsdayConfigs.GetBuildingDailyConsumeResourceInfos(buildingId)
return CreateReourceList(
XDoomsdayConfigs.BuildingConfig:GetProperty(buildingId, "WorkingDailyConsumeResourceId"),
XDoomsdayConfigs.BuildingConfig:GetProperty(buildingId, "WorkingDailyConsumeResourceCount"),
true
)
end
--获取建筑工作中每日获得资源列表
function XDoomsdayConfigs.GetBuildingDailyGainResourceInfos(buildingId)
return CreateReourceList(
XDoomsdayConfigs.BuildingConfig:GetProperty(buildingId, "WorkingDailyGainResourceId"),
XDoomsdayConfigs.BuildingConfig:GetProperty(buildingId, "WorkingDailyGainResourceCount"),
true
)
end
--建筑类型(一期只区分简单建筑类型)
XDoomsdayConfigs.BUILDING_TYPE = {
NORMAL = 0, --普通
RUINS = 1, --废墟
INOPERABLE = 2, --不可操作类型
TEAM = 3 --哨站(用于解锁探索小队)
}
function XDoomsdayConfigs.IsBuildingRuins(buildingId)
return XDoomsdayConfigs.BuildingConfig:GetProperty(buildingId, "Type") == XDoomsdayConfigs.BUILDING_TYPE.RUINS
end
function XDoomsdayConfigs.IsBuildingInOperable(buildingId)
if not XTool.IsNumberValid(buildingId) then
return false
end
return XDoomsdayConfigs.BuildingConfig:GetProperty(buildingId, "Type") == XDoomsdayConfigs.BUILDING_TYPE.INOPERABLE
end
--建筑状态
XDoomsdayConfigs.BUILDING_STATE = {
EMPTY = 0, --空
WAITING = 1, --等待分配
WORKING = 2, --工作中
PENDING = 3 --工作中断
}
--不同建筑状态的图标
local CSXGameClientConfig = CS.XGame.ClientConfig
XDoomsdayConfigs.BuildingTypeIcon = {
[XDoomsdayConfigs.BUILDING_STATE.EMPTY] = CSXGameClientConfig:GetString("DoomsdayBuildingStateIconEmpty"),
[XDoomsdayConfigs.BUILDING_STATE.WAITING] = CSXGameClientConfig:GetString("DoomsdayBuildingStateIconWaiting"),
[XDoomsdayConfigs.BUILDING_STATE.WORKING] = CSXGameClientConfig:GetString("DoomsdayBuildingStateIconWorking"),
[XDoomsdayConfigs.BUILDING_STATE.PENDING] = CSXGameClientConfig:GetString("DoomsdayBuildingStateIconPending")
}
XDoomsdayConfigs.EmptyBuildingIcon = CSXGameClientConfig:GetString("DoomsdayBuildingIconEmpty")
--资源类型
XDoomsdayConfigs.RESOURCE_TYPE = {
WOOD = 1, --木材
STEEL = 2, --钢材
MEDICINE = 3, --血清
FOOD = 4 --食物
}
XDoomsdayConfigs.SPECIAL_RESOURCE_TYPE_INHANBITANT = -1 --特殊资源类型:居民
--资源分配方式
XDoomsdayConfigs.RESOURCE_ALLOCTION_FUNC_NAME = {
ALL = "GetResourceAllocationByAllocateToAll", --给所有人分配
HALF = "GetResourceAllocationByAllocateToHalf", --给一半人分配
MOST = "GetResourceAllocationByAllocateToMost", --给尽可能多的人分配
NONE = "GetResourceAllocationByAllocateToNone" --不分配
}
--获取加减不同颜色的数字文本 +50-50
function XDoomsdayConfigs.GetNumerText(num)
if num > 0 then
return CsXTextManagerGetText("DoomsdayNumberUp", math.abs(num))
end
if num < 0 then
return CsXTextManagerGetText("DoomsdayNumberDown", math.abs(num))
end
return ""
end
--获取加减不同颜色的数字文本 50/100 红色100/100 蓝色)
function XDoomsdayConfigs.GetRequireNumerText(cur, max)
if cur < max then
return CsXTextManagerGetText("DoomsdayRequireNumberDown", cur, max)
else
return CsXTextManagerGetText("DoomsdayRequireNumberUp", cur, max)
end
end
--每日结算报告
XDoomsdayConfigs.REPORT_ID = {
BUILDING_ADD = 1, --营地增加资源
TEAM_ADD = 2, --探索小队增加资源/居民数量
DEAD = 3, --死去居民文本显示
HOMELESS = 4, --不良状态随机文本(无家可归)
UNHEALTHY = 5, --不良状态随机文本(不健康)
HUNGER = 6, --不良状态随机文本(饥饿)
LOW_SAN = 7, --不良状态随机文本(精神值过低)
HOMELESS_RT = 8, --不良状态随机文本(无家可归)【反向判断】
UNHEALTHY_RT = 9, --不良状态随机文本(不健康)【反向判断】
HUNGER_RT = 10, --不良状态随机文本(饥饿)【反向判断】
LOW_SAN_RT = 11, --不良状态随机文本(精神值过低)【反向判断】
BUILDING_ADD_RT = 12 --营地增加资源【反向判断】
}
--获取随机文本报告
local function GetRandomReportText(reportId)
local descs = XDoomsdayConfigs.ReportConfig:GetProperty(reportId, "Desc")
return descs[XTool.GetRandomNumbers(#descs, 1)[1]]
end
--获取异常状态/死亡居民随机文本报告
function XDoomsdayConfigs.GetRandomReportTextBad(reportId, addInhabitantCount)
local desc, addText = GetRandomReportText(reportId), ""
if XTool.IsNumberValid(addInhabitantCount) then
addText =
CsXTextManagerGetText(
"DoomsdayReportResource",
addInhabitantCount,
CsXTextManagerGetText("DoomsdayInhabitantName")
)
end
if not string.IsNilOrEmpty(addText) then
desc = string.gsub(desc, "{0}", addText)
end
return desc
end
--获取获得资源随机文本报告
function XDoomsdayConfigs.GetRandomReportTextFix(reportId, addResourceDic, addInhabitantCount)
local desc, addText = "", ""
if XTool.IsNumberValid(addInhabitantCount) then
addText =
CsXTextManagerGetText(
"DoomsdayReportResource",
addInhabitantCount,
CsXTextManagerGetText("DoomsdayInhabitantName")
)
end
if not XTool.IsTableEmpty(addResourceDic) then
for resourceId, resource in pairs(addResourceDic) do
local count = resource:GetProperty("_Count")
if XTool.IsNumberValid(count) then
local newText =
CsXTextManagerGetText(
"DoomsdayReportResource",
count,
XDoomsdayConfigs.ResourceConfig:GetProperty(resourceId, "Name")
)
addText = string.IsNilOrEmpty(addText) and newText or addText .. "" .. newText
end
end
end
if not string.IsNilOrEmpty(addText) then
desc = GetRandomReportText(reportId)
desc = string.gsub(desc, "{0}", addText)
else
if reportId == XDoomsdayConfigs.REPORT_ID.BUILDING_ADD then
desc = GetRandomReportText(XDoomsdayConfigs.REPORT_ID.BUILDING_ADD_RT)
end
end
return desc
end
--检查指定地点Id是否为大本营
function XDoomsdayConfigs.CheckPlaceIsCamp(stageId, placeId)
return XDoomsdayConfigs.StageConfig:GetProperty(stageId, "FirstPlace") == placeId
end
function XDoomsdayConfigs.GetCreateTeamCostResourceList(teamId)
local infoList = {}
local countList = XDoomsdayConfigs.CreatTeamConfig:GetProperty(teamId, "SpendResourceCount")
for index, resourceId in pairs(XDoomsdayConfigs.CreatTeamConfig:GetProperty(teamId, "SpendResourceType")) do
tableInsert(
infoList,
{
ResourceId = resourceId,
Count = countList[index] or 0
}
)
end
return infoList
end
--关卡失败原因
XDoomsdayConfigs.SETTLE_LOSE_REASON = {
INHABITANT_DIE_OUT = 1, --居民死光
INHABITANT_CRAZY = 2, --居民SAN值全部降为0
INHABITANT_TIME_OUT = 3 --时间用尽未达成主目标
}
--关卡失败描述文本
function XDoomsdayConfigs.InitText()
XDoomsdayConfigs.LOSE_REASON_TEXT = {
[XDoomsdayConfigs.SETTLE_LOSE_REASON.INHABITANT_DIE_OUT] = CsXTextManagerGetText("DoomsdayLoseReasonDieOut"), --居民死光
[XDoomsdayConfigs.SETTLE_LOSE_REASON.INHABITANT_CRAZY] = CsXTextManagerGetText("DoomsdayLoseReasonCrazy"), --居民SAN值全部降为0
[XDoomsdayConfigs.SETTLE_LOSE_REASON.INHABITANT_TIME_OUT] = CsXTextManagerGetText("DoomsdayLoseReasonTimeOut") --时间用尽未达成主目标
}
end
--探索小队状态
XDoomsdayConfigs.TEAM_STATE = {
WAITING = 1, --待命
MOVING = 2, --行进中
BUSY = 3 --事件中
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,751 @@
XDoubleTowersConfigs = XDoubleTowersConfigs or {}
XDoubleTowersConfigs.StageState = {
-- 通关
Clear = 1,
-- 未通关
NotClear = 2,
-- 未解锁
Lock = 3
}
XDoubleTowersConfigs.ReasonOfLockGroup = {
-- 已解锁
None = 0,
-- 前置关卡未通关
PreconditionStageNotClear = 1,
-- 未到开放时间
TimeLimit = 2
}
--模块类型
XDoubleTowersConfigs.ModuleType = {
Role = 1, --角色
Guard = 2 --守卫
}
-- 每组最多关卡数量
XDoubleTowersConfigs.MaxStageAmountPerGroup = 3
-- teamId 一支队伍就一个人,没必要保存服务端
XDoubleTowersConfigs.TeamId = 19
XDoubleTowersConfigs.TeamTypeId = 130
-- 活动总控表
local ACTIVITY_TAB = "Share/Fuben/DoubleTower/DoubleTowerActivity.tab"
-- 关卡组表
local GROUP_TAB = "Share/Fuben/DoubleTower/DoubleTowerStageGroup.tab"
-- 关卡表
local STAGE_TAB = "Share/Fuben/DoubleTower/DoubleTowerStage.tab"
-- 情报表
local INFORMATION_TAB = "Client/Fuben/DoubleTower/DoubleTowerInformation.tab"
-- 角色(帮手)配置表
local ROLE_TAB = "Share/Fuben/DoubleTower/DoubleTowerRole.tab"
-- 守卫配置表
local GUARD_TAB = "Share/Fuben/DoubleTower/DoubleTowerGuard.tab"
-- 插件表
local PLUGIN_TAB = "Share/Fuben/DoubleTower/DoubleTowerPlugin.tab"
-- 插件详情表
local PLUGIN_LEVEL_TAB = "Share/Fuben/DoubleTower/DoubleTowerPluginLevel.tab"
--region 无脑get配置
local ActivityConfigs = nil
local GroupConfigs = nil
local StageConfigs = nil
local InformationConfigs = nil
local RoleConfigs = nil
local GuardConfigs = nil
local PluginConfigs = nil
local PluginLevelConfigs = nil
function XDoubleTowersConfigs.Init()
end
local function GetActivityConfigs()
if not ActivityConfigs then
ActivityConfigs = XTableManager.ReadByIntKey(ACTIVITY_TAB, XTable.XTableDoubleTowerActivity, "Id")
end
return ActivityConfigs
end
local function GetGroupConfigs()
if not GroupConfigs then
GroupConfigs = XTableManager.ReadByIntKey(GROUP_TAB, XTable.XTableDoubleTowerStageGroup, "Id")
end
return GroupConfigs
end
local function GetStageConfigs()
if not StageConfigs then
StageConfigs = XTableManager.ReadByIntKey(STAGE_TAB, XTable.XTableDoubleTowerStage, "Id")
end
return StageConfigs
end
local function GetInformationConfigs()
if not InformationConfigs then
InformationConfigs = XTableManager.ReadByIntKey(INFORMATION_TAB, XTable.XTableDoubleTowerInformation, "Id")
end
return InformationConfigs
end
local function GetRoleConfigs()
if not RoleConfigs then
RoleConfigs = XTableManager.ReadByIntKey(ROLE_TAB, XTable.XTableDoubleTowerRole, "Id")
end
return RoleConfigs
end
local function GetGuardConfigs()
if not GuardConfigs then
GuardConfigs = XTableManager.ReadByIntKey(GUARD_TAB, XTable.XTableDoubleTowerGuard, "Id")
end
return GuardConfigs
end
local function GetPluginConfigs()
if not PluginConfigs then
PluginConfigs = XTableManager.ReadByIntKey(PLUGIN_TAB, XTable.XTableDoubleTowerPlugin, "Id")
end
return PluginConfigs
end
local function GetPluginLevelConfigs()
if not PluginLevelConfigs then
PluginLevelConfigs = XTableManager.ReadByIntKey(PLUGIN_LEVEL_TAB, XTable.XTableDoubleTowerPluginLevel, "Id")
end
return PluginLevelConfigs
end
function XDoubleTowersConfigs.GetActivityCfg(activityId)
local config = GetActivityConfigs()[activityId]
if not config then
XLog.Error(
"XDoubleTowersConfigs GetActivityCfg error:配置不存在Id:" .. (activityId or "nil") .. " ,Path:" .. ACTIVITY_TAB
)
end
return config
end
function XDoubleTowersConfigs.GetDefaultActivityId()
local cfg = GetActivityConfigs()
for key, value in pairs(cfg) do
return key
end
return false
end
function XDoubleTowersConfigs.GetGroupConfigs()
return GetGroupConfigs()
end
function XDoubleTowersConfigs.GetStageGroupCfg(groupId)
return GetGroupConfigs()[groupId] or {}
end
function XDoubleTowersConfigs.GetAllStageConfigs()
return GetStageConfigs()
end
function XDoubleTowersConfigs.GetStageCfg(id)
return GetStageConfigs()[id] or {}
end
function XDoubleTowersConfigs.GetInfoCfg(id)
return GetInformationConfigs()[id]
end
local function GetRoleCfg(id)
local config = GetRoleConfigs()[id]
if not config then
XLog.ErrorTableDataNotFound("XDoubleTowersConfigs.GetRoleCfg", "RoleConfigs", ROLE_TAB, "Id", id)
return
end
return config
end
local function GetGuardCfg(id)
local config = GetGuardConfigs()[id]
if not config then
XLog.ErrorTableDataNotFound("XDoubleTowersConfigs.GetGuardCfg", "GuardConfigs", GUARD_TAB, "Id", id)
return
end
return config
end
local function GetPluginCfg(id)
local config = GetPluginConfigs()[id]
if not config then
XLog.ErrorTableDataNotFound("XDoubleTowersConfigs.GetPluginCfg", "PluginCfgs", PLUGIN_TAB, "Id", id)
return
end
return config
end
local function GetPluginLevelCfg(id)
return GetPluginLevelConfigs()[id]
end
--endregion
-------------------------------------------------------------------------------------------
function XDoubleTowersConfigs.GetTimeLimitId(activityId)
return XDoubleTowersConfigs.GetActivityCfg(activityId).OpenTimeId
end
function XDoubleTowersConfigs.GetActivityBackground(activityId)
return XDoubleTowersConfigs.GetActivityCfg(activityId).BannerBg
end
---@return string@活动名/标题
function XDoubleTowersConfigs.GetTitleName(activityId)
return XDoubleTowersConfigs.GetActivityCfg(activityId).Name
end
---@return number@收菜货币的id
function XDoubleTowersConfigs.GetCoinItemId(activityId)
return XDoubleTowersConfigs.GetActivityCfg(activityId).RewardItemId
end
---@return number@收菜间隔
function XDoubleTowersConfigs.GetGatherInterval(activityId)
return XDoubleTowersConfigs.GetActivityCfg(activityId).RewardTimer
end
---@return number@一次收菜多少代币
function XDoubleTowersConfigs.GetGatherCoins(activityId)
return XDoubleTowersConfigs.GetActivityCfg(activityId).RewardItemCount
end
---@return number@图文教学界面对应helpCourse.tab
function XDoubleTowersConfigs.GetHelpKey(activityId)
return XDoubleTowersConfigs.GetActivityCfg(activityId).HelpKey
end
local _StageGroupAmount = nil
---@return number@关卡组数量从一之门到n之门不算特殊关卡
function XDoubleTowersConfigs.GetStageGroupAmount()
if not _StageGroupAmount then
_StageGroupAmount = 0
local groupConfigs = GetGroupConfigs()
for groupId, cfg in pairs(groupConfigs) do
if not cfg.IsSpecial then
_StageGroupAmount = _StageGroupAmount + 1
end
end
end
return _StageGroupAmount
end
local function SortId(id1, id2)
return id1 < id2
end
local _GroupIndex2Id = nil
local function InitGroupIndex2Id()
if not _GroupIndex2Id then
_GroupIndex2Id = {}
local groupConfigs = GetGroupConfigs()
for groupId, cfg in pairs(groupConfigs) do
if not _GroupIndex2Id[cfg.ActivityId] then
_GroupIndex2Id[cfg.ActivityId] = {}
end
local t = _GroupIndex2Id[cfg.ActivityId]
t[#t + 1] = groupId
end
for activity, group2Id in pairs(_GroupIndex2Id) do
table.sort(group2Id, SortId)
end
end
end
---@return number@ groupId
function XDoubleTowersConfigs.GetGroupId(activityId, groupIndex)
InitGroupIndex2Id()
return _GroupIndex2Id[activityId] and _GroupIndex2Id[activityId][groupIndex]
end
function XDoubleTowersConfigs.GetActivityIdByStageId(stageId)
local groupId = XDoubleTowersConfigs.GetGroupIdByStageId(stageId)
local groupCfg = XDoubleTowersConfigs.GetStageGroupCfg(groupId)
return groupCfg and groupCfg.ActivityId
end
local _GroupId2Stage = nil
---@return table@ {stageId1,stageId2,stageId3}
local function GetGroup(activityId, groupId)
if not _GroupId2Stage then
local stageConfigs = GetStageConfigs()
_GroupId2Stage = {}
for id, cfg in pairs(stageConfigs) do
local groupActivityId = XDoubleTowersConfigs.GetActivityIdByStageId(cfg.Id)
if groupActivityId then
if not _GroupId2Stage[groupActivityId] then
_GroupId2Stage[groupActivityId] = {}
end
local groupId2Stage = _GroupId2Stage[groupActivityId]
groupId2Stage[cfg.GroupId] = groupId2Stage[cfg.GroupId] or {}
local groupIdArray = groupId2Stage[cfg.GroupId]
groupIdArray[#groupIdArray + 1] = cfg.Id
end
end
for activity, groupId2Stage in pairs(_GroupId2Stage) do
for groupId, group in pairs(groupId2Stage) do
table.sort(group, SortId)
end
end
end
return _GroupId2Stage[activityId][groupId] or {}
end
function XDoubleTowersConfigs.GetGroup(activityId, groupId)
return GetGroup(activityId, groupId)
end
local function GetGroupCfg(groupId)
return GetGroupConfigs()[groupId] or {}
end
function XDoubleTowersConfigs.GetStageId(activityId, groupId, stageIndex)
return GetGroup(activityId, groupId)[stageIndex]
end
function XDoubleTowersConfigs.GetStageName(stageId)
return XDoubleTowersConfigs.GetStageCfg(stageId).Name
end
function XDoubleTowersConfigs.GetStageTip(stageId)
return XDoubleTowersConfigs.GetStageCfg(stageId).BuffDesc
end
function XDoubleTowersConfigs.GetPreconditionStage(stageId)
return XDoubleTowersConfigs.GetStageCfg(stageId).PreStageId
end
-- 关卡组 按时间开放
function XDoubleTowersConfigs.GetGroupTimeLimitId(groupId)
return GetGroupCfg(groupId).OpenTimeId
end
function XDoubleTowersConfigs.GetGroupName(groupId)
return GetGroupCfg(groupId).Name
end
local _StageAmount = {}
function XDoubleTowersConfigs.GetTotalNormalStageAmount(activityId)
if _StageAmount[activityId] then
return _StageAmount[activityId]
end
local stageAmount = 0
local allGroup = GetGroupConfigs()
for groupId, groupCfg in pairs(allGroup) do
if groupCfg.ActivityId == activityId and not groupCfg.IsSpecial then
local group = GetGroup(activityId, groupId)
stageAmount = stageAmount + #group
end
end
_StageAmount[activityId] = stageAmount
return stageAmount
end
local _SpecialGroupId = {}
function XDoubleTowersConfigs.GetSpecialGroupId(activityId)
if _SpecialGroupId[activityId] ~= nil then
return _SpecialGroupId[activityId]
end
local groupConfigs = GetGroupConfigs()
for groupId, cfg in pairs(groupConfigs) do
if cfg.IsSpecial and activityId == cfg.ActivityId then
_SpecialGroupId[activityId] = groupId
return groupId
end
end
_SpecialGroupId[activityId] = false
return false
end
local _Stage2InfoGroup = nil
function XDoubleTowersConfigs.GetInfoIdGroup(stageId)
if not _Stage2InfoGroup then
_Stage2InfoGroup = {}
for infoId, info in pairs(GetInformationConfigs()) do
_Stage2InfoGroup[info.StageId] = _Stage2InfoGroup[info.StageId] or {}
local group = _Stage2InfoGroup[info.StageId]
group[#group + 1] = info.Id
end
end
return _Stage2InfoGroup[stageId] or {}
end
function XDoubleTowersConfigs.GetGroupIdByStageId(stageId)
return XDoubleTowersConfigs.GetStageCfg(stageId).GroupId
end
function XDoubleTowersConfigs.GetGroupPreconditionStage(groupId)
return XDoubleTowersConfigs.GetStageGroupCfg(groupId).PreStageId
end
function XDoubleTowersConfigs.GetEnemyInfoImg(infoId)
return XDoubleTowersConfigs.GetInfoCfg(infoId).BossImage
end
function XDoubleTowersConfigs.GetEnemyInfoRoundDesc(infoId)
return XDoubleTowersConfigs.GetInfoCfg(infoId).RoundDesc
end
function XDoubleTowersConfigs.GetEnemyInfoTypeDesc(infoId)
return XDoubleTowersConfigs.GetInfoCfg(infoId).TypeDesc
end
function XDoubleTowersConfigs.GetGroupIndexByStageId(stageId)
local groupId = XDoubleTowersConfigs.GetGroupIdByStageId(stageId)
InitGroupIndex2Id()
local activityId = XDoubleTowersConfigs.GetActivityIdByStageId(stageId)
local groupIndex2Id = _GroupIndex2Id[activityId]
if not groupIndex2Id then
return false
end
for groupIndex = 1, #groupIndex2Id do
if groupIndex2Id[groupIndex] == groupId then
return groupIndex
end
end
return false
end
function XDoubleTowersConfigs.GetMaxCoins(activityId)
return XDoubleTowersConfigs.GetActivityCfg(activityId).RewardMaxCount
end
function XDoubleTowersConfigs.GetRolePluginMaxCount()
local activityId = XDataCenter.DoubleTowersManager.GetActivityId()
local config = XDoubleTowersConfigs.GetActivityCfg(activityId)
return config and config.RolePluginMaxCount
end
function XDoubleTowersConfigs.GetGuardPluginMaxCount()
local activityId = XDataCenter.DoubleTowersManager.GetActivityId()
local config = XDoubleTowersConfigs.GetActivityCfg(activityId)
return config and config.GuardPluginMaxCount
end
function XDoubleTowersConfigs.GetActivityRewardItemId()
local activityId = XDataCenter.DoubleTowersManager.GetActivityId()
local config = XDoubleTowersConfigs.GetActivityCfg(activityId)
return config and config.RewardItemId
end
---------------DoubleTowerRole being-----------------
local IsInitDoubleTowerRole = false
local ActivityIdToRoleId = 0
local InitDoubleTowerRoleDic = function(activityId)
if IsInitDoubleTowerRole then
return
end
-- local configs = GetRoleConfigs()
-- for id, v in pairs(configs) do
-- if not ActivityIdToRoleId[v.ActivityId] then
-- ActivityIdToRoleId[v.ActivityId] = id
-- end
-- end
ActivityIdToRoleId = activityId
IsInitDoubleTowerRole = true
end
function XDoubleTowersConfigs.GetDoubleTowerRoleId()
local activityId = XDataCenter.DoubleTowersManager.GetActivityId()
InitDoubleTowerRoleDic(activityId)
return ActivityIdToRoleId
end
function XDoubleTowersConfigs.GetRoleBasePluginIdList()
local selectPluginType = XDoubleTowersConfigs.GetRoleSelectPluginType()
if XTool.IsNumberValid(selectPluginType) then
return XDoubleTowersConfigs.GetRolePluginLevelIdList()
end
return XDoubleTowersConfigs.GetDoubleTowerPluginIdList(selectPluginType)
end
function XDoubleTowersConfigs.GetRoleSelectPluginType()
local id = XDoubleTowersConfigs.GetDoubleTowerRoleId()
return GetRoleCfg(id).SlotPluginType
end
function XDoubleTowersConfigs.GetRolePluginLevelIdList()
local id = XDoubleTowersConfigs.GetDoubleTowerRoleId()
return GetRoleCfg(id).PluginLevelId
end
function XDoubleTowersConfigs.GetDefaultRoleBaseId()
local idList = XDoubleTowersConfigs.GetRolePluginLevelIdList()
for idx, id in ipairs(idList or {}) do
local preStage = XDoubleTowersConfigs.GetRolePreStageId(idx)
--默认为不需要前置关卡的pluginevelId
if not XTool.IsNumberValid(preStage) then
return id
end
end
return idList[1]
end
function XDoubleTowersConfigs.GetRoleDefaultPluginId()
local id = XDoubleTowersConfigs.GetDoubleTowerRoleId()
return GetRoleCfg(id).DefaultPlugin
end
function XDoubleTowersConfigs.GetRolePluginLevelId(index)
local idList = XDoubleTowersConfigs.GetRolePluginLevelIdList()
return idList[index]
end
function XDoubleTowersConfigs.GetRolePreStageId(index)
local id = XDoubleTowersConfigs.GetDoubleTowerRoleId()
local preStageIdList = GetRoleCfg(id).PreStage
return preStageIdList[index]
end
function XDoubleTowersConfigs.GetRoleIcon(index)
local id = XDoubleTowersConfigs.GetDoubleTowerRoleId()
local iconList = GetRoleCfg(id).Icon
return iconList[index]
end
function XDoubleTowersConfigs.GetRoleIconByPluginLevelId(pluginLevelId)
local idList = XDoubleTowersConfigs.GetRolePluginLevelIdList()
for index, id in ipairs(idList) do
if pluginLevelId == id then
return XDoubleTowersConfigs.GetRoleIcon(index)
end
end
end
function XDoubleTowersConfigs.GetSlotPreStageId(index, type)
local preStageIdList = {}
if type == XDoubleTowersConfigs.ModuleType.Role then
local id = XDoubleTowersConfigs.GetDoubleTowerRoleId()
preStageIdList = GetRoleCfg(id).SlotPreStageId
elseif type == XDoubleTowersConfigs.ModuleType.Guard then
local id = XDoubleTowersConfigs.GetDoubleTowerGuardId()
preStageIdList = GetGuardCfg(id).SlotPreStageId
end
return preStageIdList[index]
end
---------------DoubleTowerRole end-------------------
---------------DoubleTowerGuard being-------------------
local IsInitDoubleTowerGuard = false
local ActivityIdToGuardId = 0
local InitDoubleTowerGuardDic = function(activityId)
if IsInitDoubleTowerGuard then
return
end
-- local configs = GetGuardConfigs()
-- for id, v in pairs(configs) do
-- if not ActivityIdToGuardIdList[v.ActivityId] then
-- ActivityIdToGuardIdList[v.ActivityId] = id
-- end
-- end
ActivityIdToGuardId = activityId
IsInitDoubleTowerGuard = true
end
function XDoubleTowersConfigs.GetDoubleTowerGuardId()
local activityId = XDataCenter.DoubleTowersManager.GetActivityId()
InitDoubleTowerGuardDic(activityId)
return ActivityIdToGuardId
end
function XDoubleTowersConfigs.GetGuardBasePluginIdList()
local selectPluginType = XDoubleTowersConfigs.GetGuardSelectPluginType()
if XTool.IsNumberValid(selectPluginType) then
return XDoubleTowersConfigs.GetGuardPluginLevelIdList()
end
return XDoubleTowersConfigs.GetDoubleTowerPluginIdList(selectPluginType)
end
function XDoubleTowersConfigs.GetDefaultGuardIndex()
local idList = XDoubleTowersConfigs.GetGuardPluginLevelIdList()
for idx, _ in ipairs(idList or {}) do
local preStage = XDoubleTowersConfigs.GetGuardPreStageId(idx)
--默认为不需要前置关卡的pluginevelId
if not XTool.IsNumberValid(preStage) then
return idx
end
end
return 1
end
function XDoubleTowersConfigs.GetGuardPluginLevelId(index)
local idList = XDoubleTowersConfigs.GetGuardPluginLevelIdList()
return idList[index]
end
function XDoubleTowersConfigs.GetGuardSelectPluginType()
local id = XDoubleTowersConfigs.GetDoubleTowerGuardId()
return GetGuardCfg(id).SlotPluginType
end
function XDoubleTowersConfigs.GetGuardNpcIdList(index)
local id = XDoubleTowersConfigs.GetDoubleTowerGuardId()
local npcIdList = GetGuardCfg(id).NPCId
return npcIdList[index]
end
function XDoubleTowersConfigs.GetGuardPluginLevelIdList()
local id = XDoubleTowersConfigs.GetDoubleTowerGuardId()
return GetGuardCfg(id).PluginLevelId
end
function XDoubleTowersConfigs.GetGuardPreStageId(index)
local id = XDoubleTowersConfigs.GetDoubleTowerGuardId()
local preStageIdList = GetGuardCfg(id).PreStageId
return preStageIdList[index]
end
function XDoubleTowersConfigs.GetGuardIcon(index)
local id = XDoubleTowersConfigs.GetDoubleTowerGuardId()
local iconList = GetGuardCfg(id).Icon
return iconList[index]
end
function XDoubleTowersConfigs.GetGuardSmallIcon(index)
local id = XDoubleTowersConfigs.GetDoubleTowerGuardId()
local iconList = GetGuardCfg(id).SmallIcon
return iconList[index]
end
function XDoubleTowersConfigs.GetGuardIconByPluginLevelId(pluginLevelId, useSmallIcon)
local idList = XDoubleTowersConfigs.GetGuardPluginLevelIdList()
for index, id in ipairs(idList) do
if pluginLevelId == id then
return useSmallIcon and XDoubleTowersConfigs.GetGuardSmallIcon(index) or
XDoubleTowersConfigs.GetGuardIcon(index)
end
end
end
---------------DoubleTowerGuard end---------------------
---------------DoubleTowerPlugin begin-------------------
local IsInitDoubleTowerPlugin = false
local ActivityIdToPluginIdList = {} --key:活动Id, value:插件组Id列表
local PluginIdToLevelIdDic = {} --key1:插件Id, key2:等级, value:插件等级Id
local PluginIdToMaxLevelDic = {} --key:插件Id, value:插件最高等级
local PluginIdToLevelIdList = {}
local InitDoubleTowerPluginDic = function()
if IsInitDoubleTowerPlugin then
return
end
local configs = GetPluginConfigs()
for id, v in pairs(configs) do
if not ActivityIdToPluginIdList[v.ActivityId] then
ActivityIdToPluginIdList[v.ActivityId] = {}
end
table.insert(ActivityIdToPluginIdList[v.ActivityId], id)
end
configs = GetPluginLevelConfigs()
for id, v in pairs(configs) do
if not PluginIdToLevelIdDic[v.PluginId] then
PluginIdToLevelIdDic[v.PluginId] = {}
end
PluginIdToLevelIdDic[v.PluginId][v.Level] = id
if not PluginIdToLevelIdList[v.PluginId] then
PluginIdToLevelIdList[v.PluginId] = {}
end
table.insert(PluginIdToLevelIdList[v.PluginId], v.Id)
local curMaxLevel = PluginIdToMaxLevelDic[v.PluginId]
if not curMaxLevel or curMaxLevel < v.Level then
PluginIdToMaxLevelDic[v.PluginId] = v.Level
end
end
for _, levelIdList in pairs(PluginIdToLevelIdList) do
table.sort(
levelIdList,
function(levelIdA, levelIdB)
local levelA = XDoubleTowersConfigs.GetPluginLevel(levelIdA)
local levelB = XDoubleTowersConfigs.GetPluginLevel(levelIdB)
if levelA ~= levelB then
return levelA < levelB
end
return levelIdA < levelIdB
end
)
end
IsInitDoubleTowerPlugin = true
end
function XDoubleTowersConfigs.GetDoubleTowerPluginIdList(type)
InitDoubleTowerPluginDic()
local activityId = XDataCenter.DoubleTowersManager.GetActivityId()
local pluginIdList = ActivityIdToPluginIdList[activityId] or {}
if not type then
return pluginIdList
end
local sameTypePluginIdList = {}
for _, pluginId in ipairs(pluginIdList) do
if XDoubleTowersConfigs.GetPluginType(pluginId) == type then
table.insert(sameTypePluginIdList, pluginId)
end
end
return sameTypePluginIdList
end
function XDoubleTowersConfigs.GetPluginType(id)
return GetPluginCfg(id).Type
end
function XDoubleTowersConfigs.GetPluginIcon(id)
return GetPluginCfg(id).Icon
end
function XDoubleTowersConfigs.GetPluginDesc(id)
return GetPluginCfg(id).Desc
end
---------------DoubleTowerPlugin end---------------------
---------------DoubleTowerPluginLevel begin-------------------
function XDoubleTowersConfigs.GetPluginLevelId(pluginId, level)
InitDoubleTowerPluginDic()
level = XTool.IsNumberValid(level) and level or 1
return PluginIdToLevelIdDic[pluginId] and PluginIdToLevelIdDic[pluginId][level]
end
function XDoubleTowersConfigs.GetPluginLevelIdList(pluginId)
InitDoubleTowerPluginDic()
return PluginIdToLevelIdList[pluginId] or {}
end
function XDoubleTowersConfigs.GetPluginMaxLevel(pluginId)
InitDoubleTowerPluginDic()
return PluginIdToMaxLevelDic[pluginId] or 0
end
function XDoubleTowersConfigs.GetPluginLevelName(id)
return GetPluginLevelCfg(id).Name
end
function XDoubleTowersConfigs.GetLevelPluginId(id)
return GetPluginLevelCfg(id).PluginId
end
function XDoubleTowersConfigs.GetPluginLevel(id)
return GetPluginLevelCfg(id).Level
end
function XDoubleTowersConfigs.GetPluginLevelFightEventId(id)
return GetPluginLevelCfg(id).FightEventId
end
function XDoubleTowersConfigs.GetPluginLevelUpgradeSpend(id)
return GetPluginLevelCfg(id).UpgradeSpend
end
function XDoubleTowersConfigs.GetPluginLevelDesc(id)
return GetPluginLevelCfg(id).Desc
end
---------------DoubleTowerPluginLevel end---------------------

View file

@ -0,0 +1,271 @@
local table = table
local tableInsert = table.insert
XDrawConfigs = XDrawConfigs or {}
XDrawConfigs.ModelType = {
Role = 1,
Weapon = 2,
Partner = 3
}
XDrawConfigs.CombinationsTypes = {
Normal = 1,
Aim = 2,
NewUp = 3,
Furniture = 4,
CharacterUp = 5,
EquipSuit = 6,
}
XDrawConfigs.DrawSetType = {
Normal = 1,
Destiny = 2,
}
XDrawConfigs.RareRank = {
A = 1,
S = 2,
}
XDrawConfigs.RuleType = {
Tab = 0,
Normal = 1,
Lotto = 2,
}
XDrawConfigs.GroupType = {
Normal = 1,
Destiny = 2,
}
---
--- 卡池可掉落的奖励类型
XDrawConfigs.DrawCapacityCheckType = {
Partner = 1 -- 伙伴
}
local TABLE_DRAW_PREVIEW = "Client/Draw/DrawPreview.tab"
local TABLE_DRAW_PREVIEW_GOODS = "Client/Draw/DrawPreviewGoods.tab"
local TABLE_DRAW_COMBINATIONS = "Client/Draw/DrawCombinations.tab"
local TABLE_DRAW_PROB = "Client/Draw/DrawProbShow.tab"
local TABLE_GROUP_RULE = "Client/Draw/DrawGroupRule.tab"
local TABLE_AIMPROBABILITY = "Client/Draw/DrawAimProbability.tab"
local TABLE_DRAW_SHOW = "Client/Draw/DrawShow.tab"
local TABLE_DRAW_CAMERA = "Client/Draw/DrawCamera.tab"
local TABLE_DRAW_TABS = "Client/Draw/DrawTabs.tab"
local TABLE_DRAW_SHOW_CHARACTER = "Client/Draw/DrawShowCharacter.tab"
local TABLE_DRAW_TYPE_CHANGE = "Client/Draw/DrawTypeChange.tab"
local TABLE_DRAW_SHOW_EFFECT = "Client/Draw/DrawShowEffect.tab"
local TABLE_DRAW_GROUP_RELATION = "Client/Draw/DrawGroupRelation.tab"
local TABLE_DRAW_SKIP = "Client/Draw/DrawSkip.tab"
local TABLE_DRAW_SCENE = "Client/Draw/DrawScene.tab"
local TABLE_DRAW_NEWYEARSHOW = "Client/Draw/JPDrawNewYearShow.tab"
local DrawPreviews = {}
local DrawCombinations = {}
local DrawProbs = {}
local DrawGroupRule = {}
local DrawAimProbability = {}
local DrawShow = {}
local DrawShowEffect = {}
local DrawCamera = {}
local DrawTabs = {}
local DrawShowCharacter = {}
local DrawTypeChangeCfg = {}
local DrawSubGroupDic = {}
local DrawGroupRelationCfg = {}
local DrawGroupRelationDic = {}
local DrawSkipCfg = {}
local DrawSceneCfg = {}
local DrawNewYearShow = {}
function XDrawConfigs.Init()
DrawCombinations = XTableManager.ReadByIntKey(TABLE_DRAW_COMBINATIONS, XTable.XTableDrawCombinations, "Id")
DrawGroupRule = XTableManager.ReadByIntKey(TABLE_GROUP_RULE, XTable.XTableDrawGroupRule, "Id")
DrawShow = XTableManager.ReadByIntKey(TABLE_DRAW_SHOW, XTable.XTableDrawShow, "Type")
DrawCamera = XTableManager.ReadByIntKey(TABLE_DRAW_CAMERA, XTable.XTableDrawCamera, "Id")
DrawTabs = XTableManager.ReadByIntKey(TABLE_DRAW_TABS, XTable.XTableDrawTabs, "Id")
DrawShowCharacter = XTableManager.ReadByIntKey(TABLE_DRAW_SHOW_CHARACTER, XTable.XTableDrawShowCharacter, "Id")
DrawAimProbability = XTableManager.ReadByIntKey(TABLE_AIMPROBABILITY, XTable.XTableDrawAimProbability, "Id")
DrawTypeChangeCfg = XTableManager.ReadByIntKey(TABLE_DRAW_TYPE_CHANGE, XTable.XTableDrawTypeChange, "MainGroupId")
DrawShowEffect = XTableManager.ReadByIntKey(TABLE_DRAW_SHOW_EFFECT, XTable.XTableDrawShowEffect, "EffectGroupId")
DrawGroupRelationCfg = XTableManager.ReadByIntKey(TABLE_DRAW_GROUP_RELATION, XTable.XTableDrawGroupRelation, "NormalGroupId")
DrawSkipCfg = XTableManager.ReadByIntKey(TABLE_DRAW_SKIP, XTable.XTableDrawSkip, "DrawGroupId")
DrawSceneCfg = XTableManager.ReadByIntKey(TABLE_DRAW_SCENE, XTable.XTableDrawScene, "Id")
DrawNewYearShow = XTableManager.ReadByIntKey(TABLE_DRAW_NEWYEARSHOW, XTable.XTableDrawNewYearActivityShow, "Type")
local previews = XTableManager.ReadAllByIntKey(TABLE_DRAW_PREVIEW, XTable.XTableDrawPreview, "Id")
local previewGoods = XTableManager.ReadAllByIntKey(TABLE_DRAW_PREVIEW_GOODS, XTable.XTableRewardGoods, "Id")
for drawId, preview in pairs(previews) do
local upGoodsIds = preview.UpGoodsId
local upGoods = {}
for i = 1, #upGoodsIds do
tableInsert(upGoods, XRewardManager.CreateRewardGoodsByTemplate(previewGoods[upGoodsIds[i]]))
end
local goodsIds = preview.GoodsId
local goods = {}
for i = 1, #goodsIds do
tableInsert(goods, XRewardManager.CreateRewardGoodsByTemplate(previewGoods[goodsIds[i]]))
end
local drawPreview = {}
drawPreview.UpGoods = upGoods
drawPreview.Goods = goods
DrawPreviews[drawId] = drawPreview
end
local drawProbList = XTableManager.ReadByIntKey(TABLE_DRAW_PROB, XTable.XTableDrawProbShow, "Id")
for _, v in pairs(drawProbList) do
if not DrawProbs[v.DrawId] then
DrawProbs[v.DrawId] = {}
end
tableInsert(DrawProbs[v.DrawId], v)
end
XDrawConfigs.SetDrawSubGroupDic()
XDrawConfigs.SetGroupRelationDic()
end
function XDrawConfigs.SetDrawSubGroupDic()
for _, typeChangeGroup in pairs(DrawTypeChangeCfg or {}) do
for _, subGroupId in pairs(typeChangeGroup.SubGroupId or {}) do
if not DrawSubGroupDic[subGroupId] then
DrawSubGroupDic[subGroupId] = typeChangeGroup.MainGroupId
end
end
end
end
function XDrawConfigs.SetGroupRelationDic()
DrawGroupRelationDic = {}
for _, data in pairs(DrawGroupRelationCfg) do
if not DrawGroupRelationDic[data.NormalGroupId] then
DrawGroupRelationDic[data.NormalGroupId] = data.DestinyGroupId
else
XLog.Error("Can Not Use Same GroupId for NormalGroupId .GroupId:" .. data.NormalGroupId)
end
if not DrawGroupRelationDic[data.DestinyGroupId] then
DrawGroupRelationDic[data.DestinyGroupId] = data.NormalGroupId
else
XLog.Error("Can Not Use Same GroupId for DestinyGroupId .GroupId:" .. data.DestinyGroupId)
end
end
end
function XDrawConfigs.GetDrawGroupRelationDic()
return DrawGroupRelationDic
end
function XDrawConfigs.GetDrawCombinations()
return DrawCombinations
end
function XDrawConfigs.GetDrawGroupRule()
return DrawGroupRule
end
function XDrawConfigs.GetDrawAimProbability()
return DrawAimProbability
end
function XDrawConfigs.GetDrawShow()
return DrawShow
end
function XDrawConfigs.GetDrawNewYearShow()
return DrawNewYearShow
end
---
--- 获取'drawGroupId'卡组的跳转ID数组
function XDrawConfigs.GetDrawSkipList(drawGroupId)
if DrawSkipCfg[drawGroupId] then
return DrawSkipCfg[drawGroupId].SkipId
end
return {}
end
function XDrawConfigs.GetDrawShowCharacter()
return DrawShowCharacter
end
function XDrawConfigs.GetDrawCamera()
return DrawCamera
end
function XDrawConfigs.GetDrawTabs()
return DrawTabs
end
function XDrawConfigs.GetDrawPreviews()
return DrawPreviews
end
function XDrawConfigs.GetDrawProbs()
return DrawProbs
end
function XDrawConfigs.GetDrawTypeChangeCfg()
return DrawTypeChangeCfg
end
function XDrawConfigs.GetDrawGroupRelationCfg()
return DrawGroupRelationCfg
end
function XDrawConfigs.GetDrawTypeChangeCfgById(id)
return DrawTypeChangeCfg[id]
end
function XDrawConfigs.GetDrawSubGroupDic()
return DrawSubGroupDic
end
function XDrawConfigs.GetDrawTabById(id)
if not DrawTabs[id] then
XLog.Error("Client/Draw/DrawTabs.tab Id = " .. id .. " Is Null")
end
return DrawTabs[id]
end
function XDrawConfigs.GetDrawGroupRuleById(id)
if not DrawGroupRule[id] then
XLog.Error("Client/Draw/DrawGroupRule.tab Id = " .. id .. " Is Null")
end
return DrawGroupRule[id]
end
function XDrawConfigs.GetDrawShowEffectById(id)
if not DrawShowEffect[id] then
XLog.Error("Client/Draw/DrawShowEffect.tab Id = " .. id .. " Is Null")
end
return DrawShowEffect[id]
end
function XDrawConfigs.GetOpenUpEffect(id)
return XDrawConfigs.GetDrawShowEffectById(id).PanelOpenUp
end
function XDrawConfigs.GetOpenDownEffect(id)
return XDrawConfigs.GetDrawShowEffectById(id).PanelOpenDown
end
function XDrawConfigs.GetCardShowOffEffect(id)
return XDrawConfigs.GetDrawShowEffectById(id).PanelCardShowOff
end
function XDrawConfigs.GetOpenBoxEffect(id)
return XDrawConfigs.GetDrawShowEffectById(id).EffectOpenBox
end
function XDrawConfigs.GetSkipEffect(id)
return XDrawConfigs.GetDrawShowEffectById(id).SkipEffect
end
function XDrawConfigs.GetDrawSceneCfg(id)
return DrawSceneCfg[id]
end

View file

@ -0,0 +1,90 @@
XEliminateGameConfig = XEliminateGameConfig or {}
local TABLE_ELIMINATEGAME_GAME = "Share/EliminateGame/EliminateGame.tab"
local TABLE_ELIMINATEGAME_GRID = "Share/EliminateGame/EliminateGrid.tab"
local TABLE_ELIMINATEGAME_REWARD = "Share/EliminateGame/EliminateReward.tab"
local TABLE_ELIMINATEGAME_GRID_TYPE = "Share/EliminateGame/EliminateGridType.tab"
local EliminateGameConfig = {}
local EliminateGridConfig = {}
local EliminateRewardConfig = {}
local EliminateGridTypeConfig = {}
function XEliminateGameConfig.Init()
EliminateGameConfig = XTableManager.ReadByIntKey(TABLE_ELIMINATEGAME_GAME, XTable.XTableEliminateGame, "Id")
EliminateGridConfig = XTableManager.ReadByIntKey(TABLE_ELIMINATEGAME_GRID, XTable.XTableEliminateGrid, "Id")
EliminateRewardConfig = XTableManager.ReadByIntKey(TABLE_ELIMINATEGAME_REWARD, XTable.XTableEliminateReward, "Id")
EliminateGridTypeConfig = XTableManager.ReadByIntKey(TABLE_ELIMINATEGAME_GRID_TYPE, XTable.XTableEliminateGridType, "Id")
end
--获取消除游戏
function XEliminateGameConfig.GetEliminateGame(id)
if not EliminateGameConfig or not EliminateGameConfig[id] then
XLog.ErrorTableDataNotFound("XEliminateGameConfig.GetEliminateGame", "Id", TABLE_ELIMINATEGAME_GAME, "id", tostring(id))
return nil
end
return EliminateGameConfig[id]
end
--获取消除游戏格子
function XEliminateGameConfig.GetEliminateGameGrid(id)
if not EliminateGridConfig or not EliminateGridConfig[id] then
XLog.ErrorTableDataNotFound("XEliminateGameConfig.GetEliminateGameGrid", "Id", TABLE_ELIMINATEGAME_GRID, "id", tostring(id))
return nil
end
return EliminateGridConfig[id]
end
--获取消除游戏奖励
function XEliminateGameConfig.GetEliminateGameReward(id)
if not EliminateRewardConfig or not EliminateRewardConfig[id] then
XLog.ErrorTableDataNotFound("XEliminateGameConfig.GetEliminateGameReward", "Id", TABLE_ELIMINATEGAME_REWARD, "id", tostring(id))
return nil
end
return EliminateRewardConfig[id]
end
--获取格子
function XEliminateGameConfig.GetEliminateGameGridByType(typeId)
if not EliminateGridTypeConfig then
XLog.ErrorTableDataNotFound("XEliminateGameConfig.GetEliminateGameGridByType", "Id", TABLE_ELIMINATEGAME_GRID_TYPE, "typeId", tostring(typeId))
return nil
end
for i, v in pairs(EliminateGridTypeConfig) do
if v.Type == typeId then
return v
end
end
return nil
end
-- --获取格子
-- function XEliminateGameConfig.GetEliminateGameGridById(id)
-- if not EliminateGridTypeConfig or not EliminateGridTypeConfig[id] then
-- XLog.ErrorTableDataNotFound("XEliminateGameConfig.GetEliminateGameGridById", "Id", TABLE_ELIMINATEGAME_GRID_TYPE, "id", tostring(id))
-- return nil
-- end
-- return EliminateGridTypeConfig[id]
-- end
--获取消除游戏奖励
function XEliminateGameConfig.GetEliminateGameRewardByGameId(id)
local rewards = {}
for _, v in pairs(EliminateRewardConfig) do
if v.GameId == id then
table.insert(rewards, v)
end
end
return rewards
end

View file

@ -0,0 +1,994 @@
local tableInsert = table.insert
XEquipConfig = XEquipConfig or {}
XEquipConfig.MAX_STAR_COUNT = 6 -- 最大星星数
XEquipConfig.MAX_SUIT_SKILL_COUNT = 3 -- 最大套装激活技能个数
XEquipConfig.MAX_RESONANCE_SKILL_COUNT = 3 -- 最大共鸣属性/技能个数
XEquipConfig.MIN_RESONANCE_EQUIP_STAR_COUNT = 5 -- 装备共鸣最低星级
XEquipConfig.MAX_SUIT_COUNT = 6 -- 套装最大数量
XEquipConfig.DEFAULT_SUIT_ID = { -- 用来显示全部套装数量的默认套装Id
Normal = 1, --构造体
Isomer = 2, --感染体
}
XEquipConfig.CAN_NOT_AUTO_EAT_STAR = 5 -- 大于等于该星级的装备不会被当做默认狗粮选中
XEquipConfig.AWAKE_SKILL_COUNT = 2 -- 觉醒技能数量
--武器类型
XEquipConfig.EquipType = {
Universal = 0, -- 通用
Suncha = 1, -- 双枪
Sickle = 2, -- 太刀
Mount = 3, -- 挂载
Arrow = 4, -- 弓箭
Chainsaw = 5, -- 电锯
Sword = 6, -- 大剑
Hcan = 7, -- 巨炮
DoubleSwords = 8, -- 双短刀
sickle = 9, --镰刀
IsomerSword = 10, -- 感染者专用大剑
Food = 99, -- 狗粮
}
XEquipConfig.UserType = {
All = 0, --通用
Normal = 1, --构造体
Isomer = 2, --异构体/感染体
}
XEquipConfig.AddAttrType = {
Numeric = 1, -- 数值
Rate = 2, -- 基础属性的百分比
Promoted = 3, -- 等级加成
}
XEquipConfig.UserType = {
All = 0, --通用
Normal = 1, --构造体
Isomer = 2, --异构体/感染体
}
--要显示的属性排序
XEquipConfig.AttrSortType = {
XNpcAttribType.Life,
XNpcAttribType.AttackNormal,
XNpcAttribType.DefenseNormal,
XNpcAttribType.Crit,
}
XEquipConfig.EquipSite = {
Weapon = 0, -- 武器
Awareness = { -- 意识
One = 1, -- 1号位
Two = 2, -- 2号位
Three = 3, -- 3号位
Four = 4, -- 4号位
Five = 5, -- 5号位
Six = 6, -- 6号位
},
}
XEquipConfig.AwarenessSiteToStr = {
[XEquipConfig.EquipSite.Awareness.One] = CS.XTextManager.GetText("AwarenessSiteOne"),
[XEquipConfig.EquipSite.Awareness.Two] = CS.XTextManager.GetText("AwarenessSiteTwo"),
[XEquipConfig.EquipSite.Awareness.Three] = CS.XTextManager.GetText("AwarenessSiteThree"),
[XEquipConfig.EquipSite.Awareness.Four] = CS.XTextManager.GetText("AwarenessSiteFour"),
[XEquipConfig.EquipSite.Awareness.Five] = CS.XTextManager.GetText("AwarenessSiteFive"),
[XEquipConfig.EquipSite.Awareness.Six] = CS.XTextManager.GetText("AwarenessSiteSix"),
}
XEquipConfig.Classify = {
Weapon = 1, -- 武器
Awareness = 2, -- 意识
}
XEquipConfig.EquipResonanceType = {
Attrib = 1, -- 属性共鸣
CharacterSkill = 2, -- 角色技能共鸣
WeaponSkill = 3, -- 武器技能共鸣
}
--排序优先级选项
XEquipConfig.PriorSortType = {
Star = 0, -- 星级
Breakthrough = 1, -- 突破次数
Level = 2, -- 等级
Proceed = 3, -- 入手顺序
}
-- 武器部位
XEquipConfig.WeaponCase = {
Case1 = 1,
Case2 = 2,
Case3 = 3,
--[[支持继续扩展
Case4 = 4,
...
]]
}
-- 狗粮类型
XEquipConfig.EatType = {
Equip = 0,
Item = 1,
}
-- 武器模型用途
XEquipConfig.WeaponUsage = {
Role = 1, -- ui角色身上
Battle = 2, -- 战斗
Show = 3, -- ui单独展示
}
-- 装备详情UI页签
XEquipConfig.EquipDetailBtnTabIndex = {
Detail = 1,
Strengthen = 2,
Resonance = 3,
}
--武器超频界面页签状态
XEquipConfig.EquipAwakeTabIndex = {
Material = 1,
CrystalMoney = 2,
}
-- 共鸣后武器显示延时时间
XEquipConfig.WeaponResonanceShowDelay = CS.XGame.ClientConfig:GetInt("WeaponResonanceShowDelay")
-- 分解数量溢出提示文本
XEquipConfig.DecomposeRewardOverLimitTip = {
[XEquipConfig.Classify.Weapon] = CS.XTextManager.GetText("WeaponBoxWillBeFull"),
[XEquipConfig.Classify.Awareness] = CS.XTextManager.GetText("WaferBoxWillBeFull"),
}
local EquipBreakThroughIcon = {
[0] = CS.XGame.ClientConfig:GetString("EquipBreakThrough0"),
[1] = CS.XGame.ClientConfig:GetString("EquipBreakThrough1"),
[2] = CS.XGame.ClientConfig:GetString("EquipBreakThrough2"),
[3] = CS.XGame.ClientConfig:GetString("EquipBreakThrough3"),
[4] = CS.XGame.ClientConfig:GetString("EquipBreakThrough4"),
}
local EquipBreakThroughSmallIcon = {
[1] = CS.XGame.ClientConfig:GetString("EquipBreakThroughSmall1"),
[2] = CS.XGame.ClientConfig:GetString("EquipBreakThroughSmall2"),
[3] = CS.XGame.ClientConfig:GetString("EquipBreakThroughSmall3"),
[4] = CS.XGame.ClientConfig:GetString("EquipBreakThroughSmall4"),
}
local EquipBreakThroughBigIcon = {
[0] = CS.XGame.ClientConfig:GetString("EquipBreakThroughBig0"),
[1] = CS.XGame.ClientConfig:GetString("EquipBreakThroughBig1"),
[2] = CS.XGame.ClientConfig:GetString("EquipBreakThroughBig2"),
[3] = CS.XGame.ClientConfig:GetString("EquipBreakThroughBig3"),
[4] = CS.XGame.ClientConfig:GetString("EquipBreakThroughBig4"),
}
-- 共鸣图标(觉醒后图标变更)
local EquipResonanceIconPath = {
[true] = CS.XGame.ClientConfig:GetString("EquipAwakenIcon"),
[false] = CS.XGame.ClientConfig:GetString("EquipResonanceIcon"),
}
local TABLE_EQUIP_PATH = "Share/Equip/Equip.tab"
local TABLE_EQUIP_BREAKTHROUGH_PATH = "Share/Equip/EquipBreakThrough.tab"
local TABLE_EQUIP_SUIT_PATH = "Share/Equip/EquipSuit.tab"
local TABLE_EQUIP_SUIT_EFFECT_PATH = "Share/Equip/EquipSuitEffect.tab"
local TABLE_LEVEL_UP_TEMPLATE_PATH = "Share/Equip/LevelUpTemplate/"
local TABLE_EQUIP_DECOMPOSE_PATH = "Share/Equip/EquipDecompose.tab"
local TABLE_EAT_EQUIP_COST_PATH = "Share/Equip/EatEquipCost.tab"
local TABLE_EQUIP_RESONANCE_PATH = "Share/Equip/EquipResonance.tab"
local TABLE_EQUIP_RESONANCE_CONSUME_ITEM_PATH = "Share/Equip/EquipResonanceUseItem.tab"
local TABLE_WEAPON_SKILL_PATH = "Share/Equip/WeaponSkill.tab"
local TABLE_WEAPON_SKILL_POOL_PATH = "Share/Equip/WeaponSkillPool.tab"
local TABLE_EQUIP_AWAKE_PATH = "Share/Equip/EquipAwake.tab"
local TABLE_EQUIP_RES_PATH = "Client/Equip/EquipRes.tab"
local TABLE_EQUIP_MODEL_PATH = "Client/Equip/EquipModel.tab"
local TABLE_EQUIP_MODEL_TRANSFORM_PATH = "Client/Equip/EquipModelTransform.tab"
local TABLE_EQUIP_SKIPID_PATH = "Client/Equip/EquipSkipId.tab"
local TABLE_EQUIP_ANIM_PATH = "Client/Equip/EquipAnim.tab"
local TABLE_EQUIP_MODEL_SHOW_PATH = "Client/Equip/EquipModelShow.tab"
local TABLE_EQUIP_RES_BY_FOOL_PATH = "Client/Equip/EquipResByFool.tab"
local MAX_WEAPON_COUNT -- 武器拥有最大数量
local MAX_AWARENESS_COUNT -- 意识拥有最大数量
local EQUIP_EXP_INHERIT_PRECENT -- 强化时的经验继承百分比
local EQUIP_RECYCLE_ITEM_PERCENT -- 回收获得道具数量百分比
local MIN_RESONANCE_BIND_STAR -- 只有6星以上的意识才可以共鸣出绑定角色的技能
local MIN_AWAKE_STAR -- 最低可觉醒星数
local EquipTemplates = {} -- 装备配置
local EquipBreakthroughTemplate = {} -- 突破配置
local EquipResonanceTemplate = {} -- 共鸣配置
local EquipResonanceConsumeItemTemplates = {} -- 共鸣消耗物品配置
local LevelUpTemplates = {} -- 升级模板
local EquipSuitTemplate = {} -- 套装技能表
local EquipSuitEffectTemplate = {} -- 套装效果表
local WeaponSkillTemplate = {} -- 武器技能配置
local WeaponSkillPoolTemplate = {} -- 武器技能池(共鸣用)配置
local EatEquipCostTemplate = {} -- 装备强化消耗配置
local EquipResTemplates = {} -- 装备资源配置
local EquipModelTemplates = {} -- 武器模型配置
local EquipModelTransformTemplates = {} -- 武器模型UI偏移配置
local EquipSkipIdTemplates = {} -- 装备来源跳转ID配置
local EquipAwakeTemplate = {} -- 觉醒配置
local EquipAnimTemplates = {} -- 动画配置
local EquipModelShowTemplate = {} -- 控制武器模型显示
local EquipResByFoolTemplate = {} -- 愚人节装备资源替换配置
local EquipBorderDic = {} -- 装备边界属性构造字典
local EquipDecomposeDic = {}
local SuitIdToEquipTemplateIdsDic = {} -- 套装Id索引的装备Id字典
local SuitSitesDic = {} -- 套装产出部位字典
--记录超频界面的页签状态
local EquipAwakeTabIndex = XEquipConfig.EquipAwakeTabIndex.Material
local CompareBreakthrough = function(templateId, breakthrough)
local template = EquipBorderDic[templateId]
if not template then
return
end
if not template.MaxBreakthrough or template.MaxBreakthrough < breakthrough then
template.MaxBreakthrough = breakthrough
end
end
local CheckEquipBorderConfig = function()
for k, v in pairs(EquipBorderDic) do
local template = EquipBorderDic[k]
template.MinLevel = 1
local equipBreakthroughCfg = XEquipConfig.GetEquipBreakthroughCfg(k, v.MaxBreakthrough)
template.MaxLevel = equipBreakthroughCfg.LevelLimit
template.MinBreakthrough = 0
end
end
local InitEquipBreakthroughConfig = function()
local tab = XTableManager.ReadByIntKey(TABLE_EQUIP_BREAKTHROUGH_PATH, XTable.XTableEquipBreakthrough, "Id")
for _, config in pairs(tab) do
if not EquipBreakthroughTemplate[config.EquipId] then
EquipBreakthroughTemplate[config.EquipId] = {}
end
if config.AttribPromotedId == 0 then
XLog.ErrorTableDataNotFound("InitEquipBreakthroughConfig", "EquipBreakthroughTemplate",
TABLE_EQUIP_BREAKTHROUGH_PATH, "config.EquipId", tostring(config.EquipId))
end
EquipBreakthroughTemplate[config.EquipId][config.Times] = config
CompareBreakthrough(config.EquipId, config.Times)
end
end
local InitEquipLevelConfig = function()
local paths = CS.XTableManager.GetPaths(TABLE_LEVEL_UP_TEMPLATE_PATH)
XTool.LoopCollection(paths, function(path)
local key = tonumber(XTool.GetFileNameWithoutExtension(path))
LevelUpTemplates[key] = XTableManager.ReadByIntKey(path, XTable.XTableEquipLevelUp, "Level")
end)
end
local InitWeaponSkillPoolConfig = function()
local tab = XTableManager.ReadByIntKey(TABLE_WEAPON_SKILL_POOL_PATH, XTable.XTableWeaponSkillPool, "Id")
for _, config in pairs(tab) do
WeaponSkillPoolTemplate[config.PoolId] = WeaponSkillPoolTemplate[config.PoolId] or {}
WeaponSkillPoolTemplate[config.PoolId][config.CharacterId] = WeaponSkillPoolTemplate[config.PoolId][config.CharacterId] or {}
for i, skillId in ipairs(config.SkillId) do
tableInsert(WeaponSkillPoolTemplate[config.PoolId][config.CharacterId], skillId)
end
end
end
local InitEquipModelTransformConfig = function()
local tab = XTableManager.ReadByIntKey(TABLE_EQUIP_MODEL_TRANSFORM_PATH, XTable.XTableEquipModelTransform, "Id")
for id, config in pairs(tab) do
local indexId = config.IndexId
if not indexId then
XLog.ErrorTableDataNotFound("InitEquipModelTransformConfig", "tab", TABLE_EQUIP_MODEL_TRANSFORM_PATH, "id", tostring(id))
end
EquipModelTransformTemplates[indexId] = EquipModelTransformTemplates[indexId] or {}
local uiName = config.UiName
if not uiName then
XLog.ErrorTableDataNotFound("InitEquipModelTransformConfig", "配置表中UiName字段", TABLE_EQUIP_MODEL_TRANSFORM_PATH, "id", tostring(id))
end
EquipModelTransformTemplates[indexId][uiName] = config
end
end
local InitEquipSkipIdConfig = function()
local tab = XTableManager.ReadByIntKey(TABLE_EQUIP_SKIPID_PATH, XTable.XTableEquipSkipId, "Id")
for id, config in pairs(tab) do
local eatType = config.EatType
EquipSkipIdTemplates[eatType] = EquipSkipIdTemplates[eatType] or {}
local site = config.Site
if not site then
XLog.ErrorTableDataNotFound("InitEquipSkipIdConfig", "配置表中Site字段", TABLE_EQUIP_SKIPID_PATH, "id", tostring(id))
end
EquipSkipIdTemplates[eatType][site] = config
end
end
local InitEquipSuitConfig = function()
EquipSuitTemplate = XTableManager.ReadByIntKey(TABLE_EQUIP_SUIT_PATH, XTable.XTableEquipSuit, "Id")
EquipSuitEffectTemplate = XTableManager.ReadByIntKey(TABLE_EQUIP_SUIT_EFFECT_PATH, XTable.XTableEquipSuitEffect, "Id")
end
function XEquipConfig.Init()
MAX_WEAPON_COUNT = CS.XGame.Config:GetInt("EquipWeaponMaxCount")
MAX_AWARENESS_COUNT = CS.XGame.Config:GetInt("EquipChipMaxCount")
EQUIP_EXP_INHERIT_PRECENT = CS.XGame.Config:GetInt("EquipExpInheritPercent")
EQUIP_RECYCLE_ITEM_PERCENT = CS.XGame.Config:GetInt("EquipRecycleItemPercent")
MIN_RESONANCE_BIND_STAR = CS.XGame.Config:GetInt("MinResonanceBindStar")
MIN_AWAKE_STAR = CS.XGame.Config:GetInt("MinEquipAwakeStar")
EquipTemplates = CS.XNpcManager.EquipTemplateTable
EquipResTemplates = XTableManager.ReadByIntKey(TABLE_EQUIP_RES_PATH, XTable.XTableEquipRes, "Id")
EquipAwakeTemplate = XTableManager.ReadByIntKey(TABLE_EQUIP_AWAKE_PATH, XTable.XTableEquipAwake, "Id")
XTool.LoopMap(EquipTemplates, function(id, equipCfg)
EquipBorderDic[id] = {}
local suitId = equipCfg.SuitId
if suitId and suitId > 0 then
SuitIdToEquipTemplateIdsDic[suitId] = SuitIdToEquipTemplateIdsDic[suitId] or {}
tableInsert(SuitIdToEquipTemplateIdsDic[suitId], id)
SuitSitesDic[suitId] = SuitSitesDic[suitId] or {}
SuitSitesDic[suitId][equipCfg.Site] = true
end
end)
InitEquipSuitConfig()
InitEquipBreakthroughConfig()
InitEquipLevelConfig()
InitWeaponSkillPoolConfig()
InitEquipModelTransformConfig()
InitEquipSkipIdConfig()
CheckEquipBorderConfig()
--EquipBorderDic = XReadOnlyTable.Create(EquipBorderDic)
WeaponSkillTemplate = XTableManager.ReadByIntKey(TABLE_WEAPON_SKILL_PATH, XTable.XTableWeaponSkill, "Id")
EquipResonanceTemplate = XTableManager.ReadByIntKey(TABLE_EQUIP_RESONANCE_PATH, XTable.XTableEquipResonance, "Id")
EquipResonanceConsumeItemTemplates = XTableManager.ReadByIntKey(TABLE_EQUIP_RESONANCE_CONSUME_ITEM_PATH, XTable.XTableEquipResonanceUseItem, "Id")
EquipModelTemplates = XTableManager.ReadByIntKey(TABLE_EQUIP_MODEL_PATH, XTable.XTableEquipModel, "Id")
EquipAnimTemplates = XTableManager.ReadByStringKey(TABLE_EQUIP_ANIM_PATH, XTable.XTableEquipAnim, "ModelId")
EquipModelShowTemplate = XTableManager.ReadByStringKey(TABLE_EQUIP_MODEL_SHOW_PATH, XTable.XTableEquipModelShow, "Id")
EquipResByFoolTemplate = XTableManager.ReadByIntKey(TABLE_EQUIP_RES_BY_FOOL_PATH, XTable.XTableEquipResByFool, "Id")
local decomposetab = XTableManager.ReadByIntKey(TABLE_EQUIP_DECOMPOSE_PATH, XTable.XTableEquipDecompose, "Id")
for _, v in pairs(decomposetab) do
EquipDecomposeDic[v.Site .. v.Star .. v.Breakthrough] = v
end
local eatCostTab = XTableManager.ReadByIntKey(TABLE_EAT_EQUIP_COST_PATH, XTable.XTableEatEquipCost, "Id")
for _, v in pairs(eatCostTab) do
EatEquipCostTemplate[v.Site .. v.Star] = v.UseMoney
end
end
function XEquipConfig.GetMaxWeaponCount()
return MAX_WEAPON_COUNT
end
function XEquipConfig.GetMaxAwarenessCount()
return MAX_AWARENESS_COUNT
end
function XEquipConfig.GetEquipExpInheritPercent()
return EQUIP_EXP_INHERIT_PRECENT
end
function XEquipConfig.GetEquipRecycleItemId()
return XDataCenter.ItemManager.ItemId.EquipRecycleItemId
end
function XEquipConfig.GetEquipRecycleItemPercent()
return EQUIP_RECYCLE_ITEM_PERCENT / 100
end
function XEquipConfig.GetMinResonanceBindStar()
return MIN_RESONANCE_BIND_STAR
end
function XEquipConfig.GetMinAwakeStar()
return MIN_AWAKE_STAR
end
function XEquipConfig.GetEquipCfg(templateId)
local equipCfg = nil
if EquipTemplates:ContainsKey(templateId) then
equipCfg = EquipTemplates[templateId]
end
if not equipCfg then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipCfg", "equipCfg", TABLE_EQUIP_PATH, "templateId", tostring(templateId))
return
end
return equipCfg
end
--todo 道具很多地方没有检查ID类型就调用了临时处理下
function XEquipConfig.CheckTemplateIdIsEquip(templateId)
local equipCfg = nil
if EquipTemplates:ContainsKey(templateId) then
equipCfg = EquipTemplates[templateId]
end
return templateId and equipCfg
end
function XEquipConfig.GetEatEquipCostMoney(site, star)
if not site then
XLog.Error("XEquipConfig.GetEatEquipCostMoney函数参数错误site不能为空")
return
end
if not star then
XLog.Error("XEquipConfig.GetEatEquipCostMoney函数参数错误star不能为空")
return
end
return EatEquipCostTemplate[site .. star]
end
function XEquipConfig.GetEquipBorderCfg(templateId)
local template = EquipBorderDic[templateId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipBorderCfg", "template", TABLE_EQUIP_PATH, "templateId", tostring(templateId))
return
end
return template
end
function XEquipConfig.GetEquipBreakthroughCfg(templateId, times)
local template = EquipBreakthroughTemplate[templateId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipBreakthroughCfg", "template",
TABLE_EQUIP_BREAKTHROUGH_PATH, "templateId", tostring(templateId))
return
end
template = template[times]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipBreakthroughCfg", "template",
TABLE_EQUIP_BREAKTHROUGH_PATH, "templateId : times", tostring(templateId) .. " : " .. tostring(times))
return
end
return template
end
function XEquipConfig.GetEquipResCfg(templateId, breakthroughTimes)
breakthroughTimes = breakthroughTimes or 0
local breakthroughCfg = XEquipConfig.GetEquipBreakthroughCfg(templateId, breakthroughTimes)
local resId = breakthroughCfg.ResId
if not resId then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipResCfg", "resId",
TABLE_EQUIP_BREAKTHROUGH_PATH, "templateId : times", tostring(templateId) .. " : " .. tostring(breakthroughTimes))
return
end
local template = EquipResTemplates[resId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipResCfg", "template", TABLE_EQUIP_RES_PATH, "resId", tostring(resId))
return
end
return template
end
--=========== EquipModel接口(begin) ===========
function XEquipConfig.GetEquipModelName(modelTransId, usage)
local template = EquipModelTemplates[modelTransId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipModelName", "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId))
return
end
usage = usage or XEquipConfig.WeaponUsage.Role
return template.ModelName[usage] or template.ModelName[XEquipConfig.WeaponUsage.Role]
end
function XEquipConfig.GetEquipAnimController(modelTransId, usage)
local template = EquipModelTemplates[modelTransId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipAnimController", "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId))
return
end
usage = usage or XEquipConfig.WeaponUsage.Role
local controller = template.AnimController[usage]
if not controller and usage ~= XEquipConfig.WeaponUsage.Show then -- 单独展示不需默认值
controller = template.AnimController[XEquipConfig.WeaponUsage.Role]
end
return controller
end
function XEquipConfig.GetEquipUiAnimStateName(modelTransId, usage)
local template = EquipModelTemplates[modelTransId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipUiAnimStateName", "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId))
return
end
usage = usage or XEquipConfig.WeaponUsage.Role
return template.UiAnimStateName[usage] or template.UiAnimStateName[XEquipConfig.WeaponUsage.Role]
end
function XEquipConfig.GetEquipUiAnimCueId(modelTransId, usage)
local template = EquipModelTemplates[modelTransId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipUiAnimCueId", "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId))
return
end
usage = usage or XEquipConfig.WeaponUsage.Role
return template.UiAnimCueId[usage] or template.UiAnimCueId[XEquipConfig.WeaponUsage.Role]
end
function XEquipConfig.GetEquipUiAnimDelay(modelTransId, usage)
local template = EquipModelTemplates[modelTransId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipUiAnimDelay", "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId))
return
end
usage = usage or XEquipConfig.WeaponUsage.Role
return template.UiAnimDelay[usage] or template.UiAnimDelay[XEquipConfig.WeaponUsage.Role]
end
function XEquipConfig.GetEquipUiAutoRotateDelay(modelTransId, usage)
local template = EquipModelTemplates[modelTransId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipUiAutoRotateDelay", "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId))
return
end
usage = usage or XEquipConfig.WeaponUsage.Show -- 默认ui展示
return template.UiAutoRotateDelay[usage] or template.UiAutoRotateDelay[XEquipConfig.WeaponUsage.Role]
end
function XEquipConfig.GetEquipModelEffectPath(modelTransId, usage)
local template = EquipModelTemplates[modelTransId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipModelEffectPath", "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId))
return
end
usage = usage or XEquipConfig.WeaponUsage.Role
return template.ResonanceEffectPath[usage] or template.ResonanceEffectPath[XEquipConfig.WeaponUsage.Role]
end
--=========== EquipModel接口(end) ===========
function XEquipConfig.GetEquipAnimParams(roleModelId)
local template = EquipAnimTemplates[roleModelId]
if not template then
return 0
end
return template.Params or 0
end
function XEquipConfig.GetWeaponResonanceModelId(case, templateId, resonanceCount)
local modelId
local template = EquipResTemplates[templateId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponResonanceModelId", "template", TABLE_EQUIP_RES_PATH, "templateId", tostring(templateId))
return
end
if resonanceCount == 1 then
modelId = template.ResonanceModelTransId1[case]
elseif resonanceCount == 2 then
modelId = template.ResonanceModelTransId2[case]
elseif resonanceCount == 3 then
modelId = template.ResonanceModelTransId3[case]
end
return modelId or template.ModelTransId[case]
end
function XEquipConfig.GetWeaponResonanceEffectDelay(modelTransId)
local template = EquipModelTemplates[modelTransId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponResonanceEffectDelay",
"template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId))
return
end
return template.ResonanceEffectShowDelay[XEquipConfig.WeaponUsage.Show] or 0
end
--返回武器模型和位置配置(双枪只返回一把)
function XEquipConfig.GetEquipModelTransformCfg(templateId, uiName, resonanceCount, modelTransId, equipType)
local modelCfg, template
--尝试用ModelTransId索引
if not modelTransId then
modelTransId = XEquipConfig.GetWeaponResonanceModelId(XEquipConfig.WeaponCase.Case1, templateId, resonanceCount)
if not modelTransId then
XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponResonanceModelId",
"template", TABLE_EQUIP_RES_PATH, "templateId", tostring(templateId))
return
end
end
template = EquipModelTransformTemplates[modelTransId]
if template then
modelCfg = template[uiName]
end
--读不到配置时用equipType索引
if not modelCfg then
if not equipType then
local equipCfg = XEquipConfig.GetEquipCfg(templateId)
equipType = equipCfg.Type
end
template = EquipModelTransformTemplates[equipType]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipModelTransformCfg",
"template", TABLE_EQUIP_MODEL_TRANSFORM_PATH, "equipType", tostring(equipType))
return
end
modelCfg = template[uiName]
if not modelCfg then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipModelTransformCfg",
"uiName", TABLE_EQUIP_MODEL_TRANSFORM_PATH, "equipType", tostring(equipType))
return
end
end
return modelCfg
end
-- 获取一个武器所有的不同的模型列表
function XEquipConfig.GetWeaponModelCfgList(templateId, uiName, breakthroughTimes)
local modelCfgList = {}
if not templateId then
XLog.Error("XEquipManager.GetWeaponModelCfgList函数参数错误, templateId不能为空")
return modelCfgList
end
local template = XEquipConfig.GetEquipResCfg(templateId, breakthroughTimes)
-- 目前只有共鸣改变形态有可能有相同的模型所以需要区别是否有相同的id以左手id为准
local resonanceCountList = {}
local resonanceDic = {}
local modelId
for i = 0, XEquipConfig.MAX_RESONANCE_SKILL_COUNT do
modelId = XEquipConfig.GetWeaponResonanceModelId(XEquipConfig.WeaponCase.Case1, template.Id, i)
if modelId and not resonanceDic[modelId] then
resonanceDic[modelId] = true
table.insert(resonanceCountList, i)
end
end
local modelCfg
for _, resonanceCount in ipairs(resonanceCountList) do
modelCfg = {}
modelCfg.ModelId = XEquipConfig.GetWeaponResonanceModelId(XEquipConfig.WeaponCase.Case1, template.Id, resonanceCount)
modelCfg.TransformConfig = XEquipConfig.GetEquipModelTransformCfg(templateId, uiName, resonanceCount)
table.insert(modelCfgList, modelCfg)
end
return modelCfgList
end
function XEquipConfig.GetLevelUpCfg(templateId, times, level)
local breakthroughCfg = XEquipConfig.GetEquipBreakthroughCfg(templateId, times)
if not breakthroughCfg then
return
end
templateId = breakthroughCfg.LevelUpTemplateId
local template = LevelUpTemplates[templateId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetLevelUpCfg", "template", TABLE_LEVEL_UP_TEMPLATE_PATH, "templateId", tostring(templateId))
return
end
template = template[level]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetLevelUpCfg", "level", TABLE_LEVEL_UP_TEMPLATE_PATH, "templateId", tostring(templateId))
return
end
return template
end
function XEquipConfig.GetEquipSuitCfg(templateId)
local template = EquipSuitTemplate[templateId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipSuitCfg", "template", TABLE_EQUIP_SUIT_PATH, "templateId", tostring(templateId))
return
end
return template
end
function XEquipConfig.GetEquipSuitEffectCfg(templateId)
local template = EquipSuitEffectTemplate[templateId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipSuitEffectCfg", "template",
TABLE_EQUIP_SUIT_EFFECT_PATH, "templateId", tostring(templateId))
return
end
return template
end
function XEquipConfig.GetEquipTemplateIdsBySuitId(suitId)
return SuitIdToEquipTemplateIdsDic[suitId] or {}
end
function XEquipConfig.GetSuitSites(suitId)
return SuitSitesDic[suitId] or {}
end
function XEquipConfig.GetMaxSuitCount()
return XTool.GetTableCount(SuitSitesDic)
end
function XEquipConfig.GetEquipBgPath(templateId)
if not XEquipConfig.CheckTemplateIdIsEquip(templateId) then return end
local template = XEquipConfig.GetEquipCfg(templateId)
local quality = template.Quality
return XArrangeConfigs.GeQualityBgPath(quality)
end
function XEquipConfig.GetEquipQualityPath(templateId)
local template = XEquipConfig.GetEquipCfg(templateId)
local quality = template.Quality
if not quality then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipQualityPath", "Quality", TABLE_EQUIP_PATH, "templateId", tostring(templateId))
return
end
return XArrangeConfigs.GeQualityPath(quality)
end
function XEquipConfig.GetEquipResoanceIconPath(isAwaken)
return EquipResonanceIconPath[isAwaken]
end
function XEquipConfig.GetEquipDecomposeCfg(templateId, breakthroughTimes)
if not XEquipConfig.CheckTemplateIdIsEquip(templateId) then return end
breakthroughTimes = breakthroughTimes or 0
local template = XEquipConfig.GetEquipCfg(templateId)
local site = template.Site
if not site then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipDecomposeCfg", "Site", TABLE_EQUIP_PATH, "templateId", tostring(templateId))
return
end
local star = template.Star
if not star then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipDecomposeCfg", "Star", TABLE_EQUIP_PATH, "templateId", tostring(templateId))
return
end
return EquipDecomposeDic[site .. star .. breakthroughTimes]
end
function XEquipConfig.GetWeaponTypeIconPath(templateId)
return XGoodsCommonManager.GetGoodsShowParamsByTemplateId(templateId).Icon
end
function XEquipConfig.GetEquipBreakThroughIcon(breakthroughTimes)
local icon = EquipBreakThroughIcon[breakthroughTimes]
if not icon then
XLog.Error("XEquipConfig.EquipBreakThroughIcon调用错误得到的icon为空原因检查breakthroughTimes" .. breakthroughTimes .. "和EquipBreakThroughIcon")
return
end
return icon
end
function XEquipConfig.GetEquipBreakThroughSmallIcon(breakthroughTimes)
local icon = EquipBreakThroughSmallIcon[breakthroughTimes]
if not icon then
XLog.Error("XEquipConfig.GetEquipBreakThroughSmallIcon调用错误得到的icon为空原因检查breakthroughTimes" .. breakthroughTimes .. "和EquipBreakThroughSmallIcon")
return
end
return icon
end
function XEquipConfig.GetEquipBreakThroughBigIcon(breakthroughTimes)
local icon = EquipBreakThroughBigIcon[breakthroughTimes]
if not icon then
XLog.Error("XEquipConfig.GetEquipBreakThroughBigIcon调用错误得到的icon为空原因检查breakthroughTimes" .. breakthroughTimes .. "和EquipBreakThroughBigIcon")
return
end
return icon
end
function XEquipConfig.GetWeaponSkillTemplate(templateId)
local template = WeaponSkillTemplate[templateId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponSkillTemplate", "template", TABLE_WEAPON_SKILL_PATH, "templateId", tostring(templateId))
return
end
return template
end
function XEquipConfig.GetWeaponSkillInfo(weaponSkillId)
local template = WeaponSkillTemplate[weaponSkillId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponSkillInfo", "template", TABLE_WEAPON_SKILL_PATH, "weaponSkillId", tostring(weaponSkillId))
return
end
return template
end
function XEquipConfig.GetWeaponSkillAbility(weaponSkillId)
local template = WeaponSkillTemplate[weaponSkillId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponSkillAbility", "template",
TABLE_WEAPON_SKILL_PATH, "weaponSkillId", tostring(weaponSkillId))
return
end
return template.Ability
end
function XEquipConfig.GetWeaponSkillPoolSkillIds(poolId, characterId)
local template = WeaponSkillPoolTemplate[poolId]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponSkillPoolSkillIds", "template", TABLE_WEAPON_SKILL_POOL_PATH, "poolId", tostring(poolId))
return
end
local skillIds = template[characterId]
if not skillIds then
XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponSkillPoolSkillIds",
"characterId", TABLE_WEAPON_SKILL_POOL_PATH, "poolId", tostring(poolId))
return
end
return skillIds
end
function XEquipConfig.GetEquipSkipIdTemplate(eatType, site)
local template = EquipSkipIdTemplates[eatType][site]
if not template then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipSkipIdTemplate", "site", TABLE_WEAPON_SKILL_POOL_PATH, "eatType", tostring(eatType))
return
end
return template
end
function XEquipConfig.GetEquipResonanceCfg(templateId)
local equipResonanceCfg = EquipResonanceTemplate[templateId]
if not equipResonanceCfg then
return
end
return equipResonanceCfg
end
function XEquipConfig.GetEquipCharacterType(templateId)
local config = XEquipConfig.GetEquipCfg(templateId)
return config.CharacterType
end
function XEquipConfig.GetEquipResonanceConsumeItemCfg(templateId)
local equipResonanceItemCfg = EquipResonanceConsumeItemTemplates[templateId]
if not equipResonanceItemCfg then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipResonanceConsumeItemCfg",
"equipResonanceItemCfg", TABLE_EQUIP_RESONANCE_CONSUME_ITEM_PATH, "templateId", tostring(templateId))
return
end
return equipResonanceItemCfg
end
function XEquipConfig.GetNeedFirstShow(templateId)
local template = XEquipConfig.GetEquipCfg(templateId)
return template.NeedFirstShow
end
function XEquipConfig.GetEquipTemplates()
return EquipTemplates
end
function XEquipConfig.GetEquipAwakeCfg(templateId)
local equipAwakeCfg = EquipAwakeTemplate[templateId]
if not equipAwakeCfg then
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipAwakeCfg", "equipAwakeCfg", TABLE_EQUIP_AWAKE_PATH, "templateId", tostring(templateId))
return
end
return equipAwakeCfg
end
function XEquipConfig.GetEquipAwakeCfgs()
return EquipAwakeTemplate
end
function XEquipConfig.GetEquipAwakeSkillDesList(templateId, pos)
local equipAwakeCfg = XEquipConfig.GetEquipAwakeCfg(templateId)
local desList = equipAwakeCfg["AttribDes" .. pos]
if not desList then
local tempStr = "AttribDes" .. pos
XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipAwakeSkillDesList", tempStr, TABLE_EQUIP_AWAKE_PATH, "templateId", tostring(templateId))
return
end
return desList
end
function XEquipConfig.GetEquipSuitPath()
return TABLE_EQUIP_SUIT_PATH
end
function XEquipConfig.GetEquipPath()
return TABLE_EQUIP_PATH
end
function XEquipConfig.GetWeaponSkillPath()
return TABLE_WEAPON_SKILL_PATH
end
function XEquipConfig.IsDefaultSuitId(suitId)
return suitId == XEquipConfig.DEFAULT_SUIT_ID.Normal or suitId == XEquipConfig.DEFAULT_SUIT_ID.Isomer
end
function XEquipConfig.GetDefaultSuitIdCount()
local count = 0
for _, _ in pairs(XEquipConfig.DEFAULT_SUIT_ID) do
count = count + 1
end
return count
end
function XEquipConfig.GetEquipAwakeTabIndex()
return EquipAwakeTabIndex
end
function XEquipConfig.SetEquipAwakeTabIndex(equipAwakeTabIndex)
EquipAwakeTabIndex = equipAwakeTabIndex
end
function XEquipConfig.GetEquipModelShowHideNodeName(modelId, UiName)
for _, cfg in pairs(EquipModelShowTemplate) do
if cfg.ModelId == modelId and cfg.UiName == UiName then
return cfg.HideNodeName or {}
end
end
return {}
end
------------愚人节装备替换相关 begin----------------
function XEquipConfig.GetFoolEquipResCfg(templateId)
return EquipResByFoolTemplate[templateId]
end
function XEquipConfig.GetFoolWeaponResonanceModelId(case, templateId, resonanceCount)
local modelId
local template = XEquipConfig.GetFoolEquipResCfg(templateId)
if not template then
return
end
if resonanceCount == 1 then
modelId = template.ResonanceModelTransId1[case]
elseif resonanceCount == 2 then
modelId = template.ResonanceModelTransId2[case]
elseif resonanceCount == 3 then
modelId = template.ResonanceModelTransId3[case]
end
return modelId or template.ModelTransId[case]
end
------------愚人节装备替换相关 end----------------

View file

@ -0,0 +1,301 @@
XEscapeConfigs = XEscapeConfigs or {}
local SHARE_TABLE_PATH = "Share/Fuben/Escape/"
local CLIENT_TABLE_PATH = "Client/Fuben/Escape/"
--章节难度
XEscapeConfigs.Difficulty = {
Normal = 1,
Hard = 2,
}
--关卡层状态
XEscapeConfigs.LayerState = {
Lock = 1, --未开启
Now = 2, --当前可挑战
Pass = 3, --已通关
}
--结算显示的界面布局
XEscapeConfigs.ShowSettlePanel = {
SelfWinInfo = 1, --战后结算
AllWinInfo = 2, --阶段结算
}
--章节结算显示的参数类型
XEscapeConfigs.ChapterSettleCondType = {
RemainTime = 1, --剩余时间
HitTimes = 2, --受击
TrapedTimes = 3, --陷阱受击
}
--战后结算显示的参数类型
XEscapeConfigs.FightSettleCondType = {
StageName = 1, --关卡名
Score = 2, --积分
}
function XEscapeConfigs.Init()
XConfigCenter.CreateGetProperties(XEscapeConfigs, {
"EscapeActivity",
"EscapeChapter",
"EscapeLayer",
"EscapeStage",
"EscapeTask",
"EscapeClientConfig",
"EscapeStageColorPrefab",
}, {
"ReadByIntKey", SHARE_TABLE_PATH .. "EscapeActivity.tab", XTable.XTableEscapeActivity, "Id",
"ReadByIntKey", SHARE_TABLE_PATH .. "EscapeChapter.tab", XTable.XTableEscapeChapter, "Id",
"ReadByIntKey", SHARE_TABLE_PATH .. "EscapeLayer.tab", XTable.XTableEscapeLayer, "Id",
"ReadByIntKey", SHARE_TABLE_PATH .. "EscapeStage.tab", XTable.XTableEscapeStage, "StageId",
"ReadByIntKey", CLIENT_TABLE_PATH .. "EscapeTask.tab", XTable.XTableEscapeTask, "Id",
"ReadByStringKey", CLIENT_TABLE_PATH .. "EscapeClientConfig.tab", XTable.XTableEscapeClientConfig, "Key",
"ReadByIntKey", CLIENT_TABLE_PATH .. "EscapeStageColorPrefab.tab", XTable.XTableEscapeStageColorPrefab, "Id",
})
end
function XEscapeConfigs.GetEscapeStageIdList()
local configs = XEscapeConfigs.GetEscapeStage()
local stageIdList = {}
for stageId in pairs(configs) do
table.insert(stageIdList, stageId)
end
return stageIdList
end
--机器人Id是否在关卡类型表中
function XEscapeConfigs.IsStageTypeRobot(robotId)
local robotIdList = XFubenConfigs.GetStageTypeRobot(XDataCenter.FubenManager.StageType.Escape)
for _, robotIdCfg in ipairs(robotIdList) do
if robotId == robotIdCfg then
return true
end
end
return false
end
--------------------------EscapeActivity 活动表 begin------------------------
function XEscapeConfigs.GetActivityTimeId(id)
local config = XEscapeConfigs.GetEscapeActivity(id, true)
return config.TimeId
end
function XEscapeConfigs.GetActivityName(id)
local config = XEscapeConfigs.GetEscapeActivity(id, true)
return config.Name
end
function XEscapeConfigs.GetActivityBackground(id)
local config = XEscapeConfigs.GetEscapeActivity(id, true)
return config.Background
end
--------------------------EscapeActivity 活动表 end------------------------
--------------------------EscapeChapter 章节表 begin------------------------
local IsInitEscapeChapterDic = false
local EscapeGroupIdToChapterIdsDic = {} --组Id对应的章节Id列表
local InitTheatreDecorationDic = function()
if IsInitEscapeChapterDic then
return
end
local configs = XEscapeConfigs.GetEscapeChapter()
for chapterId, v in pairs(configs) do
if not EscapeGroupIdToChapterIdsDic[v.GroupId] then
EscapeGroupIdToChapterIdsDic[v.GroupId] = {}
end
table.insert(EscapeGroupIdToChapterIdsDic[v.GroupId], chapterId)
end
for _, chapterIdList in pairs(EscapeGroupIdToChapterIdsDic) do
table.sort(chapterIdList, function(a, b)
local difficultyA = XEscapeConfigs.GetChapterDifficulty(a)
local difficultyB = XEscapeConfigs.GetChapterDifficulty(b)
if difficultyA ~= difficultyB then
return difficultyA < difficultyB
end
return a < b
end)
end
IsInitEscapeChapterDic = true
end
function XEscapeConfigs.GetEscapeChapterGroupIdList()
InitTheatreDecorationDic()
local groupIdList = {}
for groupId in pairs(EscapeGroupIdToChapterIdsDic) do
table.insert(groupIdList, groupId)
end
table.sort(groupIdList, function(a, b)
return a < b
end)
return groupIdList
end
function XEscapeConfigs.GetEscapeChapterIdListByGroupId(groupId)
InitTheatreDecorationDic()
return EscapeGroupIdToChapterIdsDic[groupId]
end
function XEscapeConfigs.GetChapterName(id)
local config = XEscapeConfigs.GetEscapeChapter(id, true)
return config.Name
end
function XEscapeConfigs.GetChapterEnvironmentDesc(id)
local config = XEscapeConfigs.GetEscapeChapter(id, true)
return config.EnvironmentDesc
end
function XEscapeConfigs.GetChapterOpenCondition(id)
local config = XEscapeConfigs.GetEscapeChapter(id, true)
return config.OpenCondition
end
function XEscapeConfigs.GetChapterTimeId(id)
local config = XEscapeConfigs.GetEscapeChapter(id, true)
return config.TimeId
end
function XEscapeConfigs.GetChapterDifficulty(id)
local config = XEscapeConfigs.GetEscapeChapter(id, true)
return config.Difficulty
end
function XEscapeConfigs.GetChapterLayerIds(id)
local config = XEscapeConfigs.GetEscapeChapter(id, true)
return config.LayerIds
end
function XEscapeConfigs.GetChapterBuffDesc(id)
local config = XEscapeConfigs.GetEscapeChapter(id, true)
return config.BuffDesc
end
function XEscapeConfigs.GetChapterShowFightEventIds(id)
local config = XEscapeConfigs.GetEscapeChapter(id, true)
return config.ShowFightEventIds
end
function XEscapeConfigs.GetChapterInitialTime(id)
local config = XEscapeConfigs.GetEscapeChapter(id, true)
return config.InitialTime
end
--------------------------EscapeChapter 章节表 end--------------------------
--------------------------EscapeLayer 区域表 begin--------------------------
function XEscapeConfigs.GetLayerClearStageCount(id)
local config = XEscapeConfigs.GetEscapeLayer(id, true)
return config.ClearStageCount
end
function XEscapeConfigs.GetLayerStageIds(id)
local config = XEscapeConfigs.GetEscapeLayer(id, true)
return config.StageIds
end
--------------------------EscapeLayer 区域表 end----------------------------
--------------------------EscapeStage 关卡表 begin--------------------------
function XEscapeConfigs.GetStageColor(id)
local config = XEscapeConfigs.GetEscapeStage(id, true)
return config.Color
end
function XEscapeConfigs.GetStageAwardTime(id)
local config = XEscapeConfigs.GetEscapeStage(id, true)
return config.AwardTime
end
function XEscapeConfigs.GetStageGridDesc(id)
local config = XEscapeConfigs.GetEscapeStage(id, true)
return config.GridDesc
end
--------------------------EscapeStage 关卡表 end----------------------------
--------------------------EscapeTask 任务表 begin------------------------
function XEscapeConfigs.GetTaskGroupIdList()
local configs = XEscapeConfigs.GetEscapeTask()
local taskGroupIdList = {}
for id in pairs(configs) do
table.insert(taskGroupIdList, id)
end
return taskGroupIdList
end
function XEscapeConfigs.GetTaskIdList(id)
local config = XEscapeConfigs.GetEscapeTask(id, true)
return config.TaskId
end
function XEscapeConfigs.GetTaskName(id)
local config = XEscapeConfigs.GetEscapeTask(id, true)
return config.Name
end
--------------------------EscapeTask 任务表 end---------------------------
--------------------------EscapeClientConfig begin------------------------
function XEscapeConfigs.GetHelpKey()
local config = XEscapeConfigs.GetEscapeClientConfig("HelpKey", true)
return config.Values[1]
end
function XEscapeConfigs.GetRemainTimeColor()
local config = XEscapeConfigs.GetEscapeClientConfig("RemainTimeColor", true)
return config.Values
end
function XEscapeConfigs.GetRemainTimeShowColor()
local config = XEscapeConfigs.GetEscapeClientConfig("RemainTimeShowColor", true)
return config.Values
end
function XEscapeConfigs.GetChapterSettleCondDesc()
local config = XEscapeConfigs.GetEscapeClientConfig("ChapterSettleCondDesc", true)
return config.Values
end
function XEscapeConfigs.GetChapterSettleRemainTimeGradeImgPath(score)
local gradeIndex = XEscapeConfigs.GetGradeIndexByScore(score)
local gradeConfig = XEscapeConfigs.GetEscapeClientConfig("ChapterSettleRemainTimeGradeImgPath", true)
return gradeConfig.Values[gradeIndex or #gradeConfig.Values]
end
function XEscapeConfigs.GetChapterSettleRemainTimeGrade(score)
local gradeIndex = XEscapeConfigs.GetGradeIndexByScore(score)
local config = XEscapeConfigs.GetEscapeClientConfig("ChapterSettleRemainTimeGrade", true)
return config.Values[gradeIndex or #config.Values]
end
function XEscapeConfigs.GetGradeIndexByScore(score)
local scoreConfig = XEscapeConfigs.GetEscapeClientConfig("ChapterSettleRemainTimeScore", true)
for i, value in ipairs(scoreConfig.Values) do
local scoreCfg = tonumber(value)
if scoreCfg and score >= scoreCfg then
return i
end
end
end
function XEscapeConfigs.GetDifficultyName(difficulty)
local config = XEscapeConfigs.GetEscapeClientConfig("DifficultyName", true)
return config.Values[difficulty] or ""
end
function XEscapeConfigs.GetMainBg(index)
local config = XEscapeConfigs.GetEscapeClientConfig("MainBg", true)
return config.Values[index]
end
function XEscapeConfigs.GetFightSettleCondDesc(index)
local config = XEscapeConfigs.GetEscapeClientConfig("FightSettleCondDesc", true)
return config.Values[index] or config.Values
end
--------------------------EscapeClientConfig end--------------------------
--------------------------EscapeStageColorPrefab 关卡颜色对应的预制 begin------------------------
function XEscapeConfigs.GetEscapeStageColorPrefabById(id)
local config = XEscapeConfigs.GetEscapeStageColorPrefab(id, true)
return config.Prefab
end
--------------------------EscapeStageColorPrefab end--------------------------

View file

@ -0,0 +1,182 @@
XExhibitionConfigs = XExhibitionConfigs or {}
local TABLE_CHARACTER_EXHIBITION = "Client/Exhibition/Exhibition.tab"
local TABLE_CHARACTER_EXHIBITION_LEVEL = "Client/Exhibition/ExhibitionLevel.tab"
local TABLE_CHARACTER_GROW_TASK_INFO = "Share/Exhibition/ExhibitionReward.tab"
local DefaultPortraitImagePath = CS.XGame.ClientConfig:GetString("DefaultPortraitImagePath")
local ExhibitionLevelPoint = {}
local ExhibitionConfig = {}
local ExhibitionGroupNameConfig = {}
local ExhibitionGroupLogoConfig = {}
local ExhibitionGroupDescConfig = {}
local CharacterExhibitionLevelConfig = {}
local GrowUpTasksConfig = {}
local CharacterGrowUpTasksConfig = {}
local CharacterGrowUpTasksConfigByType = {}
local CharacterHeadPortrait = {}
local CharacterGraduationPortrait = {}
local ExhibitionConfigByTypeAndPort = {}
local ExhibitionConfigByTypeAndGroup = {}
local CharacterToExhibitionTypeTable = {}
local InVisibleGroupTable = {}
function XExhibitionConfigs.Init()
CharacterExhibitionLevelConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_EXHIBITION_LEVEL, XTable.XTableExhibitionLevel, "LevelId")
ExhibitionConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_EXHIBITION, XTable.XTableCharacterExhibition, "Id")
for _, v in pairs(ExhibitionConfig) do
if v.Port ~= nil then
CharacterHeadPortrait[v.CharacterId] = v.HeadPortrait
CharacterGraduationPortrait[v.CharacterId] = v.GraduationPortrait
ExhibitionGroupNameConfig[v.GroupId] = v.GroupName
ExhibitionGroupLogoConfig[v.GroupId] = v.GroupLogo
ExhibitionGroupDescConfig[v.GroupId] = v.GroupDescription
if v.Type and not ExhibitionConfigByTypeAndPort[v.Type] then
ExhibitionConfigByTypeAndPort[v.Type] = {}
ExhibitionConfigByTypeAndGroup[v.Type] = {}
end
ExhibitionConfigByTypeAndPort[v.Type][v.Port] = v
ExhibitionConfigByTypeAndGroup[v.Type][v.GroupId] = v
if v.Type then
if not InVisibleGroupTable[v.Type] then InVisibleGroupTable[v.Type] = {} end
if InVisibleGroupTable[v.Type][v.GroupId] == nil then InVisibleGroupTable[v.Type][v.GroupId] = true end
if v.InVisible == 1 then InVisibleGroupTable[v.Type][v.GroupId] = false end
end
end
if v.CharacterId and v.CharacterId ~= 0 and not CharacterToExhibitionTypeTable[v.CharacterId] then
CharacterToExhibitionTypeTable[v.CharacterId] = v.Type
end
end
GrowUpTasksConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_GROW_TASK_INFO, XTable.XTableExhibitionReward, "Id")
for task, v in pairs(GrowUpTasksConfig) do
if CharacterGrowUpTasksConfig[v.CharacterId] == nil then
CharacterGrowUpTasksConfig[v.CharacterId] = {}
end
CharacterGrowUpTasksConfig[v.CharacterId][task] = v
local type = CharacterToExhibitionTypeTable[v.CharacterId] or 1
if not CharacterGrowUpTasksConfigByType[type] then CharacterGrowUpTasksConfigByType[type] = {} end
if not CharacterGrowUpTasksConfigByType[type][v.Id] then
CharacterGrowUpTasksConfigByType[type][v.Id] = v
end
end
ExhibitionLevelPoint[1] = CS.XGame.ClientConfig:GetInt("ExhibitionLevelPoint_01")
ExhibitionLevelPoint[2] = CS.XGame.ClientConfig:GetInt("ExhibitionLevelPoint_02")
ExhibitionLevelPoint[3] = CS.XGame.ClientConfig:GetInt("ExhibitionLevelPoint_03")
ExhibitionLevelPoint[4] = CS.XGame.ClientConfig:GetInt("ExhibitionLevelPoint_04")
end
function XExhibitionConfigs.GetDefaultPortraitImagePath()
return DefaultPortraitImagePath
end
function XExhibitionConfigs.GetExhibitionLevelPoints()
return ExhibitionLevelPoint
end
function XExhibitionConfigs.GetGrowUpLevelMax()
local maxPoint = 0
for i = 1, 4 do
maxPoint = maxPoint + ExhibitionLevelPoint[i]
end
return maxPoint
end
function XExhibitionConfigs.GetExhibitionConfig()
return ExhibitionConfig
end
function XExhibitionConfigs.GetExhibitionPortConfigByType(showType)
if not showType then return ExhibitionConfig end
return ExhibitionConfigByTypeAndPort[showType] or {}
end
function XExhibitionConfigs.GetExhibitionGroupNameConfig()
return ExhibitionGroupNameConfig
end
function XExhibitionConfigs.GetExhibitionGroupConfigByType(showType)
if not showType then return ExhibitionConfig end
return ExhibitionConfigByTypeAndGroup[showType] or {}
end
function XExhibitionConfigs.GetExhibitionConfigByTypeAndGroup(showType, groupId)
return ExhibitionConfigByTypeAndGroup[showType][groupId]
end
function XExhibitionConfigs.GetExhibitionTypeByCharacterId(characterId)
return CharacterToExhibitionTypeTable[characterId]
end
function XExhibitionConfigs.GetExhibitionGroupLogoConfig()
return ExhibitionGroupLogoConfig
end
function XExhibitionConfigs.GetExhibitionGroupDescConfig()
return ExhibitionGroupDescConfig
end
function XExhibitionConfigs.GetExhibitionInVisbleGroupTable(exhibitionType)
return InVisibleGroupTable[exhibitionType] or {}
end
function XExhibitionConfigs.GetIsExhibitionInVisbleGroup(exhibitionType, groupId)
return InVisibleGroupTable[exhibitionType] and InVisibleGroupTable[exhibitionType][groupId] or false
end
function XExhibitionConfigs.GetExhibitionLevelConfig()
return CharacterExhibitionLevelConfig
end
function XExhibitionConfigs.GetCharacterGrowUpTasks(characterId)
local config = CharacterGrowUpTasksConfig[characterId]
if not config then
XLog.Error("XExhibitionConfigs.GetCharacterGrowUpTasks error: 角色解放配置错误characterId: " .. characterId .. " ,path: " .. TABLE_CHARACTER_GROW_TASK_INFO)
return
end
return config
end
function XExhibitionConfigs.GetCharacterGrowUpTask(characterId, level)
local levelTasks = XExhibitionConfigs.GetCharacterGrowUpTasks(characterId)
for _, config in pairs(levelTasks) do
if config.LevelId == level then
return config
end
end
end
function XExhibitionConfigs.GetCharacterGrowUpTasksConfig()
return CharacterGrowUpTasksConfig
end
function XExhibitionConfigs.GetExhibitionGrowUpLevelConfig(level)
return CharacterExhibitionLevelConfig[level]
end
function XExhibitionConfigs.GetExhibitionLevelNameByLevel(level)
return CharacterExhibitionLevelConfig[level].Name or ""
end
function XExhibitionConfigs.GetExhibitionLevelDescByLevel(level)
return CharacterExhibitionLevelConfig[level].Desc or ""
end
function XExhibitionConfigs.GetExhibitionLevelIconByLevel(level)
return CharacterExhibitionLevelConfig[level].LevelIcon or ""
end
function XExhibitionConfigs.GetCharacterHeadPortrait(characterId)
return CharacterHeadPortrait[characterId]
end
function XExhibitionConfigs.GetCharacterGraduationPortrait(characterId)
return CharacterGraduationPortrait[characterId]
end
function XExhibitionConfigs.GetGrowUpTasksConfig()
return GrowUpTasksConfig
end
function XExhibitionConfigs.GetGrowUpTasksConfigByType(exhibitionType)
if not exhibitionType then return GrowUpTasksConfig end
return CharacterGrowUpTasksConfigByType[exhibitionType] or {}
end

View file

@ -0,0 +1,609 @@
XExpeditionConfig = XExpeditionConfig or {}
--基础角色表
local TABLE_EXPEDITION_BASE_CHARACTER = "Share/Fuben/Expedition/ExpeditionBaseCharacter.tab"
--角色表
local TABLE_EXPEDITION_CHARACTER = "Share/Fuben/Expedition/ExpeditionCharacter.tab"
--远征章节表
local TABLE_EXPEDITION_CHAPTER = "Share/Fuben/Expedition/ExpeditionChapter.tab"
--远征关卡表
local TABLE_EXPEDITION_STAGE = "Share/Fuben/Expedition/ExpeditionStage.tab"
--玩法配置
local TABLE_EXPEDITION_CONFIG = "Share/Fuben/Expedition/ExpeditionConfig.tab"
--角色基础组合羁绊表
local TABLE_EXPEDITION_COMBO = "Share/Fuben/Expedition/ExpeditionCombo.tab"
--角色组合羁绊子分类表
local TABLE_EXPEDITION_CHILDCOMBO = "Share/Fuben/Expedition/ExpeditionChildCombo.tab"
--角色分类展示表
local TABLE_EXPEDITION_CHARACTER_TYPE = "Share/Fuben/Expedition/ExpeditionCharacterType.tab"
--角色阶级升级表
local TABLE_EXPEDITION_CHARACTER_ELEMENTS = "Client/Fuben/Expedition/ExpeditionCharacterElements.tab"
--羁绊大类表
local TABLE_EXPEDITION_COMBO_TYPENAME = "Client/Fuben/Expedition/ExpeditionComboTypeName.tab"
--螺母购买刷新次数表
local TABLE_EXPEDITION_DRAW_CONSUME = "Share/Fuben/Expedition/ExpeditionDrawConsume.tab"
--全局增益羁绊
local TABLE_EXPEDITION_GLOBAL_COMBO = "Share/Fuben/Expedition/ExpeditionGlobalCombo.tab"
--队伍位置表
local TABLE_EXPEDITION_TEAMPOS = "Share/Fuben/Expedition/ExpeditionTeamPos.tab"
--招募概率表
local TABLE_EXPEDITION_DRAWPR = "Share/Fuben/Expedition/ExpeditionDrawPR.tab"
--招募概率星数对照表
local TABLE_EXPEDITION_DRAWRANK = "Share/Fuben/Expedition/ExpeditionDrawRank.tab"
--关卡层对照表
local TABLE_EXPEDITION_STAGETIER = "Client/Fuben/Expedition/ExpeditionStageTier.tab"
--关卡层对照表
local TABLE_EXPEDITION_DEFAULT_TEAM = "Share/Fuben/Expedition/ExpeditionDefaultTeam.tab"
local BaseConfig = {}
local ChildComboConfig = {}
local ComboConfig = {}
local CharacterTypeConfig = {}
local CharacterConfig = {}
local CharacterElements = {}
local BaseCharacterConfig = {}
local ChapterConfig = {}
local EStageConfig = {}
local ComboTypeNameConfig = {}
local DrawConsumeConfig = {}
local GlobalComboConfig = {}
local TeamPosConfig = {}
local DrawPRConfig = {}
local DrawRankConfig = {}
local StageTierConfig = {}
local DefaultTeamConfig = {}
local Type2CharacterDic = {}
local Rank2CharacterDic = {}
local Chapter2StageDic = {}
local Chapter2StageTierDic = {}
local Chapter2ConfigDic = {}
local Chapter2TeamPosDic = {}
local Chapter2DefaultTeamDic = {}
local Order2ComboTypeDic = {}
local DefaultTeamId2ChildComboDic = {}
local TierId2StageIdDic = {}
local Chapter2StageIdDic = {}
local NewBaseConfigIndex = 0
--local BaseComboStatus = {} 废弃
local BaseComboDic = {}
local StageToEStageDic = {}
local ComboConditionList = {
[1] = "MemberNum", -- 检查合计数量
[2] = "TotalRank", -- 检查合计等级
[3] = "TargetMember", -- 检查对应角色等级
[4] = "TargetTypeAndRank", -- 检查指定特征的高于指定等级的人
}
--=====================
--关卡难度枚举
--=====================
XExpeditionConfig.StageDifficulty = {
Normal = 1, --普通难度
NightMare = 2, --噩梦难度
}
XExpeditionConfig.DifficultyName = {
[1] = "Normal",
[2] = "NightMare",
}
XExpeditionConfig.TierType = {
Normal = 1, --普通层(包含剧情关卡与普通战斗关卡)
Infinity = 2, --无尽层
}
XExpeditionConfig.StageType = {
Story = 1, -- 1 剧情关
Battle = 2, -- 2 战斗关
Infinity = 3, -- 3 无尽关
AfterBrush = 4, -- 4 复刷关
}
-- 关卡前置条件类型
XExpeditionConfig.PreStageCheckType = {
And = 1,
Or = 2,
}
XExpeditionConfig.MemberDetailsType = {
RecruitMember = 1,
FireMember = 2
}
local InitConfig = function()
BaseConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_CONFIG, XTable.XTableExpeditionConfig, "Id")
ComboConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_COMBO, XTable.XTableExpeditionCombo, "Id")
ChildComboConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_CHILDCOMBO, XTable.XTableExpeditionChildCombo, "Id")
ChapterConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_CHAPTER, XTable.XTableExpeditionChapter, "Id")
EStageConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_STAGE, XTable.XTableExpeditionStage, "Id")
BaseCharacterConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_BASE_CHARACTER, XTable.XTableExpeditionBaseCharacter, "Id")
CharacterConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_CHARACTER, XTable.XTableExpeditionCharacter, "Id")
CharacterTypeConfig = XTableManager.ReadByStringKey(TABLE_EXPEDITION_CHARACTER_TYPE, XTable.XTableExpeditionCharacterType, "Id")
ComboTypeNameConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_COMBO_TYPENAME, XTable.XTableExpeditionComboTypeName, "Id")
DrawConsumeConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_DRAW_CONSUME, XTable.XTableExpeditionDrawConsume, "Id")
GlobalComboConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_GLOBAL_COMBO, XTable.XTableExpeditionGlobalCombo, "Id")
CharacterElements = XTableManager.ReadByIntKey(TABLE_EXPEDITION_CHARACTER_ELEMENTS, XTable.XTableExpeditionCharacterElements, "Id")
TeamPosConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_TEAMPOS, XTable.XTableExpeditionTeamPos, "Id")
DrawPRConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_DRAWPR, XTable.XTableExpeditionDrawPR, "Level")
DrawRankConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_DRAWRANK, XTable.XTableExpeditionDrawRank, "Id")
StageTierConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_STAGETIER, XTable.XTableExpeditionStageTier, "Id")
DefaultTeamConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_DEFAULT_TEAM, XTable.XTableExpeditionDefaultTeam, "TeamId")
end
local GetNewBaseConfigId = function()
for id, cfg in pairs(BaseConfig) do
if cfg.TimeId and cfg.TimeId > 0 then
NewBaseConfigIndex = id
return
end
end
XLog.Error("XExpeditionConfig:没有任何一项配置了TimeId请检查表格" .. TABLE_EXPEDITION_CONFIG)
end
local InitComboConfig = function()
for _, comboCfg in pairs(ComboConfig) do
if not BaseComboDic[comboCfg.ChildComboId] then
BaseComboDic[comboCfg.ChildComboId] = {}
end
table.insert(BaseComboDic[comboCfg.ChildComboId], comboCfg)
end
for _, comboTypeCfg in pairs(ComboTypeNameConfig) do
Order2ComboTypeDic[comboTypeCfg.OrderId] = comboTypeCfg
end
end
local InitStages = function()
for _, tier in pairs(StageTierConfig) do
if not Chapter2StageTierDic[tier.ChapterId] then Chapter2StageTierDic[tier.ChapterId] = {} end
Chapter2StageTierDic[tier.ChapterId][tier.OrderId] = tier
if not Chapter2StageDic[tier.ChapterId] then Chapter2StageDic[tier.ChapterId] = {} end
if not Chapter2StageDic[tier.ChapterId][tier.Difficulty] then
Chapter2StageDic[tier.ChapterId][tier.Difficulty] = {}
end
--if not Chapter2StageTierDic[eStage.ChapterId] then Chapter2StageTierDic[eStage.ChapterId] = {} end
--if not Chapter2StageTierDic[eStage.ChapterId][eStage.TierId] then Chapter2StageTierDic[eStage.ChapterId][eStage.TierId] = {} end
Chapter2StageDic[tier.ChapterId][tier.Difficulty][tier.OrderId] = tier
end
for id, eStage in pairs(EStageConfig) do
--Chapter2StageTierDic[eStage.ChapterId][eStage.TierId][eStage.OrderId] = eStage
if not StageToEStageDic[eStage.StageId] then
StageToEStageDic[eStage.StageId] = eStage
end
if not TierId2StageIdDic[eStage.TierId] then
TierId2StageIdDic[eStage.TierId] = {}
end
TierId2StageIdDic[eStage.TierId][eStage.OrderId] = id
if not Chapter2StageIdDic[eStage.ChapterId] then
Chapter2StageIdDic[eStage.ChapterId] = {}
end
table.insert(Chapter2StageIdDic[eStage.ChapterId] , id)
end
end
local InitCharacter = function()
for _, v in pairs(BaseCharacterConfig) do
for _, type in pairs(v.Type) do
if not Type2CharacterDic[type] then Type2CharacterDic[type] = {} end
if not Type2CharacterDic[type][v.Id] then Type2CharacterDic[type][v.Id] = 1 end
end
Rank2CharacterDic[v.Id] = {}
end
end
local InitRank2CharacterDic = function()
for _, v in pairs(CharacterConfig) do
Rank2CharacterDic[v.BaseId][v.Rank] = v
if not Rank2CharacterDic[v.BaseId].MaxRank or Rank2CharacterDic[v.BaseId].MaxRank < v.Rank then
Rank2CharacterDic[v.BaseId].MaxRank = v.Rank
end
end
end
local InitTeam = function()
for _, v in pairs(TeamPosConfig) do
if not Chapter2TeamPosDic[v.ChapterId] then Chapter2TeamPosDic[v.ChapterId] = {} end
table.insert(Chapter2TeamPosDic[v.ChapterId], v)
end
for id, chapter in pairs(ChapterConfig) do
if not Chapter2DefaultTeamDic[id] then Chapter2DefaultTeamDic[id] = {} end
for order, defaultTeamId in pairs(chapter.DefaultTeamIds) do
Chapter2DefaultTeamDic[id][order] = XExpeditionConfig.GetDefaultTeamCfgByTeamId(defaultTeamId)
end
end
for id, childCombo in pairs(ChildComboConfig) do
if childCombo.DefaultTeamId > 0 then
DefaultTeamId2ChildComboDic[childCombo.DefaultTeamId] = childCombo
end
end
end
function XExpeditionConfig.Init()
InitConfig()
GetNewBaseConfigId()
InitStages()
InitCharacter()
InitRank2CharacterDic()
InitComboConfig()
InitTeam()
end
function XExpeditionConfig.GetExpeditionConfig()
return BaseConfig
end
function XExpeditionConfig.GetExpeditionConfigById(Id)
return BaseConfig[Id] or BaseConfig[NewBaseConfigIndex]
end
function XExpeditionConfig.GetLastestExpeditionConfig()
if NewBaseConfigIndex == 0 then
return BaseConfig[1]
end
return BaseConfig[NewBaseConfigIndex]
end
function XExpeditionConfig.GetEChapterCfg()
return ChapterConfig
end
function XExpeditionConfig.GetChapterCfgById(chapterId)
if not ChapterConfig[chapterId] then
XLog.ErrorTableDataNotFound("XExpeditionConfig.GetChapterCfgById", "虚像地平线章节数据",
TABLE_EXPEDITION_CHAPTER, "Id", tostring(chapterId))
return nil
end
return ChapterConfig[chapterId]
end
function XExpeditionConfig.GetChapterRewardIdById(chapterId)
return ChapterConfig[chapterId] and ChapterConfig[chapterId].RewardId or 0
end
--==============
--根据章节返回【【关卡层】】列表
--返回的是关卡层列表,不是关卡
--==============
function XExpeditionConfig.GetEStageListByChapterId(chapterId)
return Chapter2StageDic[chapterId] or {}
end
--==============
--根据关卡层Id返回该层所有关卡Id列表
--返回的是关卡
--==============
function XExpeditionConfig.GetEStageIdsByTierId(tierId)
if not TierId2StageIdDic[tierId] then
XLog.ErrorTableDataNotFound(
"XExpeditionConfig.GetEStageIdsByTierId",
"虚像地平线关卡数据",
TABLE_EXPEDITION_STAGE,
"TierId",
tostring(tierId))
return nil
end
return TierId2StageIdDic[tierId]
end
--==============
--根据章节Id返回该章节所有关卡Id列表
--返回的是关卡
--==============
function XExpeditionConfig.GetEStageIdsByChapterId(chapterId)
if not Chapter2StageIdDic[chapterId] then
XLog.ErrorTableDataNotFound(
"XExpeditionConfig.GetEStageIdsByChapterId",
"虚像地平线关卡数据",
TABLE_EXPEDITION_STAGE,
"chapterId",
tostring(chapterId))
return nil
end
return Chapter2StageIdDic[chapterId]
end
function XExpeditionConfig.GetStageList()
return StageToEStageDic
end
function XExpeditionConfig.GetEStageByStageId(stageId)
return StageToEStageDic[stageId]
end
function XExpeditionConfig.GetEStageIdByStageId(stageId)
return StageToEStageDic[stageId] and StageToEStageDic[stageId].Id
end
function XExpeditionConfig.GetOrderIdByStageId(stageId)
return StageToEStageDic[stageId].OrderId
end
function XExpeditionConfig.GetBaseCharacterCfg()
return BaseCharacterConfig
end
function XExpeditionConfig.GetBaseCharacterCfgById(baseId)
return BaseCharacterConfig[baseId]
end
function XExpeditionConfig.GetBaseIdByECharId(eCharacterId)
return CharacterConfig[eCharacterId].BaseId
end
function XExpeditionConfig.GetCharacterIdByBaseId(baseId)
return BaseCharacterConfig[baseId] and BaseCharacterConfig[baseId].CharacterId or 0
end
function XExpeditionConfig.GetCharacterElementByBaseId(baseId)
return BaseCharacterConfig[baseId] and BaseCharacterConfig[baseId].Elements or {}
end
function XExpeditionConfig.GetCharacterMaxRankByBaseId(baseId)
return Rank2CharacterDic[baseId].MaxRank
end
function XExpeditionConfig.GetCharacterCfgByBaseIdAndRank(baseId, rank)
local base = Rank2CharacterDic[baseId]
if not base then
return nil
end
if base.MaxRank < rank then
return base[base.MaxRank]
else
return base[rank]
end
end
function XExpeditionConfig.GetCharacterCfgs()
return CharacterConfig
end
function XExpeditionConfig.GetCharacterCfgById(Id)
if not CharacterConfig[Id] then
XLog.ErrorTableDataNotFound("XExpeditionConfig.GetCharacterById", "虚像地平线角色", TABLE_EXPEDITION_CHARACTER, "Id", tostring(Id))
end
return CharacterConfig[Id]
end
function XExpeditionConfig.GetEStageCfg(EStageId)
if not EStageConfig[EStageId] then
XLog.ErrorTableDataNotFound("XExpeditionConfig.GetEStageCfg", "虚像地平线关卡", TABLE_EXPEDITION_STAGE, "Id", tostring(EStageId))
return nil
end
return EStageConfig[EStageId]
end
function XExpeditionConfig.GetCharacterElementById(elementId)
return CharacterElements[elementId]
end
function XExpeditionConfig.GetComboTable()
return ComboConfig
end
function XExpeditionConfig.GetChildComboTable()
return ChildComboConfig
end
--================
--根据子羁绊类型Id获取具体羁绊列表
--================
function XExpeditionConfig.GetComboByChildComboId(childComboId)
if not BaseComboDic[childComboId] then
XLog.ErrorTableDataNotFound(
"XExpeditionConfig.GetComboByChildComboId",
"虚像地平线成员组合数据",
TABLE_EXPEDITION_COMBO,
"ChildComboId",
tostring(childComboId))
return nil
end
return BaseComboDic[childComboId]
end
function XExpeditionConfig.GetChildComboById(id)
if not ChildComboConfig[id] then
XLog.ErrorTableDataNotFound("XExpeditionConfig.GetEStageCfg",
"虚像地平线羁绊子分类数据", TABLE_EXPEDITION_CHILDCOMBO, "Id", tostring(id))
return nil
end
return ChildComboConfig[id]
end
function XExpeditionConfig.GetComboById(comboId)
if not ComboConfig[comboId] then
XLog.ErrorTableDataNotFound("XExpeditionConfig.GetComboById", "虚像地平线阵容", TABLE_EXPEDITION_COMBO, "Id", tostring(comboId))
return nil
end
return ComboConfig[comboId]
end
function XExpeditionConfig.GetCharactersByCharacterType(typeId)
if not Type2CharacterDic[typeId] then
XLog.ErrorTableDataNotFound("XExpeditionConfig.GetCharactersByCharacterType", "虚像地平线角色词条", TABLE_EXPEDITION_CHARACTER_TYPE, "Id", tostring(typeId))
return nil
end
return Type2CharacterDic[typeId]
end
function XExpeditionConfig.IsCharacterHasTypes(characterId, typeIds)
for _, typeId in pairs(typeIds) do
local id = tonumber(typeId)
if not Type2CharacterDic[id] or not Type2CharacterDic[id][characterId] then
return false
end
end
return true
end
function XExpeditionConfig.GetBaseComboTypeConfig()
return ComboTypeNameConfig
end
function XExpeditionConfig.GetBaseComboTypeCfgByOrderId(orderId)
return Order2ComboTypeDic[orderId]
end
function XExpeditionConfig.GetBaseComboTypeNameById(id)
return ComboTypeNameConfig[id].Name or ""
end
function XExpeditionConfig.GetBuyDrawMaxTime()
return #DrawConsumeConfig
end
function XExpeditionConfig.GetDrawPriceByCount(count)
return DrawConsumeConfig[count] and DrawConsumeConfig[count].ConsumeCount or 0
end
function XExpeditionConfig.GetGlobalConfigs()
return GlobalComboConfig
end
function XExpeditionConfig.GetGlobalConfigById(comboId)
return GlobalComboConfig[comboId]
end
function XExpeditionConfig.GetRankByRankWeightId(index)
return DrawRankConfig[index] and DrawRankConfig[index].Rank or 1
end
--================
--获取队伍位置数据
--@param teamPosId:位置ID
--================
function XExpeditionConfig.GetTeamPosCfgById(teamPosId)
if not TeamPosConfig[teamPosId] then
XLog.ErrorTableDataNotFound(
"XExpeditionConfig.GetTeamPosCfgById",
"虚像地平线队伍位置数据",
TABLE_EXPEDITION_TEAMPOS,
"Id",
tostring(teamPosId))
return nil
end
return TeamPosConfig[teamPosId]
end
--================
--获取队伍位置数量
--================
function XExpeditionConfig.GetTeamPosListByChapterId(currentChapterId)
if not TeamPosConfig or not Chapter2TeamPosDic or not Chapter2TeamPosDic[currentChapterId] then return 0 end
return Chapter2TeamPosDic[currentChapterId]
end
--================
--获取招募概率配置表
--================
function XExpeditionConfig.GetDrawPRConfig()
return DrawPRConfig
end
--================
--获取招募星数对照表配置
--================
function XExpeditionConfig.GetDrawRankConfig()
return DrawRankConfig
end
--================
--获取所有关卡层配置
--================
function XExpeditionConfig.GetAllStageTierConfig()
return StageTierConfig
end
--================
--根据章节ID获取关卡层列表(按OrderId排列)配置
--@param chapterId:章节ID
--@param noTips:是否要打印错误日志信息
--================
function XExpeditionConfig.GetStageTierListByChapterId(chapterId, noTips)
if not Chapter2StageTierDic[chapterId] then
if not noTips then
XLog.ErrorTableDataNotFound(
"XExpeditionConfig.GetStageTierListByChapterId",
"虚像地平线关卡层数据",
TABLE_EXPEDITION_STAGETIER,
"ChapterId",
tostring(chapterId))
end
return nil
end
return Chapter2StageTierDic[chapterId]
end
--================
--根据关卡层ID获取关卡层配置
--@param tierId:关卡层ID
--@param noTips:是否要打印错误日志信息
--================
function XExpeditionConfig.GetStageTierConfigByTierId(tierId, noTips)
if not StageTierConfig[tierId] then
if not noTips then
XLog.ErrorTableDataNotFound(
"XExpeditionConfig.GetStageTierConfigByTierId",
"虚像地平线关卡层数据",
TABLE_EXPEDITION_STAGETIER,
"Id",
tostring(tierId))
end
return nil
end
return StageTierConfig[tierId]
end
--================
--获取所有预设队伍配置
--================
function XExpeditionConfig.GetAllDefaultTeamCfgs()
return DefaultTeamConfig
end
--================
--根据章节ID获取预设队伍配置列表
--@param chapterId:章节ID
--@param noTips:是否要打印错误日志信息
--================
function XExpeditionConfig.GetDefaultTeamCfgsByChapterId(chapterId, noTips)
if not Chapter2DefaultTeamDic[chapterId] then
if not noTips then
XLog.ErrorTableDataNotFound(
"XExpeditionConfig.GetDefaultTeamCfgsByChapterId",
"虚像地平线关卡层数据",
TABLE_EXPEDITION_CHAPTER,
"Id",
tostring(chapterId))
end
return nil
end
return Chapter2DefaultTeamDic[chapterId]
end
--================
--根据预设队伍ID获取预设队伍配置
--@param teamId:队伍Id
--@param noTips:是否要打印错误日志信息
--================
function XExpeditionConfig.GetDefaultTeamCfgByTeamId(teamId, noTips)
if not DefaultTeamConfig[teamId] then
if not noTips then
XLog.ErrorTableDataNotFound(
"XExpeditionConfig.GetDefaultTeamCfgByTeamId",
"虚像地平线关卡层数据",
TABLE_EXPEDITION_DEFAULT_TEAM,
"TeamId",
tostring(teamId))
end
return nil
end
return DefaultTeamConfig[teamId]
end
--================
--根据预设队伍ID获取对应队伍羁绊配置
--@param teamId:队伍Id
--@param noTips:是否要打印错误日志信息
--================
function XExpeditionConfig.GetChildComboByDefaultTeamId(teamId, noTips)
if not DefaultTeamId2ChildComboDic[teamId] then
if not noTips then
XLog.ErrorTableDataNotFound(
"XExpeditionConfig.GetChildComboByDefaultTeamId",
"虚像地平线基础羁绊数据",
TABLE_EXPEDITION_CHILDCOMBO,
"DefaultTeamId",
tostring(teamId))
end
return nil
end
return DefaultTeamId2ChildComboDic[teamId]
end

Some files were not shown because too many files have changed in this diff Show more