Example #1
0
    public static void DrawDragDrop(string label, OnDrop onDrop, float height = 50.0f)
    {
        Event    evt      = Event.current;
        GUIStyle guiStyle = GUI.skin.GetStyle("Box");

        guiStyle.alignment = TextAnchor.MiddleCenter;
        Rect dropArea = GUILayoutUtility.GetRect(0.0f, height, GUILayout.ExpandWidth(true));

        GUI.Box(dropArea, label, guiStyle);

        switch (evt.type)
        {
        case EventType.DragUpdated:
        case EventType.DragPerform:
            if (!dropArea.Contains(evt.mousePosition))
            {
                return;
            }

            DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

            if (evt.type == EventType.DragPerform)
            {
                DragAndDrop.AcceptDrag();

                onDrop(DragAndDrop.objectReferences);
            }
            break;
        }
    }
Example #2
0
 internal protected virtual void TriggerOnDrop(Component sender, int x, int y, MouseButton button)
 {
     if (OnDrop != null)
     {
         OnDrop.Invoke(new MouseButtonEventArgs(sender, x, y, button));
     }
 }
Example #3
0
        /// <summary>
        /// Raises a notification that a collection of specified <paramref name="fileNames"/>
        /// has been dropped.
        /// </summary>
        /// <param name="fileNames">
        /// A collection with the file names of the dropped files.
        /// </param>
        public void Drop(string[] fileNames)
        {
            bool onlyFiles           = fileNames.Where(IsFilePath).Count() == fileNames.Length;
            bool onlyDirectories     = !onlyFiles && fileNames.Where(x => !IsFilePath(x)).Count() == fileNames.Length;
            bool directoriesAndFiles = !onlyFiles && !onlyDirectories;

            OnDrop?.Invoke(this, new DropDataEventArgs(fileNames, onlyDirectories, onlyFiles, directoriesAndFiles));
        }
Example #4
0
    public void OnEndDrag(PointerEventData eventData)
    {
        DraggedInstance = null;
        _offsetToMouse  = Vector3.zero;


        OnDrop?.Invoke(Camera.main.ScreenToWorldPoint(
                           new Vector3(Input.mousePosition.x, Input.mousePosition.y, _zDistanceToCamera)
                           ), gameObject);
    }
Example #5
0
        /// <summary>
        /// The SmashDown
        /// </summary>
        public void SmashDown()
        {
            while (CanMoveDown(CurrentPiece))
            {
                CurrentPiece.MoveDown();
                OnSlide?.Invoke();
            }

            Checkout();
            OnDrop?.Invoke();
        }
Example #6
0
 public void DropOverhead()
 {
     if (overheadRB != null)
     {
         overheadRB.transform.parent = null;
         overheadRB.bodyType         = RigidbodyType2D.Dynamic;
         overheadRB = null;
         OnDrop?.Invoke();
         playerControl.overhead.SwitchState(OverheadState.None);
     }
 }
