-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from lilith-avatar/dev
v2.5版本更新
- Loading branch information
Showing
63 changed files
with
1,213 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
{ | ||
"input_folder": "./xls", | ||
"output_folder": "./code", | ||
"input_folder": "./Xls", | ||
"output_folder": "./Code", | ||
"output_lua_template": "['World']['Global']['Xls']['{sheet_name}XlsModule'].ModuleScript.lua", | ||
"kv_xls": [ | ||
"GlobalSetting.xlsx" | ||
], | ||
"kv_xls": "['GlobalSetting.xlsx']", | ||
"translate_xls": "LanguagePack.xls" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ code/*.xlsx | |
*.smap.storage | ||
*.iso | ||
~$* | ||
*.idea/ | ||
*.idea/ | ||
*.vscode/ |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- 玩家加入 | ||
-- @script Auto assign | ||
-- @copyright Lilith Games, Avatar Team | ||
|
||
--- 编辑器默认方法, 删了报错 | ||
-- run once when script init | ||
autoAssign = function() | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
Code/['World']['Global']['Define']['DefaultModule'].ModuleScript.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- 全局默认定义:用于定义数据,节点属性等 | ||
--- @module Data Default | ||
--- @copyright Lilith Games, Avatar Team | ||
local Default = {} | ||
|
||
--! 说明:这个module当作脚本使用 | ||
|
||
--* Data.Global和Data.Player中的默认值,用于框架初始化 | ||
|
||
Data.Default = Data.Default or {} | ||
|
||
-- 全局变量定义 | ||
Data.Default.Global = {} | ||
|
||
-- 玩家数据,初始化定义 | ||
Data.Default.Player = { | ||
-- 玩家ID, 框架默认 | ||
uid = '', | ||
-- 玩家属性 | ||
attr = {}, | ||
-- 背包 | ||
bag = {}, | ||
-- 统计数据 | ||
stats = {} | ||
} | ||
|
||
return Default |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
Code/['World']['Global']['Framework']['Client']['ClientDataSyncModule'].ModuleScript.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
--- 游戏客户端数据同步 | ||
--- @module Client Sync Data, Client-side | ||
--- @copyright Lilith Games, Avatar Team | ||
--- @author Yuancheng Zhang | ||
local ClientDataSync = {} | ||
|
||
-- Localize global vars | ||
local FrameworkConfig, MetaData = FrameworkConfig, MetaData | ||
|
||
-- 客户端私有数据 | ||
local rawDataGlobal = {} | ||
local rawDataPlayer = {} | ||
|
||
--- 打印数据同步日志 | ||
local PrintLog = FrameworkConfig.DebugMode and FrameworkConfig.Debug.ShowDataSyncLog and function(...) | ||
print('[DataSync][Client]', ...) | ||
end or function() | ||
end | ||
|
||
--! 初始化 | ||
|
||
--- 数据初始化 | ||
function ClientDataSync.Init() | ||
print('[DataSync][Client] Init()') | ||
InitEventsAndListeners() | ||
InitDataDefines() | ||
end | ||
|
||
--- 初始化事件和绑定Handler | ||
function InitEventsAndListeners() | ||
if localPlayer.C_Event == nil then | ||
world:CreateObject('FolderObject', 'S_Event', localPlayer) | ||
end | ||
|
||
-- 数据同步事件 | ||
world:CreateObject('CustomEvent', 'DataSyncS2CEvent', localPlayer.C_Event) | ||
localPlayer.C_Event.DataSyncS2CEvent:Connect(DataSyncS2CEventHandler) | ||
|
||
-- 长期存储成功事件 | ||
if not localPlayer.C_Event.LoadPlayerDataSuccessEvent then | ||
world:CreateObject('CustomEvent', 'LoadPlayerDataSuccessEvent', localPlayer.C_Event) | ||
end | ||
end | ||
|
||
--- 校验数据定义 | ||
function InitDataDefines() | ||
--* 客户端全局数据 | ||
Data.Global = Data.Global or MetaData.New(rawDataGlobal, MetaData.Enum.GLOBAL, MetaData.Enum.CLIENT) | ||
-- 默认赋值 | ||
for k, v in pairs(Data.Default.Global) do | ||
Data.Global[k] = v | ||
end | ||
|
||
--* 客户端玩家数据 | ||
local uid = localPlayer.UserId | ||
local path = MetaData.Enum.PLAYER .. uid | ||
Data.Player = Data.Player or MetaData.New(rawDataPlayer, path, uid) | ||
-- 默认赋值 | ||
for k, v in pairs(Data.Default.Player) do | ||
Data.Player[k] = v | ||
end | ||
end | ||
|
||
--- 开始同步 | ||
function ClientDataSync.Start() | ||
print('[DataSync][Client] 客户端数据同步开启') | ||
MetaData.ClientSync = true | ||
end | ||
|
||
--! Event handler | ||
|
||
--- 数据同步事件Handler | ||
function DataSyncS2CEventHandler(_path, _value) | ||
if not MetaData.ClientSync then | ||
return | ||
end | ||
|
||
PrintLog(string.format('收到 _path = %s, _value = %s', _path, table.dump(_value))) | ||
|
||
local uid = localPlayer.UserId | ||
|
||
--* 收到服务器数据 | ||
if string.startswith(_path, MetaData.Enum.GLOBAL) then | ||
--* Data.Global 全局数据 | ||
MetaData.Set(rawDataGlobal, _path, _value, uid, false) | ||
elseif string.startswith(_path, MetaData.Enum.PLAYER .. uid) then | ||
--* Data.Player 玩家数据 | ||
MetaData.Set(rawDataPlayer, _path, _value, uid, false) | ||
else | ||
error( | ||
string.format( | ||
'[DataSync][Client] _path错误 _player = %s, _path = %s, _value = %s', | ||
localPlayer, | ||
_path, | ||
table.dump(_value) | ||
) | ||
) | ||
end | ||
end | ||
|
||
return ClientDataSync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
Code/['World']['Global']['Framework']['DataModule'].ModuleScript.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- 游戏数据 | ||
--- @module Game Data, Both-side | ||
--- @copyright Lilith Games, Avatar Team | ||
--- @author Yuancheng Zhang | ||
local Data = {} | ||
|
||
-- 客户端 | ||
-- 1. Data.Global | ||
-- 2. Data.Player | ||
|
||
-- 服务器 | ||
-- 1. Data.Global | ||
-- 2. Data.Players | ||
|
||
--! 这个Module为空 | ||
--! 数据定义在:ClientDataSyncModule、ServerDataSyncModule | ||
|
||
return Data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.