void Update() { float mouseWheel = Input.GetAxis("Mouse ScrollWheel"); if (mouseWheel > 0.0f) { if (Camera.main.orthographic) { Camera.main.orthographicSize *= 0.9f; } else { Camera.main.transform.position = Vector3.Scale(Camera.main.transform.position, new Vector3(1.0f, 0.9f, 1.0f)); } } else if (mouseWheel < 0.0f) { if (Camera.main.orthographic) { Camera.main.orthographicSize *= 1.0f / 0.9f; } else { Camera.main.transform.position = Vector3.Scale(Camera.main.transform.position, new Vector3(1.0f, 1.0f / 0.9f, 1.0f)); } } if (!menuEnabled && !GetComponent <WarpDialog>().warpMenuEnabled) { //start drag if (Input.GetMouseButtonDown(0)) { mousePosition = Input.mousePosition; } //dragging if (Input.GetMouseButton(0)) { Vector3 newMousePosition = Input.mousePosition; if (newMousePosition != this.mousePosition) { Vector3 cameraHeight = new Vector3(0.0f, 0.0f, Camera.main.transform.position.y); Vector3 mouseDelta = Camera.main.ScreenToWorldPoint(this.mousePosition + cameraHeight) - Camera.main.ScreenToWorldPoint(newMousePosition + cameraHeight); Camera.main.transform.position += mouseDelta; mousePosition = newMousePosition; } } } //menu if (Input.GetMouseButtonDown(1)) { WarpDialog warpDialog = GetComponent <WarpDialog>(); if (menuEnabled) { menuEnabled = false; } else if (warpDialog.warpMenuEnabled) { warpDialog.warpMenuEnabled = false; } else if (DetectGame() == 1 && HighLightedBox != null && HighLightedBox.name == "Actor") { warpDialog.LoadActor(HighLightedBox); warpDialog.warpMenuEnabled = true; } else if (!GetComponent <Vars>().enabled) { menuEnabled = true; } } if (Input.GetMouseButtonUp(0) && !RectTransformUtility.RectangleContainsScreenPoint(Panel, Input.mousePosition)) { menuEnabled = false; } if (menuEnabled != Panel.gameObject.activeSelf) { Panel.gameObject.SetActive(menuEnabled); } RefreshHighLightedBox(); if (!GetComponent <WarpDialog>().warpMenuEnabled) { foreach (var key in keyCodes) { if (Input.GetKeyDown(key)) { ProcessKey(key); } } } }
void Update() { float mouseWheel = Input.GetAxis("Mouse ScrollWheel"); if (mouseWheel != 0.0f) { Vector3 cameraHeight = new Vector3(0.0f, 0.0f, Camera.main.transform.position.y); Vector3 mouseBeforeZoom = Camera.main.ScreenToWorldPoint(Input.mousePosition + cameraHeight); float scale = 0.9f; if (mouseWheel < 0.0f) { scale = 1.0f / scale; } if (Camera.main.orthographic) { Camera.main.orthographicSize *= scale; } else { Camera.main.transform.position = Vector3.Scale(Camera.main.transform.position, new Vector3(1.0f, scale, 1.0f)); } cameraHeight = new Vector3(0.0f, 0.0f, Camera.main.transform.position.y); Camera.main.transform.position += mouseBeforeZoom - Camera.main.ScreenToWorldPoint(Input.mousePosition + cameraHeight); } if (!menuEnabled && !GetComponent <WarpDialog>().WarpMenuEnabled) { //start drag if (Input.GetMouseButtonDown(0)) { dragging = false; mousePosition = startDragPosition = Input.mousePosition; } //dragging if (Input.GetMouseButton(0)) { Vector3 newMousePosition = Input.mousePosition; if (newMousePosition != this.mousePosition) { Vector3 cameraHeight = new Vector3(0.0f, 0.0f, Camera.main.transform.position.y); Vector3 mouseDelta = Camera.main.ScreenToWorldPoint(this.mousePosition + cameraHeight) - Camera.main.ScreenToWorldPoint(newMousePosition + cameraHeight); Camera.main.transform.position += mouseDelta; mousePosition = newMousePosition; if ((startDragPosition - newMousePosition).magnitude > 4.0f) { dragging = true; } } } } //menu if (Input.GetMouseButtonDown(1)) { WarpDialog warpDialog = GetComponent <WarpDialog>(); if (menuEnabled) { menuEnabled = false; } else if (warpDialog.WarpMenuEnabled) { warpDialog.WarpMenuEnabled = false; if (speedRunMode) { warpDialog.WarpActorBox = null; //reset to player warpDialog.WarpActorBoxId = -1; } } else if (dosBoxEnabled && highLightedBox != null && highLightedBox.name == "Actor") { warpDialog.LoadActor(highLightedBox); warpDialog.WarpMenuEnabled = true; } else { menuEnabled = true; } } if (Input.GetMouseButtonUp(0) && !RectTransformUtility.RectangleContainsScreenPoint(Panel, Input.mousePosition)) { menuEnabled = false; } if (menuEnabled != Panel.gameObject.activeSelf) { Panel.gameObject.SetActive(menuEnabled); } DosBox dosBox = GetComponent <DosBox>(); dosBox.ShowAdditionalInfo = ShowAdditionalInfo.BoolValue && dosBoxEnabled; dosBox.ShowAITD1Vars = dosBox.ShowAdditionalInfo && isAITD1 && dosBox.IsCDROMVersion; dosBox.SpeedRunMode = speedRunMode; dosBox.RefreshMemory(); dosBox.CalculateFPS(); dosBox.UpdateAllActors(); dosBox.UpdateBoxInfo(); if (isAITD1) { dosBox.UpdateTargetSlot(highLightedBox); } RefreshHighLightedBox(); RefreshSelectedBox(); //process keys if (!GetComponent <WarpDialog>().WarpMenuEnabled) { foreach (var key in keyCodes) { if (Input.GetKeyDown(key)) { ProcessKey(key); } } } //automatic link if (!dosBoxEnabled && linkToDosBoxTimer.Elapsed > 1.0f) { LinkToDosBox(); linkToDosBoxTimer.Restart(); } }