예제 #1
0
 public void AddObject(ISelectableObject selectableObject)
 {
     if (!Objects.Contains(selectableObject))
     {
         Objects.Add(selectableObject);
     }
 }
예제 #2
0
        public new void MouseUp(IViewportController viewportController, MouseEventArgs e)
        {
            if (Editor.SelectionBox.SelectedObject != null)
            {
                Editor.SelectionBox.MouseUp(viewportController, e);
            }
            else
            {
                Ray ray = viewportController.CreateViewportRay(e.X, e.Y);
                ISelectableObject selectedObject = null;
                float             d = float.MaxValue;

                foreach (ISelectableObject selectable in Editor.SelectableObjects)
                {
                    Pair <bool, float> pair = selectable.RayIntersects(ray, viewportController);

                    if (pair.first && pair.second < d)
                    {
                        d = pair.second;
                        selectedObject = selectable;
                    }
                }

                Editor.SelectionBox.SelectedObject = selectedObject;
            }
        }
예제 #3
0
 public override void OtherObjectSelected(ISelectableObject selectedObject)
 {
     if (selectedObject is IInventoryTourist)
     {
         Deselect();
     }
 }
예제 #4
0
 public GameObjectSizingAction(Point ptBegin, Point ptEnd, int sizingValue, ISelectableObject shape)
 {
     this.ptBegin     = ptBegin;
     this.ptEnd       = ptEnd;
     this.sizingValue = sizingValue;
     this.shape       = shape;
 }
예제 #5
0
 public void ObjectSelected(ISelectableObject newlySelectedObject)
 {
     for (int i = 0; i < SelectedObjects.Count; i++)
     {
         SelectedObjects[i].OtherObjectSelected(newlySelectedObject);
     }
     SelectedObjects.Add(newlySelectedObject);
 }
예제 #6
0
        public void SizingGameObject(Point ptBegin, Point ptEnd, int sizingValue, ISelectableObject shape)
        {
            if (ptBegin == ptEnd)
            {
                return;
            }
            var action = new GameObjectSizingAction(ptBegin, ptEnd, sizingValue, shape);

            HandlePushAction(action, false);
        }
예제 #7
0
        public void MovingGameObject(int moveX, int moveY, ISelectableObject shape)
        {
            if (moveX == moveY && moveX == 0)
            {
                return;
            }
            var action = new GameObjectMovingAction(moveX, moveY, shape);

            HandlePushAction(action, false);
        }
예제 #8
0
 /// <summary>
 /// 取消对象选择
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public ISelectableObject Remove(ISelectableObject obj)
 {
     if (!this.SelectionObjects.Contains(obj))
     {
         return(obj);
     }
     this.SelectionObjects.Remove(obj);
     obj.Selected(false);
     return(obj);
 }
예제 #9
0
 /// <summary>
 /// 添加选择对象
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public ISelectableObject Add(ISelectableObject obj)
 {
     if (this.SelectionObjects.Contains(obj))
     {
         return(obj);
     }
     this.SelectionObjects.Add(obj);
     obj.Selected(true);
     return(obj);
 }
예제 #10
0
    public void SingleSelect(ISelectableObject selectableObject)
    {
        if (SingleSelectedObject != null && !SingleSelectedObject.Equals(null))
        {
            SingleSelectedObject.OnSingleUnselected();
        }

        SingleSelectedObject = selectableObject;
        SingleSelectedObject.OnSingleSelected();
    }
예제 #11
0
 public void OnPointToAnotherObject(ISelectableObject anotherObject)
 {
     if (anotherObject is Ship)
     {
         Debug.Log("Another ship.");
     }
     else if (anotherObject is Planet)
     {
         Debug.Log("Planet " + ((Planet)anotherObject).Name);
     }
 }
예제 #12
0
        // Update is called once per frame
        void Update()
        {
            if (Input.touchCount > 0)
            {
                Touch   touch = Input.GetTouch(0);
                Vector2 tPos  = touch.position;

                if (touch.phase == TouchPhase.Began)
                {
                    Ray ray = arcamera.ScreenPointToRay(tPos);
                    if (Physics.Raycast(ray, out RaycastHit hit))
                    {
                        //Destroy(hit.transform.gameObject);

                        ISelectableObject selected = hit.transform.gameObject.GetComponent <ISelectableObject>();

                        if (selected != null)
                        {
                            if (selected.IsSelected == false)
                            {
                                selected.OnSelectEnter();
                            }
                            else
                            {
                                selected.OnSelectExit();
                            }

                            selected.IsSelected = !selected.IsSelected;
                        }
                    }
                }

                List <ARRaycastHit> hits = new List <ARRaycastHit>();
                if (raycastManager.Raycast(tPos, hits, TrackableType.PlaneWithinPolygon))
                {
                    Pose pose = hits[0].pose;

                    if (placed == null)
                    {
                        placed = Instantiate(player);
                        placed = Instantiate(level, pose.position, Quaternion.identity);

                        planeManager.planePrefab = null;
                        foreach (var plane in planeManager.trackables)
                        {
                            plane.gameObject.SetActive(false);
                        }
                    }
                }
            }
        }
        public void SetLocation(ISelectableObject thisImage, double x, double y)
        {
            View thisView;

            thisView = (View)thisImage;
            Rectangle thisRect;

            thisRect = new Rectangle(x, y, thisView.WidthRequest, thisView.HeightRequest);
            if (thisView.Width == 0)
            {
                throw new BasicBlankException("The width can't be 0");
            }
            SetLayoutBounds((View)thisImage, thisRect);
        }
