public override void Stop()
 {
     _disposable?.Dispose();
     _disposable     = null;
     pingpong_switch = false;
     base.Stop();
 }
Example #2
0
 public void Start()
 {
     if (parent.isCoroutine)
     {
         comp.StopCoroutine(methodName);
         comp.StartCoroutine(methodName);
     }
     else
     {
         if (_disposable != null)
             _disposable.Dispose();
         _disposable = taskFunc();
     }
 }
        /// <summary>
        /// All-in-one. Update the graphic on the overlay if it was previously added
        /// otherwise, make it and add it
        /// </summary>
        /// <param name="newLocation">The new location to be added to the map</param>
        /// <param name="mapView"></param>
        /// <returns></returns>
        public static void UpdateMapOverlay(ArcGIS.Core.Geometry.MapPoint point, MapView mapView)
        {
            if (_overlayObject != null)
            {
                _overlayObject.Dispose();
                _overlayObject = null;

                AddToMapOverlay(point, mapView);
            }
            else
            {
                //first time
                AddToMapOverlay(point, mapView);
            }
        }
Example #4
0
        protected void onInspectorGUIEnd()
        {
            System.IDisposable endArea = null;
            if (hasToggleArea == false && propertyNames.Count > 0)
            {
                endArea = area();
            }

            ToggleArea endToggleArea = null;

            foreach (var p in propertyNames)
            {
                var property = serializedObject.FindProperty(p);

                if (property == null)
                {
                    helpBox(p, target.GetType().GetField(p).FieldType);
                    continue;
                }
                var headerName = getToggleAreaName(property.name);
                if (headerName != null)
                {
                    if (endToggleArea != null)
                    {
                        endToggleArea.Dispose();
                    }

                    endToggleArea = toggleArea(headerName);
                }

                if (endToggleArea != null && endToggleArea.open == false)
                {
                    continue;
                }

                //var indentLevel = property.isArray || property.hasVisibleChildren;
                //if (indentLevel) ++EditorGUI.indentLevel;
                EditorGUILayout.PropertyField(property, true);
                //if (indentLevel) --EditorGUI.indentLevel;
            }

            if (endToggleArea != null)
            {
                endToggleArea.Dispose();
                endToggleArea = null;
            }

            if (endArea != null)
            {
                endArea.Dispose();
            }

            if (endToggleArea != null && endArea != null)
            {
                Debug.LogError("endToggleArea != null && endArea != null", this);
            }

            //
            serializedObject.ApplyModifiedProperties();
        }
 internal override void AddFieldStoreValueToSyndicationItem(SyndicationItem syndicationItem)
 {
     if (!string.IsNullOrEmpty(base.FieldStoreValue))
     {
         MatchCollection matchCollection           = base.SplitFieldStoreValue();
         System.Collections.IEnumerator enumerator = matchCollection.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 Match match = (Match)enumerator.Current;
                 syndicationItem.Categories.Add(new SyndicationCategory(base.GetOriginalValue(match.Value)));
             }
             return;
         }
         finally
         {
             System.IDisposable disposable = enumerator as System.IDisposable;
             if (disposable != null)
             {
                 disposable.Dispose();
             }
         }
     }
     base.AddFieldStoreValueToSyndicationItem(syndicationItem);
 }
Example #6
0
    void SetObservable()
    {
        System.IDisposable disposable = null;
        currentTime = gameTotalTime;

        System.IDisposable dis = null;

        dis = Observable.Interval(System.TimeSpan.FromSeconds(1)).Skip(1).Subscribe(_ => {
            UpdateCost(recoveryCost);

            currentTime        = Mathf.Max(0, currentTime - 1);
            gameTimeLabel.text = string.Format("Time : {0}", currentTime);
            if (currentTime == 0)
            {
                dis.Dispose();
                countDown.text = "Finish!!";

                Observable.Timer(System.TimeSpan.FromSeconds(3)).Subscribe(__ => {
                    CheckWinner();
                }).AddTo(gameObject);
            }
        }).AddTo(gameObject);


        Observable.Interval(System.TimeSpan.FromSeconds(3)).Skip(1).Subscribe(_ => {
            CheckTransmission();
        }).AddTo(gameObject);
    }
