Example #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);
        }
Example #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);
        }
Example #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);
        }
        public IDropModel Drop(IDragModel drag)
        {
            var drop = this.ExDragDropUseCase.Drop(drag);

            if (drop != default(IDropModel))
            {
                this.DragId2DropIdMap[drag.GetInstanceID()] = drop.GetInstanceID();
            }
            else
            {
                this.DragId2DropIdMap[drag.GetInstanceID()] = -1;
            }

            return(drop);
        }
Example #5
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);
            }
        }
Example #6
0
        public IDropModel Drop(IDragModel drag)
        {
            var dragId = drag.GetInstanceID();
            var drop   = default(IDropModel);

            // dragに対するdropが存在する場合
            if (this.DragId2DropId2AreaMap.ContainsKey(dragId))
            {
                // dragに該当する最大のdropを探す
                var dropId = this.DragId2DropId2AreaMap[dragId].FindMaxOrDefault(it => it.Value).Key;
                drop = this.DropId2DropMap.GetOrDefault(dropId);

                // 他に専有していたDragがあれば、専有しなくなったことを通知する
                var found = this.FixedDragDropListProperty.Value.Find(it => it.Drop.GetInstanceID() == dropId);
                if (found != default(DragDropModel))
                {
                    this.DragId2DropSubjectMap
                    .GetOrSet(found.Drag.GetInstanceID(), () => new Subject <IDropModel>())
                    .OnNext(null);
                }

                // Dropを通知する
                this.DragId2DropSubjectMap.GetOrSet(dragId, () => new Subject <IDropModel>()).OnNext(drop);
                this.DragId2DropId2AreaMap[dragId].Clear();

                // 確定したDragDropを更新する
                this.FixedDragDropListProperty.Value = this.FixedDragDropListProperty.Value
                                                       .Where(it => it.Drag.GetInstanceID() != dragId)
                                                       .Where(it => it.Drop.GetInstanceID() != dropId)
                                                       .ToList();

                if (drop != default(IDropModel))
                {
                    this.FixedDragDropListProperty.Value.Add(new DragDropModel {
                        Drag = drag, Drop = drop
                    });
                }
            }

            // 通知する
            this.FixedDragDropListProperty.SetValueAndForceNotify(this.FixedDragDropListProperty.Value);
            return(drop);
        }
Example #7
0
 public static int GetInstanceID(this IDragModel model)
 {
     return(model?.Collider2D?.GetInstanceID() ?? 0);
 }
 public IObservable <IDropModel> GetDroppedAsObservable(IDragModel drag)
 {
     return(this.ExDragDropUseCase.GetDroppedAsObservable(drag));
 }
 public void DragOut(IDropModel drop, IDragModel drag)
 {
     this.ExDragDropUseCase.DragOut(drop, drag);
 }
Example #10
0
 public static void Drop(this IDragDropPresenter presenter, IDragModel drag)
 {
     presenter.DragDropUseCase.Drop(drag);
 }
Example #11
0
 public static IObservable <IDropModel> GetDroppedAsObservable(
     this IDragDropPresenter presenter, IDragModel drag)
 {
     return(presenter.DragDropUseCase.GetDroppedAsObservable(drag));
 }
Example #12
0
 public IObservable <IDropModel> GetDroppedAsObservable(IDragModel drag)
 {
     return(this.DragId2DropSubjectMap.GetOrSet(drag.GetInstanceID(), () => new Subject <IDropModel>()));
 }