Ejemplo n.º 1
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);
    }
Ejemplo n.º 2
0
 private void Awake()
 {
     m_toggleFactor
     .OnClickAsObservable()
     .Subscribe(_ => gameObject.SetActive(!gameObject.activeSelf))
     .AddTo(this);
     gameObject.SetActive(m_defaultIsActive);
 }
Ejemplo n.º 3
0
 private void ResetValue()
 {
     resetButton
     .OnClickAsObservable()
     .Delay(TimeSpan.FromSeconds(Const.UI_ANIMATION_TIME))
     .Subscribe(_ => _scrollRect.verticalNormalizedPosition = 1.0f)
     .AddTo(_scrollRect);
 }
Ejemplo n.º 4
0
        private void Start()
        {
            mButton.OnClickAsObservable().Subscribe(_ => enemy.CurrentHp.Value -= 99);
            mToggle.OnValueChangedAsObservable().SubscribeToInteractable(mButton);

            enemy.CurrentHp.SubscribeToText(mText);

            enemy.IsDead.Where(isDead => isDead)
            .Subscribe(_ => { mToggle.interactable = mButton.interactable = false; })
            .AddTo(this);
        }
Ejemplo n.º 5
0
 private void Awake()
 {
     m_activateFactor
     .OnClickAsObservable()
     .Subscribe(_ => gameObject.SetActive(true))
     .AddTo(this);
     m_inactivateFactor
     .OnClickAsObservable()
     .Subscribe(_ => gameObject.SetActive(false))
     .AddTo(this);
     gameObject.SetActive(m_defaultIsActive);
 }
Ejemplo n.º 6
0
 private void OnPushResetButton(IVolumeUpdatable bgm, IVolumeUpdatable se)
 {
     resetButton
     .OnClickAsObservable()
     .Subscribe(_ =>
     {
         bgm.SetVolume(bgmSlider.maxValue / 2.0f);
         se.SetVolume(seSlider.maxValue / 2.0f);
         SetSliderValue(bgm, se);
     })
     .AddTo(resetButton);
 }
Ejemplo n.º 7
0
    void Start()
    {
        #region Sample
        var cubePool = new CubePool(transform, m_pCubePrefab);

        m_btn.OnClickAsObservable().Subscribe(_ =>
        {
            var cube = cubePool.Rent();
            Observable.Interval(TimeSpan.FromSeconds(5)).First().Subscribe(x =>
            {
                cubePool.Return(cube);
            });
        }).AddTo(this);
        #endregion
    }
Ejemplo n.º 8
0
    void Start()
    {
        SubscribeButton1();


        var subscription2 = CoroutineButtonDispose.OnClickAsObservable()
                            .Subscribe(_ =>
        {
            if (Button1Subcription == null)
            {
                SubscribeButton1();
            }
            else
            {
                Button1Subcription.Dispose();
                Button1Subcription = null;
            }
        });
    }
 /**
  * <summary>Through this method, it is possible to define multiple behaviors, like for example the
  * onClick event/function that should be triggered when a button is pressed.</summary>
  */
 private void AddObservables()
 {
     connectButton.OnClickAsObservable().Subscribe(connect => ConnectSensors()).AddTo(disposables);
     DeviceOption1.OnClickAsObservable().Subscribe(click => SelectedDevice(DeviceOption1)).AddTo(disposables);
     DeviceOption2.OnClickAsObservable().Subscribe(click => SelectedDevice(DeviceOption2)).AddTo(disposables);
     DeviceOption3.OnClickAsObservable().Subscribe(click => SelectedDevice(DeviceOption3)).AddTo(disposables);
     DeviceOption4.OnClickAsObservable().Subscribe(click => SelectedDevice(DeviceOption4)).AddTo(disposables);
     DeviceOption5.OnClickAsObservable().Subscribe(click => SelectedDevice(DeviceOption5)).AddTo(disposables);
     DeviceOption6.OnClickAsObservable().Subscribe(click => SelectedDevice(DeviceOption6)).AddTo(disposables);
     DeviceOption7.OnClickAsObservable().Subscribe(click => SelectedDevice(DeviceOption7)).AddTo(disposables);
     DeviceOption8.OnClickAsObservable().Subscribe(click => SelectedDevice(DeviceOption8)).AddTo(disposables);
     DeviceOption9.OnClickAsObservable().Subscribe(click => SelectedDevice(DeviceOption9)).AddTo(disposables);
     DeviceOption10.OnClickAsObservable().Subscribe(click => SelectedDevice(DeviceOption10)).AddTo(disposables);
     DeviceOption11.OnClickAsObservable().Subscribe(click => SelectedDevice(DeviceOption11)).AddTo(disposables);
     sensorsConnectedProperty.Subscribe(sensorsConnected => SensorsConnectionChange(sensorsConnected)).AddTo(disposables);
     scanButton.OnClickAsObservable().Subscribe(click => Scan()).AddTo(disposables);
     statusTextProperty.SubscribeToText(statusText).AddTo(disposables);
     valueTextProperty.SubscribeToText(valueText).AddTo(disposables);
 }
