public void AddComponent(string componentName) { if (m_EngineObj == null || componentName == default(string)) { return; } string strComName = "XWorld." + componentName; Type type = Type.GetType(strComName); if (type == null) { return; } ComponentBase baseCom = m_EngineObj.AddComponent(type) as ComponentBase; if (baseCom != null) { m_ComponentsList.Add(baseCom); return; } GameLogger.Error(LOG_CHANNEL.ERROR, "AddComponent failed! component is not base of ComponentBase! component named : " + strComName); }
private void InitDefineTable(string sContent) { string[] values = sContent.Split('\r'); string[] lables = values[0].TrimStart('\n').Split('\t'); string[] types = values[1].TrimStart('\n').Split('\t'); if (values.Length - 2 <= 0) { GameLogger.Error(LOG_CHANNEL.ASSET, "当前表格行数不足三行!"); return; } m_TableDefine = new Dictionary <string, ConfigData>(); for (int i = 2; i < values.Length; i++) { string[] subValues = values[i].TrimStart('\n').Split('\t'); if (subValues.Length != lables.Length) { continue; } ConfigData data = new ConfigData(); for (int j = 0; j < subValues.Length; j++) { data.AddValue(types[j], lables[j], subValues[j]); } m_TableDefine.Add(data.GetString("tableName"), data); relativePathToNameDict.Add(data.GetString("tablePath"), data.GetString("tableName")); } }
public void AddAgent(ITaskAgent <T> agent) { if (agent == null) { GameLogger.Error(LOG_CHANNEL.LOGIC, "Task agent is invalid."); } agent.Initialize(); m_FreeAgents.Push(agent); }
private void AddGMCommand(string gm, GMCommandFunction func) { if (m_GMCommandDict.ContainsKey(gm)) { GameLogger.Error(LOG_CHANNEL.LOGIC, "GMCommand Add Error!"); return; } m_GMCommandDict.Add(gm, func); }
private void OnLoadTableComplete(LoadResult result) { if (result.isSuccess) { bool isSuccess = true; string content = ""; string relativePath = result.assetNames[0]; try { TextAsset asset = result.assets[0] as TextAsset; if (asset == null) { GameLogger.Error(LOG_CHANNEL.ASSET, relativePath + " ERROR! load table asset is NULL,暂时跳过"); return; } content = asset.text; if (string.IsNullOrEmpty(content)) { GameLogger.Error(LOG_CHANNEL.ASSET, relativePath + " ERROR! load table content is NULL or empty,暂时跳过"); return; } ResourcesProxy.DestroyAsset(relativePath); } catch (Exception e) { isSuccess = false; GameLogger.Error(LOG_CHANNEL.ASSET, relativePath + " Parse Failed : " + e.ToString()); } finally { if (isSuccess) { string name = relativePathToNameDict[relativePath]; ConfigData data = m_TableDefine[name]; string tableName = data.GetString("tableName"); string tablePath = data.GetString("tablePath"); string tablePK2 = data.GetString("extKey"); ConfigDataTableManager.Instance.LoadTable(tableName, content, tablePK2); } else { //TODO 留给之后对应加载的job使用 } } } else { //TODO 留给之后对应加载的job使用 GameLogger.Error(LOG_CHANNEL.ASSET, result.assetNames[0] + " Load Failed!"); } }
private void OnLoadDefineTableComplete(LoadResult result) { if (result.isSuccess) { bool isSuccess = true; string relativePath = result.assetNames[0]; string content = ""; try { TextAsset asset = result.assets[0] as TextAsset; if (asset == null) { GameLogger.Error(LOG_CHANNEL.ASSET, relativePath + " ERROR! load table asset is NULL,暂时跳过"); return; } content = asset.text; if (string.IsNullOrEmpty(content)) { GameLogger.Error(LOG_CHANNEL.ASSET, relativePath + " ERROR! load table content is NULL or empty,暂时跳过"); return; } ResourcesProxy.DestroyAsset(relativePath); } catch (Exception e) { isSuccess = false; GameLogger.Error(LOG_CHANNEL.ASSET, relativePath + " Parse Failed : " + e.ToString()); } finally { if (isSuccess) { InitConfigData(content); LoadAllTable(); } else { //TODO 留给之后对应加载的job使用 } } } else { //TODO 留给之后对应加载的job使用 GameLogger.Error(LOG_CHANNEL.ASSET, result.assetNames[0] + " Load Failed!"); } }
private static XWorldGameManagerBase RegisterGameManager(Type managerClass) { XWorldGameManagerBase newManager = Activator.CreateInstance(managerClass) as XWorldGameManagerBase; if (newManager == null) { GameLogger.Error(LOG_CHANNEL.LOGIC, "Register manager " + managerClass.ToString() + " failed!"); return(null); } GameLogger.DebugLog(LOG_CHANNEL.LOGIC, " Register manager " + managerClass.ToString()); InsertManagerToList(newManager); newManager.InitManager(); return(newManager); }
public void HandleGMCommand(string command) { string[] strs = command.Split(' '); if (strs.Length <= 0) { return; } string key = strs[0]; if (!m_GMCommandDict.ContainsKey(key)) { GameLogger.Error(LOG_CHANNEL.LOGIC, "GMCommand don't contain this command!"); return; } List <string> list = new List <string>(strs); list.RemoveAt(0); object[] objs = list.ToArray(); m_GMCommandDict[key](objs); }
protected void OnEngineObjectLoadEnd(LoadResult result) { if (!result.isSuccess) { GameLogger.Error(LOG_CHANNEL.ERROR, "Load Engine Object Failed! modelName : " + m_strName); return; } m_ModelResObj = result.assets[0] as GameObject; m_EngineObj = GameObject.Instantiate(result.assets[0] as GameObject); //GameLogger.LogFormat(Galaxy.LOG_CHANNEL.LOGIC, "actor name = " + result.assetNames[0]); if (m_EngineObj == null) { GameLogger.Error(LOG_CHANNEL.ERROR, "Create Engine Object Failed! modelName : " + m_strName); return; } ClientID = m_EngineObj.gameObject.GetInstanceID(); AfterCreateEngineObj(); SetOwner(this); }