Exemplo n.º 1
0
 public void OnManipulationUpdated(ManipulationEventData eventData)
 {
     if (_gridWorld)
     {
         _gridWorld.transform.position = _startPosition + eventData.CumulativeDelta;
     }
     eventData.Use();
 }
Exemplo n.º 2
0
        // .................................................................... INTERFACE IManipulationHandler

        void IManipulationHandler.OnManipulationStarted(ManipulationEventData eventData)
        {
            if (isTapped)
            {
                InputManager.Instance.PushModalInputHandler(gameObject);
                manipulationOriginalPosition = hostTransform.localPosition;
                eventData.Use();
            }
        }
Exemplo n.º 3
0
    public void OnManipulationUpdated(ManipulationEventData eventData)
    {
        //transform.position = _startPosition + eventData.CumulativeDelta;

        GridParent.transform.position = _startPosition + eventData.CumulativeDelta;

        // GridParent.GridContainer.transform.position = _gridStartPosition + eventData.CumulativeDelta;
        eventData.Use();
    }
Exemplo n.º 4
0
 void IManipulationHandler.OnManipulationCanceled(ManipulationEventData eventData)
 {
     Debug.LogFormat("OnManipulationCanceled\r\nSource: {0}  SourceId: {1}\r\nCumulativeDelta: {2} {3} {4}",
                     eventData.InputSource,
                     eventData.SourceId,
                     eventData.CumulativeDelta.x,
                     eventData.CumulativeDelta.y,
                     eventData.CumulativeDelta.z);
     eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
 }
Exemplo n.º 5
0
 public void OnManipulationCompleted(ManipulationEventData eventData)
 {
     InputManager.Instance.PopModalInputHandler();
     //transform.SetParent(GridParent.GridContainer.transform);
     if (!GridParent.transform.GetComponent <WorldAnchor>())
     {
         GridParent.transform.gameObject.AddComponent <WorldAnchor>();
     }
     eventData.Use();
 }
Exemplo n.º 6
0
    public void OnManipulationStarted(ManipulationEventData eventData)
    {
        InputManager.Instance.PushModalInputHandler(gameObject);
        if (GridParent.transform.GetComponent <WorldAnchor>())
        {
            DestroyImmediate(GridParent.transform.GetComponent <WorldAnchor>());
        }

        _startPosition = GridParent.transform.position;
        //_gridStartPosition = GridParent.GridContainer.transform.position;
        eventData.Use();
    }
Exemplo n.º 7
0
    void IManipulationHandler.OnManipulationUpdated(ManipulationEventData eventData)
    {
        if (isManipulationEnabled)
        {
            if (eventData.used)
            {
                return;
            }
            eventData.Use();

            transform.position = manipulationOriginalPosition + eventData.CumulativeDelta;
        }
    }
Exemplo n.º 8
0
        public void OnManipulationUpdated(ManipulationEventData eventData)
        {
            if (LogGesturesUpdateEvents)
            {
                Debug.LogFormat("OnManipulationUpdated\r\nSource: {0}  SourceId: {1}\r\nCumulativeDelta: {2} {3} {4}",
                                eventData.InputSource,
                                eventData.SourceId,
                                eventData.CumulativeDelta.x,
                                eventData.CumulativeDelta.y,
                                eventData.CumulativeDelta.z);

                eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
            }
        }
Exemplo n.º 9
0
    public void OnManipulationCanceled(ManipulationEventData eventData)
    {
        InputManager.Instance.PopModalInputHandler();

        if (!_gridWorld.transform.GetComponent <WorldAnchor>())
        {
            _gridWorld.transform.gameObject.AddComponent <WorldAnchor>();
        }

        _grid      = null;
        _gridWorld = null;

        eventData.Use();
    }
Exemplo n.º 10
0
    void IManipulationHandler.OnManipulationStarted(ManipulationEventData eventData)
    {
        if (isManipulationEnabled)
        {
            if (eventData.used)
            {
                return;
            }
            eventData.Use();

            InputManager.Instance.PushModalInputHandler(gameObject);

            manipulationOriginalPosition = transform.position;
        }
    }