Example #7
0
    void SetSpawnObservable()
    {
        if (spawnDisposable != null)
        {
            spawnDisposable.Dispose();
        }
        if (currentUnitButton == null)
        {
            return;
        }

        var time = (UnitSettingLoader.GetSetting(currentUnitButton.ButtonId).hitPoint / 2f) * 0.01f;

        spawnDisposable = background.OnClickAsObservable().ThrottleFirst(System.TimeSpan.FromSeconds(time)).Subscribe(_ => {
            if (!gameStart)
            {
                return;
            }
            if (currentUnitButton == null || string.IsNullOrEmpty(currentUnitButton.ButtonId))
            {
                return;
            }
            CreateOwnUnit(currentUnitButton.ButtonId, Input.mousePosition);
        }).AddTo(gameObject);
    }
Example #8
0
        public void TestFilterAdd()
        {
            IReactiveSet <int> source = new ReactiveSet <int>();

            FilterSet <int> filtered = new FilterSet <int>(source, x => x > 4);

            source.Add(3);
            source.Add(4);
            source.Add(5);
            source.Add(6);

            Assert.IsFalse(filtered.IsSubscribed);

            List <int> ints = new List <int>();

            System.IDisposable disp = filtered.ObserveAdd().Subscribe(@event => { ints.Add(@event.Value); });

            CollectionAssert.AreEquivalent(ints, new [] { 5, 6 });

            Assert.IsTrue(filtered.IsSubscribed);

            source.Add(7);
            CollectionAssert.AreEquivalent(ints, new [] { 5, 6, 7 });

            disp.Dispose();

            Assert.IsFalse(filtered.IsSubscribed);
        }
Example #9
0
 public static void Destroy(this System.IDisposable obj)
 {
     if (obj != null)
     {
         obj.Dispose();
     }
 }
Example #10
0
 /// <summary>
 /// Disposes a object if possible.
 /// </summary>
 /// <param name="oDisp">IDisposable to dispose</param>
 public static void Dispose(System.IDisposable oDisp)
 {
     if (oDisp != null)
     {
         oDisp.Dispose();
     }
 }
Example #11
0
        /// <summary>
        /// This code depicts what code is generated by compiler internally for foreach loop in 1P72
        /// </summary>
        public static void CompilerGeneratedCodeForForeach()
        {
            var people = new List <Person>()
            {
                new Person()
                {
                    FirstName = "Jhon", LastName = "Doe"
                },
                new Person()
                {
                    FirstName = "Jane", LastName = "Doe"
                }
            };

            List <Person> .Enumerator e = people.GetEnumerator();

            try
            {
                Person v;
                while (e.MoveNext())
                {
                    //If here we change the value of e.Current,
                    //the iterator pattern cannot detemine what to do on next step.
                    //And thus in corresponding foreach loop the value assigning to variables in not allowed.
                    v = e.Current;
                }
            }
            finally
            {
                System.IDisposable d = e as System.IDisposable;
                d.Dispose();
            }
        }
Example #12
0
    void Update()
    {
        if (StateManager.Instance.matchingState != MatchingState.Matching)
        {
            elapesedSeconds = 0;
            return;
        }
        elapesedSeconds += Time.deltaTime;

        bool isElapsedSeconds          = elapesedSeconds > POLLING_RATE_SECONDS;
        bool isWebRequestNull          = requestEvent == null;
        bool isPreviousWebRequestIsEnd = true;

        if (!isWebRequestNull)
        {
            isPreviousWebRequestIsEnd = webRequestStatus.isDone;
        }
        if (isElapsedSeconds && isPreviousWebRequestIsEnd)
        {
            elapesedSeconds = 0;
            //リクエスト設定し、飛ばす。
            //Debug.Log(REQUEST_URL);
            request          = UnityWebRequest.Get(REQUEST_URL);
            webRequestStatus = request.Send();

            //リクエストの結果を受け取る。
            requestEvent = this.ObserveEveryValueChanged(x => x.webRequestStatus.isDone)
                           .Where(isDone => isDone == true)
                           .Subscribe(isDone =>
            {
                if (request.isNetworkError)
                {
                    Debug.LogError(request.error);
                }
                else
                {
                    if (request.responseCode == 200)
                    {
                        string rawJson = request.downloadHandler.text;
                        //Debug.Log(rawJson);
                        AnswerData answer = JsonUtility.FromJson <AnswerData>(rawJson);
                        if (answer.result)
                        {
                            SetTaxiInfo(answer.taxi_number, answer.taxi_lat, answer.taxi_lng);
                            SetMatchingState(MatchingState.Matched);
                        }
                    }
                    else
                    {
                        Debug.LogError("MatchingChecker:API doesn't return responseCode 200");
                    }
                }

                if (requestEvent != null)
                {
                    requestEvent.Dispose();
                }
            });
        }
    }
Example #13
0
 public void Close()
 {
     _connectStream?.Dispose();
     _connectStream = null;
     _tcpClient?.Close();
     _tcpClient = null;
 }