Ejemplo n.º 10
0
    public void Awake()
    {
        _fmpInfo = null;
        var handle = GetActiveWindow();

        if (handle != System.IntPtr.Zero)
        {
            _fmpListener = new FMPMessageListener();
            _fmpListener.FMPMessageEvent += (s, e) =>
            {
                switch (e.Message)
                {
                case FMPMessage.StartFMP:
                {
                    _fmpInfo = FMPControl.GetFMPInfo();
                }
                break;

                case FMPMessage.EndFMP:
                {
                    _fmpInfo = null;
                }
                break;
                }
            };
            _fmpListener.AssignHandle(handle);
        }
        _fmpInfo = FMPControl.GetFMPInfo();

        _currentSceneType = SceneType.Unspecified;
        this.UpdateAsObservable().Subscribe(_ => FMPWork.Update(_fmpInfo)).AddTo(this);

        FMPWork.MusicTitle.SubscribeToText(_musicTitle).AddTo(this);
        FMPWork.MusicCreator.SubscribeToText(_musicCreator).AddTo(this);
        FMPWork.Status
        .Select(value => (value != FMPStat.None && (value & FMPStat.Play) != 0) ? "Pause" : "Play")
        .SubscribeToText(_playOrPauseButton.GetComponentInChildren <UnityEngine.UI.Text>())
        .AddTo(this);

        try
        {
            var musics = System.IO.Directory.GetFiles(Application.streamingAssetsPath, "*.owi");
            if (musics != null && musics.Length > 0)
            {
                int index = 0;
                _nextMusicButton.OnClickAsObservable().Select(_ => musics[(index++) % musics.Length])
                .ObserveOn(Scheduler.ThreadPool)
                .Subscribe(value =>
                {
                    FMPControl.MusicLoadAndPlay(value);
                }).AddTo(this);
            }
        }
        catch
        {
        }

        _playOrPauseButton.OnClickAsObservable().Subscribe(_ =>
        {
            if ((FMPWork.Status.Value & (FMPStat.Pause | FMPStat.Play)) != 0)
            {
                FMPControl.MusicPause();
            }
            else
            {
                FMPControl.MusicPlay();
            }
        }).AddTo(this);

        FMPWork.Progress.Subscribe(value => _playProgress.value = value).AddTo(this);
        FMPWork.PlayTime
        .Select(value => (new System.DateTime(value.Ticks)).ToString(_timeFormat))
        .SubscribeToText(_playTime).AddTo(this);

        FMPWork.MusicStartEvent.Subscribe(_ =>
        {
            var sb = new System.Text.StringBuilder();
            if (FMPWork.FMChannelCount.Value > 0)
            {
                sb.AppendFormat("FM: {0}ch\n", FMPWork.FMChannelCount.Value);
            }
            if (FMPWork.SSGChannelCount.Value > 0)
            {
                sb.AppendFormat("SSG: {0}ch\n", FMPWork.SSGChannelCount.Value);
            }
            if (FMPWork.PCMChannelCount.Value > 0)
            {
                sb.AppendFormat("PCM: {0}ch\n", FMPWork.PCMChannelCount.Value);
            }
            sb.AppendFormat("Total: {0}ch", FMPWork.ActiveChannelCount);
            _channelCountInfo.text = sb.ToString();
        }).AddTo(this);

        Observable.Create <Tuple <int, int> >(observer =>
        {
            var sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            return(FMPWork.AverageCalorie.Zip(
                       FMPWork.InstantCalorie,
                       (value1, value2) =>
            {
                return new Tuple <int, int>(value1, value2);
            }).Subscribe(value =>
            {
                if (sw.ElapsedMilliseconds > 1000)
                {
                    observer.OnNext(value);
                    sw.Reset();
                    sw.Start();
                }
            }));
        })
        .Select(value =>
        {
            return(string.Format("Calorie\nAvg {0}\nInstant {1}", value.Item1, value.Item2));
        })
        .SubscribeToText(_calorieInfo)
        .AddTo(this);

        ChangeSubScene(SceneType.LevelMeter2011);
    }
Ejemplo n.º 11
0
 protected CompositeBindable <Unit> Bind(Button button, CompositeDisposable disposable = null) =>
 Bind(button.OnClickAsObservable(), disposable);
Ejemplo n.º 12
0
 private void SubscribeButton1()
 {
     Button1Subcription =
         CoroutineButton.OnClickAsObservable()
         .Subscribe(_ => { StartCoroutine(CoroutineButtonMove()); });
 }