Remove() public method

public Remove ( item ) : bool
return bool
Example #1
0
    public void SortTest()
    {
        var collection = new ReactiveCollection <int>();

        collection.Add(1);
        collection.Add(5);
        collection.Add(4);

        var sorted = collection.Sort((a, b) => a.CompareTo(b), null);

        Assert.AreEqual(3, sorted.Count);
        Assert.AreEqual(true, IsSorted(sorted));


        collection.Add(0);
        collection.Add(8);
        collection.Add(2);

        Assert.AreEqual(6, sorted.Count);
        Assert.AreEqual(true, IsSorted(sorted));

        collection.Remove(1);
        collection.Remove(4);
        collection.Remove(5);
        collection.Add(1);

        Assert.AreEqual(4, sorted.Count);
        Assert.AreEqual(true, IsSorted(sorted));
    }
    /// <summary>
    /// ReactiveCollectionの実行
    /// </summary>
    private void ExcuteReactiveCollection()
    {
        // ReactiveCollection
        ReactiveCollection <string> rcString = new ReactiveCollection <string>();

        // Subscribe時に値を発行
        // 要素追加時
        rcString
        .ObserveAdd()
        .Subscribe(x => {
            Debug.Log(string.Format("[{0}]番目に[{1}]を追加", x.Index, x.Value));
        });

        // 要素削除時
        rcString
        .ObserveRemove()
        .Subscribe(x => {
            Debug.Log(string.Format("[{0}]番目の[{1}]を削除", x.Index, x.Value));
        });

        // 要素を追加するとOnNext
        rcString.Add("Hoge");
        rcString.Add("Fuga");
        rcString.Add("Foo");

        // 要素を削除するとOnNext
        rcString.Remove("Fuga");
        foreach (string str in rcString)
        {
            Debug.Log("rcStringの中身 : " + str);
        }

        // 存在しないので呼ばれない
        rcString.Remove("nothing");
    }
 protected virtual bool RemoveCommand(CommandBase item)
 {
     lock (_lockingQueue)
     {
         return(_outstandingCommands
                .Remove(item));
     }
 }
Example #4
0
 public void RemoveChatChannelList(string channelName)
 {
     if (chatChannelList.Contains(channelName))
     {
         chatChannelList.Remove(channelName);
     }
 }
Example #5
0
        void Start()
        {
            // merge Button click and push enter key on input field.
            var submit = Observable.Merge(
                AddButton.OnClickAsObservable().Select(_ => ToDoInput.text),
                ToDoInput.OnEndEditAsObservable().Where(_ => Input.GetKeyDown(KeyCode.Return)));

            // add to reactive collection
            submit.Where(x => x != "")
            .Subscribe(x => {
                ToDoInput.text = "";                           // clear input field
                var item       = Instantiate(SampleItemPrefab) as GameObject;
                (item.GetComponentInChildren(typeof(Text)) as Text).text = x;
                toDos.Add(item);
            });

            // Collection Change Handling
            toDos.ObserveCountChanged().Subscribe(x => Title.text = "TODO App, ItemCount:" + x);
            toDos.ObserveAdd().Subscribe(x => {
                x.Value.transform.SetParent(TodoList.transform, false);
            });
            toDos.ObserveRemove().Subscribe(x => {
                GameObject.Destroy(x.Value);
            });

            // Clear
            ClearButton.OnClickAsObservable()
            .Subscribe(_ => {
                var removeTargets = toDos.Where(x => x.GetComponent <Toggle>().isOn).ToArray();
                foreach (var item in removeTargets)
                {
                    toDos.Remove(item);
                }
            });
        }
