void Start() { var bgmPlayer = BgmPlayer.Instance; if (bgmPlayer == null) { Debug.LogWarning("BgmPlayerが見つかりませんでした。"); return; } CurrentVolume .Subscribe(newVolume => bgmPlayer.Volume = newVolume) .AddTo(this); if (Slider == null) { return; } CurrentVolume .Subscribe(newVolume => Slider.value = Mathf.Clamp01(newVolume)) .AddTo(this); Slider.OnValueChangedAsObservable() .Subscribe(newVolume => CurrentVolume.Value = newVolume) .AddTo(this); Slider.value = bgmPlayer.Volume; }
void Start() { var sePlayer = SePlayer.Instance; if (sePlayer == null) { Debug.LogWarning("SePlayerが見つかりませんでした。"); return; } CurrentVolume .Subscribe(newVolume => sePlayer.Volume = newVolume) .AddTo(this); if (Slider == null) { return; } CurrentVolume .Subscribe(newVolume => Slider.value = Mathf.Clamp01(newVolume)) .AddTo(this); Slider.OnValueChangedAsObservable() .Subscribe(newVolume => CurrentVolume.Value = newVolume) .AddTo(this); Slider.OnValueChangedAsObservable() .Skip(1) .Where(_ => PlaySeOnVolumeChanged) .Throttle(TimeSpan.FromSeconds(.3f)) .Subscribe(newVolume => sePlayer.Play(0)) .AddTo(this); Slider.value = sePlayer.Volume; }
void Start() { setup(); //フリーズ条件:talk game.talkEvent.Subscribe(f => { freezed.Value = f; }).AddTo(gameObject); //フリーズ条件:GameClear game.clearEvent.Subscribe(f => { if (f) { freezed.Value = true; animator.speed = 0; } }).AddTo(gameObject); //アニメーション遷移 FreezableUpdate.Subscribe(_ => { animator.SetFloat("YSpeed", rb2d.velocity.y); }); //横移動 this.UpdateAsObservable().Select(_ => Input.GetButton("DASH") && is_grounded.Value).Subscribe(b => speed_walk = b ? 5.0f : 3.0f); FreezableUpdate.Subscribe(_ => { input_lr.Value = enable_input ? Input.GetAxis("Horizontal") : 0; }); input_lr.Subscribe(i => { animator.SetBool("isRunning", input_lr.Value != 0); front_way = input_lr.Value != 0 ? input_lr.Value.CompareTo(0) : front_way; }); FreezableFixedUpdate.Subscribe(_ => { if (is_grounded.Value) { walk_to_lr(input_lr.Value); } else { fly_to_lr(input_lr.Value); } }); //接地判定 this.OnTriggerStay2DAsObservable().Where(c => c.tag == "Ground").ThrottleFrame(2).Subscribe(_ => is_grounded.Value = false); this.OnTriggerStay2DAsObservable().Where(c => c.tag == "Ground").Subscribe(_ => is_grounded.Value = true); is_grounded.Subscribe(i => animator.SetBool("isGrounded", i)); //ジャンプ FreezableUpdate.Where(_ => Input.GetButtonDown("Fire1")).Where(_ => is_grounded.Value).Subscribe(p => { animator.SetTrigger("Leap"); Observable.NextFrame(FrameCountType.FixedUpdate).Subscribe(_ => rb2d.AddForce(new Vector2(0, speed_jump) * rb2d.mass, ForceMode2D.Impulse)); }); }
private void Start() { mediator = GetComponent <PlayerMediator>(); specialPoint .Subscribe(x => mediator.OnSpecialChanged(x / maxSpecialPoint)) .AddTo(this); // ポイントが最大になったらバフ specialPoint .Where(x => x >= maxSpecialPoint && !isBuffing) .Subscribe(_ => { isBuffing = true; mediator.StartBuff(); CutInAsync().Forget(); }) .AddTo(this); // ポイントが0になったらバフ解除 specialPoint .Where(x => x <= 0 && isBuffing) .Subscribe(_ => { isBuffing = false; mediator.StopBuff(); bgmPlayer.Play(soundDatabase.MainBgm); }) .AddTo(this); }
void IInitializable.Initialize() { var settings = _localStorage.Model; _master.Value = settings.Master; _bgm.Value = settings.BGM; _se.Value = settings.SE; _voice.Value = settings.Voice; _master .Subscribe(x => _localStorage.Model.Master = x) .AddTo(_disposable); _bgm .Subscribe(x => _localStorage.Model.BGM = x) .AddTo(_disposable); _se .Subscribe(x => _localStorage.Model.SE = x) .AddTo(_disposable); _voice .Subscribe(x => _localStorage.Model.Voice = x) .AddTo(_disposable); }
public Character(CharacterPawn pawn, IInputSource inputSource, CharacterStatus status, CharacterStateController stateController, CharacterStateController weaponStateController, int teamId, CharacterInfo info) { Status = status; Health = new FloatReactiveProperty(Status.MaxHealth.Value); Pawn = pawn; InputSource = inputSource; StateController = stateController; WeaponStateController = weaponStateController; TeamId = teamId; Info = info; Inventory = new BasicInventory(this); pawn.SetCharacter(this); StateController.Initialize(this); WeaponStateController.Initialize(this); var inputSourceDisposable = inputSource as IDisposable; if (inputSourceDisposable != null) { _compositeDisposable.Add(inputSourceDisposable); } Observable.EveryUpdate().Subscribe(OnUpdate).AddTo(_compositeDisposable); status.MoveSpeed.Subscribe(UpdatePawnSpeed).AddTo(_compositeDisposable); Health.Subscribe(OnHealthChange); //.AddTo( _compositeDisposable ); Instances.Add(this); Status.ModifierCalculator.Changed += OnModifiersChange; }
public AtomModel(JSONAtomModel model) { fromJSON(model); maxStockSubscriber = rMaxStock.Subscribe(_ => MaxStockUpgradePrice = (int)(AtomicWeight * MaxStock)); harvestRateSubscriber = rHarvestRate.Subscribe(_ => HarvestRateUpgradePrice = (int)(Mathf.Pow(5f, HarvestRate) * AtomicWeight)); }
private void OnEnable() { material = new Material(Shader.Find("Hidden/Vignette")); Size.Subscribe(f => material.SetFloat("_Size", f)); Brightness.Subscribe(f => material.SetFloat("_Brightness", f)); }
private void Awake() { rb = GetComponent <Rigidbody>(); successForce.Subscribe(force => successVector = new Vector3(0, -force, 0)); errorForce.Subscribe(force => errorVector = new Vector3(0, -force, 0)); }
public void SetGraph(Graph input) { this.graph = input; foreach (Node node in graph.GetNodes()) { GameObject obj = Instantiate(nodePrefab) as GameObject; obj.name = node.ID.ToString(); int degree = node.neighbor.Count; obj.transform.localScale = Vector3.one * (nodeBaseSize.Value + degree * nodeSizeUp.Value); obj.transform.SetParent(nodeParent.transform); obj.SetActive(false); nodeObj.Add(node.ID, obj); Vector3 pos = randomPos(); nodePosition.Add(node.ID, pos); } nodeBaseSize.Subscribe(x => { NodeSizeUpdate(x, nodeSizeUp.Value); }); nodeSizeUp.Subscribe(x => { NodeSizeUpdate(nodeBaseSize.Value, x); }); alpha.Subscribe(x => { NodeColorAlphaUpdate(x); }); edgeWidth.Subscribe(x => { DrawAllEdge(); }); edgeAlpha.Subscribe(x => { DrawAllEdge(); }); }
public void Awake() { MainThreadDispatcher.Initialize(); Application.targetFrameRate = -1; //LogHelper.LogCallbackAsObservable() // .ObserveOnMainThread() // .Where(x => x.LogType == LogType.Exception) // .Subscribe(x => logtext.AppendLine(x.ToString())); ObservableLogger.Listener.LogToUnityDebug(); ObservableLogger.Listener.ObserveOnMainThread().Subscribe(x => { logtext.AppendLine(x.Message); }); #if UNITY_5_3 //button.OnClickAsObservable().Subscribe(_ => //{ // UnityEngine.Debug.Log("---"); // Observable.EveryGameObjectUpdate().Subscribe(x => Debug.Log("EveryGameObjectUpdate" + x)); // Observable.EveryUpdate().Subscribe(x => Debug.Log("EveryUpdate:" + x)); // // Observable.EveryAfterUpdate().Subscribe(x => Debug.Log("EveryAfterUpdate:" + x)); // Observable.EveryLateUpdate().Subscribe(x => Debug.Log("EveryLateUpdate:" + x)); // Observable.EveryEndOfFrame().Subscribe(x => Debug.Log("EveryEndOfFrame:" + x)); // UnityEngine.Debug.Log("---"); //}); #endif FloAAX.Subscribe(x => Debug.Log("FloAAX:" + x)); }
void Start() { if (debugShowFuel) { var textMesh = gameObject.AddHoverText(Color.yellow); fuel.Subscribe(f => textMesh.text = f.ToString("#.00") + " / " + initialFuel).AddTo(this); } }
private void Awake() { material = new Material(Shader.Find("Hidden/SimpleToon")); Offset.Subscribe(OnOffsetChange); Threshold.Subscribe(OnThresholdChange); ColorDarken.Subscribe(OnColorDarkenChange); }
public override void Register(HealthComponent component) { _healthComponent = component; _internalHealthValue.Value = component.MaxHealth; _internalHealthValue.Subscribe(v => MessageBroker.Default.Publish(new HealthActSet { ComponentToChange = component, Value = v, })); }
void Awake() { health = new FloatReactiveProperty(initialHealth); if (debugShowHealth) { var textMesh = gameObject.AddHoverText(Color.white, 4f); health.Subscribe(f => textMesh.text = f.ToString("#.00") + " / " + initialHealth).AddTo(this); } }
public void SetUIMovementProperty(FloatReactiveProperty prop) { #if !UNITY_EDITOR if (m_UIMove != null) { m_UIMove.Dispose(); } #endif m_UIMove = prop; #if !UNITY_EDITOR m_UIMove.Subscribe(x => m_Moving.Value = x); #endif }
public override void Setup() { CurtainAlpha.Subscribe(e => { curtain.alpha = Mathf.Clamp01(e); CurtainIsActive = e >= 0.0001f; LoadingScreenIsActive = e >= 0.999f; }).AddTo(this); CurtainAlpha.Value = 0; loadingScreen.SetActive(false); }
internal void UpdateModel(AtomModel model) { _model = model; _startTime = Time.time; _originalMaxStock = _model.MaxStock; _atomMessage = new AtomMessage(_model.AtomicNumber, 1); AddReactor(timePercent); AddReactor ( _model.rHarvestRate .Subscribe(rate => { _model.Stock = (int)(((float)_model.Stock / _model.MaxStock) * (_originalMaxStock * _model.HarvestRate)); _model.MaxStock = (int)(_originalMaxStock * _model.HarvestRate); _harvestTime = _model.AtomicWeight / _model.HarvestRate; _startTime = -(timePercent.Value * _harvestTime) + Time.time; }) ); AddReactor ( Observable.EveryUpdate() .Subscribe(_ => timePercent.Value = (Time.time - _startTime) / _harvestTime) ); AddReactor ( timePercent.Subscribe(percent => UISlider.value = UISlider.maxValue * percent) ); AddReactor ( _model.rStock.Where(_ => _model.Stock <= 0).Subscribe(_ => DestroyReactors()) ); AddReactor ( timePercent .Where(value => value >= 1f) .Subscribe(_ => { _startTime = Time.time; _model.Stock -= 1; Messenger.Dispatch(AtomMessage.ATOM_HARVEST, _atomMessage); }) ); }
private void Bind() { _config.bgmVolume.Subscribe(ChangeBgmVolume).AddTo(this); _config.seVolume.Subscribe(ChangeSeVolume).AddTo(this); #if UNITY_EDITOR bgmVolume.Value = _config.bgmVolume.Value; seVolume.Value = _config.seVolume.Value; // インスペクタからコンフィグの値を操作する bgmVolume.Subscribe(volume => _config.bgmVolume.Value = volume).AddTo(this); seVolume.Subscribe(volume => _config.seVolume.Value = volume).AddTo(this); #endif }
public override void OnRegister() { base.OnRegister(); // Init view view.init(); loadingRandomPhrase.SubscribeToText(view.random_phrase); loadProgress.Subscribe(x => view.progress_bar.value = x); StartCoroutine("GenerateRandomPhrase"); // We are ready to load game data // Listen for when all the data will be ready loadCompleteSignal.AddListener(OnLoadComplete); // The signal carry the handle where we want to be notified on progress loadGameDataSignal.Dispatch(loadProgress); }
// Use this for initialization void Start() { StaminaObservale.Subscribe(value => { StaminaGauge.transform.localScale = new Vector3(value / staminaMax, StaminaGauge.transform.localScale.y, StaminaGauge.transform.localScale.z); }).AddTo(gameObject); IsStandingByObservable .Skip(1) .Subscribe(value => { if (value) { Stamina -= Time.fixedDeltaTime * 2; } }).AddTo(gameObject); }
void Start() { intProperty.Subscribe(it => Debug.Log(it)); longProperty.Subscribe(it => Debug.Log(it)); floatProperty.Subscribe(it => Debug.Log(it)); doubleProperty.Subscribe(it => Debug.Log(it)); byteProperty.Subscribe(it => Debug.Log(it)); boolProperty.Subscribe(it => Debug.Log(it)); stringProperty.Subscribe(it => Debug.Log(it)); vector2Property.Subscribe(it => Debug.Log(it)); vector3Property.Subscribe(it => Debug.Log(it)); vector4Property.Subscribe(it => Debug.Log(it)); quaternionProperty.Subscribe(it => Debug.Log(it)); colorProperty.Subscribe(it => Debug.Log(it)); boundsProperty.Subscribe(it => Debug.Log(it)); animationCurveProperty.Subscribe(it => Debug.Log(it)); }
protected override void InitializeComponent(IUIContext context, bool isPlaying) { base.InitializeComponent(context, isPlaying); if (!isPlaying) { return; } _horizontalScrollbarVisibility .Merge(_verticalScrollbarVisibility) .Subscribe(_ => UpdateScrollbarVisibility(), Debug.LogError) .AddTo(this); _scrollSensitivity .Subscribe(v => PeerScrollRect.scrollSensitivity = v, Debug.LogError) .AddTo(this); }
public override void Register(AudioSourceVolumeFromSettingsComponent component) { _volume.Subscribe(v => component.volume.Value = v).AddToLifecycleOf(component); var audioSources = component.GetComponents <AudioSource>(); //we use the initially set volume on the audio source as max volume var maxVolumes = audioSources.Select(x => x.volume).ToArray(); component.volume .Subscribe(v => { for (var i = 0; i < audioSources.Length; i++) { audioSources[i].volume = maxVolumes[i] * v; } }) .AddToLifecycleOf(component); }
private void Start() { body.OnDamage() .Where(_ => !IsStan) .Subscribe(damage => { bodyHp -= damage; // Dead判定 if (bodyHp <= 0) { Stan(); } }); brain.OnDamage() .Where(_ => IsStan) .Subscribe(damage => { brainHp.Value -= damage; if (brainHp.Value <= 0) { Dead(); } }); Observable.Interval(TimeSpan.FromSeconds(10)) .Subscribe(_ => { if (Random.Range(0, 100) < 70) { AttackLow(); } else { AttackHigh(); } }) .AddTo(gameObject); hpBar.MaxValue = brainHp.Value; brainHp .Subscribe(hp => hpBar.Play(hp)) .AddTo(gameObject); }
void Start() { grindsLeft = new FloatReactiveProperty(grindsUntilSharp); if (emitSparks) { sparkParticlesGameObject = Instantiate(CachedSparksParticle, transform) as GameObject; sparkParticlesGameObject.transform.localScale = Vector3.one; sparkParticlesGameObject.transform.localPosition = Vector3.zero; sparkParticlesGameObject.transform.localRotation = Quaternion.identity; sparkParticles = sparkParticlesGameObject.GetComponent <ParticleSystem>(); } if (debugShowGrindsUntilSharp) { var textMesh = gameObject.AddHoverText(Color.blue, -2f); grindsLeft.Subscribe(f => textMesh.text = f.ToString("#.00") + " / " + grindsUntilSharp).AddTo(this); } }
private void Awake() { Energy.Subscribe(e => { IsAccelerating.Value = Energy.Value > 0f; }); RemainBoostCount.Subscribe(c => { CanBoost.Value = c > 0; }); BaseSpeed.Subscribe(s => { SpeedToShow.Value = s * s * 60 * 60; }); //加速 Observable.EveryUpdate() .Subscribe(_ => { if (this.Energy.Value >= 0f) { float useEnergy = Mathf.Min(Time.deltaTime * UseRatio, this.Energy.Value); this.BaseSpeed.Value += useEnergy * EnergyToSpeedRatio; this.Energy.Value -= useEnergy; } }); //ゲームオーバー判定 Observable.EveryUpdate() .Subscribe(_ => { if (!CanBoost.Value && Energy.Value <= 0f) { //燃料切れ&加速終了 this.IsGameOver.Value = true; } }); }
public Character(CharacterPawnBase pawn, CharacterStatus status, CharacterStateController stateController, int teamId, CharacterInfo info) { this.Status = status; this.Health = new FloatReactiveProperty(this.Status.MaxHealth.Value); this.Pawn = pawn; this.StateController = stateController; this.TeamId = teamId; this.Info = info; this.Inventory = new BasicInventory(this); pawn.SetCharacter(this); this.StateController.Initialize(this); Observable.EveryUpdate().Subscribe(OnUpdate).AddTo(_compositeDisposable); Health.Subscribe(OnHealthChange); //.AddTo( _compositeDisposable ); //Instances.Add( this ); Status.ModifierCalculator.Changed += OnModifiersChange; }
protected override void InitializeComponent(IUIContext context, bool isPlaying) { base.InitializeComponent(context, isPlaying); _value .Subscribe(v => PeerSlider.value = v, Debug.LogError) .AddTo(this); if (!isPlaying) { return; } PeerSlider .OnValueChangedAsObservable() .Subscribe(v => Value = v, Debug.LogError) .AddTo(this); _minValue .Subscribe(v => PeerSlider.minValue = v, Debug.LogError) .AddTo(this); _maxValue .Subscribe(v => PeerSlider.maxValue = v, Debug.LogError) .AddTo(this); _background .Select(v => v.ValueFor(this)) .Subscribe(v => v.Update(PeerBackground, DefaultBackground), Debug.LogError) .AddTo(this); _fillImage .Select(v => v.ValueFor(this)) .Subscribe(v => v.Update(PeerFill, DefaultFillImage), Debug.LogError) .AddTo(this); _handleImage .Select(v => v.ValueFor(this)) .Subscribe(v => v.Update(PeerHandle, DefaultHandleImage), Debug.LogError) .AddTo(this); }
public override void Register(BackgroundMusicComponent component) { MessageBroker.Default .Receive <AudioActMusicStart>() .Subscribe(start => { if (start.CrossFadeTime == TimeSpan.Zero) { _currentMusic.Source.Stop(); _currentMusic = component; _currentMusic.Source.Play(); } else { _lastMusic = _currentMusic; _currentMusic = component; _currentMusic.Source.volume = 0; _currentMusic.Source.Play(); FadeIn(_currentMusic, start.CrossFadeTime, 0f); // TODO FadeOut(_lastMusic, start.CrossFadeTime); } }) .AddTo(component); MessageBroker.Default .Receive <AudioActMusicStop>() .Subscribe(stop => { }) .AddTo(component); _musicIsMuted .Subscribe(b => component.Source.mute = b) .AddTo(component); _musicVolume .Subscribe(f => component.Source.volume = f) .AddTo(component); }