Exemple #1
0
    private void OnSwiped(SwipeHandler.Direction direction, GameObject swipedObject)
    {
        if (direction == SwipeHandler.Direction.None || IsItMe(swipedObject) == false || IsAnyTweenActive())
        {
            return;
        }

        _lastNeighbourInGradient = HasNeighbour(direction);
        if (_lastNeighbourInGradient == null)
        {
            return;
        }

        _lastStackedAmount = _lastNeighbourInGradient.GetStackedInGradients().Count;
        _lastDirection     = direction;

        switch (_lastDirection)
        {
        case SwipeHandler.Direction.Up:
            LeanAnimation(_upJoint, Vector3.right, 180, true, _lastStackedAmount, false);
            break;

        case SwipeHandler.Direction.Down:
            LeanAnimation(_downJoint, Vector3.right, -180, true, _lastStackedAmount, false);
            break;

        case SwipeHandler.Direction.Right:
            LeanAnimation(_rightJoint, Vector3.forward, -180, false, _lastStackedAmount, false);
            break;

        case SwipeHandler.Direction.Left:
            LeanAnimation(_leftJoint, Vector3.forward, 180, false, _lastStackedAmount, false);
            break;
        }
    }
Exemple #2
0
    private InGradient HasNeighbour(SwipeHandler.Direction direction)
    {
        RaycastHit hitInfo;
        Ray        upRay    = new Ray(transform.position, Vector3.forward);
        Ray        rightRay = new Ray(transform.position, Vector3.right);
        Ray        downRay  = new Ray(transform.position, Vector3.back);
        Ray        leftRay  = new Ray(transform.position, Vector3.left);

        switch (direction)
        {
        case SwipeHandler.Direction.Up:
            if (Physics.Raycast(upRay, out hitInfo, transform.localScale.z, layerMask))
            {
                return(hitInfo.transform.gameObject.GetComponent <InGradient>());
            }
            break;

        case SwipeHandler.Direction.Right:
            if (Physics.Raycast(rightRay, out hitInfo, transform.localScale.x, layerMask))
            {
                return(hitInfo.transform.gameObject.GetComponent <InGradient>());
            }
            break;

        case SwipeHandler.Direction.Down:
            if (Physics.Raycast(downRay, out hitInfo, transform.localScale.z, layerMask))
            {
                return(hitInfo.transform.gameObject.GetComponent <InGradient>());
            }
            break;

        case SwipeHandler.Direction.Left:
            if (Physics.Raycast(leftRay, out hitInfo, transform.localScale.x, layerMask))
            {
                return(hitInfo.transform.gameObject.GetComponent <InGradient>());
            }
            break;
        }

        return(null);
    }