void Update() { if (!UIDialogMessage.IsShow() && Input.GetKeyDown(KeyCode.Escape)) { Hide(); } }
void Update() { if (!UIDialogMessage.IsShow() && Input.GetKeyDown(KeyCode.Escape)) { _Hide(); } if (bdNext != null) { Available = bdNext.PriceInfoCheck(Price); } }
void Update() { if (!UIDialogMessage.IsShow() && Input.GetKeyDown(KeyCode.Escape)) { _Hide(); } int GenCountTotal = 0; int GenTimeTotal = 0; for (int i = 0; i < building.queUnitGen.Count; ++i) { GenQueItem item = building.queUnitGen[i]; GenCountTotal += item.Count; GenTimeTotal += item.GetGenLeftTime(); } TrainingInfo.text = "Train Troops " + GenCountTotal.ToString() + "/" + bd.TrainingQueueMax.ToString(); CapacityInfo.text = "Troop capacity after training: 51 / 200"; TimeLeft.text = BENumber.SecToString(GenTimeTotal); GemCount.text = "10,000"; }
void Update() { // get delta time from BETime float deltaTime = BETime.deltaTime; // if user pressed escape key, show quit messagebox if (!UIDialogMessage.IsShow() && !isModalShow && Input.GetKeyDown(KeyCode.Escape)) { UIDialogMessage.Show("Do you want to quit this program?", "Yes,No", "Quit?", null, (result) => { MessageBoxResult(result); }); } // if in camera animation if (InFade) { //camera zoom in FadeAge += Time.deltaTime * 0.7f; if (FadeAge > 1.0f) { InFade = false; FadeAge = 1.0f; zoomCurrent = 64.0f; // 游戏开始时放大倍数(最终值) } goCameraRoot.transform.position = Vector3.Lerp(new Vector3(-5.5f, 0, -5), Vector3.zero, FadeAge); goCamera.transform.localPosition = Vector3.Lerp(new Vector3(0, 0, -128.0f), new Vector3(0, 0, -64.0f), FadeAge); // 游戏开始时放大倍数(中间值) } Exp.Update(); Gold.Update(); Elixir.Update(); Gem.Update(); Shield.ChangeTo(Shield.Target() - (double)deltaTime); Shield.Update(); HouseInfo.text = BEWorkerManager.instance.GetAvailableWorkerCount().ToString() + "/" + BEGround.instance.GetBuildingCount(1).ToString(); if (UIDialogMessage.IsShow() || isModalShow) { return; } //if(EventSystem.current.IsPointerOverGameObject()) return; if (Input.GetMouseButton(0)) { if (EventSystem.current.IsPointerOverGameObject()) { //Debug.Log("left-click over a GUI element!"); return; } //Click MouseButton if (!bInTouch) { bInTouch = true; ClickAfter = 0.0f; bTemporarySelect = false; Dragged = false; mousePosOld = Input.mousePosition; mousePosLast = Input.mousePosition; vCamRootPosOld = goCameraRoot.transform.position; //when a building was selected and user drag mouse on the map //check mouse drag start is over selected building or not //if not do not move selected building Ray ray = Camera.main.ScreenPointToRay(mousePosOld); RaycastHit hit; if (Physics.Raycast(ray, out hit) && (hit.collider.gameObject.tag == "Building")) { MouseClickedBuilding = BuildingFromObject(hit.collider.gameObject); } else { MouseClickedBuilding = null; } //Debug.Log ("Update buildingSelected:"+((buildingSelected != null) ? buildingSelected.name : "none")); } else { //Mouse Button is in pressed //if mouse move certain diatance if (Vector3.Distance(Input.mousePosition, mousePosLast) > 0.01f) { // set drag flag on if (!Dragged) { Dragged = true; // show tile grid 显示建筑物降落网格(亮度变0.3) if ((buildingSelected != null) && (MouseClickedBuilding == buildingSelected)) { BETween.alpha(ground.gameObject, 0.1f, 0.0f, 0.3f); //Debug.Log ("ground alpha to 0.1"); } } mousePosLast = Input.mousePosition; // if selected building exist if ((buildingSelected != null) && (MouseClickedBuilding == buildingSelected)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); float enter; xzPlane.Raycast(ray, out enter); Vector3 vTarget = ray.GetPoint(enter); // move selected building buildingSelected.Move(vTarget); } // else camera panning else { if (camPanningUse) { Vector3 vDelta = (Input.mousePosition - mousePosOld) * 0.008f; Vector3 vForward = goCameraRoot.transform.forward; vForward.y = 0.0f; vForward.Normalize(); Vector3 vRight = goCameraRoot.transform.right; vRight.y = 0.0f; vRight.Normalize(); Vector3 vMove = -vForward * vDelta.y + -vRight * vDelta.x; goCameraRoot.transform.position = vCamRootPosOld + vMove; } } } // Not Move else { if (!Dragged) { ClickAfter += Time.deltaTime; if (!bTemporarySelect && (ClickAfter > 0.5f)) { bTemporarySelect = true; //Debug.Log ("Update2 buildingSelected:"+((buildingSelected != null) ? buildingSelected.name : "none")); Pick(); } } } } } else { //Release MouseButton if (bInTouch) { bInTouch = false; // if in drag state if (Dragged) { // seleted building exist if (buildingSelected != null) { // hide tile grid if (MouseClickedBuilding == buildingSelected) { BETween.alpha(ground.gameObject, 0.1f, 0.3f, 0f); } if (buildingSelected.Landable && buildingSelected.OnceLanded) { BuildingLandUnselect(); } } } else { if (bTemporarySelect) { // land building if ((buildingSelected != null) && (MouseClickedBuilding != buildingSelected) && buildingSelected.OnceLanded) { BuildingLandUnselect(); } } else { // land building if ((buildingSelected != null) && (MouseClickedBuilding != buildingSelected) && buildingSelected.OnceLanded) { BuildingLandUnselect(); } //Debug.Log ("Update3 buildingSelected:"+((buildingSelected != null) ? buildingSelected.name : "none")); Pick(); } } } } //zoom if (!InFade) { zoomCurrent -= Input.GetAxis("Mouse ScrollWheel") * zoomSpeed; zoomCurrent = Mathf.Clamp(zoomCurrent, zoomMin, zoomMax); goCamera.transform.localPosition = new Vector3(0, 0, -zoomCurrent); } // pinch zoom for mobile touch input if (Input.touchCount == 2) { // Store both touches. Touch touchZero = Input.GetTouch(0); Touch touchOne = Input.GetTouch(1); // Find the position in the previous frame of each touch. Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition; Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition; // Find the magnitude of the vector (the distance) between the touches in each frame. float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude; float touchDeltaMag = (touchZero.position - touchOne.position).magnitude; // Find the difference in the distances between each frame. float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag; zoomCurrent += deltaMagnitudeDiff * perspectiveZoomSpeed; zoomCurrent = Mathf.Clamp(zoomCurrent, zoomMin, zoomMax); goCamera.transform.localPosition = new Vector3(0, 0, -zoomCurrent); } }