public override void execute() { // make a lane selection GameObject laneGo = null; bool hadInput = false; // Look for all fingers for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); Ray ray = Camera.main.ScreenPointToRay(touch.position); if (HitUtils.detectHitLane(ray, out laneGo)) { selectionTime += Time.deltaTime; hadInput = true; } } if (!mouseDown && Input.touchCount == 0) { //Touch was released, stop counting selectionTime = 0f; } if (Input.GetMouseButtonUp(0)) { selectionTime = 0f; mouseDown = false; } if (Input.GetMouseButtonDown(0)) { mouseDown = true; } if (mouseDown && Input.GetMouseButton(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (HitUtils.detectHitLane(ray, out laneGo)) { selectionTime += Time.deltaTime; hadInput = true; } } if (hadInput && selectionTime >= 1f) { selectionTime = 0f; mouseDown = false; SelectedLane = laneGo.GetComponent <Lane>(); checkReveal(); } }
private void handleTouch() { bool hadTouch = Input.touchCount > 0; bool hitHand = false; bool hitLane = false; GameObject lane = null; // Look for all fingers for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); Ray ray = Camera.main.ScreenPointToRay(touch.position); GameObject card = HitUtils.detectHandCardHit(ray, gameObject.transform); if (card != null) { selectCard(card); hitHand = true; } if (!hitHand && selectedCard != null && !hitLane) { //if hand card was already selected, check if a lane was selected hitLane = HitUtils.detectHitLane(ray, out lane); } } if (hadTouch && hitLane) { tryPlayCard(lane); } if (hadTouch && !hitHand && !hitLane) { //handle hand deselection here selectLapse = 0f; selectedCard = null; highlightManager.select(null); } }
private void handleMouseAndKeyboard() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); GameObject card = HitUtils.detectHandCardHit(ray, gameObject.transform); if (Input.GetMouseButtonDown(0)) { GameObject lane = null; bool hitLane = HitUtils.detectHitLane(ray, out lane); if (card != null) { selectCard(card); } else if (selectedCard != null && !hitLane) { //Deselect hand card selectLapse = 0f; selectedCard = null; highlightManager.select(null); } else if (hitLane) { tryPlayCard(lane); } } else if (card != null && selectedCard == null) { // add a hover effect on what would be the current selection highlightManager.select(card.transform); } else if (selectedCard == null) { // remove hover effect highlightManager.select(null); } }