Exemplo n.º 1
0
 private void OnFingerDown(Lean.Touch.LeanFinger finger)
 {
     if (curr_finger == null)
     {
         curr_finger = finger;
     }
 }
Exemplo n.º 2
0
    public void OnFingerSet(Lean.Touch.LeanFinger finger)
    {
        if (useInput == false)
        {
            return;
        }

        if (playerInput == null)
        {
            return;
        }

        if (inGameCamera == null)
        {
            inGameCamera = GameManager.Instance.cameraManager.GetCamera();
        }

        Vector3 playerPos = playerInput.transform.position;
        Vector3 fingerPos = finger.GetWorldPosition(Vector3.Distance(playerPos, inGameCamera.transform.position), inGameCamera);

        Vector3 dir = (fingerPos - playerPos);

        playerInput.AddDirection(dir);

        if (OnFingerSetAction != null)
        {
            OnFingerSetAction.Invoke();
        }
    }
Exemplo n.º 3
0
 private void OnFingerUp(Lean.Touch.LeanFinger finger)
 {
     if (finger == curr_finger)
     {
         curr_finger = null;
     }
 }
Exemplo n.º 4
0
 private void OnFingerDown(Lean.Touch.LeanFinger finger)
 {
     if (finger.Index == 0 && hasAuthority)
     {
         trackFinger = finger;
         fingerDown  = true;
     }
 }
Exemplo n.º 5
0
 private void OnFingerUp(Lean.Touch.LeanFinger finger)
 {
     if (finger.Index == 0 && hasAuthority)
     {
         fingerDown  = false;
         trackFinger = null;
     }
 }
