Exemplo n.º 1
0
        private void NotifyDragEmpty(IDropModel drop, IDragModel drag)
        {
            var dropId = drop.GetInstanceID();

            this.MostOverlapDroppingSubject.OnNext(new DragDropModel {
                Drop = null, Drag = drag
            });
            this.DropId2DragSubjectMap.GetOrSet(dropId, () => new Subject <IDragModel>()).OnNext(null);
        }
Exemplo n.º 2
0
        public void Drag(IDropModel drop, IDragModel drag)
        {
            var dropId      = drop.GetInstanceID();
            var dragId      = drag.GetInstanceID();
            var overlapArea = drop.Collider2D.CalcOverlapArea(drag.Collider2D);

            this.DropId2DropMap[dropId] = drop;
            this.DragId2DropId2AreaMap.GetOrSet(dragId, () => new Dictionary <int, float>())[dropId] = overlapArea;
            this.NotifyDrag(drop, drag);
        }
Exemplo n.º 3
0
        private void NotifyDrag(IDropModel drop, IDragModel drag)
        {
            var dropId = drop.GetInstanceID();
            var dragId = drag.GetInstanceID();

            // NOTE: drop数がおおいと遅いかも
            var mostOverlapDropColliderId = this.DragId2DropId2AreaMap[dragId].FindMaxOrDefault(it => it.Value).Key;
            var mostOverlapDropCollider   = this.DropId2DropMap[mostOverlapDropColliderId];

            this.MostOverlapDroppingSubject.OnNext(new DragDropModel {
                Drop = mostOverlapDropCollider, Drag = drag
            });
            this.DropId2DragSubjectMap.GetOrSet(dropId, () => new Subject <IDragModel>()).OnNext(drag);
        }
Exemplo n.º 4
0
        public void DragOut(IDropModel drop, IDragModel drag)
        {
            var dropId = drop.GetInstanceID();
            var dragId = drag.GetInstanceID();

            this.DropId2DropMap.Remove(dropId);
            this.DragId2DropId2AreaMap.GetOrSet(dragId, () => new Dictionary <int, float>()).Remove(dropId);

            if (this.DragId2DropId2AreaMap[dragId].Count <= 0)
            {
                this.NotifyDragEmpty(drop, drag);
            }
            else
            {
                this.NotifyDrag(drop, drag);
            }
        }
Exemplo n.º 5
0
 public IObservable <IDragModel> GetDraggingAsObservable(IDropModel drop)
 {
     return(this.DropId2DragSubjectMap.GetOrSet(drop.GetInstanceID(), () => new Subject <IDragModel>()));
 }