private void Form1_Load(object sender, EventArgs e) { mFormsTimer = new System.Windows.Forms.Timer(); mFormsTimer.Interval = 50; mFormsTimer.Tick += new System.EventHandler(this.TimerEventProcessor); mFormsTimer.Start(); context_ = BufferedGraphicsManager.Current; last_tick_time_ = TimeUtility.Instance.GetElapsedTimeUs() / 1000; last_movedir_ = 0; last_adjust_ = 0; operation.SelectedIndex = 0; LogUtil.OnOutput += (Log_Type type, string msg) => { Console.WriteLine("Log {0}:{1}", type, msg); }; FileReaderProxy.RegisterReadFileHandler((string filePath) => { byte[] buffer = null; try { buffer = File.ReadAllBytes(filePath); } catch (Exception ex) { Console.WriteLine("Exception:{0}\n{1}", ex.Message, ex.StackTrace); return(null); } return(buffer); }); }
public static void OnStart(string dataPath) { GfxMoudle.Instance.RegisteLog(); HomePath.Instance.SetHomePath(dataPath); FileReaderProxy.RegisterReadFileHandler((string filePath) => { try { return(File.ReadAllBytes(filePath)); } catch (Exception e) { LogUtil.Error("Exception:{0}\n{1}", e.Message, e.StackTrace); return(null); } }); LoadConfig(); GfxMoudle.Instance.OnStart(s_Logic); s_Logic.OnStart(); }
private void Init(string[] args) { m_NameHandleCallback = this.OnNameHandleChanged; m_MsgCallback = this.OnMessage; m_CmdCallback = this.OnCommand; m_MsgResultCallback = this.OnMessageResult; CenterClientApi.Init("store", args.Length, args, m_NameHandleCallback, m_MsgCallback, m_MsgResultCallback, m_CmdCallback); m_Channel = new PBChannel(DashFire.DataStore.MessageMapping.Query, DashFire.DataStore.MessageMapping.Query); m_Channel.DefaultServiceName = "Lobby"; LogSys.Init("./config/logconfig.xml"); DataStoreConfig.Init(); ArkCrossEngine.GlobalVariables.Instance.IsClient = false; FileReaderProxy.RegisterReadFileHandler((string filePath) => { byte[] buffer = null; try { buffer = File.ReadAllBytes(filePath); } catch (Exception e) { LogSys.Log(LOG_TYPE.ERROR, "Exception:{0}\n{1}", e.Message, e.StackTrace); return(null); } return(buffer); }, (string filepath) => { return(File.Exists(filepath)); }); LogSystem.OnOutput += (Log_Type type, string msg) => { switch (type) { case Log_Type.LT_Debug: LogSys.Log(LOG_TYPE.DEBUG, msg); break; case Log_Type.LT_Info: LogSys.Log(LOG_TYPE.INFO, msg); break; case Log_Type.LT_Warn: LogSys.Log(LOG_TYPE.WARN, msg); break; case Log_Type.LT_Error: case Log_Type.LT_Assert: LogSys.Log(LOG_TYPE.ERROR, msg); break; } }; DbThreadManager.Instance.Init(DataStoreConfig.LoadThreadNum, DataStoreConfig.SaveThreadNum); DataOpSystem.Instance.Init(m_Channel); DataCacheSystem.Instance.Init(); LogSys.Log(LOG_TYPE.INFO, "DataStore initialized"); }
// Use this for initialization internal void Start() { UnityEngine.Application.targetFrameRate = 30; #if (UNITY_IOS || UNITY_ANDROID) && !(UNITY_EDITOR) QualitySettings.vSyncCount = 2; #endif try { if (!GameControler.IsInited) { // register to game thread ArkProfiler.RegisterOutput(LogicSystem.LogFromGfx); // register to gfx thread, output to game console ArkProfiler.RegisterOutput2(UnityEngine.Debug.Log); // register file read handler FileReaderProxy.RegisterReadFileHandler(EngineReadFileProxy, EngineFileExistsProxy); /// Unity Editor: <path_to_project_folder>/Assets /// iOS player: <path_to_player_app_bundle>/<AppName.app>/Data (this folder is read only, use Application.persistentDataPath to save data). /// Android: Normally it would point directly to the APK. The exception is if you are running a split binary build in which case it points to the the OBB instead. string dataPath = UnityEngine.Application.dataPath; /// Point to data path which have write permission string persistentDataPath = Application.persistentDataPath; /// Point to readonly data, note some platofrm like android points to compressed apk, witch cant be directory accesssed, use www. etc instead string streamingAssetsPath = UnityEngine.Application.streamingAssetsPath; /// Point to temp data path, may clean by system string tempPath = UnityEngine.Application.temporaryCachePath; LogicSystem.LogFromGfx("dataPath:{0} persistentDataPath:{1} streamingAssetsPath:{2} tempPath:{3}", dataPath, persistentDataPath, streamingAssetsPath, tempPath); Debug.Log(string.Format("dataPath:{0} persistentDataPath:{1} streamingAssetsPath:{2} tempPath:{3}", dataPath, persistentDataPath, streamingAssetsPath, tempPath)); // store log in tempPath, others to persistentDataPath #if !UNITY_EDITOR GlobalVariables.Instance.IsDevice = true; #else // if in editor, use streamingAssetsPath instead GlobalVariables.Instance.IsDevice = false; #endif #if UNITY_ANDROID || UNITY_WEBGL if (!UnityEngine.Application.isEditor) { streamingAssetsPath = persistentDataPath + "/Tables"; } #endif #if UNITY_WEBGL // init web socket before gamelogic initialize m_WebSocket = new WebGLSocket(); ArkCrossEngine.Network.WebSocketWrapper.Instance.SetInstance(m_WebSocket); #endif LogSystem.OnOutput2 = (Log_Type type, string msg) => { #if DEBUG if (Log_Type.LT_Error == type) { UnityEngine.Debug.LogError(msg); } else if (Log_Type.LT_Info != type) { UnityEngine.Debug.LogWarning(msg); } #endif }; GameControler.Init(tempPath, streamingAssetsPath); NormLog.Instance.Init(); NormLog.Instance.Record(GameEventCode.GameStart); LogicSystem.LogFromGfx("game log saved to: {0}", tempPath); } // try preload all skills used by npc in spec scene, also character LogicSystem.OnAfterLoadScene += AfterLoadScene; } catch (Exception ex) { LogicSystem.LogErrorFromGfx("GameLogic.Start throw exception:{0}\n{1}", ex.Message, ex.StackTrace); Debug.Log(string.Format("GameLogic.Start throw exception:{0}\n{1}", ex.Message, ex.StackTrace)); } }
static void Main(string[] args) { if (args.Length != 5) { Console.WriteLine("[Usage:]lobbyrobot robotGroup threadnum robotnumperthread gmscript.gm url"); Console.WriteLine("Current args num: {0}", args.Length); return; } int robotGroup = int.Parse(args[0]); int threadNum = int.Parse(args[1]); int robotNum = int.Parse(args[2]); string wayPointScript = args[3]; string url = args[4]; string gmTxt = File.ReadAllText(wayPointScript); // file name as scene id string filename = Path.GetFileNameWithoutExtension(wayPointScript); int sceneId = int.Parse(filename); Console.WriteLine("===================================================="); Console.WriteLine("robot group: {0}", robotGroup); Console.WriteLine("thread num: {0}", threadNum); Console.WriteLine("robot num per thread: {0}", robotNum); Console.WriteLine("gmScript {0}:", wayPointScript); Console.WriteLine("url: {0}", url); Console.WriteLine("===================================================="); Console.WriteLine("{0}", gmTxt); Console.WriteLine("===================================================="); Console.WriteLine("Load tables ..."); LogSystem.OnOutput = (Log_Type type, string msg) => { Console.WriteLine(msg); }; FileReaderProxy.RegisterReadFileHandler((string filePath) => { byte[] buffer = null; try { buffer = File.ReadAllBytes(filePath); } catch (Exception e) { LogSystem.Error("Exception:{0}\n{1}", e.Message, e.StackTrace); return(null); } return(buffer); }, (string path) => { return(File.Exists(path)); }); GlobalVariables.Instance.IsClient = false; string tmpPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); HomePath.CurHomePath = Path.Combine(tmpPath, "../DcoreEnv/bin"); Console.WriteLine("home path:{0}", HomePath.CurHomePath); SceneConfigProvider.Instance.Load(FilePathDefine_Server.C_SceneConfig, "ScenesConfigs"); ItemConfigProvider.Instance.Load(FilePathDefine_Server.C_ItemConfig, "ItemConfig"); PlayerConfigProvider.Instance.LoadPlayerConfig(FilePathDefine_Server.C_PlayerConfig, "PlayerConfig"); SkillConfigProvider.Instance.CollectData(SkillConfigType.SCT_SKILL, FilePathDefine_Server.C_SkillSystemConfig, "SkillConfig"); SkillConfigProvider.Instance.CollectData(SkillConfigType.SCT_IMPACT, FilePathDefine_Server.C_ImpactSystemConfig, "ImpactConfig"); Console.WriteLine("Startup robots ..."); List <RobotThread> threads = new List <RobotThread>(); for (int i = 0; i < threadNum; ++i) { RobotThread thread = new RobotThread(); threads.Add(thread); thread.Start(); for (int j = 0; j < robotNum; ++j) { string user = string.Format("robot_{0}_{1}_{2}", robotGroup, i, j); string pwd = "robot"; thread.QueueAction(thread.AddRobot, url, user, pwd, gmTxt, sceneId); } } Console.WriteLine("Enter infinite running ..."); for (;;) { Thread.Sleep(1000); } }
private void Init(string[] args) { m_NameHandleCallback = this.OnNameHandleChanged; m_MsgCallback = this.OnMessage; m_CmdCallback = this.OnCommand; m_MsgResultCallback = this.OnMessageResult; CenterClientApi.Init("roomserver", args.Length, args, m_NameHandleCallback, m_MsgCallback, m_MsgResultCallback, m_CmdCallback); Console.WriteLine("begin init roomserver..."); HomePath.InitHomePath(); bool ret = LogSys.Init("./config/logconfig.xml"); System.Diagnostics.Debug.Assert(ret); last_tick_time_ = TimeUtility.GetServerMilliseconds(); last_send_roominfo_time_ = last_tick_time_; is_continue_register_ = true; channel_ = new PBChannel(MessageMapping.Query, MessageMapping.Query); channel_.DefaultServiceName = "Lobby"; lobby_connector_ = new Connector(channel_); server_ip_ = "127.0.0.1"; server_port_ = 9528; StringBuilder sb = new StringBuilder(256); if (CenterClientApi.GetConfig("name", sb, 256)) { room_server_name_ = sb.ToString(); } if (CenterClientApi.GetConfig("ServerIp", sb, 256)) { server_ip_ = sb.ToString(); } if (CenterClientApi.GetConfig("ServerPort", sb, 256)) { server_port_ = uint.Parse(sb.ToString()); } if (CenterClientApi.GetConfig("Debug", sb, 256)) { int debug = int.Parse(sb.ToString()); if (debug != 0) { GlobalVariables.Instance.IsDebug = true; } } GlobalVariables.Instance.IsClient = false; FileReaderProxy.RegisterReadFileHandler((string filePath) => { byte[] buffer = null; try { buffer = File.ReadAllBytes(filePath); } catch (Exception e) { LogSys.Log(LOG_TYPE.ERROR, "Exception:{0}\n{1}", e.Message, e.StackTrace); return(null); } return(buffer); }, (string filepath) => { return(File.Exists(filepath)); }); LogSystem.OnOutput += (Log_Type type, string msg) => { switch (type) { case Log_Type.LT_Debug: LogSys.Log(LOG_TYPE.DEBUG, msg); break; case Log_Type.LT_Info: LogSys.Log(LOG_TYPE.INFO, msg); break; case Log_Type.LT_Warn: LogSys.Log(LOG_TYPE.WARN, msg); break; case Log_Type.LT_Error: case Log_Type.LT_Assert: LogSys.Log(LOG_TYPE.ERROR, msg); break; } }; LoadData(); LogSys.Log(LOG_TYPE.DEBUG, "room server init ip: {0} port: {1}", server_ip_, server_port_); ret = Serialize.Init(); if (!ret) { LogSys.Log(LOG_TYPE.DEBUG, "Serialize init error !!!"); } else { LogSys.Log(LOG_TYPE.DEBUG, "Serialize init OK."); } thread_count_ = 16; per_thread_room_count_ = 20; uint tick_interval = 50; room_mgr_ = new RoomManager(thread_count_, per_thread_room_count_, tick_interval, lobby_connector_); room_mgr_.Init(); IOManager.Instance.Init((int)server_port_); room_mgr_.StartRoomThread(); AiViewManager.Instance.Init(); SceneLogicViewManager.Instance.Init(); ImpactViewManager.Instance.Init(); ServerSkillSystem.StaticInit(); ServerStorySystem.StaticInit(); DashFire.GmCommands.GmStorySystem.StaticInit(); channel_.Register <Msg_LR_ReplyRegisterRoomServer>(HandleReplyRegisterRoomServer); room_mgr_.RegisterMsgHandler(channel_); LogSys.Log(LOG_TYPE.DEBUG, "room server init ok."); }
private void Init(string[] args) { m_NameHandleCallback = this.OnNameHandleChanged; m_MsgCallback = this.OnMessage; m_CmdCallback = this.OnCommand; m_MsgResultCallback = this.OnMessageResult; CenterClientApi.Init("lobby", args.Length, args, m_NameHandleCallback, m_MsgCallback, m_MsgResultCallback, m_CmdCallback); LogSys.Init("./config/logconfig.xml"); LobbyConfig.Init(); if (LobbyConfig.IsDebug) { GlobalVariables.Instance.IsDebug = true; } GlobalVariables.Instance.IsClient = false; FileReaderProxy.RegisterReadFileHandler((string filePath) => { byte[] buffer = null; try { buffer = File.ReadAllBytes(filePath); } catch (Exception e) { LogSys.Log(LOG_TYPE.ERROR, "Exception:{0}\n{1}", e.Message, e.StackTrace); return(null); } return(buffer); }, (string filePath) => { return(File.Exists(filePath)); }); LogSystem.OnOutput += (Log_Type type, string msg) => { switch (type) { case Log_Type.LT_Debug: LogSys.Log(LOG_TYPE.DEBUG, msg); break; case Log_Type.LT_Info: LogSys.Log(LOG_TYPE.INFO, msg); break; case Log_Type.LT_Warn: LogSys.Log(LOG_TYPE.WARN, msg); break; case Log_Type.LT_Error: case Log_Type.LT_Assert: LogSys.Log(LOG_TYPE.ERROR, msg); break; } }; LoadData(); LogSys.Log(LOG_TYPE.INFO, "Init Config ..."); s_Instance = this; InstallMessageHandlers(); LogSys.Log(LOG_TYPE.INFO, "Init Messenger ..."); m_DataStoreThread.Init(m_StoreChannel); LogSys.Log(LOG_TYPE.INFO, "Init DataStore ..."); m_ServerBridgeThread.Init(m_BridgeChannel); LogSys.Log(LOG_TYPE.INFO, "Init BillingClient ..."); m_GmServerThread.Init(m_GmSvrChannel); LogSys.Log(LOG_TYPE.INFO, "Init GmServerThread ..."); Start(); LogSys.Log(LOG_TYPE.INFO, "Start Threads ..."); }