예제 #14
0
    public void MultiSelect(ISelectableObject selectableObject)
    {
        if (MultiSelectedObjects.Contains(selectableObject))
        {
            MultiSelectedObjects.Remove(selectableObject);
            if (!selectableObject.Equals(null))
            {
                selectableObject.OnMultiUnselected();
            }
        }
        else
        {
            if (selectableObject.Equals(null))
            {
                return;
            }

            MultiSelectedObjects.Add(selectableObject);
            selectableObject.OnMultiSelected();
        }
    }
예제 #15
0
        public bool MouseDown(IViewportController viewportController, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.mouseDownPos = viewportController.MouseToGrid(e.X, e.Y);
                this.selectedGrip = this.GetSelectedGrip(viewportController, e.X, e.Y);

                // create a new box
                if (this.selectedGrip == ResizableBox.MG_NONE)
                {
                    this.selectedObject = null;
                    this.min            = mouseDownPos;
                    this.max            = mouseDownPos;

                    if (this.isCreated)
                    {
                        this.Destroy();
                    }
                }
            }

            return(this.selectedGrip != ResizableBox.MG_NONE);
        }
예제 #16
0
    /// <summary>
    /// 预览鼠标下的对象
    /// </summary>
    private void PreviewSelect()
    {
        var obj = MouseRayHitObj();

        if (obj != null && !Contains(obj))
        {
            if (this.previewObject == null)
            {
                this.previewObject = obj;
                obj.PreviewSelect(true);
                return;
            }
            else
            {
                return;
            }
        }
        if (this.previewObject != null)
        {
            this.previewObject.PreviewSelect(false);
            this.previewObject = null;
        }
    }
예제 #17
0
        public async Task DoAnimateAsync(ISelectableObject thisImage)
        {
            thisImage.IsSelected = false;
            GameBoard !.Clear();
            GameBoard.AddChild(thisImage);
            try
            {
                GameBoard.SetLocation(thisImage, LocationFrom.X, LocationFrom.Y);
            }
            catch (Exception ex)
            {
                UIPlatform.ShowError(ex.Message);
                return;
            }
            _startX       = (int)LocationFrom.X; // myLocation.X
            _startY       = (int)LocationFrom.Y; // myLocation.Y
            _destinationX = (int)LocationTo.X;
            _destinationY = (int)LocationTo.Y;
            var temps = LongestTravelTime / _interval;

            _totalSteps = (int)temps;
            _image      = thisImage;
            await RunAnimations();
        }
 public void AddChild(ISelectableObject thisImage)
 {
     Children.Add((View)thisImage);
 }
예제 #19
0
 public void ObjectDeselected(ISelectableObject deselectedObject)
 {
     SelectedObjects.Remove(deselectedObject);
 }
예제 #20
0
 public override void OtherObjectSelected(ISelectableObject selectedObject)
 {
 }
예제 #21
0
        public bool MouseDown(IViewportController viewportController, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.mouseDownPos = viewportController.MouseToGrid(e.X, e.Y);
                this.selectedGrip = this.GetSelectedGrip(viewportController, e.X, e.Y);

                // create a new box
                if (this.selectedGrip == ResizableBox.MG_NONE)
                {
                    this.selectedObject = null;
                    this.min = mouseDownPos;
                    this.max = mouseDownPos;

                    if (this.isCreated)
                        this.Destroy();
                }
            }

            return this.selectedGrip != ResizableBox.MG_NONE;
        }
예제 #22
0
 public void RemoveObject(ISelectableObject selectableObject)
 {
     Objects.Remove(selectableObject);
 }
 ///	<interface>ISelectionManager</interface>
 /// <summary>
 /// Sets the selection.
 /// </summary>
 /// <param name="selectableObject">The array of ISelectableObject values to select.</param>
 public void SetSelection(ISelectableObject[] selectableObjects)
 {
 }
예제 #24
0
 public bool ContainsObject(ISelectableObject selectableObject)
 {
     return(Objects.Contains(selectableObject));
 }
