public override void Update() { if (GlobalVariables.GetGlobalVariables().keyBindShowDevelopWindows.IsDown()) { GlobalVariables.GetGlobalVariables().developWindows.IsEnable = true; } if (GlobalVariables.GetGlobalVariables().keyBindHideDevelopWindows.IsDown()) { GlobalVariables.GetGlobalVariables().developWindows.IsEnable = false; } if (GlobalVariables.GetGlobalVariables().keyBindReadAllTxt.IsDown()) { GlobalVariables.GetGlobalVariables().mscTranslate.translateText.ReadTranslateTextDict(); } if (GlobalVariables.GetGlobalVariables().keyBindWriteGameObjectToTxt.IsDown()) { WriteGameObject("Systems"); logger.LOG("写入所有Systems路径下的GameObject到txt"); } if (GlobalVariables.GetGlobalVariables().keyBindWriteFVToTxt.IsDown()) { string[] text = { FsmVariablesUtil.GetAllFsmVariablesAndVaule() }; File.WriteAllLines(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "_FsmVariables.txt"), text); logger.LOG("写入所有FsmVariables变量到FsmVariables.txt"); } if (GlobalVariables.GetGlobalVariables().developWindows.isShowCameraData) { ReadCameraState(); } }
public string GetSign(string source, int salt) { string str = appid + source + salt + apikey; string result = StringToMd5(str); logger.LOG("StringToMd5 : " + str + "->" + result); return(result); }
public void Init() { logger.LOG("Mod初始化 ... "); ModelInit(); GameObjectInit(); FsmVariablesInit(); logger.LOG("Mod初始化完成"); this.isInit = true; }
private void CONNECTION_STATE_CHANGED(object SENDER, EventArgs E) { if (LOGGER_ON) { LOGGER.METHOD_ENTER(); } ConnectionState STATE = CONNECTION.State; //Get the current connection status. LOGGER.LOG(string.Format("Connection state change detected. Current state : {0}", STATE.ToString())); //Write to log. //Set a simple property FULLY_CONNECTED so that other classes can easily check. if (STATE == ConnectionState.Open) //If the connection is fully open... { FULLY_CONNECTED = true; //Set fully connected to true. } else //If the connection is not fully open... { FULLY_CONNECTED = false; //Set fully connected to false. } var ARGS = new CONNECTION_CHANGED_EVENT_ARGS(FULLY_CONNECTED); //Insert FULLY_CONNECTED state into the arguments that the delegate will carry out. CONNECTION_CHANGED?.Invoke(null, ARGS); //Send out the delegate to notify other classes. if (LOGGER_ON) { LOGGER.METHOD_EXIT(); } }
public MAIN_FORM() { InitializeComponent(); LOGGER.METHOD_ENTER(); LOGGER.LOG("The form initialized."); LOGGER.METHOD_EXIT(); }
private void FUNCT_0() { LOGGER.METHOD_ENTER(); LOGGER.LOG("Here!"); FUNCT_1(); LOGGER.METHOD_EXIT(); }
private void BTN_CLICK(object sender, EventArgs e) { LOGGER.METHOD_ENTER(); LOGGER.LOG("Button clicked."); FUNCT_0(); LOGGER.METHOD_EXIT(); }
public void MoneyWindowFunction(int windowsId) { string moneyStr = money.ToString(); GUILayout.BeginHorizontal("box"); GUILayout.Label("修改金钱:"); moneyStr = GUILayout.TextField(moneyStr); try { money = float.Parse(moneyStr); } catch (Exception e) { logger.LOG("金钱值转换异常:" + e.Message); moneyStr = money.ToString(); } if (GUILayout.Button("修改")) { GlobalVariables.GetGlobalVariables().fsmFloatPlayerMoney.Value = money; } if (GUILayout.Button("关闭")) { isShowWindow = false; } GUILayout.EndHorizontal(); GUI.DragWindow(); }
private int FUNCT_1() { LOGGER.METHOD_ENTER(); LOGGER.LOG("Here too!"); FUNCT_2(); LOGGER.METHOD_EXIT_SUCCESS(); return(0); }
/// <summary> /// This method will connect to the database selected. If all goes well, it will echo back the name of the Database. /// </summary> /// <param name="NAME">The name of the database to connect to.</param> /// <returns>On success it will echo back the name of the database. On failure it will return null.</returns> public string CONNECT_TO_DATABASE(string NAME) { if (LOGGER_ON) { LOGGER.METHOD_ENTER(); } if (!FULLY_CONNECTED) //If the connection is not fully connected... { if (LOGGER_ON) { LOGGER.METHOD_EXIT_FAIL(); } return(null); //Escape out. } try { MySqlCommand COMMAND = new MySqlCommand(string.Format("use {0};", NAME), CONNECTION); int RESULT = COMMAND.ExecuteNonQuery(); //Execute command. if (RESULT == 0) //If everything went fine. { if (LOGGER_ON) { LOGGER.LOG(string.Format("Connection to {0} successful.", NAME)); } if (LOGGER_ON) { LOGGER.METHOD_EXIT_SUCCESS(); } return(NAME); //Echo back the database you've connected to. } else //If the command exited with a non-zero code... { if (LOGGER_ON) { LOGGER.LOG(string.Format("ExecuteNonQuery returned {0}.", RESULT)); } if (LOGGER_ON) { LOGGER.METHOD_EXIT_FAIL(); } return(null); } } catch (Exception EX) //If something went wrong... { if (LOGGER_ON) { LOGGER.EXCEPTION(EX.Message); } if (LOGGER_ON) { LOGGER.METHOD_EXIT_FAIL(); } return(null); //Escape out. } }
static void Main(string[] args) { STRING_EXTENSIONS.LOGGER_ON = true; LOGGER.METHOD_ENTER(); LOGGER.LOG("Extensions Test Application"); TRUNCATE_AND_PAD_TEST(); CENTER_TEST(); LOGGER.OPEN_LOG(); LOGGER.METHOD_EXIT(); }
static void CENTER_TEST() { LOGGER.METHOD_ENTER(); LOGGER.LOG("Testing CENTER."); string TEST_STRING = "TEST"; TEST_STRING = TEST_STRING.CENTER(20, '*'); LOGGER.LOG(string.Format("Centered string : {0}", TEST_STRING)); LOGGER.METHOD_EXIT(); }
private void SetCheckGameObjectList(out List <GameObject> checkGameObjectList) { checkGameObjectList = new List <GameObject>(); if (GlobalVariables.GetGlobalVariables().gameObjectEngine == null) { logger.LOG("找不到玩家的引擎,要么装车上了,要么还没碰引擎基本组件"); } else { checkGameObjectList.Add(GlobalVariables.GetGlobalVariables().gameObjectEngine); } if (GlobalVariables.GetGlobalVariables().gameObjectSatsuma == null) { logger.LOG("找不到玩家的车辆,什么?逗我吧..."); } else { checkGameObjectList.Add(GlobalVariables.GetGlobalVariables().gameObjectSatsuma); } }
/// <summary> /// Disconnects from the current database. Note that this method does not indicate success or failure. /// </summary> public void DISCONNECT_FROM_DATABASE() { if (LOGGER_ON) { LOGGER.METHOD_ENTER(); } LOGGER.LOG("Closing connection."); CONNECTION.Close(); //No exceptions are generated by these method calls. if (LOGGER_ON) { LOGGER.METHOD_EXIT(); } }
static void TRUNCATE_AND_PAD_TEST() { LOGGER.METHOD_ENTER(); LOGGER.LOG("Testing TRUNCATE_AND_PAD."); string TEST_STRING = "Very super extremely extra grand enormous string"; LOGGER.LOG(string.Format("Original string: {0}", TEST_STRING)); TEST_STRING = TEST_STRING.TRUNCATE_AND_PAD(10); LOGGER.LOG(string.Format("Truncated string: {0}", TEST_STRING)); TEST_STRING = "Little string"; LOGGER.LOG(string.Format("Original string: {0}", TEST_STRING)); TEST_STRING = TEST_STRING.TRUNCATE_AND_PAD(30, '*'); LOGGER.LOG(string.Format("Padded string: {0}", TEST_STRING)); LOGGER.METHOD_EXIT(); }
private void BTN_USE_SELECTED_TABLE_CLICK(object sender, EventArgs e) { LOGGER.METHOD_ENTER(); string SELECTED_TABLE = DGV_2.SelectedCells[0].Value.ToString(); DataTable TABLE = CONNECTION.GET_TABLE(SELECTED_TABLE); if (TABLE == null) { LOGGER.LOG("GET_METHOD returned nothing."); LOGGER.METHOD_EXIT_FAIL(); } DGV_3.DataSource = TABLE; LBL_TABLE.Text = string.Format("Table {0} Selected", SELECTED_TABLE); LBL_TABLE.Image = Properties.Resources.table_green; GRP_BOX_TABLE.Enabled = false; DGV_2.DataSource = null; DGV_2.Refresh(); LOGGER.METHOD_EXIT_SUCCESS(); }
private int FUNCT_2() { LOGGER.METHOD_ENTER(); LOGGER.LOG("Gonna divide by zero."); try { int ZERO = 0; int NOT_ZERO = 5; int RESULT = NOT_ZERO / ZERO; } catch (Exception EX) { LOGGER.EXCEPTION(EX.Message); LOGGER.METHOD_EXIT_FAIL(); return(-1); } LOGGER.METHOD_EXIT_SUCCESS(); return(0); }
static int Main(string[] args) //Debug setup of this test applicatrion { LOGGER.METHOD_ENTER(); string FILEPATH = args[0]; //Get the filepath. No checks in place because this is a test application. var FRAME_SET = new List <char[, ]>(); //Where the ASCII art will be stored. try { FRAME_SET = ASCII_RENDER.PROCESS_IMAGE(FILEPATH, 30, 30); } //Try to process the image. catch (Exception EX) //If anything failed, catch the exception. { LOGGER.EXCEPTION(EX.Message); //Write the exception to the log. LOGGER.METHOD_EXIT_FAIL(); //Write the failed exit to the log. return(-1); } int RETURN_CODE = ASCII_RENDER.RENDER_IMAGE(FRAME_SET, 10, 10); //Render the image. LOGGER.LOG(string.Format("Return code: {0}", RETURN_CODE)); LOGGER.METHOD_EXIT_SUCCESS(); LOGGER.OPEN_LOG(); return(RETURN_CODE); //Exit with the RENDER_IMAGE return code. }
public void TeleportTo(string teleportObjectName, string targetObjectName) { logger.LOG("远程传送 " + teleportObjectName + " 到 " + targetObjectName); GameObject targetGameObject = GameObject.Find(targetObjectName); if (targetGameObject == null) { logger.LOG("无法找到目标:" + targetObjectName); return; } GameObject teleportObject = GameObject.Find(teleportObjectName); if (teleportObject == null) { logger.LOG("无法找到要传送的目标:" + teleportObjectName); return; } TeleportTo(teleportObject, targetGameObject); }
public override void Update() { if (GlobalVariables.GetGlobalVariables().keyBindShowItemListUI.IsDown()) { GlobalVariables.GetGlobalVariables().itemTransmitter.isShowWindow = !GlobalVariables.GetGlobalVariables().itemTransmitter.isShowWindow; } if (GlobalVariables.GetGlobalVariables().keyBindAddGameObjectToItemList.IsDown()) { if (GlobalVariables.GetGlobalVariables().physicsRaycast.mainCameraRaycastHits != null && GlobalVariables.GetGlobalVariables().physicsRaycast.mainCameraRaycastHits.Length > 0) { foreach (RaycastHit hitInfo in GlobalVariables.GetGlobalVariables().physicsRaycast.mainCameraRaycastHits) { GameObject targetGameObject = hitInfo.collider.gameObject; if (targetGameObject != null && CanPickUp(targetGameObject)) { string partName = targetGameObject.name.Replace("(Clone)", "").Replace("(itemx)", "").Replace("(xxxxx)", ""); string text = partName + "(" + GlobalVariables.GetGlobalVariables().mscTranslate.translateText.TranslateString(partName, TranslateText.DICT_PARTNAME) + ")" + "|" + targetGameObject.GetInstanceID(); if (!itemDict.ContainsKey(text)) { itemDict.Add(text, targetGameObject); } else { logger.LOG(targetGameObject + "已经在背包,不允许拾取(再次传送到垃圾堆)"); } targetGameObject.transform.parent = null; GlobalVariables.GetGlobalVariables().teleport.TeleportTo(targetGameObject, GlobalVariables.GetGlobalVariables().gameObjectLandfillSpawn); } } } } float scrollWheel = Input.GetAxis("Mouse ScrollWheel"); int scrollWheelInt = 0; if (scrollWheel > 0) { scrollWheelInt = -1; } else if (scrollWheel < 0) { scrollWheelInt = 1; } selectItemKeyIndex += scrollWheelInt; if (itemDict.Keys.Count <= selectItemKeyIndex || selectItemKeyIndex < 0) { selectItemKeyIndex = itemDict.Keys.Count - 1; } if (GlobalVariables.GetGlobalVariables().keyBindRemoveGameObjectFormItemList.IsDown()) { if (itemDict.Count > 0 && selectItemKey != null && !"".Equals(selectItemKey)) { logger.LOG("是否在菜单:" + GlobalVariables.GetGlobalVariables().fsmBoolPlayerInMenu.Value); if (GlobalVariables.GetGlobalVariables().fsmBoolPlayerInMenu.Value) { GlobalVariables.GetGlobalVariables().teleport.TeleportTo(itemDict[selectItemKey], GlobalVariables.GetGlobalVariables().gameObjectPalyer); } else { TeleportToCamera(itemDict[selectItemKey]); } itemDict.Remove(selectItemKey); selectItemKey = null; selectItemKeyIndex--; if (selectItemKeyIndex < 0) { selectItemKeyIndex = 0; } } } }
private void FORM_LOAD(object sender, EventArgs e) { LOGGER.METHOD_ENTER(); LOGGER.LOG("The form loaded."); LOGGER.METHOD_EXIT(); }
public void InitTranslateApi() { autoTranslateApiAppId = translateTextDict[DICT_CONFIG]["AUTO_TRANSLATE_API_APP_ID"]; autoTranslateApiApikey = translateTextDict[DICT_CONFIG]["AUTO_TRANSLATE_API_API_KEY"]; isEnableAutoTranslateApi = translateTextDict[DICT_CONFIG]["IS_ENABLE_AUTO_TRANSLATE_API"].ToLower() == "true"; logger.LOG("自动翻译API启用状态 :" + isEnableAutoTranslateApi); logger.LOG("自动翻译API appid :" + autoTranslateApiAppId); logger.LOG("自动翻译API apikey :" + autoTranslateApiApikey); if (isEnableAutoTranslateApi) { translateApi = new TranslateApi(autoTranslateApiAppId, autoTranslateApiApikey); logger.LOG("初始化自动翻译API完成"); } else { logger.LOG("不使用自动翻译API"); translateApi = null; } }
public override void OnLoad() { try { GlobalVariables.GetGlobalVariables().mscTranslateChs = this; Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindShowWelcomeWindows); Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindHideWelcomeWindows); Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindTargetTeleportToPlayer); Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindStaticTargetTeleportToPlayer); Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindPlayerTeleportToTarget); Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindGameOverTextToTxt); Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindAddGameObjectToItemList); Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindRemoveGameObjectFormItemList); Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindShowItemListUI); Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindShowDevelopWindows); Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindHideDevelopWindows); Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindReadAllTxt); Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindWriteGameObjectToTxt); Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindWriteFVToTxt); Keybind.Add(this, GlobalVariables.GetGlobalVariables().keyBindShowOtherBolt); } catch (Exception e) { logger.LOG("OnLoad Exception : " + e.Message); logger.LOG(e); } }
/// <summary> /// Connects to the database defined in intialization. /// </summary> /// <returns> /// <para> 0: Connection success.</para> /// <para> 1: A connection-level error occurred while opening the connection.</para> /// <para> 2: Cannot open a connection without specifying a data source or server.</para> /// <para> 3: Unhandled exception type.</para> /// </returns> public int CONNECT_TO_HOST(string HOST, string PORT, string USER, string PASSWORD) { if (LOGGER_ON) { LOGGER.METHOD_ENTER(); } try { string CONNECTION_STRING_NO_PW = "server=" + HOST + ";User ID=" + USER + ";Port=" + PORT; string CONNECTION_STRING = CONNECTION_STRING_NO_PW + ";Password="******";Password={Hidden, nice try}"; if (LOGGER_ON) { LOGGER.LOG(string.Format("Connection string constructed: {0}", CONNECTION_STRING_HIDDEN_PW)); } CONNECTION.ConnectionString = CONNECTION_STRING; CONNECTION.Open(); } catch (Exception EX) { if (LOGGER_ON) { LOGGER.EXCEPTION(EX.Message); } if (EX.InnerException is MySqlException) { if (LOGGER_ON) { LOGGER.EXCEPTION("A connection-level error occurred while opening the connection."); } if (LOGGER_ON) { LOGGER.METHOD_EXIT_FAIL(); } return(1); } else if (EX.InnerException is InvalidOperationException) { if (LOGGER_ON) { LOGGER.EXCEPTION("Cannot open a connection without specifying a data source or server."); } if (LOGGER_ON) { LOGGER.METHOD_EXIT_FAIL(); } return(2); } else { if (LOGGER_ON) { LOGGER.EXCEPTION("Unhandled exception type."); } if (LOGGER_ON) { LOGGER.METHOD_EXIT_FAIL(); } return(3); } } if (LOGGER_ON) { LOGGER.METHOD_EXIT_SUCCESS(); } return(0); }
private void GuiGameObjectExplorerWindows(int windowsId) { if (GUILayout.Button("关闭 unity版本:" + Application.unityVersion)) { isShow = false; } try { scrollPosition = GUILayout.BeginScrollView(scrollPosition); GUILayout.BeginArea(new Rect(0, 0, 500, 600)); if (GUILayout.Button("所有GameObject列表(先输筛选的文本再点)")) { parentGameObject = null; gameObjectList = GameObjectUtil.GetAllGameObject(); } if (GUILayout.Button("所有GameObject写入txt(out目录,会卡到吐血)")) { parentGameObject = null; gameObjectList = GameObjectUtil.GetAllGameObject(); string text = ""; int index = 0; foreach (GameObject gameObject in gameObjectList) { text += GameObjectUtil.GetGameObjectText(gameObject, 0, true, true, true, false, false); text += "\n"; logger.LOG("写入gameObject ->" + index++); File.WriteAllText(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "out/_AllGameObject" + index + "_" + gameObject.name + ".txt"), text); } } GUILayout.BeginHorizontal(); if (GUILayout.Button("读取根节点")) { parentGameObject = null; // gameObjectList = new List<GameObject>(Application. UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects()); gameObjectList = GameObjectUtil.GetRootGameObject(); } if (parentGameObject != null) { if (GUILayout.Button("<")) { if (parentGameObject.transform.parent == null) { parentGameObject = null; gameObjectList = GameObjectUtil.GetRootGameObject(); // gameObjectList = new List<GameObject>( UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects()); } else { gameObjectList = GameObjectUtil.GetChildGameObjectList(parentGameObject.transform.parent.gameObject); parentGameObject = parentGameObject.transform.parent.gameObject; } } } GUILayout.EndHorizontal(); searchName = GUILayout.TextField(searchName); gameObjectListScrollPosition = GUILayout.BeginScrollView(gameObjectListScrollPosition); if (gameObjectList != null) { foreach (GameObject gameObject in gameObjectList) { if (searchName != null && !searchName.Equals("")) { if (gameObject.name.ToLower().IndexOf(searchName.ToLower()) == -1) { continue; } } GUILayout.BeginHorizontal(); if (GUILayout.Button(gameObject.name)) { selectGameObject = gameObject; selectGameObjectComponent = new List <Component>(gameObject.GetComponents <Component>()); } if (GUILayout.Button(">")) { parentGameObject = gameObject; gameObjectList = GameObjectUtil.GetChildGameObjectList(gameObject); } if (GUILayout.Button("传过去")) { GlobalVariables.GetGlobalVariables().teleport.TeleportTo(GameObjectUtil.GetGameObjectPath(gameObject)); } if (GUILayout.Button("传过来")) { GameObject playerGameObject = GameObject.Find("PLAYER"); Vector3 clonePosition = new Vector3(playerGameObject.transform.position.x, playerGameObject.transform.position.y + 3f, playerGameObject.transform.position.z); gameObject.transform.position = clonePosition; } if (GUILayout.Button("克隆")) { GameObject playerGameObject = GameObject.Find("PLAYER"); Vector3 clonePosition = new Vector3(playerGameObject.transform.position.x, playerGameObject.transform.position.y + 3f, playerGameObject.transform.position.z); // GameObject cloneGameObject = MonoBehaviour.Instantiate(gameObject, clonePosition, gameObject.transform.rotation) as GameObject; gameObject.SetActive(false); GameObject cloneGameObject = GameObject.Instantiate(gameObject); cloneGameObject.transform.position = clonePosition; } if (gameObject.activeSelf == false) { if (GUILayout.Button("启用")) { gameObject.SetActive(true); } } else { if (GUILayout.Button("禁用")) { gameObject.SetActive(false); } } GUILayout.EndHorizontal(); } } GUILayout.EndScrollView(); GUILayout.EndArea(); GUILayout.BeginArea(new Rect(500, 0, 500, 600)); if (selectGameObject != null) { GUILayout.Label("选中GameObject:" + GameObjectUtil.GetGameObjectPath(selectGameObject)); if (GUILayout.Button("写入txt")) { File.WriteAllText(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "_gameObject.txt"), GameObjectUtil.GetGameObjectText(selectGameObject, 0, true, true, true, false, false)); } viewScrollPosition = GUILayout.BeginScrollView(viewScrollPosition); string text = ""; foreach (Component component in selectGameObjectComponent) { Type type = component.GetType(); GUILayout.Label(type.FullName); GUILayout.BeginVertical("box"); foreach (FieldInfo fieldInfo in type.GetFields()) { string view = fieldInfo.Name + " : " + fieldInfo.GetValue(component); text += view + "\n"; GUILayout.Label(view); } foreach (PropertyInfo propertyInfo in type.GetProperties()) { try { string view = " " + propertyInfo.Name + " : \n" + propertyInfo.GetValue(component, null); text += view + "\n"; GUILayout.Label(view); } catch (Exception e) { string view = " " + propertyInfo.Name + " : \n Error " + e.Message; text += view + "\n"; GUILayout.Label(view); } } if (component.GetType().Name.Equals("PlayMakerFSM")) { PlayMakerFSM playMakerFSM = component as PlayMakerFSM; string view = "Component is PlayMakerFSM : \n" + FsmVariablesUtil.GetAllFsmVariablesAndVaule(playMakerFSM.FsmVariables); text += view + "\n"; GUILayout.Label(view); } GUILayout.EndVertical(); } if (GUILayout.Button("写入显示内容到txt")) { File.WriteAllText(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "_gameObjectViewText.txt"), text); } GUILayout.EndScrollView(); } GUILayout.EndArea(); GUILayout.EndScrollView(); } catch (Exception e) { GUILayout.Label("exception : " + e.Message); } GUI.DragWindow(); }