Example #6
0
 private void OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer)
 {
     if (_playersReactiveCollection != null)
     {
         _playersReactiveCollection.Remove(otherPlayer);
     }
 }
        void Start()
        {
            foreach (var item in collection)
            {
                Debug.Log(item);
            }

            // 集合添加数据时订阅
            collection.ObserveAdd()
            .Subscribe(addValue =>
            {
                Debug.Log("added " + addValue);
            });

            // 集合移除数据时订阅
            collection.ObserveRemove()
            .Subscribe(removeValue =>
            {
                Debug.Log("remove " + removeValue);
            });

            // 集合每次数据变动监听每
            collection.ObserveCountChanged()
            .Subscribe(count =>
            {
                Debug.Log("collection count " + count);
            });

            collection.Add(6);
            collection.Remove(2);
        }
    void Start()
    {
        var mcSession       = UnityMCSessionNativeInterface.GetMcSessionNativeInterface();
        var connectingPeers = new ReactiveCollection <string>();

        mcSession.StateChangedAsObservable()
        .Subscribe(t =>
        {
            switch (t.Item2)
            {
            case UnityMCSessionState.Connecting:
                break;

            case UnityMCSessionState.Connected:
                connectingPeers.Add(t.Item1.DisplayName);
                break;

            case UnityMCSessionState.NotConnected:
                connectingPeers.Remove(t.Item1.DisplayName);
                break;
            }
        })
        .AddTo(this);

        connectingPeers.ObserveAdd()
        .AsUnitObservable()
        .Merge(connectingPeers.ObserveRemove().AsUnitObservable())
        .Select(_ => connectingPeers)
        .Subscribe(Refresh)
        .AddTo(this);
    }
 private void AddInCollection(CollectionAddEvent <Info> addEvent)
 {
     addEvent.Value.Health.Life
     .Where(x => x <= 0)
     .DelayFrame(0, FrameCountType.EndOfFrame)
     .Subscribe(_ => m_Enemies.Remove(addEvent.Value));
 }
Example #10
0
    // ReactiveCollectionの練習
    void ReactiveCollectionPractice()
    {
        var collection = new ReactiveCollection <string>();

        collection
        .ObserveAdd()
        .Subscribe(x =>
        {
            Debug.Log(string.Format("Add [{0}] = {1}", x.Index, x.Value));
        });

        collection
        .ObserveRemove()
        .Subscribe(x =>
        {
            Debug.Log(string.Format("Remove [{0}] = {1}", x.Index, x.Value));
        });

        collection.Add("Apple");
        collection.Add("Baseball");
        collection.Add("Cherry");
        collection.Remove("Apple");

        Debug.Log("====================");
    }
Example #11
0
    void Start()
    {
        var submit = Observable.Merge(_addButton.OnClickAsObservable().Select(_ => _inputField.text),
                                      _inputField.OnEndEditAsObservable().Where(_ => Input.GetKeyDown(KeyCode.Return)));

        submit.Where(_ => _ != "")
        .Subscribe(_ =>
        {
            _inputField.text = "";
            var item         = Instantiate(_itemPrefab);
            item.GetComponentInChildren <Text>().text = _;
            _reactives.Add(item);
        });

        _reactives.ObserveCountChanged().Subscribe(_ => _numsText.text = "Count:" + _.ToString());

        _reactives.ObserveAdd().Subscribe(_ =>
        {
            _.Value.SetActive(true);
            _.Value.transform.SetParent(_listTransform, false);
        });

        _reactives.ObserveRemove().Subscribe(_ =>
        {
            GameObject.Destroy(_.Value);
        });

        _clearButton.OnClickAsObservable().Subscribe(_ =>
        {
            var removes = _reactives.Where(__ => __.GetComponent <Toggle>().isOn);
            removes.ToList().ForEach(___ => _reactives.Remove(___));
        });
    }
Example #12
0
        protected override void OnEnable()
        {
            _lifeTime?.Release();

            GameLog.Log("GameFlowWindow : OnEnable");
            graph = null;

            base.OnEnable();

            _lifeTime.AddCleanUpAction(() => windows.Remove(this));

            if (!windows.Contains(this))
            {
                windows.Add(this);
            }

            MessageBroker.Default
            .Receive <UniGraphSaveMessage>()
            .Where(x => x.graph == _targetGraph)
            .Do(x => Save())
            .Subscribe()
            .AddTo(_lifeTime);

            MessageBroker.Default
            .Receive <UniGraphReloadMessage>()
            .Where(x => x.graph == _targetGraph)
            .Do(x => Save())
            .Do(x => Reload())
            .Subscribe()
            .AddTo(_lifeTime);

            Reload();
        }