예제 #25
0
 ///	<interface>ISelectionManager</interface>
 /// <summary>
 /// Sets the selection.
 /// </summary>
 /// <param name="selectableObject">The ISelectableObject value to select.</param>
 public void SetSelection(ISelectableObject selectableObject)
 {
 }
예제 #26
0
 public override void OnSelectableEnter(ISelectableObject selectableObject)
 {
     throw new System.NotImplementedException();
 }
        public void OnMouseMove(PointF screenLocation)
        {
            if ([email protected])
            {
                return;
            }
            if (_mouseManager.Active)
            {
                PointF oldFirstCorner = _mouseManager.FirstCorner;
                _mouseManager.FirstCorner  = _mouseManager.SecondCorner;
                _mouseManager.SecondCorner = _convertWorldView.GetWorldPoint(screenLocation);

                switch (_modifiledObjectState)
                {
                case ModifiledObjectState.None:
                    break;

                case ModifiledObjectState.Moving:
                    if (@interface.CurrentObject != null)
                    {
                        @interface.CurrentObject.Move(_mouseManager.Delta);
                        @interface.RefreshCanvas();
                    }
                    break;

                case ModifiledObjectState.Sizing:
                    if (@interface.CurrentObject != null)
                    {
                        @interface.CurrentObject.SetSizing(_prepareSizingValue, _mouseManager.FirstCorner.ToPoint(), _mouseManager.SecondCorner.ToPoint());
                        @interface.RefreshCanvas();
                    }
                    @interface.RefreshCanvas();
                    break;

                case ModifiledObjectState.Selecting:
                    _mouseManager.FirstCorner = oldFirstCorner;
                    var r = @interface.SelectingRect = _mouseManager.BoudingRect;
                    if (@interface.CurrentObject == null)
                    {
                        @interface.CurrentObject = new GroupSelectable();
                        @interface.AddLayerObject(@interface.CurrentObject);
                    }
                    try
                    {
                        if ([email protected])
                        {
                            @interface.CurrentObject.Objects.RemoveAll(obj
                                                                       => ((GameObject)obj).Active == false || (!obj.BoudingRect.IntersectsWith(r))
                                                                       );
                        }
                        foreach (GameObject obj in @interface.Objects.Objects)
                        {
                            if (!obj.Active)
                            {
                                continue;
                            }
                            if ([email protected](obj) && obj.BoudingRect.IntersectsWith(r))
                            {
                                @interface.CurrentObject.Objects.Add(obj);
                            }
                        }
                    }
                    catch
                    {
                    }

                    @interface.RefreshCanvas();
                    break;
                }
                _mouseManager.FirstCorner = oldFirstCorner;
            }
            else
            {
                _prepareObject = null;
                var ptWorld             = _convertWorldView.GetWorldPoint(screenLocation);
                var objCanSelectByPoint = @interface.Objects.ObjectCanSelectByPoint(ptWorld);
                if (objCanSelectByPoint != null)
                {
                    @interface.SelectCursor = Cursors.SizeAll;
                    _modifiledObjectState   = ModifiledObjectState.Moving;
                    if (@interface.CurrentObject == null)
                    {
                        _prepareObject = objCanSelectByPoint;
                    }
                    else
                    {
                        if (@interface.CurrentObject.ContainsObject(objCanSelectByPoint))
                        {
                            _prepareSizingValue = @interface.CurrentObject.SizingPointValue(ptWorld);
                            if (_prepareSizingValue != -1)
                            {
                                _modifiledObjectState   = ModifiledObjectState.Sizing;
                                @interface.SelectCursor = PointSizeValueHelper.GetCursor(_prepareSizingValue);
                            }
                        }
                        else
                        {
                            _prepareObject = objCanSelectByPoint;
                        }
                    }
                }
                else
                {
                    _modifiledObjectState = ModifiledObjectState.None;
                }
            }
        }
 public static void SelectUnselectItem(this ISelectableObject thisItem)
 {
     thisItem.IsSelected = !thisItem.IsSelected;
 }
예제 #29
0
 public bool Contains(ISelectableObject obj) => this.SelectionObjects.Contains(obj);
예제 #30
0
 public override void OtherObjectSelected(ISelectableObject selectedObject)
 {
     throw new System.NotImplementedException();
 }
예제 #31
0
 public void OnPointToAnotherObject(ISelectableObject anotherObject)
 {
 }
 public GameObjectMovingAction(int moveX, int moveY, ISelectableObject shape)
 {
     this.moveX = moveX;
     this.moveY = moveY;
     this.shape = shape;
 }
 public void Initialize(ISelectableObject selectableObject)
 {
     isInitialized = true;
     SelectionManager.RegisterSelectableObject(this);
     currentSelectableObject = selectableObject;
 }