예제 #1
0
 void OnMouseDown()
 {
     if (MobileEvents.OnMobileUse != null)
     {
         MobileEvents.OnMobileUse();
     }
 }
예제 #2
0
 void OnMouseUp()
 {
     if (MobileEvents.OnMobileUseUp != null)
     {
         MobileEvents.OnMobileUseUp();
     }
 }
예제 #3
0
 public void CloseInventory()
 {
     if (MobileEvents.OnMobileInventoryWantsClosed != null)
     {
         MobileEvents.OnMobileInventoryWantsClosed();
     }
 }
예제 #4
0
 public void OpenInventory()
 {
     if (MobileEvents.OnMobileInventory != null)
     {
         MobileEvents.OnMobileInventory();
     }
 }
예제 #5
0
 public void OnPointerUp(PointerEventData eventData)
 {
     if (MobileEvents.OnMobileUseUp != null)
     {
         MobileEvents.OnMobileUseUp();
     }
 }
예제 #6
0
 public void OnPointerDown(PointerEventData eventData)
 {
     if (MobileEvents.OnMobileUse != null)
     {
         MobileEvents.OnMobileUse();
     }
 }
예제 #7
0
    public void CloseInventory()
    {
        if (spawnRoutine != null)
        {
            StopCoroutine(spawnRoutine);
        }
        spawnRoutine = SpawnItems(false);
        StartCoroutine(spawnRoutine);

        if (MobileEvents.OnMobileInventoryClosed != null)
        {
            MobileEvents.OnMobileInventoryClosed();
        }
    }
예제 #8
0
    public void OnDrag(PointerEventData eventData)
    {
        Vector2 pos;

        if (RectTransformUtility.ScreenPointToLocalPointInRectangle(JoystickBackground.rectTransform, eventData.position, eventData.pressEventCamera, out pos))
        {
            //Recalculate to local space
            pos.x /= JoystickBackground.rectTransform.sizeDelta.x;
            pos.y /= JoystickBackground.rectTransform.sizeDelta.y;

            inputVector = pos;
            float inputLength = inputVector.magnitude;
            if (inputLength > 1)
            {
                inputVector.Normalize();
            }

            if (inputLength >= 0.98f)
            {
                if (MobileEvents.OnMobileSprintDown != null)
                {
                    MobileEvents.OnMobileSprintDown();
                }
                sentSprint = true;
            }
            else
            {
                if (sentSprint)
                {
                    if (MobileEvents.OnMobileSprintUp != null)
                    {
                        MobileEvents.OnMobileSprintUp();
                    }
                    sentSprint = false;
                }
            }

            //Move handle image
            JoystickHandle.rectTransform.position = JoystickBackground.rectTransform.position + new Vector3(JoystickBackground.rectTransform.sizeDelta.x * inputVector.x, JoystickBackground.rectTransform.sizeDelta.y * inputVector.y, 0);
        }
    }
예제 #9
0
    public void OnPointerUp(PointerEventData eventData)
    {
        ray = mainCam.ScreenPointToRay(eventData.position);

        if (Physics.RaycastNonAlloc(ray, hits, 10f, interactionLayers, QueryTriggerInteraction.Collide) > 0)
        {
            for (int i = 0; i < hits.Length; i++)
            {
                if (hits[i].transform != null)
                {
                    if (potentialInteractions.Contains(hits[i].transform))
                    {
                        GameManager.InteractWithObject(hits[i].transform.gameObject);
                    }
                }
            }
        }

        if (MobileEvents.OnMobileUseUp != null)
        {
            MobileEvents.OnMobileUseUp();
        }
    }