예제 #1
0
        void Update()
        {
            // Collect all the finished WWWs.
            var keysToRemove = new List <string>();

            foreach (var keyValue in m_DownloadingWWWs)
            {
                WWW download = keyValue.Value;

                // If downloading fails.
                if (download.error != null)
                {
                    m_DownloadingErrors.Add(keyValue.Key, string.Format("Failed downloading bundle {0} from {1}: {2}", keyValue.Key, download.url, download.error));
                    keysToRemove.Add(keyValue.Key);
                    continue;
                }

                // If downloading succeeds.
                if (download.isDone)
                {
                    AssetBundle bundle = download.assetBundle;
                    if (bundle == null)
                    {
                        m_DownloadingErrors.Add(keyValue.Key, string.Format("{0} is not a valid asset bundle.", keyValue.Key));
                        keysToRemove.Add(keyValue.Key);
                        continue;
                    }

                    //Debug.Log("Downloading " + keyValue.Key + " is done at frame " + Time.frameCount);
                    m_LoadedAssetBundles.Add(keyValue.Key, new LoadedAssetBundle(download.assetBundle));
                    keysToRemove.Add(keyValue.Key);
                }
            }

            // Remove the finished WWWs.
            foreach (var key in keysToRemove)
            {
                WWW download = m_DownloadingWWWs[key];
                m_DownloadingWWWs.Remove(key);
                download.Dispose();
            }

            // Update all in progress operations
            for (int i = 0; i < m_InProgressOperations.Count;)
            {
                if (!m_InProgressOperations[i].Update())
                {
                    m_InProgressOperations.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }
        }
예제 #2
0
        public void RxDictObserve()
        {
            var dict = new ReactiveDictionary <string, int>();

            var count = 0;
            DictionaryAddEvent <string, int>     addE     = null;
            DictionaryRemoveEvent <string, int>  removeE  = null;
            DictionaryReplaceEvent <string, int> replaceE = null;
            var resetCount = 0;

            dict.ObserveCountChanged().Subscribe(x => count = x);
            dict.ObserveAdd().Subscribe(x => addE           = x);
            dict.ObserveRemove().Subscribe(x => removeE     = x);
            dict.ObserveReplace().Subscribe(x => replaceE   = x);
            dict.ObserveReset().Subscribe(x => resetCount  += 1);

            dict.Add("a", 100);
            count.Is(1);
            addE.Key.Is("a"); addE.Value.Is(100);

            dict.Add("b", 200);
            count.Is(2);
            addE.Key.Is("b"); addE.Value.Is(200);

            count     = -1;
            dict["a"] = 300;
            count.Is(-1);     // not fired
            addE.Key.Is("b"); // not fired
            replaceE.Key.Is("a"); replaceE.OldValue.Is(100); replaceE.NewValue.Is(300);

            dict["c"] = 400;
            count.Is(3);
            replaceE.Key.Is("a"); // not fired
            addE.Key.Is("c"); addE.Value.Is(400);

            dict.Remove("b");
            count.Is(2);
            removeE.Key.Is("b"); removeE.Value.Is(200);

            count = -1;
            dict.Remove("z");
            count.Is(-1);        // not fired
            removeE.Key.Is("b"); // not fired

            dict.Clear();
            count.Is(0);
            resetCount.Is(1);

            count = -1;
            dict.Clear();
            resetCount.Is(2);
            count.Is(-1); // not fired
        }
예제 #3
0
        public void RxDictObserve()
        {
            var dict = new ReactiveDictionary<string, int>();

            var count = 0;
            DictionaryAddEvent<string, int> addE = null;
            DictionaryRemoveEvent<string, int> removeE = null;
            DictionaryReplaceEvent<string, int> replaceE = null;
            var resetCount = 0;

            dict.ObserveCountChanged().Subscribe(x => count = x);
            dict.ObserveAdd().Subscribe(x => addE = x);
            dict.ObserveRemove().Subscribe(x => removeE = x);
            dict.ObserveReplace().Subscribe(x => replaceE = x);
            dict.ObserveReset().Subscribe(x => resetCount += 1);

            dict.Add("a", 100);
            count.Is(1);
            addE.Key.Is("a"); addE.Value.Is(100);

            dict.Add("b", 200);
            count.Is(2);
            addE.Key.Is("b"); addE.Value.Is(200);

            count = -1;
            dict["a"] = 300;
            count.Is(-1); // not fired
            addE.Key.Is("b"); // not fired
            replaceE.Key.Is("a"); replaceE.OldValue.Is(100); replaceE.NewValue.Is(300);

            dict["c"] = 400;
            count.Is(3);
            replaceE.Key.Is("a"); // not fired
            addE.Key.Is("c"); addE.Value.Is(400);

            dict.Remove("b");
            count.Is(2);
            removeE.Key.Is("b"); removeE.Value.Is(200);

            count = -1;
            dict.Remove("z");
            count.Is(-1); // not fired
            removeE.Key.Is("b"); // not fired

            dict.Clear();
            count.Is(0);
            resetCount.Is(1);

            count = -1;
            dict.Clear();
            resetCount.Is(2);
            count.Is(-1); // not fired
        }
        void Start()
        {
            foreach (var item in dic)
            {
                Debug.LogFormat("key:{0}, value:{1}", item.Key, item.Value);
            }

            dic.ObserveAdd()
            .Subscribe(item =>
            {
                Debug.LogFormat("Add key:{0}, value:{1}", item.Key, item.Value);
            });

            dic.ObserveRemove()
            .Subscribe(item =>
            {
                Debug.LogFormat("Remove key:{0}, value:{1}", item.Key, item.Value);
            });

            dic.ObserveCountChanged()
            .Subscribe(count =>
            {
                Debug.Log("Dic count " + count);
            });

            dic.Add("fn", "法语");
            dic.Remove("en");
        }
예제 #5
0
        public override MemoryBrowser CreateMemoryBrowser(string id, object root)
        {
            var mBrowser = new MemoryBrowser(root);

            browsers.Add(id, mBrowser);
            return(mBrowser);
        }
 /// <summary>
 /// 测试字典
 /// </summary>
 private void ChinarReactiveDictionary()
 {
     Print("----------------以下为字典测试----------------");
     //观察  列表发生相应变化 并订阅相应 输出信息,为了便于查看
     chinarReactiveDictionary.ObserveAdd().Subscribe(_ => Print("添加:" + _));
     chinarReactiveDictionary.ObserveRemove().Subscribe(_ => PrintR("移除:" + _));
     chinarReactiveDictionary.ObserveCountChanged().Subscribe(_ => print("数量:" + _));
     chinarReactiveDictionary.ObserveReplace().Subscribe(_ => print("替换:" + _));
     chinarReactiveDictionary.ObserveReset().Subscribe(_ => print("重置:" + _));
     //测试列表信息变动 (只要数量发生改变,ObserveCountChanged 都会被调用,所以一下不用写)
     chinarReactiveDictionary.Add(0, "A");      //对应 —— ObserveAdd
     chinarReactiveDictionary.Add(1, "B");      //对应 —— ObserveAdd
     chinarReactiveDictionary.Remove(0);        //—— ObserveRemove
     chinarReactiveDictionary[0] = "Chinar-替换"; //—— ObserveReplace
     chinarReactiveDictionary.Clear();          //—— ObserveReset
 }
        async UniTask TransIn(string name)
        {
            GameObject transObject = null;

            if (!_transObjects.TryGetValue(name, out transObject))
            {
                transObject = await _factory.Create(name);

                _transObjects.Add(name, transObject);
            }

            if (transObject == null)
            {
                Debug.unityLogger.LogError(GetType().Name, $"{name} is not found.");
                return;
            }

            var transition = transObject.GetComponent <ITransition>();

            if (transition == null)
            {
                Debug.unityLogger.LogError(GetType().Name, $"{name} is not implementation.");
                return;
            }

            _transStack.Push(transition);
            await transition.OnTransIn(_settings.DefaultDuration);

            _onTransInComplete.OnNext(Unit.Default);
        }
예제 #8
0
 void IInitializable.Initialize()
 {
     _intent
     .OnShowAsObservable()
     .Where(_ => !_isShow.Value)
     .Do(_ => _isShow.Value = true)
     .Select(type => {
         Context context = null;
         if (!_contexts.TryGetValue(type, out context))
         {
             var loadingObject = _factory.Create(type);
             context           = new Context()
             {
                 Loading = loadingObject.GetComponent <ILoading>(),
                 Object  = loadingObject,
             };
             _contexts.Add(type, context);
         }
         return(context.Loading);
     })
     .SelectMany(x => x.OnShowAsObservable().First().Select(_ => x))
     .SelectMany(x => _intent.OnHideAsObservable().First().Select(_ => x))
     .SelectMany(x => x.OnHideAsObservable().First())
     .Do(_ => _isShow.Value = false)
     .Subscribe()
     .AddTo(_disposable);
 }
        void IInitializable.Initialize()
        {
            _intent.OnTransInAsObservable()
            .Where(x => x != TransMode.None)
            .Select(trans => {
                GameObject transObject = null;
                if (!_transObjects.TryGetValue(trans, out transObject))
                {
                    transObject = _factory.Create(trans);
                    _transObjects.Add(trans, transObject);
                }
                return(transObject);
            })
            .Select(x => x.GetComponent <ITransition>())
            .Where(x => x != null)
            .Do(x => _transStack.Push(x))
            .SelectMany(x => x.OnTransInAsObservable().First())
            .Subscribe(_onTransInComplete.OnNext)
            .AddTo(_disposable);

            _intent.OnTransOutAsObservable()
            .Where(_ => _transStack.Count > 0)
            .Select(_ => _transStack.Pop())
            .SelectMany(x => x.OnTransOutAsObservable().First())
            .Subscribe(_onTransOutComplete.OnNext)
            .AddTo(_disposable);
        }
예제 #10
0
        void IInitializable.Initialize()
        {
            _intent
            .OnOpenAsObservable()
            .Select(request => {
                Context context = null;
                if (!_contexts.TryGetValue(request.Type, out context))
                {
                    var toastObject = _factory.Create(request.Type);
                    context         = new Context()
                    {
                        Toast  = toastObject.GetComponent <IToast>(),
                        Object = toastObject,
                    };
                    _contexts.Add(request.Type, context);
                }
                return(new Request()
                {
                    Toast = context.Toast,
                    Param = request.Param,
                });
            })
            .Where(x => x.Toast != null)
            .Subscribe(x => {
                if (_current.Value == null)
                {
                    _isOpen.Value  = true;
                    _current.Value = x;
                }
                else
                {
                    _requests.Enqueue(x);
                }
            })
            .AddTo(_disposable);

            Observable
            .EveryUpdate()
            .Where(_ => _current.Value == null)
            .Select(_ => _requests.Count > 0)
            .Do(x => _isOpen.Value = x)
            .Where(x => x)
            .Select(_ => _requests.Dequeue())
            .Subscribe(x => _current.Value = x)
            .AddTo(_disposable);

            _current
            .Where(x => x != null)
            .SelectMany(x => x.Toast.OnOpenAsObservable(x.Param)
                        .First()
                        .Select(_ => x))
            .SelectMany(x => Observable.Timer(TimeSpan.FromSeconds(_settings.ShowDuration))
                        .First()
                        .Select(_ => x))
            .SelectMany(x => x.Toast.OnCloseAsObservable())
            .Subscribe(_ => _current.Value = null)
            .AddTo(_disposable);
        }
예제 #11
0
        public PlayerCore CreatePlayer(PlayerId id, Vector3 position, Vector3[] respawnPositions, IGameStateProvider gameStateProvider)
        {
            var go   = Instantiate(_playerPrefab, position, Quaternion.LookRotation(Vector3.back));
            var core = go.GetComponent <PlayerCore>();

            core.InitializePlayer(id, respawnPositions, gameStateProvider);
            _players.Add(id, core);
            return(core);
        }
예제 #12
0
    // Start is called before the first frame update
    void Start()
    {
        languageCode.ObserveAdd().Subscribe(code => Debug.LogFormat("Add: {0}", code));
        languageCode.ObserveRemove().Subscribe(code => Debug.LogFormat("Removed: {0}", code));
        languageCode.ObserveCountChanged().Subscribe(count => Debug.LogFormat("Count: {0}", count));

        languageCode.Add("jp", "日文");
        languageCode.Remove("en");
    }
예제 #13
0
    void Start()
    {
        mLanguageCode.ObserveAdd().Subscribe(addLag => Debug.LogFormat("add {0}", addLag));
        mLanguageCode.ObserveRemove().Subscribe(removeLag => Debug.LogFormat("remove {0}", removeLag));
        mLanguageCode.ObserveCountChanged().Subscribe(count => Debug.LogFormat("count {0}", count));

        mLanguageCode.Add("jp", "日语");
        mLanguageCode.Remove("en");
    }
예제 #14
0
 public void AddBubble(BubbleViewModel bubbleViewModel, bool processMerges = false)
 {
     _bubbleViewModels.Add(bubbleViewModel.GridPosition.Value, bubbleViewModel);
     if (processMerges)
     {
         _bubbleAddedSerialDisposable.Disposable = bubbleViewModel.IsOnGrid
                                                   .SkipLatestValueOnSubscribe()
                                                   .IfTrue()
                                                   .Subscribe(_ => StartMerging(bubbleViewModel));
     }
 }
예제 #15
0
 void Add(string name, long amount)
 {
     if (!_resources.TryGetValue(name, out var viewModel))
     {
         var model = new ResourceModel(name, 0);
         _model.Content.Add(model);
         viewModel = new ResourceViewModel(model);
         _resources.Add(name, viewModel);
     }
     viewModel.Add(amount);
 }
예제 #16
0
    /// <summary>
    /// Create player
    /// </summary>
    /// <param name="id">プレイヤーID</param>
    /// <param name="pos">初期ポジション</param>
    /// <param name="Respawnpos">リスポーンポジション</param>
    /// <returns></returns>
    EnemyCore Create(int id, Vector3 pos, Vector3 Respawnpos)
    {
        //Instantiate Player prefab
        EnemyCore prefab = Instantiate(EnemyPrefab, pos, Quaternion.LookRotation(Vector3.back));

        var core = prefab.GetComponent <EnemyCore>();

        //initialization player
        core.Initialize(id, pos, this);
        _enemies.Add(id, core);
        return(core);
    }
예제 #17
0
    /// <summary>
    /// ReactiveDictionaryの実行
    /// </summary>
    private void ExcuteReactiveDictionary()
    {
        // ReactiveDictionary
        ReactiveDictionary <string, int> reactiveDictionary = new ReactiveDictionary <string, int>();

        // Subscribe時に値を発行
        // 要素追加時
        reactiveDictionary
        .ObserveAdd()
        .Subscribe(x => {
            Debug.Log(string.Format("要素追加, Key : {0}, Value : {1}", x.Key, x.Value));
        });

        // 要素削除時
        reactiveDictionary
        .ObserveRemove()
        .Subscribe(x => {
            Debug.Log(string.Format("要素削除, Key : {0}, Value : {1}", x.Key, x.Value));
        });

        // 要素数変化時
        reactiveDictionary
        .ObserveCountChanged()
        .Subscribe(x => {
            Debug.Log(string.Format("要素数変化, Count : {0}", x));
        });

        // 要素を追加するとOnNext
        reactiveDictionary.Add("スライム", 10);
        reactiveDictionary.Add("ドラゴン", 100);
        reactiveDictionary.Add("魔王", 1000);

        // 要素を削除するとOnNext
        reactiveDictionary.Remove("スライム");
        foreach (var keyValue in reactiveDictionary)
        {
            Debug.Log(string.Format("Dictionaryの中身, Key : {0}, Value : {1}", keyValue.Key, keyValue.Value));
        }
    }
예제 #18
0
        void IInitializable.Initialize()
        {
            for (int x = 0; x < FieldSize.Value; x++)
            {
                for (int y = 0; y < FieldSize.Value; y++)
                {
                    m_field.Add(new Vector2Int(x, y), null);
                }
            }

            m_onStateChanged = m_stateChangedObservable
                               .OnStateChanged()
                               .Subscribe(OnStateChanged);
        }
예제 #19
0
    public void SelectTeam(int clientId, int lane, int teamIdx)
    {
        if (!PlayerSequences.ContainsKey(lane))
        {
            PlayerSequences.Add(lane, new PlayerSquenceReactiveProperty());
            GameObject actor = Instantiate(Teams[teamIdx].actor, Vector3.zero,
                                           Quaternion.identity, Players[lane].transform);

            RuntimeAnimatorController animatorController = Teams[teamIdx].isTightEnd ? TightEndController : WideController;

            Players[lane]
            .Initialize(lane, actor, IdleController, animatorController, Teams[teamIdx].actorHeight, PlayerSequences[lane]);
        }
    }
예제 #20
0
        void IInitializable.Initialize()
        {
            _intent
            .OnStartAsObservable()
            .Select(x => {
                Context context = null;
                if (!_contexts.TryGetValue(x, out context))
                {
                    var tapEffectObject = _factory.Create(x);
                    context             = new Context()
                    {
                        TapEffect = tapEffectObject.GetComponent <ITapEffect>(),
                        Object    = tapEffectObject,
                    };
                    _contexts.Add(x, context);
                }
                return(context);
            })
            .Subscribe(x => _currentContext.Value = x)
            .AddTo(_disposable);

            _intent
            .OnStopAsObservable()
            .Subscribe(_ => _currentContext.Value = null)
            .AddTo(_disposable);

            var current = Observable.EveryUpdate()
                          .Select(_ => _currentContext.Value)
                          .Where(x => x != null)
                          .Select(x => x.TapEffect)
                          .Publish()
                          .RefCount();

            current
            .Where(_ => Input.GetMouseButtonDown(0))
            .SelectMany(x => x.OnShowAsObservable().First())
            .Subscribe()
            .AddTo(_disposable);

            current
            .Where(_ => Input.GetMouseButtonUp(0))
            .SelectMany(x => x.OnHideAsObservable().First())
            .Subscribe()
            .AddTo(_disposable);

            current
            .Where(_ => Input.GetMouseButton(0))
            .Subscribe(x => x.OnMove(Input.mousePosition))
            .AddTo(_disposable);
        }
예제 #21
0
 void initObtainedObjectCounts()
 {
     obtainedObjectCounts.Add(GameItemType.coin.ToString(), 0);
     obtainedObjectCounts.Add(GameItemType.jewel.ToString(), 0);
     obtainedObjectCounts.Add(GameItemType.securityCamera.ToString(), 0);
     obtainedObjectCounts.Add(GameItemType.bread.ToString(), 0);
     obtainedObjectCounts.Add(GameItemType.treasureCoin.ToString(), 0);
     obtainedObjectCounts.Add(GameItemType.empty.ToString(), 0);
 }
예제 #22
0
파일: Test.cs 프로젝트: BetrC/UniRx
        public static void ReactiveDictionaryExample()
        {
            var dict = new ReactiveDictionary <int, string>()
            {
                { 1, "Tom" },
                { 2, "Jack" }
            };

            dict.ObserveAdd()
            .Subscribe(value => { Debug.Log($"Add: {value}"); });
            dict.ObserveRemove()
            .Subscribe(value => { Debug.Log($"Remove: {value}"); });
            dict.Add(3, "Tony");
            dict.Remove(1);
        }
예제 #23
0
        public void AddAnimalRemoteData(AnimalRemoteData animal)
        {
            // Seeding the Meta to GameState Instances.
            animal.FarmEntityData =
                _staticDataModel.MetaData.Animals.First(a => a.AnimalType.Equals(animal.AnimalType));

            // Creating Models respecting to GameStateEntries.
            var tmp = _animalFactory.Create();

            // Seeding the GameStateData to the in-memory Model.
            tmp.SeedAnimalRemoteData(animal);

            // Adding it to the Animals List.
            AnimalRemoteDatas.Add(animal.Id, tmp);
        }
예제 #24
0
        private async UniTask <ILoading> Find(string name)
        {
            Context context = null;

            if (!_contexts.TryGetValue(name, out context))
            {
                var loadingObject = await _factory.Create(name);

                context = new Context()
                {
                    Loading = loadingObject.GetComponent <ILoading>(),
                    Object  = loadingObject,
                };
                _contexts.Add(name, context);
            }
            return(context.Loading);
        }
        private async UniTask Start(string name)
        {
            Context context = null;

            if (!_contexts.TryGetValue(name, out context))
            {
                var tapEffectObject = await _factory.Create(name);

                context = new Context()
                {
                    TapEffect = tapEffectObject.GetComponent <ITapEffect>(),
                    Object    = tapEffectObject,
                };
                _contexts.Add(name, context);
            }

            _currentContext.Value = context;
        }
예제 #26
0
        void Awake()
        {
            _Client = new AgoraClient();

            _Client.OnUserJoinedAsObservable()
            .Subscribe(userId =>
            {
                _RemoteUsers.Add(userId, "User-" + userId);
            })
            .AddTo(this);

            _Client.OnUserLeftAsObservable()
            .Subscribe(userId =>
            {
                _RemoteUsers.Remove(userId);
            })
            .AddTo(this);
        }
예제 #27
0
        public static ManagedReactiveDictionary <TKey, TElement> ToManagedReactiveDictionary <TSource, TKey, TElement>(
            this IObservable <IEnumerable <TSource> > source,
            Func <TSource, TKey> keySelector,
            Func <TSource, TElement> elementFactory,
            Action <TElement> elementDisposer)
        {
            var dict         = new ReactiveDictionary <TKey, TElement>();
            var newDict      = new Dictionary <TKey, TSource>();
            var keysToRemove = new List <TKey>();
            var subscription = source
                               .Subscribe(items =>
            {
                foreach (var item in items)
                {
                    newDict.Add(keySelector.Invoke(item), item);
                }
                foreach (var kvp in dict)
                {
                    if (!newDict.ContainsKey(kvp.Key))
                    {
                        keysToRemove.Add(kvp.Key);
                    }
                }
                foreach (var key in keysToRemove)
                {
                    var element = dict[key];
                    dict.Remove(key);
                    elementDisposer.Invoke(element);
                }
                foreach (var kvp in newDict)
                {
                    if (!dict.ContainsKey(kvp.Key))
                    {
                        dict.Add(kvp.Key, elementFactory.Invoke(kvp.Value));
                    }
                }
                newDict.Clear();
                keysToRemove.Clear();
            });

            return(new ManagedReactiveDictionary <TKey, TElement>(dict,
                                                                  StableCompositeDisposable.Create(dict, subscription)));
        }
예제 #28
0
    // Use this for initialization
    void Start()
    {
        var reactiveDictionary = new ReactiveDictionary <int, string>()
        {
            { 0, "酒酣胸胆尚开张" },
            { 1, "鬓微霜" },
            { 2, "又何妨" }
        };

        reactiveDictionary.ObserveAdd()
        .Subscribe(addStr =>
        {
            Debug.LogFormat("add str{0}", addStr);
        });

        reactiveDictionary.ObserveRemove()
        .Subscribe(RemoveStr =>
        {
            Debug.LogFormat("Remove str{0}", RemoveStr);
        });

        reactiveDictionary.ObserveReplace()
        .Subscribe(MoveStr =>
        {
            Debug.LogFormat("Move str{0}", MoveStr);
        });

        reactiveDictionary.ObserveCountChanged()
        .Subscribe(addStr =>
        {
            Debug.LogFormat("Change str{0}", addStr);
        });

        reactiveDictionary.Add(3, "射天狼");
        reactiveDictionary.Remove(0);


        foreach (var item in reactiveDictionary)
        {
            Debug.LogFormat("item:{0}", item);
        }
    }
        public void Initialize(NetworkObject networkedObjectPrefab, Transform networkedObjectParent)
        {
            if (_Initialized)
            {
                return;
            }

            _NetworkObjectPrefab = networkedObjectPrefab;
            _NetworkObjectParent = networkedObjectParent;

            ObserveNetworkSpawnedObjects();

            OnNetworkObjectSpawnedAsObservable()
            .Subscribe(spawnedObjects =>
            {
                // Debug.Log("SpawnedNetObjects: " + spawnedObjects.Count);
                foreach (var networkObject in spawnedObjects)
                {
                    T component = networkObject.GetComponent <T>();
                    if (component != null)
                    {
                        _NetworkObjects.Add(networkObject.NetworkObjectId, component);
                    }
                }
            })
            .AddTo(this);

            OnNetworkObjectDestroyedAsObservable()
            .Subscribe(destroyedObjectIds =>
            {
                // Debug.Log("DestroyedNetObjects: " + destroyedObjectIds.Count);
                foreach (ulong objectId in destroyedObjectIds)
                {
                    _NetworkObjects.Remove(objectId);
                }
            })
            .AddTo(this);

            _Initialized = true;
        }
예제 #30
0
        public void TestAddingAndRemoving()
        {
            // New dictionary
            ReactiveDictionary <string, int> dict = new ReactiveDictionary <string, int>();

            Assert.IsFalse(dict.TryGetValue("A", out int _));
            Assert.AreEqual(0, dict.Count);

            // Add {A, 1}
            dict["A"] = 1;
            Assert.IsTrue(dict.TryGetValue("A", out int value));
            Assert.AreEqual(1, value);
            Assert.AreEqual(1, dict.Count);

            Assert.IsTrue(dict.SequenceEqual(new[]
            {
                new KeyValuePair <string, int>("A", 1)
            }));
            Assert.IsTrue(dict.Keys.SequenceEqual(new[] { "A" }));
            Assert.IsTrue(dict.Values.SequenceEqual(new[] { 1 }));

            // Add {B, 1}
            dict.Add("B", 2);
            Assert.AreEqual(2, dict["B"]);
            Assert.AreEqual(2, dict.Count);

            // Remove A
            Assert.IsTrue(dict.Remove("A"));
            Assert.IsFalse(dict.TryGetValue("A", out int _));
            Assert.AreEqual(1, dict.Count);

            Assert.IsTrue(dict.ContainsKey("B"));
            Assert.IsFalse(dict.ContainsKey("A"));
            Assert.IsFalse(dict.ContainsKey("Z"));

            // Clear
            dict.Clear();
            Assert.AreEqual(0, dict.Count);
            Assert.IsTrue(dict.SequenceEqual(new KeyValuePair <string, int> [0]));
        }
        private async UniTask Open(RequestDialog request)
        {
            Context context = null;

            if (!_contexts.TryGetValue(request.Name, out context))
            {
                var dialogObject = await _factory.Spawn(request.Name);

                context = new Context()
                {
                    Dialog = dialogObject.GetComponent <IDialog>(),
                    Object = dialogObject,
                };
                _contexts.Add(request.Name, context);
            }

            await Open(new Request()
            {
                Dialog = context.Dialog,
                Param  = request.Param,
            });
        }