Exemplo n.º 11
0
    void IManipulationHandler.OnManipulationUpdated(ManipulationEventData eventData)
    {
        if (!InputManager.Instance.CheckModalInputStack(gameObject) || _gesturesManager.IsNavigating)
        {
            return;
        }

        transform.position = _startPosition + eventData.CumulativeDelta;
        //  Quaternion rot = Quaternion.LookRotation(_cameraTransform.forward);
        //    rot.z = rot.x = 0;
        //    rot.y += _startRotation;
        //     transform.rotation = rot;

        MoveBuilding();

        eventData.Use();
    }
Exemplo n.º 12
0
        void IManipulationHandler.OnManipulationUpdated(ManipulationEventData eventData)
        {
            if (isTapped)
            {
                var cumulativeUpdate = eventData.CumulativeDelta;

                switch (translationConstraint)
                {
                case AxisAndPlaneConstraint.X_AXIS_ONLY:
                    cumulativeUpdate.y = 0;
                    cumulativeUpdate.z = 0;
                    break;

                case AxisAndPlaneConstraint.Y_AXIS_ONLY:
                    cumulativeUpdate.x = 0;
                    cumulativeUpdate.z = 0;
                    break;

                case AxisAndPlaneConstraint.Z_AXIS_ONLY:
                    cumulativeUpdate.x = 0;
                    cumulativeUpdate.y = 0;
                    break;

                case AxisAndPlaneConstraint.XY_PLANE_ONLY:
                    cumulativeUpdate.z = 0;
                    break;

                case AxisAndPlaneConstraint.XZ_PLANE_ONLY:
                    cumulativeUpdate.x += cumulativeUpdate.y / 2f;
                    cumulativeUpdate.z += cumulativeUpdate.y / 2f;
                    cumulativeUpdate.y  = 0;
                    break;

                case AxisAndPlaneConstraint.YZ_PLANE_ONLY:
                    cumulativeUpdate.x = 0;
                    break;

                default:     // case NONE:
                    break;
                }

                hostTransform.localPosition = manipulationOriginalPosition + cumulativeUpdate * translationFactor;
                eventData.Use();
            }
        }
Exemplo n.º 13
0
    public void OnManipulationStarted(ManipulationEventData eventData)
    {
        InputManager.Instance.PushModalInputHandler(gameObject);

        _startPosition = transform.position;


        //Make a new grid
        _grid      = Game.CurrentSession.City.CreateGrid(10, 10, GridParent.transform.position + new Vector3(-1.5f, 0, 0));
        _gridWorld = _grid.WorldGrid;

        if (_gridWorld.transform.GetComponent <WorldAnchor>())
        {
            DestroyImmediate(_gridWorld.transform.GetComponent <WorldAnchor>());
        }

        eventData.Use();
    }
Exemplo n.º 14
0
    void IManipulationHandler.OnManipulationCanceled(ManipulationEventData eventData)
    {
        TileEntity entity      = gridTile.Entity;
        Vector2Int oldPosition = (entity == null) ? gridTile.Position : entity.ParentTile.Position;

        SwapBuilding();

        //Call the move start event on the tile entity
        if (oldPosition != entity.ParentTile.Position)
        {
            entity.OnMoveComplete();
        }
        else if (entity != null)
        {
            entity.OnMoveCancelled();
        }

        eventData.Use();
    }
Exemplo n.º 15
0
    void IManipulationHandler.OnManipulationStarted(ManipulationEventData eventData)
    {
        UIManager.Instance.SwitchState(UIManager.MenuState.Off);
        //We now also check if the entity is allowed to be moved.
        if (_gesturesManager.IsNavigating || !_tileParent.GridTileCounterpart.Entity.CanBeMoved)
        {
            return;
        }

        InputManager.Instance.PushModalInputHandler(gameObject);

        _startPosition  = transform.position;
        _startPosition += Vector3.up * offset;

        _startRotation     = transform.rotation.y;
        transform.position = _startPosition;
        gameObject.layer   = LayerMask.NameToLayer("Ignore Raycast");

        //Call the move start event on the tile entity
        gridTile?.Entity?.OnMoveStart();

        eventData.Use();
    }
Exemplo n.º 16
0
 void IManipulationHandler.OnManipulationCanceled(ManipulationEventData eventData)
 {
     InputManager.Instance.PopModalInputHandler();
     eventData.Use();
 }