void PlayEvent() { switch (eventTag) { case Event.enemy: Enemies(); break; case Event.cutscene: Cutscenes(); break; case Event.text: Text(); break; case Event.evento: myEvent.Invoke(); break; case Event.multiplosEventos: startRandomize = true; break; case Event.eventoAutoDestroi: myEvent.Invoke(); Destroy(this); break; } }
void RandomizeSounds() { if (timeToPlay >= 0) { timeToPlay -= Time.deltaTime; } else { timeToPlay = Random.Range(5f, 10f); int randomOp = Random.Range(1, 4); switch (randomOp) { case 1: randomEvent1.Invoke(); break; case 2: randomEvent2.Invoke(); break; case 3: randomEvent3.Invoke(); break; case 4: randomEvent4.Invoke(); break; } } }
void ComputeSwipeDirection(Vector2 initialPosition, Vector2 currentPosition) { InfoOnTouch infoOnTouch = new InfoOnTouch(); Vector2 helperVector = currentPosition - initialPosition; if (Mathf.Abs(helperVector.x) > Mathf.Abs(helperVector.y)) { if (Math.Sign(helperVector.x) == -1) { infoOnTouch.Swipe = SwipeDirection.LEFT; } else { infoOnTouch.Swipe = SwipeDirection.RIGHT; } infoOnTouch.DistanceSwiped = helperVector.x; } else { if (Math.Sign(helperVector.y) == -1) { infoOnTouch.Swipe = SwipeDirection.DOWN; } else { infoOnTouch.Swipe = SwipeDirection.UP; } infoOnTouch.DistanceSwiped = helperVector.y; } OnTouchEvent?.Invoke(this, infoOnTouch); }
private void TouchController() { #if UNITY_EDITOR if (Input.GetMouseButtonDown(0)) { OnTouchDown?.Invoke(Input.mousePosition, 0); } if (Input.GetMouseButton(0)) { OnTouch?.Invoke(Input.mousePosition, 0); } if (Input.GetMouseButtonUp(0)) { OnTouchUp?.Invoke(Input.mousePosition, 0); } #elif UNITY_ANDROID || UNITY_IOS Touch[] activeTouches = Input.touches; int touchCount = activeTouches.Length; for (int i = 0; i < touchCount; i++) { switch (activeTouches[i].phase) { case TouchPhase.Began: OnTouchDown?.Invoke(activeTouches[i].position, i); break; case TouchPhase.Stationary: OnTouch?.Invoke(activeTouches[i].position, i); break; case TouchPhase.Moved: OnTouch?.Invoke(activeTouches[i].position, i); break; case TouchPhase.Ended: OnTouchUp?.Invoke(activeTouches[i].position, i); break; case TouchPhase.Canceled: OnTouchUp?.Invoke(activeTouches[i].position, i); break; } } #endif }
void FixedUpdate() { if (Input.touchCount > 0) { touch = Input.GetTouch(0); if (lastTouchPositionX.Equals(0f)) { lastTouchPositionX = touch.position.x; } else { ratio = (touch.position.x - lastTouchPositionX) / Screen.width; lastTouchPositionX = touch.position.x; OnTouchEvent?.Invoke(ratio); } } else { lastTouchPositionX = 0f; } }
public void OnTouchAction(Element element, TouchActionEventArgs args) { OnTouchEvent?.Invoke(element, args); }
void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData) => OnTouchEvent?.Invoke(new TouchEvent(TouchState.Enter, Stone));
void IPointerUpHandler.OnPointerUp(PointerEventData eventData) => OnTouchEvent?.Invoke(new TouchEvent(TouchState.Up, Stone));
void IPointerDownHandler.OnPointerDown(PointerEventData eventData) => OnTouchEvent?.Invoke(new TouchEvent(TouchState.Down, Stone));
protected virtual void OnTouchElement(IElement element, SKTouchEventArgs e) { OnTouchEvent?.Invoke(element, e); }