Example #14
0
        void Start()
        {
            int count = 0;

            GetComponent <View>().Attach <MVVMSampleVM>(vm =>
            {
                vm.Text.Value = "Click !";
                vm.Button     = new DelegateCommand(() =>
                {
                    count++;
                    vm.Text.Value = "Clicked";
                    var item      = new SampleMVVMTextVM {
                        Text = "test" + count
                    };
                    item.OnButton += (index) =>
                    {
                        Debug.Log(index);
                    };
                    vm.Collection.Add(item);
                    vm.ToggleMessage.Value = count % 2 == 0;
                    m_Disposable.Dispose();
                });
                vm.Slider = new DelegateCommand <float>(v => vm.Position.Value = new Vector3(0, v * 10f, 0));
                vm.Submit = new DelegateCommand <string>(Log);
                //vm.Messenger.Register<Event, string>(this, Event.Submit, OnSubmit);
                m_Disposable = vm.Messenger.WeakRegisterHandle(this);
                vm.Messenger.Register <string>(this, Event.Submit, (x) => OnSubmit(x));
                (vm as IViewModel).Event.Subscribe <Event, string>(Event.Submit, (x) => OnSubmit(x));
            });
        }
Example #15
0
 private void OnDestroy()
 {
     if (interval != null)
     {
         interval.Dispose();
     }
 }
Example #16
0
        public void Main()
        {
            var people = new List <Person>()
            {
                new Person()
                {
                    FirstName = "Johm", LastName = "Doe"
                },
                new Person()
                {
                    FirstName = "Jane", LastName = "Doe"
                }
            };

            List <Person> .Enumerator e = people.GetEnumerator();

            try
            {
                Person v;
                while (e.MoveNext())
                {
                    v = e.Current;
                }
            }
            finally
            {
                System.IDisposable d = e as System.IDisposable;
                if (d != null)
                {
                    d.Dispose();
                }
            }
        }
Example #17
0
        public void GetObservableComponentStream()
        {
            Entity firstEntity = this.entityDB.CreateEntity("First entity");

            this.entityDB.AddComponent(firstEntity, 0);

            System.Action update = () =>
            {
                this.entityDB.GetEntitiesWithComponent <int>()
                .Subscribe(entity => entity.Item2.SetValue(entity.Item2.Value + 1));
            };

            int callCount = 0;

            System.IDisposable subscription =
                this.entityDB.GetObservableComponentStream <int>()
                .Subscribe(component => callCount++);

            update();
            update();

            subscription.Dispose();

            Assert.AreEqual(2, callCount, "Component update event not triggered correct amount of times");
        }
Example #18
0
 public static void TryDispose(System.IDisposable obj)
 {
     if (obj == null)
     {
         return;
     }
     obj.Dispose();
 }
Example #19
0
 private void MultiplySkillExecute()
 {
     if (_tempStream != null)
     {
         _tempStream.Dispose();
     }
     _tempStream = Observable.FromCoroutine(MultiplyAsync).Subscribe().AddTo(this);
 }
Example #20
0
 void System.IDisposable.Dispose()
 {
     System.IDisposable disposable = m_writer as System.IDisposable;
     if (disposable != null)
     {
         disposable.Dispose();
     }
 }
Example #21
0
        public override void OnEnter()
        {
            var target = Fsm.GetOwnerDefaultTarget(gameObject);

            if (!target)
            {
                LogWarning("OnPointerDown action of " + this.Name + " has no game object set.");

                Finish();
                return;
            }

            IObservable <PointerEventData> observable = GetRequestedObservable(target, PointerEventType);

            eventTrigger = observable.TakeUntilDestroy(target)
                           .Subscribe(eventData =>
            {
                if (debug != null && debug.Value)
                {
                    Log("OnPointerDownUp action triggered on event " + PointerEventType.ToString());
                }

                if (sendEvent != null)
                {
                    Fsm.Event(sendEvent);
                    eventTrigger.Dispose();

                    if (debug != null && debug.Value)
                    {
                        Log("OnPointerDownUp action sends " + sendEvent.Name + " event on " + PointerEventType.ToString());
                    }
                }

                if (storeWorldPosition != null)
                {
                    StoreWorldPosition(eventData);
                }

//						// too many things in question atm
//						if (storeTargetObject != null)
//						{
//							StoreTargetObject(eventData);
//						}
            });
        }
Example #22
0
 public void Dispose() 
 {
     if (Stream != null)
         Stream.Dispose();
     if (_response != null)
         _response.Dispose();
     if (_client != null)
         _client.Dispose();
 }
