コード例 #1
0
 void OnDestroy()
 {
     if (this.subscription != null)
     {
         this.subscription.Dispose();
         this.subscription = null;
     }
 }
コード例 #2
0
ファイル: SkillHolder.cs プロジェクト: nearyc/BrickSaboteur
 private void MultiplySkillExecute()
 {
     if (_tempStream != null)
     {
         _tempStream.Dispose();
     }
     _tempStream = Observable.FromCoroutine(MultiplyAsync).Subscribe().AddTo(this);
 }
コード例 #3
0
 public FileResponse(int statusCode, System.Collections.Generic.Dictionary <string, System.Collections.Generic.IEnumerable <string> > headers, System.IO.Stream stream, System.IDisposable client, System.IDisposable response)
 {
     StatusCode = statusCode;
     Headers    = headers;
     Stream     = stream;
     _client    = client;
     _response  = response;
 }
コード例 #4
0
ファイル: Utility.cs プロジェクト: rogalag/Smrvfx
 public static void TryDispose(System.IDisposable obj)
 {
     if (obj == null)
     {
         return;
     }
     obj.Dispose();
 }
コード例 #5
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         System.IDisposable disposableTarget = this.target;
         disposableTarget.Dispose();
     }
 }
コード例 #6
0
        protected override void OnTriggered()
        {
            var buttonModel = Models.ButtonModel;

            subs = buttonModel.CharPanelActive.AsObservable()
                   .Where(val => val == false)
                   .Subscribe(OnCharPanelChanged)
                   .AddTo(this);
        }
コード例 #7
0
ファイル: BaseUDP.cs プロジェクト: kosuda-tatsuya/Klib
 public void Close()
 {
     _updateListenPacketStream?.Dispose();
     _updateListenPacketStream = null;
     _th?.Abort();
     _th = null;
     _udp?.Close();
     _udp = null;
 }
コード例 #8
0
ファイル: BaseTCP.cs プロジェクト: kosuda110/VFXGraphStudy
 protected void StartServer()
 {
     _startServerStream = UniRxUtils.StartCoroutine(StartServerEnumerator, () =>
     {
         Debug.Log($"Success start tcp server : IpAddress = {_host} Port = {_port}");
         _startServerStream        = null;
         _updateListenPacketStream = Observable.EveryUpdate().Subscribe(_ => UpdateListenPacket());
     });
 }
コード例 #9
0
 public void Close()
 {
     _connectStream?.Dispose();
     _connectStream = null;
     _nStream?.Dispose();
     _nStream = null;
     _tcpClient?.Close();
     _tcpClient = null;
 }
コード例 #10
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);
 }
コード例 #11
0
    void Update()
    {
        if (StateManager.Instance.uiState != UIState.Map)
        {
            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);

                        SetComments(answer.comments);
                    }
                    else
                    {
                        Debug.LogError("MatchingChecker:API doesn't return responseCode 200");
                    }
                }

                if (requestEvent != null)
                {
                    requestEvent.Dispose();
                }
            });
        }
    }
コード例 #12
0
ファイル: GameManager.cs プロジェクト: mevlme44/SpaceBattle
 public void WaitForClick(GameObject panel)
 {
     clickEvent = Observable.EveryUpdate()
                  .Where(_ => Input.anyKeyDown)
                  .Subscribe(_ =>
     {
         Click();
     }).AddTo(panel);
 }
コード例 #13
0
        public static void NotifyMissingDispose(System.IDisposable disposable)
        {
            if (disposable == null)
            {
                return;
            }

            Debug.LogError($"An IDisposable instance of type '{disposable.GetType().FullName}' has not been disposed.");
        }
コード例 #14
0
ファイル: SampleUniRx.cs プロジェクト: zeraddul32/TestProject
    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();
        });
    }
コード例 #15
0
 void Awake()
 {
     noteSubscription = MessageBroker.Default.Receive <NoteEvent>()
                        .Where(e => e.Track == track)
                        .Subscribe(e => Spawn(e.Note, e.Power));
     trackSubscription = MessageBroker.Default.Receive <TrackEvent>()
                         .Where(e => e.Track == track)
                         .Subscribe(e => UpdateEnabled(e.State));
 }
コード例 #16
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");
        });
    }