Exemplo n.º 6
0
 private bool IgnoreInput(Lean.Touch.LeanFinger finger)
 {
     //if input does not belong to filter
     if (!this.InputFilter.GetFingers().Contains(finger))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 7
0
 private void onFingerDown(Lean.Touch.LeanFinger finger)
 {
     //Debug.Log("Finger down event");
     if (Lean.Touch.LeanTouch.Fingers.Count > 1)
     {
         //Debug.Log("Multiple Fingers Down -  Clear Lines");
         detector.ClearLines();
     }
 }
Exemplo n.º 8
0
    public void SetActive(Lean.Touch.LeanFinger finger, PlayerEntity curPlayer)
    {
        if (_activeObject != null)
        {
            Destroy(_activeObject);
        }
        _activeObject = null;

        curPlayer.ActivateSpecialPower(_type.Type);
    }
Exemplo n.º 9
0
    private void SelectionLock(Lean.Touch.LeanFinger finger)
    {
        if (this.IgnoreInput(finger))
        {
            return;
        }

        //force update before locking
        this.Update();
        this.SelectionLocked = true;
    }
Exemplo n.º 10
0
    void OnFingerUp(Lean.Touch.LeanFinger finger)
    {
        if (finger.Index == 0)
        {
            _dragFinger = null;

            if (_dragTiles != null)
            {
                if (_dragTiles.Count >= 3)
                {
                    Combo();
                }

                _dragTiles.Clear();
                _line.positionCount = 0;
            }

            if (_selectedUI != null)
            {
                if (_selectedUI.name.Contains("Color"))
                {
                    //_selectedUI.GetComponent<SpecialPowerUI>().Fly();
                    if (_selectedUI.GetComponent <SpecialPowerUI>().Type == TileTypes.ESubState.blue || _selectedUI.GetComponent <SpecialPowerUI>().Type == TileTypes.ESubState.green)
                    {
                        RootController.Instance.GetCurrentPlayer().EmptyPower(_selectedUI.GetComponent <SpecialPowerUI>().Type);
                    }
                }

                _selectedUI = null;
            }
        }
        if (finger.Index == 1)
        {
            if (_selectedUI2 != null)
            {
                //_selectedUI2.GetComponent<SpecialPowerUI>().Fly();
                _selectedUI2 = null;
            }
        }

        if (_gridController)
        {
            foreach (HexTile tile in _gridController.AllTilesAsHexTile())
            {
                tile.selected = false;
            }

            if (RootController.Instance.GetMyPlayerEntity())
            {
                RootController.Instance.GetMyPlayerEntity().ClearSelectionData();
            }
        }
    }
Exemplo n.º 11
0
    private void SwipeHappened(Lean.Touch.LeanFinger finger)
    {
        if (finger.SwipeScaledDelta.x > 0) //Swipe Right
        {
            fingerMovement += 1;
        }

        else if (finger.SwipeScaledDelta.x < 0) //Swipe Left
        {
            fingerMovement -= 1;
        }
    }
Exemplo n.º 12
0
    void PassTurn()
    {
        _curPlayer.Heal(5);

        _dragFinger = null;
        if (_dragTiles != null)
        {
            _dragTiles.Clear();
            _line.positionCount = 0;
        }

        EndTurn();
    }
Exemplo n.º 13
0
    public void GoThere(Lean.Touch.LeanFinger finger)
    {
        float dist = (camera.transform.position - transform.position).magnitude;

        var ray = finger.GetRay(camera);

        Vector3 touchWorldPos = finger.GetWorldPosition(dist);

        //Debug.Log("Go there, Actual pos is " + touchWorldPos);
        touchWorldPos.y = 2;

        transform.position += (touchWorldPos - transform.position).normalized * speed * Time.deltaTime;
    }
Exemplo n.º 14
0
    private void CheckOnFingerDistance()
    {
        if (curr_finger != null)
        {
            Vector2 start = curr_finger.StartScreenPosition;
            Vector2 curr  = curr_finger.ScreenPosition;

            if (Mathf.Abs(Vector2.Distance(start, curr)) > 40)
            {
                OnFingerSwipe(curr_finger);
                Debug.Log("swiped");
                curr_finger = null;
            }
        }
    }
Exemplo n.º 15
0
    void OnFingerUp(Lean.Touch.LeanFinger finger)
    {
        if (finger.Index == 0)
        {
            _dragFinger = null;

            if (_dragTiles != null)
            {
                if (_dragTiles.Count >= 3)
                {
                    Combo();
                }

                _dragTiles.Clear();
                _line.positionCount = 0;
            }

            if (_selectedUI != null)
            {
                if (_selectedUI.name.Contains("Color"))
                {
                    _selectedUI.GetComponent <SpecialPowerUI>().Fly();
                }

                _selectedUI = null;
            }
        }
        if (finger.Index == 1)
        {
            if (_selectedUI2 != null)
            {
                _selectedUI2.GetComponent <SpecialPowerUI>().Fly();
                _selectedUI2 = null;
            }
        }

        if (_gridController)
        {
            foreach (HexTile tile in _gridController.AllTilesAsHexTile())
            {
                tile.selected = false;
            }
        }
    }
Exemplo n.º 16
0
    public void SetActive(Lean.Touch.LeanFinger finger, Player curPlayer)
    {
        if (_activeObject != null)
        {
            Destroy(_activeObject);
        }
        _activeObject = null;

        _active = true;
        _finger = finger;
        if (_type.Type == TileTypes.ESubState.red)
        {
            _activeObject = Instantiate(Resources.Load <GameObject>("SpecialSelect"));
        }
        else if (_type.Type == TileTypes.ESubState.yellow)
        {
            _activeObject = Instantiate(Resources.Load <GameObject>("YellowSpecial"));
        }
        else if (_type.Type == TileTypes.ESubState.blue)
        {
            curPlayer.BlueTileEffect(); //Shield
        }
        else if (_type.Type == TileTypes.ESubState.green)
        {
            curPlayer.GreenTileEffect();
        }

        if (_activeObject != null)
        {
            _activeObject.name = "SpecialSelect";
            _activeObject.transform.SetParent(this.transform.parent.parent, false);
            _activeObject.GetComponent <MissileUI>().target = RootController.Instance.NextPlayer(curPlayer.playerNumber);
            _activeObject.GetComponent <MissileUI>().Type   = _type.Type;

            _curPos  = _finger.GetWorldPosition(1f, Camera.current);
            _lastPos = _finger.GetWorldPosition(1f, Camera.current);
        }
    }
Exemplo n.º 17
0
 private void SelectionUnlock(Lean.Touch.LeanFinger finger)
 {
     this.SelectionLocked = false;
 }
Exemplo n.º 18
0
 private void FingerUp(Lean.Touch.LeanFinger finger)
 {
     isOn = false;
 }
Exemplo n.º 19
0
 private void FingerDown(Lean.Touch.LeanFinger finger)
 {
     isOn = true;
 }
Exemplo n.º 20
0
    void idk(Lean.Touch.LeanFinger finger)
    {
        /* Workaround for now
         * This is to prevent finger touch to "bleed" through the finish button and prevent unintentional drawing
         * TODO: Refactor variable names
         */
        var test = Lean.Touch.LeanTouch.RaycastGui(finger.ScreenPosition);

        if (test.Count > 0)
        {
            var idk1 = test[0];

            if (idk1.gameObject.name == "RecognizeButtonText")
            {
                //Debug.Log("Clicked on button: " + idk1.gameObject.name);
                return;
            }
        }

        //No way to specify the GUI we want :/ bummer
        if (finger.IsOverGui)
        {
            //Started pressing this frame
            if (finger.Down)
            {
                if (recognized)
                {
                    recognized = false;
                }


                strokeID++;

                Transform tmpGesture = Instantiate(GesturePrefab, Vector3.zero, Quaternion.identity) as Transform;
                currentGestureLineRenderer = tmpGesture.GetComponent <UILineRendererList>();

                //Set the parent
                currentGestureLineRenderer.transform.SetParent(DrawingLinesParent.transform);

                //TODO: better this out
                //Remember to set the rect transform in the proper position (bottom left)
                currentGestureLineRenderer.transform.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0);
                currentGestureLineRenderer.transform.GetComponent <RectTransform>().anchorMax = new Vector2(0, 0);
                currentGestureLineRenderer.transform.GetComponent <RectTransform>().pivot     = new Vector2(0, 0);

                gestureLinesRenderer.Add(currentGestureLineRenderer);
            }
            else if (finger.IsActive)
            {
                points.Add(new Point(finger.ScreenPosition.x, -finger.ScreenPosition.y, strokeID));

                var point = new Vector2()
                {
                    x = finger.ScreenPosition.x, y = finger.ScreenPosition.y
                };
                currentGestureLineRenderer.AddPoint(point);
                //currentGestureLineRenderer.SetAllDirty();
                //currentGestureLineRenderer.SetPosition(currentGestureLineRenderer.positionCount - 1, Camera.main.ScreenToWorldPoint(new Vector3(info.ScreenPosition.x, info.ScreenPosition.y, 10)));
            }
        }
    }
