Esempio n. 1
0
    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;
        }
    }
Esempio n. 2
0
    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);
    }
Esempio n. 4
0
        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
        }
Esempio n. 5
0
 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;
     }
 }
Esempio n. 6
0
 public void OnTouchAction(Element element, TouchActionEventArgs args)
 {
     OnTouchEvent?.Invoke(element, args);
 }
Esempio n. 7
0
 void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData) => OnTouchEvent?.Invoke(new TouchEvent(TouchState.Enter, Stone));
Esempio n. 8
0
 void IPointerUpHandler.OnPointerUp(PointerEventData eventData) => OnTouchEvent?.Invoke(new TouchEvent(TouchState.Up, Stone));
Esempio n. 9
0
 void IPointerDownHandler.OnPointerDown(PointerEventData eventData) => OnTouchEvent?.Invoke(new TouchEvent(TouchState.Down, Stone));
 protected virtual void OnTouchElement(IElement element, SKTouchEventArgs e)
 {
     OnTouchEvent?.Invoke(element, e);
 }