コード例 #1
0
 //Deselects the interactable
 public void deselectInteractable()
 {
     if (interactableEditorState.Equals(EditorState.EDITING) && !transformEditorState.Equals(EditorState.EDITING)) //Controller is colliding with an interactable
     {
         interactableEditorState = EditorState.IDLE;                                                               //Reset interactableEditorState
         interactableEditing     = null;                                                                           //Remove reference to the selected transform
         transformTool.gameObject.SetActive(false);                                                                //Hide transform tool
     }
 }
コード例 #2
0
        private void SelectProcess(GameTime dt)
        {
            _cursorEntity = TrySelectEntity();

            if (_cursorEntity != null)
            {
                HintManager.Instance.SpawnHint(_cursorEntity.Name, new Vector2(20f, 728f), 500, 6, null, 1);
            }

            if (Mouse.GetState().LeftButton.Equals(ButtonState.Pressed) && !_leftClick)
            {
                _leftClick = true;
                GameEntity select = _cursorEntity;
                if (_tryEntity == null)
                {
                    _tryEntity = select;
                    _clicks++;
                }
                else if (_tryEntity != null)
                {
                    if (_tryEntity.Equals(select))
                    {
                        _clicks++;
                    }
                    else
                    {
                        _clicks    = 0;
                        _tryEntity = select;
                    }
                }

                if (_state.Equals(EditorState.Selected) && _cursorEntity != null && _cursorEntity.Equals(_selectedEntity))
                {
                    Vector3 m3D = SceneManager.Instance.IntersectScreenRayWithPlane(_selectedEntity.GetPosition().Z);
                    _dragging = true;
                    _relative = new Vector3(m3D.X, m3D.Y, _selectedEntity.GetPosition().Z) - _selectedEntity.GetPosition();
                }
            }
            else if (Mouse.GetState().LeftButton.Equals(ButtonState.Released) && _leftClick)
            {
                _leftClick = false;
                _clickTime = dt.TotalGameTime.TotalMilliseconds;

                _dragging = false;
            }
            else if (Mouse.GetState().LeftButton.Equals(ButtonState.Released) && !_leftClick)
            {
                if (dt.TotalGameTime.TotalMilliseconds - _clickTime > ClickInterval)
                {
                    _clicks = 0;
                }
            }

            if (_clicks == RequiredClicks)
            {
                _clicks = 0;
                if (_selectedEntity != null && !_selectedEntity.Equals(_tryEntity))
                {
                    _state = EditorState.None;
                }

                switch (_state)
                {
                case EditorState.None:
                    _selectedEntity = _tryEntity;
                    _state          = EditorState.Selected;
                    break;

                case EditorState.Selected:
                    _state = EditorState.Rotating;
                    break;

                case EditorState.Rotating:
                    _state = EditorState.Scaling;
                    break;

                case EditorState.Scaling:
                    _state = EditorState.Selected;
                    break;
                }

                _tryEntity = null;
            }
            /*end selection*/

            /*deselection*/
            if (Mouse.GetState().RightButton.Equals(ButtonState.Pressed))
            {
                _selectedEntity = null;
                _state          = EditorState.None;
            }
        }