迁移数据表到 Luban,移除 JsonNet、EnumUtility
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
//------------------------------------------------------------
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
using GameFramework.DataTable;
|
||||
using GameFramework.Event;
|
||||
using SepCore.Sound;
|
||||
using UnityGameFramework.Runtime;
|
||||
@@ -18,7 +16,7 @@ namespace SepCore.Procedure
|
||||
{
|
||||
public class ProcedureChangeScene : ProcedureBase
|
||||
{
|
||||
private int _nextSceneId = 0;
|
||||
private int _nextSceneType = 0;
|
||||
private bool _isChangeSceneComplete = false;
|
||||
private int _backgroundMusicId = 0;
|
||||
|
||||
@@ -53,18 +51,10 @@ namespace SepCore.Procedure
|
||||
// 还原游戏速度
|
||||
GameEntry.Base.ResetNormalGameSpeed();
|
||||
|
||||
_nextSceneId = procedureOwner.GetData<VarInt32>("NextSceneId");
|
||||
|
||||
IDataTable<DRScene> dtScene = GameEntry.DataTable.GetDataTable<DRScene>();
|
||||
DRScene drScene = dtScene.GetDataRow(_nextSceneId);
|
||||
if (drScene == null)
|
||||
{
|
||||
Log.Warning("Can not load scene '{0}' from data table.", _nextSceneId.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.Scene.LoadScene(AssetUtility.GetSceneAsset(drScene.AssetName), Constant.AssetPriority.SceneAsset, this);
|
||||
_backgroundMusicId = drScene.BackgroundMusicId;
|
||||
_nextSceneType = procedureOwner.GetData<VarInt32>("NextSceneType");
|
||||
SceneConfig sceneConfig = GameEntry.Luban.Get<SceneConfig>(_nextSceneType);
|
||||
GameEntry.Scene.LoadScene(AssetUtility.GetSceneAsset(sceneConfig.AssetName), Constant.AssetPriority.SceneAsset, this);
|
||||
_backgroundMusicId = sceneConfig.BackgroundMusicId;
|
||||
}
|
||||
|
||||
protected override void OnLeave(ProcedureOwner procedureOwner, bool isShutdown)
|
||||
@@ -86,20 +76,20 @@ namespace SepCore.Procedure
|
||||
return;
|
||||
}
|
||||
|
||||
SceneId sceneId = (SceneId)_nextSceneId;
|
||||
switch (sceneId)
|
||||
SceneType sceneType = (SceneType)_nextSceneType;
|
||||
switch (sceneType)
|
||||
{
|
||||
case SceneId.Menu:
|
||||
case SceneType.Menu:
|
||||
ChangeState<ProcedureMenu>(procedureOwner);
|
||||
break;
|
||||
case SceneId.StressTest:
|
||||
case SceneType.StressTest:
|
||||
ChangeState<ProcedureStressTest>(procedureOwner);
|
||||
break;
|
||||
case SceneId.Game:
|
||||
case SceneType.Game:
|
||||
ChangeState<ProcedureGame>(procedureOwner);
|
||||
break;
|
||||
default:
|
||||
Log.Debug($"Scene {sceneId.ToString()} don't configure a procedure");
|
||||
Log.Debug($"Scene {sceneType.ToString()} don't configure a procedure");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using GameFramework;
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
using GameFramework.Resource;
|
||||
using System.Collections.Generic;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
using SepCore.CustomUtility;
|
||||
using TMPro;
|
||||
@@ -15,23 +14,7 @@ namespace SepCore.Procedure
|
||||
{
|
||||
public class ProcedurePreload : ProcedureBase
|
||||
{
|
||||
public static readonly string[] DataTableNames = new string[]
|
||||
{
|
||||
"Entity",
|
||||
"Enemy",
|
||||
"Weapon",
|
||||
"Music",
|
||||
"Scene",
|
||||
"Sound",
|
||||
"UIForm",
|
||||
"UISound",
|
||||
"Goods",
|
||||
"Prop",
|
||||
"Role",
|
||||
"Level",
|
||||
"LevelUpReward",
|
||||
"LevelRarity",
|
||||
};
|
||||
private const string LubanTablesFlag = "LubanTables";
|
||||
|
||||
private Dictionary<string, bool> _loadedFlag = new Dictionary<string, bool>();
|
||||
|
||||
@@ -43,8 +26,6 @@ namespace SepCore.Procedure
|
||||
|
||||
GameEntry.Event.Subscribe(LoadConfigSuccessEventArgs.EventId, OnLoadConfigSuccess);
|
||||
GameEntry.Event.Subscribe(LoadConfigFailureEventArgs.EventId, OnLoadConfigFailure);
|
||||
GameEntry.Event.Subscribe(LoadDataTableSuccessEventArgs.EventId, OnLoadDataTableSuccess);
|
||||
GameEntry.Event.Subscribe(LoadDataTableFailureEventArgs.EventId, OnLoadDataTableFailure);
|
||||
GameEntry.Event.Subscribe(LoadDictionarySuccessEventArgs.EventId, OnLoadDictionarySuccess);
|
||||
GameEntry.Event.Subscribe(LoadDictionaryFailureEventArgs.EventId, OnLoadDictionaryFailure);
|
||||
|
||||
@@ -59,8 +40,6 @@ namespace SepCore.Procedure
|
||||
{
|
||||
GameEntry.Event.Unsubscribe(LoadConfigSuccessEventArgs.EventId, OnLoadConfigSuccess);
|
||||
GameEntry.Event.Unsubscribe(LoadConfigFailureEventArgs.EventId, OnLoadConfigFailure);
|
||||
GameEntry.Event.Unsubscribe(LoadDataTableSuccessEventArgs.EventId, OnLoadDataTableSuccess);
|
||||
GameEntry.Event.Unsubscribe(LoadDataTableFailureEventArgs.EventId, OnLoadDataTableFailure);
|
||||
GameEntry.Event.Unsubscribe(LoadDictionarySuccessEventArgs.EventId, OnLoadDictionarySuccess);
|
||||
GameEntry.Event.Unsubscribe(LoadDictionaryFailureEventArgs.EventId, OnLoadDictionaryFailure);
|
||||
|
||||
@@ -79,7 +58,7 @@ namespace SepCore.Procedure
|
||||
}
|
||||
}
|
||||
|
||||
procedureOwner.SetData<VarInt32>("NextSceneId", (int)SceneId.Menu);
|
||||
procedureOwner.SetData<VarInt32>("NextSceneType", (int)SceneType.Menu);
|
||||
ChangeState<ProcedureChangeScene>(procedureOwner);
|
||||
}
|
||||
|
||||
@@ -88,11 +67,18 @@ namespace SepCore.Procedure
|
||||
// Preload configs
|
||||
LoadConfig("DefaultConfig");
|
||||
|
||||
// Preload data tables
|
||||
foreach (string dataTableName in DataTableNames)
|
||||
{
|
||||
LoadDataTable(dataTableName);
|
||||
}
|
||||
// Preload Luban data tables
|
||||
_loadedFlag.Add(LubanTablesFlag, false);
|
||||
GameEntry.Luban.LoadTables(
|
||||
() =>
|
||||
{
|
||||
_loadedFlag[LubanTablesFlag] = true;
|
||||
Log.Info("Load Luban data tables OK.");
|
||||
},
|
||||
errorMessage =>
|
||||
{
|
||||
Log.Error("Load Luban data tables failure with error message '{0}'.", errorMessage);
|
||||
});
|
||||
|
||||
// Preload fonts
|
||||
LoadFont("MainFont");
|
||||
@@ -106,13 +92,6 @@ namespace SepCore.Procedure
|
||||
GameEntry.Config.ReadData(configAssetName, this);
|
||||
}
|
||||
|
||||
private void LoadDataTable(string dataTableName)
|
||||
{
|
||||
string dataTableAssetName = AssetUtility.GetDataTableAsset(dataTableName, false);
|
||||
_loadedFlag.Add(dataTableAssetName, false);
|
||||
GameEntry.DataTable.LoadDataTable(dataTableName, dataTableAssetName, this);
|
||||
}
|
||||
|
||||
private void LoadFont(string fontName)
|
||||
{
|
||||
_loadedFlag.Add(Utility.Text.Format("Font.{0}", fontName), false);
|
||||
@@ -173,29 +152,7 @@ namespace SepCore.Procedure
|
||||
ne.ConfigAssetName, ne.ErrorMessage);
|
||||
}
|
||||
|
||||
private void OnLoadDataTableSuccess(object sender, GameEventArgs e)
|
||||
{
|
||||
LoadDataTableSuccessEventArgs ne = (LoadDataTableSuccessEventArgs)e;
|
||||
if (ne.UserData != this)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_loadedFlag[ne.DataTableAssetName] = true;
|
||||
Log.Info("Load data table '{0}' OK.", ne.DataTableAssetName);
|
||||
}
|
||||
|
||||
private void OnLoadDataTableFailure(object sender, GameEventArgs e)
|
||||
{
|
||||
LoadDataTableFailureEventArgs ne = (LoadDataTableFailureEventArgs)e;
|
||||
if (ne.UserData != this)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Error("Can not load data table '{0}' from '{1}' with error message '{2}'.", ne.DataTableAssetName,
|
||||
ne.DataTableAssetName, ne.ErrorMessage);
|
||||
}
|
||||
|
||||
private void OnLoadDictionarySuccess(object sender, GameEventArgs e)
|
||||
{
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.Event;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Entity;
|
||||
using SepCore.Definition;
|
||||
using GameFramework.Fsm;
|
||||
using GameFramework.Procedure;
|
||||
using SepCore.EnemyManager;
|
||||
using SepCore.Simulation;
|
||||
using SepCore.Timer;
|
||||
@@ -49,15 +45,9 @@ namespace SepCore.Procedure
|
||||
{
|
||||
_currentLevel = _procedureGame.CurrentLevel;
|
||||
|
||||
var drLevel = GameEntry.DataTable.GetDataTableRow<DRLevel>(_currentLevel);
|
||||
|
||||
if (drLevel == null)
|
||||
{
|
||||
throw new Exception($"GameStateBattle.OnEnter: {_currentLevel} is not found.");
|
||||
}
|
||||
|
||||
_levelTimerHandle = GameEntry.Timer.ScheduleOnce(drLevel.Duration, OnLevelTimeUp, this);
|
||||
_enemyManager.OnInit(drLevel, Player);
|
||||
var levelConfig = GameEntry.Luban.Get<LevelConfig>(_currentLevel);
|
||||
_levelTimerHandle = GameEntry.Timer.ScheduleOnce(levelConfig.Duration, OnLevelTimeUp, this);
|
||||
_enemyManager.OnInit(levelConfig, Player);
|
||||
|
||||
if (Player != null) Player.Enable = true;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using GameFramework.Fsm;
|
||||
@@ -131,14 +131,12 @@ namespace SepCore.Procedure
|
||||
await GameEntry.UIRouter.OpenUIAsync(UIFormType.HudForm);
|
||||
|
||||
int selectedRoleId = procedureOwner.GetData<VarInt32>("SelectedRoleId").Value;
|
||||
var role = GameEntry.DataTable.GetDataTableRow<DRRole>(selectedRoleId);
|
||||
if (role == null)
|
||||
{
|
||||
Log.Error("ProcedureGame.EnterAsync() can not load role '{0}'.", selectedRoleId.ToString());
|
||||
return;
|
||||
}
|
||||
var roles = GameEntry.Luban.GetTable<RoleConfig>();
|
||||
var role = roles.FirstOrDefault(r => r.Id == selectedRoleId)
|
||||
?? (selectedRoleId >= 0 && selectedRoleId < roles.Count ? roles[selectedRoleId] : roles[0]);
|
||||
var expConfig = GameEntry.Luban.Get<LevelExperienceConfig>(role.Name);
|
||||
|
||||
Player.InitRole(role);
|
||||
Player.InitRole(role, expConfig);
|
||||
InitGameState();
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace SepCore.Procedure
|
||||
|
||||
if (_startGame)
|
||||
{
|
||||
procedureOwner.SetData<VarInt32>("NextSceneId", (int)SceneId.Game);
|
||||
procedureOwner.SetData<VarInt32>("NextSceneType", (int)SceneType.Game);
|
||||
procedureOwner.SetData<VarInt32>("SelectedRoleId", _selectedRoleId);
|
||||
ChangeState<ProcedureChangeScene>(procedureOwner);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"GUID:363c5eb08ff8e6a439b85e37b8c20d96",
|
||||
"GUID:47a82ffa13c291447ab895cd0bc251cd",
|
||||
"GUID:436e23dbdc31e7d4fb5c3f804548b2df",
|
||||
"GUID:0e1d182005e0ae647ab3fa40f5492dbb"
|
||||
"GUID:0e1d182005e0ae647ab3fa40f5492dbb",
|
||||
"GUID:3bb549212964b4192b427888ac9382e7"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
Reference in New Issue
Block a user