예제 #1
0
 public void AbortMethod()
 {
     card.Deselect();
     inputManager.currentSelectedCard = null;
     if (captasUse != null)
     {
         StopCoroutine(captasUse);
     }
 }
예제 #2
0
 public void AbortMethod()
 {
     card.Deselect();
     sonobuyDeployer.Abort();
     inputManager.currentSelectedCard = null;
 }
예제 #3
0
 public void AbortMethod()
 {
     card.Deselect();
     inputManager.getEntityTarget     = false;
     inputManager.currentSelectedCard = null;
 }
    void Update()
    {
        //Tap Input
        if (Input.touchCount == 1)
        {
            touch = Input.GetTouch(0);

            pointerData          = new PointerEventData(currentEventSystem);
            pointerData.position = touch.position;
            currentEventSystem.RaycastAll(pointerData, raycastResults);

            if (raycastResults.Count < 1 || (raycastResults.Count == 1 && raycastResults[0].gameObject.TryGetComponent <InteractableUI>(out var I)))
            {
                touchingGame = true;

                if (getEntityTarget)
                {
                    gettingEntityTarget = true;

                    //Get the sea position and pass it to the player controller
                    touchedSeaPosition = GetSeaPosition();

                    //Move with gizmo if not dragging a card
                    if (!isDraggingCard)
                    {
                        playerController.SetEntityMoveTarget(touchedSeaPosition);
                    }
                }
                else
                {
                    if (canUseCam)
                    {
                        //If touched check if selected a Entity
                        if (touch.phase == TouchPhase.Began)
                        {
                            RaycastHit hit;
                            Ray        touchRay;
                            touchRay = mainCamera.ScreenPointToRay(touch.position);
                            if (Physics.Raycast(touchRay, out hit, 200f, selectableEntityLayer))
                            {
                                playerController.currentSelectedEntity = hit.collider.transform.parent.GetComponent <PlayerOceanEntity>();
                                camController.SetTarget(hit.collider.transform);

                                //Select Button
                                GameManager.Instance.playerController.currentSelectedEntity.linkedButton.SelectEntity();
                            }
                        }

                        //If drag then move camera
                        else if (touch.deltaPosition.magnitude > 5f)
                        {
                            camController.moveDirection = -touch.deltaPosition;
                        }
                    }
                }
            }

            if (touch.deltaPosition.magnitude < 5f)
            {
                camController.moveDirection = Vector2.zero;
            }
        }

        //Glide Input
        else if (Input.touchCount == 2)
        {
            Vector2 touch0;
            Vector2 touch1;

            touch0 = Input.GetTouch(0).position;
            touch1 = Input.GetTouch(1).position;

            if (distance == 0)
            {
                distance = Vector2.Distance(touch0, touch1);
            }

            lastDistance = distance;
            distance     = Vector2.Distance(touch0, touch1);
            float deltaDistance = distance - lastDistance;

            if (deltaDistance > 1 && camController.zoomIntensity <= 1)
            {
                camController.zoomIntensity -= (0.01f * camController.zoomSpeed) * (1 - Mathf.Clamp01(0.01f * deltaDistance));
                camController.zoomIntensity  = Mathf.Clamp01(camController.zoomIntensity);
            }
            else if (deltaDistance < -1 && camController.zoomIntensity >= 0)
            {
                camController.zoomIntensity += (0.01f * camController.zoomSpeed) * (1 - Mathf.Clamp01(0.01f * deltaDistance));
                camController.zoomIntensity  = Mathf.Clamp01(camController.zoomIntensity);
            }
        }

        //No fingers on screen.
        else if (Input.touchCount == 0)
        {
            camController.moveDirection = Vector2.zero;
            distance = 0;

            touchingGame = false;

            if (gettingEntityTarget)
            {
                if (playerController.currentSelectedEntity.GetType() != typeof(Helicopter))
                {
                    getEntityTarget     = false;
                    gettingEntityTarget = false;
                    if (currentSelectedCard != null)
                    {
                        currentSelectedCard.Deselect();
                    }


                    playerController.SetEntityMoveTarget(touchedSeaPosition);
                    touchedSeaPosition = new Vector2(-9999, -9999);

                    soundHandler.PlaySound(setTargetSound, audioSource, targetGroup);
                }
            }
        }
    }