コード例 #17
0
ファイル: SelfDespawn.cs プロジェクト: bbangwon/ACube201804
 // Use this for initialization
 void Start()
 {
     interval = Observable.IntervalFrame(360)
                .First()
                .Subscribe(_ =>
     {
         transform.parent = PoolManager.Pools["ParticlePool"].transform;
         PoolManager.Pools["ParticlePool"].Despawn(this.transform);
     });
 }
コード例 #18
0
        private void OnDisable()
        {
            if (_updateStream == null)
            {
                return;
            }

            _updateStream.Dispose();
            _updateStream = null;
        }
コード例 #19
0
ファイル: BaseUDP.cs プロジェクト: kosuda-tatsuya/Klib
 protected void StartServer(int port)
 {
     _udp = new UdpClient(port);
     _th  = new Thread(new ThreadStart(Recieve))
     {
         IsBackground = true
     };
     _th.Start();
     _updateListenPacketStream = Observable.EveryUpdate().Subscribe(_ => UpdateListenPacket());
 }
コード例 #20
0
    void PointerLoopMoving(RectTransform trans, Vector3 startPos, Vector3 endPos)
    {
        trans.localPosition = startPos;
        Vector3 target            = endPos;
        float   _pointerMoveSpeed = config["fishGame_pointerMoveSpeed"];

        moveLoopMicrotine1 = Observable.EveryFixedUpdate()
                             .Where(x => target == endPos)
                             .Subscribe(x =>
        {
            var dis_vec          = target - trans.localPosition;
            trans.localPosition += dis_vec.normalized * _pointerMoveSpeed;
            float dis            = dis_vec.sqrMagnitude;
            if (dis <= 0.05f)
            {
                trans.localPosition = target;
                target = startPos;
            }
        });

        moveLoopMicrotine2 = Observable.EveryFixedUpdate()
                             .Where(x => target == startPos)
                             .Subscribe(x =>
        {
            var dis_vec          = target - trans.localPosition;
            trans.localPosition += dis_vec.normalized * pointerMoveSpeed;
            float dis            = dis_vec.sqrMagnitude;
            if (dis <= 0.05f)
            {
                trans.localPosition = target;
                target = endPos;
            }
        });

        float _diceIntervalTime  = config["fishGame_diceIntervalTime"];
        float _diceTurnReusltPro = config["fishGame_diceTurnReusltPro"];

        randomMovePointer = Observable.Interval(System.TimeSpan.FromSeconds(_diceIntervalTime))
                            .Subscribe(x =>
        {
            //-----dice-----
            int _dice = Random.Range(1, 100);
            if (_dice <= _diceTurnReusltPro)
            {
                if (target == endPos)
                {
                    target = startPos;
                }
                else
                {
                    target = endPos;
                }
            }
        });
    }
コード例 #21
0
    void OnEnable()
    {
        DisplayCraftingScreen();

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

        inventoryObserver = Game.current.inventory.Subscribe(this);
    }
コード例 #22
0
ファイル: BaseTCP.cs プロジェクト: kosuda110/VFXGraphStudy
 public void Close()
 {
     _startServerStream?.Dispose();
     _startServerStream = null;
     _updateListenPacketStream?.Dispose();
     _updateListenPacketStream = null;
     _th?.Abort();
     _th = null;
     _tcpListener?.Stop();
     _tcpListener = null;
 }
コード例 #23
0
    void Awake()
    {
        NGUILink link = this.gameObject.GetComponent(typeof(NGUILink)) as NGUILink;

        if (link == null)
        {
            return;
        }
        Loaderbar = this.gameObject.AddComponent(typeof(CLoaderUI)) as CLoaderUI;

        pValueDisposable = Progress.Instance.ObserveEveryValueChanged(p => p.progress).Subscribe(p => Loaderbar.SetProgress(p));
    }