Exemplo n.º 21
0
 private void LeanTouch_OnFingerUp(Lean.Touch.LeanFinger obj)
 {
     this.IsHoldingDown = false;
 }
Exemplo n.º 22
0
 private void LeanTouch_OnFingerDown(Lean.Touch.LeanFinger obj)
 {
     this.IsHoldingDown = true;
 }
Exemplo n.º 23
0
 private void LeanTouch_OnFingerTap(Lean.Touch.LeanFinger obj)
 {
     //this.ball.AddTorque();
 }
Exemplo n.º 24
0
 public void Beg(Lean.Touch.LeanFinger finger)
 {
     Run = true;
 }
Exemplo n.º 25
0
 void HandleFingerTap(Lean.Touch.LeanFinger finger)
 {
 }
Exemplo n.º 26
0
    private void OnFingerSwipe(Lean.Touch.LeanFinger finger)
    {
        float angle_threshold = 90;

        float up_angle    = 0.0f;
        float right_angle = 90.0f;
        float down_angle  = 180.0f;
        float left_angle  = 270.0f;

        bool up    = false;
        bool right = false;
        bool down  = false;
        bool left  = false;

        if (finger.StartedOverGui == true)
        {
            return;
        }

        Vector2 swipeDelta = finger.SwipeScreenDelta;

        // Invalid angle?
        float angle = Mathf.Atan2(swipeDelta.x, swipeDelta.y) * Mathf.Rad2Deg;

        // up
        float delta = Mathf.DeltaAngle(angle, up_angle);

        if (delta >= angle_threshold * -0.5f && delta < angle_threshold * 0.5f)
        {
            up = true;
        }

        // right
        delta = Mathf.DeltaAngle(angle, right_angle);

        if (delta >= angle_threshold * -0.5f && delta < angle_threshold * 0.5f)
        {
            right = true;
        }

        // down
        delta = Mathf.DeltaAngle(angle, down_angle);

        if (delta >= angle_threshold * -0.5f && delta < angle_threshold * 0.5f)
        {
            down = true;
        }

        // left
        delta = Mathf.DeltaAngle(angle, left_angle);

        if (delta >= angle_threshold * -0.5f && delta < angle_threshold * 0.5f)
        {
            left = true;
        }

        if (up)
        {
            OnSwipeUp();
        }

        if (right)
        {
            OnSwipeRight();
        }

        if (down)
        {
            OnSwipeDown();
        }

        if (left)
        {
            OnSwipeLeft();
        }
    }