Example #23
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         System.IDisposable disposableTarget = this.target;
         disposableTarget.Dispose();
     }
 }
Example #24
0
 /// <summary>
 /// Disposes a object if possible and sets the reference to null.
 /// </summary>
 /// <param name="o">Object reference to dispose</param>
 public static void DisposeToNull <E>(ref E o)
 {
     System.IDisposable oDisp = o as System.IDisposable;
     if (oDisp != null)
     {
         oDisp.Dispose();
     }
     o = default(E);
 }
Example #25
0
 public void Close()
 {
     _updateListenPacketStream?.Dispose();
     _updateListenPacketStream = null;
     _th?.Abort();
     _th = null;
     _udp?.Close();
     _udp = null;
 }
Example #26
0
    private void OnSetObserver(bool bEnable)
    {
        if (null != m_Observer)
        {
            m_Observer.Dispose();
            m_Observer = null;
        }

        if (false == bEnable)
        {
            return;
        }

        List <Vector2> listPosition = new List <Vector2>();

        m_Observer = Observable.EveryUpdate()

#if UNITY_EDITOR
                     .Where(_ => (Input.GetMouseButtonDown(0) || Input.GetMouseButtonUp(0)))
                     .Select(pos => new Vector2(Input.mousePosition.x, Input.mousePosition.y))
#else
                     .Where(_ => Input.touchCount > 0)
                     .Where(_ => (Input.GetTouch(0).phase == TouchPhase.Began) || (Input.GetTouch(0).phase == TouchPhase.Ended))
                     .Select(pos => Input.GetTouch(0).position)
#endif
                     .Subscribe(positions =>
        {
            if (listPosition.Count == 0)
            {
#if UNITY_EDITOR
                if (Input.GetMouseButtonUp(0))
#else
                if ((Input.GetTouch(0).phase == TouchPhase.Ended))
#endif
                { return; }
            }

            listPosition.Add(positions);

            if (listPosition.Count < 2)
            {
                return;
            }

            float fDelta = (listPosition[0] - listPosition[1]).magnitude;
            if (Mathf.Abs(fDelta) < 100.0f)
            {
                OnSetRay(listPosition);
            }
            else
            {
                OnSwipe(listPosition);
            }

            listPosition.Clear();
        });
    }
Example #27
0
 public void ResetMovement()
 {
     if (m_CurrentMovement == null)
     {
         return;
     }
     m_CurrentMovement.Dispose();
     robotState = RobotState.None;
 }
Example #28
0
    protected override void Awake()
    {
        unitTable.Add(UNITASIGN.OWN, new List <Unit> ());
        unitTable.Add(UNITASIGN.OPPONENT, new List <Unit> ());

        gameTimeLabel.text = string.Format("Time : {0}", gameTotalTime);
        UpdateCost(totalCost);

        System.IDisposable disposable = null;

        int count = 4;

        disposable = Observable.Interval(System.TimeSpan.FromSeconds(1)).Subscribe(_ => {
            count--;
            countDown.text = count.ToString();

            if (count == 0)
            {
                countDown.text = "Start!!";
            }
            if (count == -1)
            {
                disposable.Dispose();

                countDown.text = "";
                gameStart      = true;
                SetSpawnObservable();
                SetObservable();
            }
        }).AddTo(gameObject);

        var settings = new List <string> ()
        {
            "red_large_carrier",
            "red_small_carrier",
            "red_unit_1",
            "red_unit_2",
        };

        for (int i = 0; i < 4; i++)
        {
            var setting = UnitSettingLoader.GetSetting(settings [i]);
            buttonParent.Find("UnitButton_" + (i + 1).ToString()).GetComponent <UnitSpawn> ().SetParameter(setting.id);
        }

        if (Network.Client.Instance == null)
        {
            return;
        }
        Network.Client.Instance.onCloseSession           += CloseSession;
        Network.Client.Instance.Reciever.OnRecvSpawnUnit += OnRecvSpawnUnit;

        closeSession.Where(x => x).ObserveOnMainThread().Subscribe(_ => {
            UnityEngine.SceneManagement.SceneManager.LoadScene("Title");
        });
    }
Example #29
0
        private void OnDisable()
        {
            if (_updateStream == null)
            {
                return;
            }

            _updateStream.Dispose();
            _updateStream = null;
        }
Example #30
0
 public void Close()
 {
     _startServerStream?.Dispose();
     _startServerStream = null;
     _updateListenPacketStream?.Dispose();
     _updateListenPacketStream = null;
     _th?.Abort();
     _th = null;
     _tcpListener?.Stop();
     _tcpListener = null;
 }