コード例 #24
0
        public PlayerInputControlAction(IControlCharacterAction target)
        {
            this.target = target;
            //Debug.Log("PlayerInputControlAction.PlayerInputControlAction: target: " + target);

            input_dispose = MessageBroker.Default.Receive <InputEvent>().Subscribe(input => {
                //Debug.Log("PlayerInputControlAction.Recieve<InputEvent>().Subscribe: input.name: " + input.name);

                switch (input.type)
                {
                case Type.Key:
                    switch (input.name)
                    {
                    case Actions.MainAction: if (input.key_value)
                        {
                            target.OnMainAciton();
                        }
                        break;

/*
 *                          case Actions.SubAction: if(input.key_value) { target.OnSubAction(); } break;
 *                          case Actions.FocusAction: if(input.key_value) { target.OnFocusAction(); } break;
 *
 *                          case Actions.Jump: if(input.key_value) { target.OnJump(); } break;
 *                          case Actions.Dash: if(input.key_value) { target.OnDash(); } else { target.OffDash(); } break;
 *                          case Actions.Roll: if(input.key_value) { target.OnRoll(); } break;
 *                          case Actions.Reload: if(input.key_value) { target.OnReload(); } break;
 *                          case Actions.Crouch: if(input.key_value) { target.OnCrouch(); } break;
 *                          case Actions.LayDown: if(input.key_value) { target.OnLayDown(); } break;
 *
 *                          case Actions.Up: if(input.key_value) { target.OnUp(); } else { target.OffUp(); }  break;
 *                          case Actions.Down: if(input.key_value) { target.OnDown(); } else { target.OffDown(); }  break;
 *                          case Actions.Left: if(input.key_value) { target.OnLeft(); } else { target.OffLeft(); }  break;
 *                          case Actions.Right: if(input.key_value) { target.OnRight(); } else { target.OffRight(); }  break;
 *
 *                          case Actions.Menu: if(input.key_value) { target.OnMenuOpen(); } break;
 *                          case Actions.Inventory: if(input.key_value) { target.OnInventoryOpen(); } break;
 *                          case Actions.Status: if(input.key_value) { target.OnStatusOpen(); } break;
 *                          case Actions.Skill: if(input.key_value) { target.OnSkillOpen(); } break;
 *                          case Actions.Map: if(input.key_value) { target.OnMapOpen(); } break;
 */
                    }
                    break;

                case Type.None:
                    switch (input.name)
                    {
                    case Actions.Idle: target.OnIdle(); break;
                    }
                    break;
                }
            });
        }
コード例 #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @DisabledOnOs(org.junit.jupiter.api.condition.OS.WINDOWS) void shouldGiveAClearErrorMessageIfTheArchivesParentDirectoryIsNotWritable() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldGiveAClearErrorMessageIfTheArchivesParentDirectoryIsNotWritable()
        {
            Path directory = _testDirectory.directory("a-directory").toPath();
            Path archive   = _testDirectory.file("subdir/the-archive.dump").toPath();

            Files.createDirectories(archive.Parent);
            using (System.IDisposable ignored = TestUtils.WithPermissions(archive.Parent, emptySet()))
            {
                AccessDeniedException exception = assertThrows(typeof(AccessDeniedException), () => (new Dumper()).dump(directory, directory, archive, GZIP, Predicates.alwaysFalse()));
                assertEquals(archive.Parent.ToString(), exception.Message);
            }
        }
コード例 #26
0
ファイル: MediaPlayer.cs プロジェクト: wangjie0707/Temp_01
 protected void Initialise()
 {
     BaseMediaPlayer mediaPlayer = CreatePlatformMediaPlayer();
     if (mediaPlayer != null)
     {
         m_Control = mediaPlayer;
         m_Texture = mediaPlayer;
         m_Info = mediaPlayer;
         m_Player = mediaPlayer;
         m_Dispose = mediaPlayer;
     }
 }
コード例 #27
0
ファイル: MessengerExample.cs プロジェクト: vickzy13/MyTest
        void Start()
        {
            this.messenger = new Messenger();

            /* Subscribe to the message,if the "subscription" dispose,it will automatically cancel the subscription.  */
            this.subscription = this.messenger.Subscribe <TestMessage> (OnMessage);

            /*---------------------------------------------*/

            /* Post a message. */
            this.messenger.Publish(new TestMessage(this, "This is a test."));
        }