Exemplo n.º 27
0
        private void Paint(LeanFinger finger)
        {
            // If we require a selectable and it isn't selected, cancel
            if (RequiredSelectable != null && RequiredSelectable.IsSelected == false)
            {
                return;
            }

            // Make sure the mesh filter and mesh exist
            if (cachedMeshFilter == null)
            {
                cachedMeshFilter = GetComponent <MeshFilter>();
            }

            if (cachedMeshFilter.sharedMesh != null)
            {
                // Duplicate mesh?
                if (modifiedMesh == null)
                {
                    modifiedMesh = cachedMeshFilter.sharedMesh = Instantiate(cachedMeshFilter.sharedMesh);
                }

                // Duplicate indices and colors?
                if (modifiedColors == null || modifiedColors.Length != modifiedMesh.vertexCount)
                {
                    modifiedIndices = modifiedMesh.triangles;
                    modifiedColors  = modifiedMesh.colors;

                    // If the mesh has no vertex colors, make some
                    if (modifiedColors == null || modifiedColors.Length == 0)
                    {
                        modifiedColors = new Color[modifiedMesh.vertexCount];

                        for (var i = modifiedMesh.vertexCount - 1; i >= 0; i--)
                        {
                            modifiedColors[i] = Color.white;
                        }
                    }
                }

                // Raycast under the finger and paint the hit triangle
                var hit = default(RaycastHit);

                if (Physics.Raycast(finger.GetRay(Camera), out hit) == true)
                {
                    if (hit.collider.gameObject == gameObject)
                    {
                        var index = hit.triangleIndex * 3;
                        var a     = modifiedIndices[index + 0];
                        var b     = modifiedIndices[index + 1];
                        var c     = modifiedIndices[index + 2];

                        modifiedColors[a] = Color.black;
                        modifiedColors[b] = Color.black;
                        modifiedColors[c] = Color.black;

                        modifiedMesh.colors = modifiedColors;
                    }
                }
            }
        }
Exemplo n.º 28
0
 /// <summary>If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.</summary>
 public void AddFinger(LeanFinger finger)
 {
     Use.AddFinger(finger);
 }
Exemplo n.º 29
0
 /// <summary>If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove a finger.</summary>
 public void RemoveFinger(LeanFinger finger)
 {
     Use.RemoveFinger(finger);
 }
Exemplo n.º 30
0
 // Function OnFingerTap
 public void OnFingerTap(LeanFinger finger)
 {
     SelectObject(finger);
 }