Example #7
0
 public async Task OnDropCallback(string returnValue)
 {
     try
     {
         var response = JsonConvert.DeserializeObject <CalendarEventChangeResponse>(returnValue);
         await OnDrop.InvokeAsync(response);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Example #8
0
    protected override void OnDragDropStart()
    {
        onRelease = transform.parent.FindChild("Icon").GetComponent <ItemAssistRoleDrag>().onRelease;

        base.OnDragDropStart();

        //UICamera.currentTouch.dragged.transform.FindChild("GetInfo").gameObject.SetActive(false);
        //UICamera.currentTouch.dragged.transform.FindChild("Name").gameObject.SetActive(false);
        //UICamera.currentTouch.dragged.transform.FindChild("Position").gameObject.SetActive(false);
        //UICamera.currentTouch.dragged.transform.GetComponent<UISprite>().enabled = false;
        UICamera.currentTouch.dragged.transform.FindChild("Side").gameObject.SetActive(false);
        NGUITools.BringForward(UICamera.currentTouch.dragged);
    }
    public void Drop()
    {
        if (GrabInteractor != null)
        {
            OnDrop?.Invoke(this, GrabInteractor);

            var tempTransform = GrabInteractor;

            // Do this to prevent an endless loop of dropping
            GrabInteractor = null;
            tempTransform.GetComponent <PlayerInput_Interactor>().ForceDrop();
        }
        ChangeLayerOfAllColliders(InitialLayer);
    }
Example #10
0
    IEnumerator DropCoroutine(HandBehavior hand)
    {
        OnDrop?.Invoke(hand);
        this.held                  = false;
        this.transform.parent      = null;
        this.holder                = null;
        this.gameObject.layer      = layerBak;
        this.rigidbody.isKinematic = false;
        this.rigidbody.useGravity  = true;
        yield return(new WaitForSeconds(.3f));

        foreach (Collider collider in colliders)
        {
            Physics.IgnoreCollision(collider, hand.collider, false);
        }
        Physics.IgnoreCollision(this.collider, hand.collider, false);
    }
Example #11
0
    public void OnEndDrag(PointerEventData eventData)
    {
        if (state == SwipeState.DISABLE)
        {
            return;
        }

        if (cardController != null)
        {
            cardController.OnEndDrag();
        }

        OnDrop?.Invoke();

        Vector2 distance = rectTransform.anchoredPosition - pivotPoint;

        if (distance.magnitude >= swipeDetectionLimit_LR)
        {
            if (rectTransform.anchoredPosition.x < pivotPoint.x)
            {
                TriggerLeft();
            }
            else
            {
                TriggerRight();
            }
            state = SwipeState.DISABLE;
            eventData.pointerDrag = null;
            OnEndSwipe?.Invoke();

            if (isActiveAndEnabled)
            {
                Coroutine _coroutine = StartCoroutine(OnFideOut());
                _coroutine = null;
            }
        }
        else
        {
            state = SwipeState.RETURN;
        }
    }
Example #12
0
        private void CallOnDropChain(UiDragDropArgs args)
        {
            args.Handled = false;
            OnDrop?.Invoke(args);
            if (args.Handled)
            {
                return;
            }

            if (args.Target is IDragDropAware targetAware)
            {
                targetAware.OnDrop(args);
                if (args.Handled)
                {
                    return;
                }
            }

            if (args.TargetElement != containerElement && containerElement.DataContext is IDragDropAware elementAware)
            {
                elementAware.OnDrop(args);
            }
        }
Example #13
0
        /// <summary>
        /// Prevents a default instance of the <see cref="GameController"/> class from being created.
        /// </summary>
        /// <param name="width">The width<see cref="int"/></param>
        /// <param name="height">The height<see cref="int"/></param>
        private GameController(int width, int height)
        {
            if (width < 10)
            {
                throw new ArgumentException(nameof(width));
            }

            if (height < 10)
            {
                throw new ArgumentException(nameof(height));
            }

            _board             = new Board(new StatsRepository(), width, height);
            _board.OnRefresh  += () => OnRefresh?.Invoke();
            _board.OnFinish   += () => OnFinish?.Invoke();
            _board.OnLose     += () => OnLose?.Invoke();
            _board.OnClear    += () => OnClear?.Invoke();
            _board.OnMove     += () => OnMove?.Invoke();
            _board.OnSlide    += () => OnSlide?.Invoke();
            _board.OnPause    += () => OnPause?.Invoke();
            _board.OnContinue += () => OnContinue?.Invoke();
            _board.OnDrop     += () => OnDrop?.Invoke();
        }
Example #14
0
 public void TriggerOnDrop(Widget dropWidget, Widget dragWidget, PointerEventData eventData)
 {
     OnDrop?.Invoke(dropWidget, dragWidget, eventData);
 }
Example #15
0
 protected virtual Task HandleDrop(DragEventArgs args)
 {
     return(OnDrop.InvokeAsync(args));
 }
 void ObjectDrop(OnDrop pEvent)
 {
     PlayEmitter(SFX_OBJ_DROP_STRING);
 }
Example #17
0
 void OnSceneDragableMouseUp(ISceneDragable currentSceneDragable)
 {
     OnDrop?.Invoke(currentSceneDragable);
     OnSceneDragableDragEnd?.Invoke();
     OnSceneDragableActions -= OnSceneDragableMouseUp;
 }
Example #18
0
 /// <summary>
 /// Trigger the drag-and-drop end event
 /// </summary>
 /// <param name="dropObject">The object being dragged</param>
 /// <param name="jointType">Joint type</param>
 protected void OnDropAction(T dropObject, JointType jointType)
 {
     OnDrop?.Invoke(dropObject, jointType);
 }
Example #19
0
 private void OnMouseDragEnd(object?sender, MouseEventArgs e)
 {
     OnDrop?.Invoke(this);
     this.Close();
 }
Example #20
0
 public void ParentDrop(int id)
 {
     ParentId = id;
     OnDrop?.Invoke(this, null);
 }
Example #21
0
 public bool Drop(IItem item)
 {
     inventory.Remove(item);
     OnDrop?.Invoke(item);
     return(true);
 }
Example #22
0
 public void Drop()
 {
     OnDrop?.Invoke();
 }
Example #23
0
 private void Drop(Glfw.Window window, int num, string[] files)
 {
     OnDrop?.Invoke(this, new WindowFileDropEventArgs { FilesPath = new List<string>(files) });
 }
Example #24
0
 public void Dropped(IDraggable element)
 {
     OnDrop?.Invoke(element);
 }
Example #25
0
 public void InvokeDrop(GameObject self, Interactable on)
 {
     //transform.parent = previousParent;
     //previousParent = null;
     OnDrop?.Invoke(self, on);
 }
Example #26
0
 public static void DropItems()
 {
     OnDrop?.Invoke();
 }
Example #27
0
 public void Drop(CallInfo callInfo)
 {
     OnDrop?.Invoke(callInfo);
 }
Example #28
0
 public virtual void Drop()
 {
     PickedUp = false;
     OnDrop?.Invoke(this);
 }
Example #29
0
 internal virtual void DoDrop(GuiElement elem)
 {
     OnDrop?.Invoke(elem);
 }