Example #13
0
    public virtual void Respawn()
    {
        var blob = GameController.Instance.blobPrefab.InstantiateMe(GameController.Instance.RandomPosInBounds(),
                                                                    Quaternion.identity);

        blob.Sprite = skinSprite;
        blob.Tint   = coolorTint;
        blob.Size   = 2;

        blob.moveTargetRef = MoveTarget;

        mahBlobs.Add(blob);

        blob.OnDestroyAsObservable().Take(1)
        .Subscribe(_ => mahBlobs.Remove(blob))
        .AddTo(this);
    }
Example #14
0
 protected bool Remove(IView view)
 {
     if (view == null || !Contains(view))
     {
         return(false);
     }
     return(_views.Remove(view));
 }
Example #15
0
        public void RemoveItem(ItemBase itemBase, int count = 1)
        {
            InventoryItem inventoryItem;

            switch (itemBase.ItemType)
            {
            case ItemType.Consumable:
                if (!TryGetConsumable((ItemUsable)itemBase, out inventoryItem))
                {
                    break;
                }

                Consumables.Remove(inventoryItem);
                break;

            case ItemType.Costume:
                if (!TryGetCostume((Costume)itemBase, out inventoryItem))
                {
                    break;
                }

                inventoryItem.Count.Value -= count;
                if (inventoryItem.Count.Value > 0)
                {
                    break;
                }

                Costumes.Remove(inventoryItem);
                break;

            case ItemType.Equipment:
                if (!TryGetEquipment((ItemUsable)itemBase, out inventoryItem))
                {
                    break;
                }

                Equipments.Remove(inventoryItem);
                break;

            case ItemType.Material:
                if (!TryGetMaterial((Material)itemBase, out inventoryItem))
                {
                    break;
                }

                inventoryItem.Count.Value -= count;
                if (inventoryItem.Count.Value > 0)
                {
                    break;
                }

                Materials.Remove(inventoryItem);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private void OnDeleteViewport(ViewportModel value)
        {
            var window = WindowAssist.GetWindow(this);

            if (MessageBoxEx.Show($"Are you sure you want to delete viewport {value.Name.Value}?", "Delete Viewport", MessageBoxButton.YesNo, parent: window) == MessageBoxResult.Yes)
            {
                Viewports.Remove(value);
            }
        }
Example #17
0
        public ItemComponent CreateItem(Entity.ItemEntity itemEntity, Vector3 position)
        {
            var item = Instantiate(itemEntity.Component, position, Quaternion.identity);

            item.Init(itemEntity);

            item.OnGetItem.Subscribe(e =>
            {
                _normalFieldItems.Remove(item);
                _specialItemCreater.SendTrigger(ItemCreaterMessage.REDUCE_SPECIAL_ITEM_INTERVAL);
                e.FXCreateEntity     = new Entity.FXCreateEntity(e.GetPosition, Enum.FXType.Item, e.ItemColor);
                _scoreModel.AddScore = e.Score;
                _onGetItem.OnNext(e);
            });


            return(item);
        }
Example #18
0
 public void Remove(Line child)
 {
     children_.Remove(child);
     if (child.parent_ == this && child.Binding != null)
     {
         child.parent_ = null;
         child.OnLostParent();
     }
 }
Example #19
0
        // 入手する
        public MeatCard GetCard(MeatCard card)
        {
            if (_source.IndexOf(card) != -1)
            {
                _source.Remove(card);
                return(card);
            }

            return(null);
        }
 public bool Remove(ICardModel card)
 {
     Assert.IsNotNull(card);
     if (Has(card.Id) && !Empty.Value)
     {
         return(_Cards.Remove(card));
     }
     Warn($"Attempt to remove {card} that doesn't exist in {this}");
     return(false);
 }
Example #21
0
 private void OnSceneUnloaded(Scene scene)
 {
     foreach (var setup in scenesToUnload)
     {
         if (setup.Path == scene.path)
         {
             scenesToUnload.Remove(setup);
             break;
         }
     }
 }
Example #22
0
        private void AddInCollection(CollectionAddEvent <Info> addEvent)
        {
            Pools.IPooled astView = m_Pool.GetObject();
            astView.Bind(addEvent.Value);
            var pos = addEvent.Value.Positioning;

            pos.Position
            .Where(CheckExitFromZone)
            .Select(_ => addEvent.Value)
            .Subscribe(z => m_Bullets.Remove(z));
        }
Example #23
0
 private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     foreach (var setup in scenesToLoad)
     {
         if (setup.Path == scene.path)
         {
             scenesToLoad.Remove(setup);
             break;
         }
     }
 }
        public T Open()
        {
            if (_source.Count < 1)
            {
                return(default(T));
            }
            var top = _source[0];

            _source.Remove(top);
            return(top);
        }
Example #25
0
            public void DerivedCollectionShouldHandleRemovesOfFilteredItems()
            {
                var a = new ReactiveVisibilityItem <string>("A", true);
                var b = new ReactiveVisibilityItem <string>("B", true);
                var c = new ReactiveVisibilityItem <string>("C", true);
                var d = new ReactiveVisibilityItem <string>("D", false);
                var e = new ReactiveVisibilityItem <string>("E", true);

                var items = new ReactiveCollection <ReactiveVisibilityItem <string> >(new[] { a, b, c, d, e })
                {
                    ChangeTrackingEnabled = true
                };

                var onlyVisible = items.CreateDerivedCollection(
                    x => x.Value,
                    x => x.IsVisible,
                    OrderedComparer <string> .OrderByDescending(x => x).Compare
                    );

                Assert.True(onlyVisible.SequenceEqual(new[] { "E", "C", "B", "A" }, StringComparer.Ordinal));
                Assert.Equal(4, onlyVisible.Count);

                // Removal of an item from the source collection that's filtered in the derived collection should
                // have no effect on the derived.
                items.Remove(d);

                Assert.True(onlyVisible.SequenceEqual(new[] { "E", "C", "B", "A" }, StringComparer.Ordinal));
                Assert.Equal(4, onlyVisible.Count);

                c.IsVisible = false;
                Assert.Equal(3, onlyVisible.Count);
                Assert.True(onlyVisible.SequenceEqual(new[] { "E", "B", "A" }, StringComparer.Ordinal));

                items.Remove(c);
                Assert.Equal(3, onlyVisible.Count);
                Assert.True(onlyVisible.SequenceEqual(new[] { "E", "B", "A" }, StringComparer.Ordinal));

                items.Remove(b);
                Assert.Equal(2, onlyVisible.Count);
                Assert.True(onlyVisible.SequenceEqual(new[] { "E", "A" }, StringComparer.Ordinal));
            }
        public void AddDecoy(GameObject decoy)
        {
            decoyList.Add(decoy);

            decoy
            .OnDestroyAsObservable()
            .Subscribe(_ =>
            {
                decoyList.Remove(decoy);
            })
            .AddTo(gameObject);
        }
Example #27
0
        protected void OnDetectGround(IEnumerable <Collider> grounds)
        {
            lock (_grounds)
            {
                var collection = grounds.ToHashSet();

                var oldContacts = GroundContacts.Except(collection);
                var contacts    = collection.Except(GroundContacts);

                oldContacts.ForEach(c => _grounds.Remove(c));
                contacts.ForEach(c => _grounds.Add(c));
            }
        }
 private void OnCollision(Info sender, Collider coll)
 {
     if (coll.gameObject.layer == m_AsteroidLayer)
     {
         var aim = coll.gameObject.GetComponent <Asteroids.AsteroidInfoMono>();
         if (aim == null)
         {
             return;
         }
         m_AsteroidHC.SetDamage(aim.Info, 1);
         m_Bullets.Remove(sender);
     }
 }
Example #29
0
        // tileを選択
        private void SelectTile()
        {
            var currentPointData = new PointerEventData(EventSystem.current)
            {
                position = Input.mousePosition
            };

            EventSystem.current.RaycastAll(currentPointData, rayResult);

            // 飛ばしたrayの中にtileが含まれているか
            var tile = rayResult
                       .Select(x => x.gameObject.GetComponent <ITile>())
                       .FirstOrDefault(x => x != null);

            if (tile == null)
            {
                return;
            }

            audioManager.PlaySE(SfxType.TileClick);
            var coordinates = tile.Coordinates;
            var frontTile   = tileSpawner.GetTile(coordinates);

            // 現在の選択するによって場合分け
            switch (selectedCoordinates.Count())
            {
            case 0:
                if (frontTile == null)
                {
                    return;
                }
                frontTile.SetIsSelected(true);
                selectedCoordinates.Add(coordinates);
                break;

            case 1:
                if (selectedCoordinates.Contains(coordinates))
                {
                    selectedCoordinates.Remove(coordinates);
                    if (frontTile != null)
                    {
                        frontTile.SetIsSelected(false);
                    }
                }
                else
                {
                    selectedCoordinates.Add(coordinates);
                }
                break;
            }
        }
Example #30
0
        void ReactiveSubscribe()
        {
            disposables = new CompositeDisposable();
            ReactiveCollection <int> m_ReaList = new ReactiveCollection <int>();

            m_ReaList.ObserveCountChanged().Subscribe(x => { Debug.Log(x); }).AddTo(disposables);

            m_ReaList.ObserveAdd().Subscribe(x => { Debug.Log(x); }).AddTo(disposables);
            m_ReaList.ObserveRemove().Subscribe(x => Debug.Log(x)).AddTo(disposables);
            m_ReaList.Add(1);
            m_ReaList.Remove(1);

            CurrentSub = disposables;
        }
        public NotificationSettingsViewModel(NotificationSettings notification)
        {
            _notification = notification;

            Notifications = new ReactiveCollection<NotificationViewModel>();

            foreach (var notificationEntry in notification.Notifications)
            {
                Notifications.Add(new NotificationViewModel(notificationEntry, this));
            }

            AddNotificationCommand = new ReactiveCommand();
            AddNotificationCommand.Subscribe(_ =>
                {
                    Notifications.Add(new NotificationViewModel(
                                      	new NotificationEntry
                                      		{
                                      			Triggers = new[] {new NotificationTrigger()},
                                      			Actions = new[] {new NotificationAction()}
                                      		},
                                      	this));
                    Notifications.Last().Actions.First().IsEditing = true;
                    Notifications.Last().Triggers.First().IsEditing = true;
                });

            DeleteNotificationCommand = new ReactiveCommand();
            DeleteNotificationCommand.OfType<NotificationViewModel>().Subscribe(n => Notifications.Remove(n));

            (ToggleEditCommand = new ReactiveCommand()).Do(_ => Trace.WriteLine(_)).OfType<IToggleEdit>().Subscribe(editable =>
            {
                bool valueToSet = !editable.IsEditing;
                foreach (var notificationViewModel in Notifications)
                {
                    notificationViewModel.CollapseAll();
                }

                editable.IsEditing = valueToSet;
            });
        }
        public NotificationViewModel(NotificationEntry notificationEntry, NotificationSettingsViewModel parent)
        {
            _notificationEntry = notificationEntry;
            _parent = parent;
            Triggers = new ReactiveCollection<TriggerViewModel>();

            foreach (var trigger in notificationEntry.Triggers)
            {
                Triggers.Add(new TriggerViewModel(trigger));
            }

            Actions = new ReactiveCollection<ActionViewModel>();
            foreach (var notificationAction in notificationEntry.Actions)
            {
                Actions.Add(new ActionViewModel(notificationAction));
            }

            AddNewTriggerCommand = new ReactiveCommand();
            AddNewTriggerCommand.Subscribe(_ =>
                {
                    Triggers.Add(new TriggerViewModel(new NotificationTrigger()));
                    SelectedTrigger = Triggers.Last();
                    _parent.ToggleEditCommand.Execute(Triggers.Last());
                });

            AddNewActionCommand = new ReactiveCommand();
            AddNewActionCommand.Subscribe(_ =>
                {
                    Actions.Add(new ActionViewModel(new FlashTaskBarNotificationAction()));
                    SelectedAction = Actions.Last();
                    _parent.ToggleEditCommand.Execute(Actions.Last());
                });

            DeleteItemCommand = new ReactiveCommand();
            DeleteItemCommand.OfType<TriggerViewModel>().Subscribe(t => Triggers.Remove(t));
            DeleteItemCommand.OfType<ActionViewModel>().Subscribe(a => Actions.Remove(a));
        }