コード例 #28
0
    // Use this for initialization
    void Start()
    {
        this.startObserver = Slow.Instance.onStart.Subscribe(OnSlowStart);
        this.endObserver   = Slow.Instance.onEnd.Subscribe(OnSlowEnd);
        if (root == null)
        {
            this.root = transform.FindRec("Root");
        }
        //kirinuke, rengekiを設定
        var player = GameObject.FindGameObjectWithTag(TagName.Player.String());

        if (kirinuke == null)
        {
            this.kirinuke = player.GetComponent <Kirinuke>();
        }
        if (rengeki == null)
        {
            this.rengeki = player.GetComponent <Rengeki>();
        }
        rengeki.onPush.Subscribe((e) => {
            rengekiImage.fillAmount = e.parcent;
            //rengekiMask.SetParcent(e.parcent);
        });
        rengeki.onEnd.Subscribe(OnRengekiEnd);
        //kirinukeの長押し判定
        kirinukeDetector.OnLongPressBegin += () => {
            SetKirinukeMask(0f);
        };
        kirinukeDetector.OnLongPressing += (e) => {
            SetKirinukeMask(kirinukeDetector.progress);
        };
        kirinukeDetector.OnLongPressTrigger += (e) => {
            //スロー中に長押しが完了
            //切り抜け中ではない
            //回り込み中ではない
            //攻撃中ではない
            //ならば切り抜けを実行する
            if (Slow.Instance.isSlowNow &&
                !kirinuke.isRunning &&
                !rengeki.moveNow &&
                !rengeki.actionNow)
            {
                kirinuke.StartKirinuke();
            }
        };
        kirinukeDetector.OnLongPressEnd += () => {
            SetKirinukeMask(0f);
        };
        root.SetActive(false);
    }
コード例 #29
0
ファイル: RuntimeTask.cs プロジェクト: ppugend/UniBt
 public void Start()
 {
     if (parent.isCoroutine)
     {
         comp.StopCoroutine(methodName);
         comp.StartCoroutine(methodName);
     }
     else
     {
         if (_disposable != null)
             _disposable.Dispose();
         _disposable = taskFunc();
     }
 }
コード例 #30
0
ファイル: Log.cs プロジェクト: paulthorpe/WeatherTest-Paulw
        /// <summary>
        /// Log the data using the Strategy patterns implemenation and if IDisposable is supported calls the clean up code
        /// </summary>
        public void Save()
        {
            if (_StoreStragtegy != null)
            {
                _StoreStragtegy.LogData(this);

                if (_StoreStragtegy is System.IDisposable)
                {
                    //late binding of the disposable pattern
                    System.IDisposable Disposable = _StoreStragtegy as System.IDisposable;
                    Disposable.Dispose();
                }
            }
        }
コード例 #31
0
ファイル: ProcessMemory.cs プロジェクト: akinomyoga/mwg
            private void Initialize()
            {
                Process[] procs = Process.GetProcessesByName(procName);
                if (procs.Length == 0)
                {
                    return;
                }

                this.res = new InitializerFromProcess(mem, this.process = procs[0]);
                for (int i = 1; i < procs.Length; i++)
                {
                    procs[i].Close();
                }
            }
コード例 #32
0
        /// <summary>
        /// Add a point to the specified mapview
        /// </summary>
        /// <param name="point">The location of the graphic</param>
        /// <param name="mapView">The mapview to whose overlay the graphic will be added</param>
        /// <returns></returns>
        public static async void AddToMapOverlay(ArcGIS.Core.Geometry.MapPoint point, MapView mapView)
        {
            ArcGIS.Core.CIM.CIMPointSymbol symbol = null;

            await QueuedTask.Run(() =>
               {
                   // Construct point symbol
                   symbol = SymbolFactory.ConstructPointSymbol(ColorFactory.Red, 10.0, SimpleMarkerStyle.Star);
               });

            //Get symbol reference from the symbol 
            CIMSymbolReference symbolReference = symbol.MakeSymbolReference();

            await QueuedTask.Run(() =>
                {
                    _overlayObject = mapView.AddOverlay(point, symbolReference);
                });

        }
コード例 #33
0
        /// <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);
            }
        }
コード例 #34
0
 /// <summary>
 /// Remove the Point Graphic from the specified mapview
 /// </summary>
 /// <param name="mapView"></param>
 public static void RemoveFromMapOverlay(MapView mapView)
 {
     if (_overlayObject != null)
     {
         _overlayObject.Dispose();
         _overlayObject = null;
     }
 }