Skip to content

Commit ef18c59

Browse files
committed
迟迟没提交的一大波更新,多语言编辑器,Lua库,还有一些其他的优化
1 parent 8419d7b commit ef18c59

166 files changed

Lines changed: 2795 additions & 20138 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Assets/Script/Core/Application/ApplicationManager.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public static ApplicationManager Instance
1515

1616
public AppMode m_AppMode = AppMode.Developing;
1717

18+
public bool m_useAssetsBundle = false;
19+
1820
public static AppMode AppMode
1921
{
2022
get { return instance.m_AppMode; }
@@ -53,11 +55,6 @@ public void AppLaunch()
5355
InputManager.Init(); //输入管理器启动
5456
UIManager.Init(); //UIManager启动
5557

56-
if (m_useLua)
57-
{
58-
LuaManager.Init();
59-
}
60-
6158
ApplicationStatusManager.Init(); //游戏流程状态机初始化
6259
GlobalLogicManager.Init(); //初始化全局逻辑
6360

@@ -67,6 +64,11 @@ public void AppLaunch()
6764

6865
DevelopReplayManager.OnLunchCallBack += () =>
6966
{
67+
if (m_useLua)
68+
{
69+
LuaManager.Init();
70+
}
71+
7072
InitGlobalLogic(); //全局逻辑
7173
ApplicationStatusManager.EnterTestModel(m_Status);//可以从此处进入测试流程
7274
};
@@ -77,6 +79,11 @@ public void AppLaunch()
7779
{
7880
Log.Init(false); //关闭 Debug
7981

82+
if (m_useLua)
83+
{
84+
LuaManager.Init();
85+
}
86+
8087
InitGlobalLogic(); //全局逻辑
8188
ApplicationStatusManager.EnterStatus(m_Status);//游戏流程状态机,开始第一个状态
8289
}
@@ -159,13 +166,13 @@ void OnGUI()
159166
/// </summary>
160167
void SetResourceLoadType()
161168
{
162-
if (m_AppMode == AppMode.Developing)
169+
if (m_useAssetsBundle)
163170
{
164-
ResourceManager.m_gameLoadType = ResLoadType.Resource;
171+
ResourceManager.m_gameLoadType = ResLoadLocation.Streaming;
165172
}
166173
else
167174
{
168-
ResourceManager.m_gameLoadType = ResLoadType.HotUpdate;
175+
ResourceManager.m_gameLoadType = ResLoadLocation.Resource;
169176
}
170177
}
171178

Assets/Script/Core/Config/ConfigManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static void CleanCatch()
8484

8585
public static void SaveData(string ConfigName, Dictionary<string, SingleField> data)
8686
{
87-
ResourceIOTool.WriteStringByFile(PathTool.GetAbsolutePath(ResLoadType.Resource,
87+
ResourceIOTool.WriteStringByFile(PathTool.GetAbsolutePath(ResLoadLocation.Resource,
8888
PathTool.GetRelativelyPath(c_directoryName,
8989
ConfigName,
9090
c_expandName)),

Assets/Script/Core/Data/DataManager.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,27 @@ public static DataTable GetData(string DataName)
4848

4949
string dataJson = "";
5050

51-
#if UNITY_EDITOR
51+
#if UNITY_EDITOR
52+
53+
if (Application.isPlaying)
54+
{
55+
dataJson = ResourceManager.ReadTextFile(DataName);
56+
}
57+
else
58+
{
59+
5260
dataJson = ResourceIOTool.ReadStringByResource(
5361
PathTool.GetRelativelyPath(c_directoryName,
5462
DataName,
5563
c_expandName));
56-
#else
64+
}
65+
#else
5766
dataJson = ResourceManager.ReadTextFile(DataName);
58-
#endif
67+
#endif
5968

6069
if (dataJson == "")
6170
{
62-
throw new Exception("Dont Find " + DataName);
71+
throw new Exception("Dont Find ->" + DataName + "<-");
6372
}
6473

6574
data = DataTable.Analysis(dataJson);
@@ -85,7 +94,7 @@ public static void SaveData(string ConfigName, DataTable data)
8594
{
8695
ResourceIOTool.WriteStringByFile(
8796
PathTool.GetAbsolutePath(
88-
ResLoadType.Resource,
97+
ResLoadLocation.Resource,
8998
PathTool.GetRelativelyPath(
9099
c_directoryName,
91100
ConfigName,

Assets/Script/Core/Data/DataTable.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ public FieldType GetFieldType(string key)
398398
}
399399
}
400400

401+
401402
public void SetFieldType(string key,FieldType type ,string enumType)
402403
{
403404
//主键只能是String类型
@@ -429,6 +430,13 @@ public void SetFieldType(string key,FieldType type ,string enumType)
429430
}
430431
}
431432

433+
public SingleData GetLineFromKey(string key)
434+
{
435+
//主键只能是String类型
436+
return this[key];
437+
}
438+
439+
432440
public string GetEnumType(string key)
433441
{
434442
if (m_tableEnumTypes.ContainsKey(key))

Assets/Script/Core/Develop/DevelopReplayManager.cs

Lines changed: 81 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
public class DevelopReplayManager
99
{
1010
const string c_directoryName = "DevelopReplay";
11-
public const string c_expandName = "json";
11+
public const string c_eventExpandName = "inputEvent";
12+
public const string c_randomExpandName = "random";
1213

1314
const string c_recordName = "DevelopReplay";
1415
const string c_qucikLunchKey = "qucikLunch";
@@ -28,6 +29,9 @@ public class DevelopReplayManager
2829

2930
private static Action s_onLunchCallBack;
3031

32+
private static StreamWriter m_EventWriter = null;
33+
private static StreamWriter m_RandomWriter = null;
34+
3135
public static Action OnLunchCallBack
3236
{
3337
get { return s_onLunchCallBack; }
@@ -78,14 +82,12 @@ static void ChoseReplayMode(bool isReplay,string replayFileName = null)
7882
{
7983
Log.Init(true); //日志记录启动
8084

81-
s_eventStreamSerialize = new List<Dictionary<string, string>>();
82-
s_randomList = new List<int>();
83-
8485
ApplicationManager.s_OnApplicationUpdate += OnRecordUpdate;
8586
InputManager.OnEveryEventDispatch += OnEveryEventCallBack;
8687
GUIConsole.onGUICallback += RecordModeGUI;
8788
RandomService.OnRandomCreat += OnGetRandomCallBack;
88-
SaveFileName = GetLogFileName();
89+
90+
OpenWriteFileStream(GetLogFileName());
8991
}
9092

9193
ApplicationManager.s_OnApplicationOnGUI -= ReplayMenuGUI;
@@ -104,74 +106,79 @@ static void ChoseReplayMode(bool isReplay,string replayFileName = null)
104106

105107
public static void OnEveryEventCallBack(string eventName, IInputEventBase inputEvent)
106108
{
107-
//Dictionary<string, string> tmp = new Dictionary<string, string>();
109+
Dictionary<string, object> tmp = HeapObjectPool.GetSODict();
108110

109-
//tmp.Add(c_eventNameKey, inputEvent.GetType().Name);
110-
//tmp.Add(c_serializeInfoKey, inputEvent.Serialize());
111+
tmp.Add(c_eventNameKey, inputEvent.GetType().Name);
112+
tmp.Add(c_serializeInfoKey, inputEvent.Serialize());
111113

112-
//s_eventStreamSerialize.Add(tmp);
114+
WriteInputEvent(Json.Serialize(tmp));
113115
}
114116

115117
public static void OnGetRandomCallBack(int random)
116118
{
117-
s_randomList.Add(random);
119+
WriteRandomRecord(random);
118120
}
119121

120-
121-
122122
#region SaveReplayFile
123123

124-
125-
public static void SaveReplayFile(string fileName)
124+
static void OpenWriteFileStream(string fileName)
126125
{
127-
List<Dictionary<string,string>> EventStreamContent = SaveEventStream();
128-
List<int> randomListContent = SaveRandomList();
129126

130-
Dictionary<string, object> replayInfo = new Dictionary<string, object>();
131-
132-
replayInfo.Add(c_eventStreamKey, EventStreamContent);
133-
replayInfo.Add(c_randomListKey, randomListContent);
134-
135-
string content = Json.Serialize(replayInfo);
136-
137-
ResourceIOTool.WriteStringByFile(
138-
PathTool.GetAbsolutePath(ResLoadType.Persistent,
127+
try
128+
{
129+
string path = PathTool.GetAbsolutePath(ResLoadLocation.Persistent,
139130
PathTool.GetRelativelyPath(
140131
c_directoryName,
141132
fileName,
142-
c_expandName))
143-
, content);
144-
}
133+
c_randomExpandName));
145134

146-
static List<Dictionary<string, string>> SaveEventStream()
147-
{
148-
//List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
135+
string dirPath = Path.GetDirectoryName(path);
149136

150-
//for (int i = 0; i < s_eventStream.Count; i++)
151-
//{
152-
// Dictionary<string, string> tmp = new Dictionary<string, string>();
137+
if (!Directory.Exists(dirPath))
138+
Directory.CreateDirectory(dirPath);
153139

154-
// tmp.Add(c_eventNameKey, s_eventStream[i].GetType().Name);
155-
// tmp.Add(c_serializeInfoKey,s_eventStream[i].Serialize());
156140

157-
// list.Add(tmp);
158-
//}
141+
//Debug.Log("EventStream Name: " + PathTool.GetAbsolutePath(ResLoadLocation.Persistent,
142+
// PathTool.GetRelativelyPath(
143+
// c_directoryName,
144+
// fileName,
145+
// c_randomExpandName)));
159146

160-
//return list;
147+
m_RandomWriter = new StreamWriter(PathTool.GetAbsolutePath(ResLoadLocation.Persistent,
148+
PathTool.GetRelativelyPath(
149+
c_directoryName,
150+
fileName,
151+
c_randomExpandName)));
152+
m_RandomWriter.AutoFlush = true;
161153

162-
return s_eventStreamSerialize;
154+
m_EventWriter = new StreamWriter(PathTool.GetAbsolutePath(ResLoadLocation.Persistent,
155+
PathTool.GetRelativelyPath(
156+
c_directoryName,
157+
fileName,
158+
c_eventExpandName)));
159+
m_EventWriter.AutoFlush = true;
160+
161+
}
162+
catch(Exception e)
163+
{
164+
Debug.LogError(e.ToString());
165+
}
163166
}
164167

165-
static List<int> SaveRandomList()
168+
static void WriteRandomRecord(int random)
166169
{
167-
List<int> list = new List<int>();
168-
169-
for (int i = 0; i < s_randomList.Count; i++)
170+
if (m_RandomWriter != null)
170171
{
171-
list.Add(s_randomList[i]);
172+
m_RandomWriter.WriteLine(random.ToString());
172173
}
174+
}
173175

174-
return list;
176+
static void WriteInputEvent(string EventSerializeContent)
177+
{
178+
if (m_EventWriter != null)
179+
{
180+
m_EventWriter.WriteLine(EventSerializeContent);
181+
}
175182
}
176183

177184
#endregion
@@ -180,42 +187,48 @@ static List<int> SaveRandomList()
180187

181188
public static void LoadReplayFile(string fileName)
182189
{
183-
string content = ResourceIOTool.ReadStringByFile(
184-
PathTool.GetAbsolutePath(ResLoadType.Persistent,
190+
string eventContent = ResourceIOTool.ReadStringByFile(
191+
PathTool.GetAbsolutePath(ResLoadLocation.Persistent,
185192
PathTool.GetRelativelyPath(
186193
c_directoryName,
187194
fileName,
188-
c_expandName)));
195+
c_eventExpandName)));
189196

190-
Dictionary<string, object> replayInfo = (Dictionary<string, object>)Json.Deserialize(content);
197+
string randomContent = ResourceIOTool.ReadStringByFile(
198+
PathTool.GetAbsolutePath(ResLoadLocation.Persistent,
199+
PathTool.GetRelativelyPath(
200+
c_directoryName,
201+
fileName,
202+
c_randomExpandName)));
191203

192-
LoadEventStream((List<object>)replayInfo[c_eventStreamKey]);
193-
LoadRandomList((List<object>)replayInfo[c_randomListKey]);
204+
LoadEventStream(eventContent.Split('\n'));
205+
LoadRandomList(randomContent.Split('\n'));
194206
}
195207

196-
static void LoadEventStream(List<object> content)
208+
static void LoadEventStream(string[] content)
197209
{
198210
s_eventStream = new List<IInputEventBase>();
199-
200-
for (int i = 0; i < content.Count; i++)
211+
for (int i = 0; i < content.Length; i++)
201212
{
202-
Dictionary<string, object> info = (Dictionary<string, object>)(content[i]);
203-
204-
//Debug.Log(info[c_eventNameKey].ToString());
205-
//Debug.Log(info[c_eventNameKey].ToString());
206-
207-
IInputEventBase eTmp = (IInputEventBase)JsonUtility.FromJson(info[c_serializeInfoKey].ToString(), Type.GetType(info[c_eventNameKey].ToString()));
208-
s_eventStream.Add(eTmp);
213+
if (content[i] != "")
214+
{
215+
Dictionary<string, object> info = (Dictionary<string, object>)(Json.Deserialize(content[i]));
216+
IInputEventBase eTmp = (IInputEventBase)JsonUtility.FromJson(info[c_serializeInfoKey].ToString(), Type.GetType(info[c_eventNameKey].ToString()));
217+
s_eventStream.Add(eTmp);
218+
}
209219
}
210220
}
211221

212-
static void LoadRandomList(List<object> content)
222+
static void LoadRandomList(string[] content)
213223
{
214224
s_randomList = new List<int>();
215225

216-
for (int i = 0; i < content.Count; i++)
226+
for (int i = 0; i < content.Length; i++)
217227
{
218-
s_randomList.Add(int.Parse(content[i].ToString()));
228+
if (content[i] != "")
229+
{
230+
s_randomList.Add(int.Parse(content[i].ToString()));
231+
}
219232
}
220233
}
221234

@@ -350,8 +363,6 @@ static void ShowLog()
350363

351364
static Rect consoleRect = new Rect(margin, Screen.height * 0.6f, Screen.width * 0.3f, Screen.height * 0.4f - margin);
352365

353-
static string SaveFileName = "";
354-
355366
static void RecordModeGUI()
356367
{
357368
consoleRect = new Rect(margin, Screen.height * 0.5f, Screen.width * 0.4f, Screen.height * 0.5f - margin);
@@ -360,13 +371,6 @@ static void RecordModeGUI()
360371
}
361372
static void RecordModeGUIWindow(int id)
362373
{
363-
SaveFileName = GUILayout.TextField(SaveFileName,GUILayout.ExpandHeight(true));
364-
365-
if (GUILayout.Button("保存录像文件", GUILayout.ExpandHeight(true)))
366-
{
367-
SaveReplayFile(SaveFileName);
368-
}
369-
370374
if (RecordManager.GetData(c_recordName).GetRecord(c_qucikLunchKey, true))
371375
{
372376
if (GUILayout.Button("开启后台", GUILayout.ExpandHeight(true)))
@@ -428,13 +432,13 @@ static void OnRecordUpdate()
428432

429433
public static string[] GetRelpayFileNames()
430434
{
431-
FileTool.CreatPath(PathTool.GetAbsolutePath(ResLoadType.Persistent, c_directoryName));
435+
FileTool.CreatPath(PathTool.GetAbsolutePath(ResLoadLocation.Persistent, c_directoryName));
432436

433437
List<string> relpayFileNames = new List<string>();
434-
string[] allFileName = Directory.GetFiles(PathTool.GetAbsolutePath(ResLoadType.Persistent, c_directoryName));
438+
string[] allFileName = Directory.GetFiles(PathTool.GetAbsolutePath(ResLoadLocation.Persistent, c_directoryName));
435439
foreach (var item in allFileName)
436440
{
437-
if (item.EndsWith("." + c_expandName))
441+
if (item.EndsWith("." + c_eventExpandName))
438442
{
439443
string configName = FileTool.RemoveExpandName(FileTool.GetFileNameByPath(item));
440444
relpayFileNames.Add(configName);

0 commit comments

Comments
 (0)