// Update is called once per frame void Update() { if (lastHoveredTile != null) { UpdateTooltipPos(); } if (UIMainControl.InTouchMode()) { return; } if (UI.IsCursorOnUI(-1)) { if (tooltipObj.activeInHierarchy) { _SetNewHoveredTile(null); } return; } Tile tile = GridManager.GetHoveredTile(); if (tile != lastHoveredTile) { _SetNewHoveredTile(tile); } }
private void TileCursor() { if (!enableTileCursor) { return; } if (GridManager.GetHoveredTile() == null) { cursorIndicatorF.gameObject.SetActive(false); cursorIndicatorH.gameObject.SetActive(false); } else { cursorIndicatorF.position = GridManager.GetHoveredTile().GetPos() + new Vector3(0, 0.05f, 0); cursorIndicatorH.position = GridManager.GetHoveredTile().GetPos() + new Vector3(0, 0.05f, 0); bool attackable = GridManager.CanAttackTile(GridManager.GetHoveredTile()); //Tile currentTile=GameControl.GetSelectedUnit()!=null ? GameControl.GetSelectedUnit().tile : null ; //bool selected=GridManager.GetHoveredTile()==currentTile; cursorIndicatorH.gameObject.SetActive(attackable); // & !selected); cursorIndicatorF.gameObject.SetActive(!attackable); // & !selected); } //~ Tile tile=GridManager.GetHoveredTile(Input.mousePosition); //~ bool showIndicator=(tile!=null);// && tile.gameObject.activeInHierarchy); //~ if(tile!=null) cursorIndicator.position=tile.GetPos(); //~ cursorIndicator.gameObject.SetActive(showIndicator); }
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(); }
IEnumerator OnLeftCursorDown(int pointer = -1) { yield return(null); if (UI.IsCursorOnUI(pointer)) { yield break; } Tile tile = GridManager.GetHoveredTile(); if (tile != null) { if (GameControl.GetGamePhase() == _GamePhase.UnitDeployment) { GridManager.OnCursorDown(); yield break; } if (AbilityManager.InTargetMode()) { GridManager.OnCursorDown(); yield break; } heldTile = tile; holdStartedTime = Time.time; if (touchMode && GridManager.CanAttackTile(GridManager.GetHoveredTile())) { NewClickTile(tile); } else if (touchMode && GridManager.CanMoveToTile(GridManager.GetHoveredTile())) { NewClickTile(tile); } else { if (!GridManager.CanPerformAction(tile)) { //ClearLastClickTile(); dont call last click tile, we dont want to hide unit info if there's any lastClickTile = null; UIInputOverlay.SetNewHoveredTile(null); } else { GridManager.OnCursorDown(); //ClearLastClickTile() will be called as soon as unit move or attack or cast ability } } } else { ClearLastClickTile(); } //~ if(tile!=null){ //~ if(tile.unit!=null){ //~ if(!GameControl.CanSelectUnit(tile.unit)) UIUnitInfo.Show(tile); //~ else{ //~ GridManager.OnCursorDown(); //~ UIUnitInfo.Hide(); //~ return; //~ } //~ } //~ else UIUnitInfo.Hide(); //~ if(touchMode && GridManager.CanAttackTile(GridManager.GetHoveredTile())){ //~ NewClickTile(tile); //~ } //~ else if(touchMode && GridManager.CanMoveToTile(GridManager.GetHoveredTile())){ //~ NewClickTile(tile); //~ } //~ else{ //~ if(!GridManager.CanPerFormAction(tile)){ //~ //ClearLastClickTile(); dont call last click tile, we dont want to hide unit info if there's any //~ lastClickTile=null; //~ UIInputOverlay.SetNewHoveredTile(null); //~ } //~ else GridManager.OnCursorDown(); //ClearLastClickTile() will be called as soon as unit move or attack or cast ability //~ } //~ } //~ else ClearLastClickTile(); }