void Update() { if (Input.touchCount > 1) { return; } //if(TBTK.UI.IsCursorOnUI(0) || TDTK.UI.IsCursorOnUI()) return; int pointerID = Input.touchCount > 0 ? 0 : -1; //~ if(!touchMode){ //~ if(Input.GetMouseButtonDown(0)) OnLeftCursorDown(pointerID); //~ else if(Input.GetMouseButtonDown(1)) OnRightCursorDown(pointerID); //~ } //~ else{ if (Input.GetMouseButtonDown(0)) { StartCoroutine(OnLeftCursorDown(pointerID)); } else { UpdateTapAndHold(Input.GetMouseButton(0), pointerID); } if (Input.GetMouseButtonDown(1)) { if (!touchMode) { Tile tile = GridManager.GetHoveredTile(); if (tile != null && tile.unit != null) { UIUnitInfo.Show(tile); } else { UIUnitInfo.Hide(); } } else { ClearLastClickTile(); } //~ Tile hoveredTile=GridManager.GetHoveredTile(); //~ Debug.Log("Distance: "+GridManager.GetDistance(hoveredTile, GameControl.GetSelectedUnit().tile)+" "+hoveredTile+" "+GameControl.GetSelectedUnit().tile); //~ FogOfWar.InLOS(hoveredTile, GameControl.GetSelectedUnit().tile, true); } //~ } }
//~ void OnRightCursorDown(int pointer=-1){ //~ if(GridManager.GetHoveredTile()!=null) GridManager.OnCursorDown(); //~ ClearLastClickTile(); //~ } void UpdateTapAndHold(bool isHeld, int pointerID) { if (isHeld && !UI.IsCursorOnUI(pointerID)) { Tile tile = GridManager.GetHoveredTile(); if (tile != null && tile.unit != null) // && touchMode && !GameControl.CanSelectUnit(tile.unit)) { if (heldTile == tile) { if (holdStartedTime > 0 && Time.time - holdStartedTime > holdThreshhold) { UIUnitInfo.Show(tile); } return; } } } holdStartedTime = -1f; UIUnitInfo.Hide(); }
private void ClearLastClickTile() { lastClickTile = null; UIUnitInfo.Hide(); UIInputOverlay.SetNewHoveredTile(null); }