private void Awake() { activeManagerIndex = new IntReactiveProperty(); globalLevelIndex = new IntReactiveProperty(); onProgress = new UnityEvent(); onFinishRepetition = new UnityEvent(); onMistake = new UnityEvent(); if (circleManagerTemplate != null) { InstantiateCircleManagers(); } if (lineManager != null) { InitializeLineManager(); } globalLevelIndex.Subscribe(index => PushSequencesToManagers(index)); globalLevelIndex.Subscribe(_ => numVisibleManagers = CountVisibleManagers()); activeManagerIndex.Subscribe(i => SetExclusiveActiveManager(i)); #if UNITY_EDITOR DrumGameLineEditor lineEditor = GetComponentInChildren <DrumGameLineEditor>(); if (lineEditor != null) { lineEditor.SetRefreshDelegate(RefreshCurrentLevel); } #endif }
// Use this for initialization void Start() { // Change HP text when value is changed hp.SubscribeToText(hpText); // Add animation ( we use LeanTween for this because it's a simple library that just works ) hp.Subscribe(_ => AnimateObj(hpText.gameObject)); // HP Bar hp.Subscribe(currentHP => { float normalizedHP = (currentHP / 100f); LeanTween.scaleX(hpBar, normalizedHP, 0.2f) .setEase(LeanTweenType.easeOutCirc); }); // HP Delta hp.Throttle(TimeSpan.FromMilliseconds(500)).Subscribe(delayedHP => { float normalizedHP = (delayedHP / 100f); LeanTween.scaleX(hpDelta, normalizedHP, 0.2f) .setEase(LeanTweenType.easeInQuad); }); // Button actions ------------------------ damageButton.onClick.AddListener(DamageHP); resetButton.onClick.AddListener(ResetHP); }
public override void Initialize(DrumSequence firstSequence, int selfIndex, OnSequenceComplete sequenceCallback, List <Color> colorMap) { this.selfIndex = selfIndex; sequenceCompleteCallback = sequenceCallback; uiParent = transform.GetChild(0).gameObject; mainCamera = Camera.main; originalCameraPosition = mainCamera.transform.localPosition; segmentHighlighter.Initialize(); prompts = new List <DrumGamePrompt>(); promptPrefab.SetActive(false); this.colorMap = colorMap; reactiveSequence = new ReactiveProperty <DrumSequence>(firstSequence); sequenceIndex = new IntReactiveProperty(0); isVisible = new BoolReactiveProperty(); isActive = new BoolReactiveProperty(); isActive.Subscribe(active => ToggleActivePromptHighlight(active)); isActive.Subscribe(active => firstFrameActive = active); isActive.Subscribe(active => SetCamToOriginOnDisable(active)); isVisible.Subscribe(visible => SetVisibility(visible)); reactiveSequence.Subscribe(sequence => SetHiddenState(sequence)); reactiveSequence.Subscribe(sequence => SpawnAndArrangePrompts(sequence)); reactiveSequence.Subscribe(sequence => LabelDrumPrompts(sequence)); reactiveSequence.Subscribe(sequence => ColorDrumPrompts(sequence)); reactiveSequence.Subscribe(sequence => SetRepeatsValue(sequence)); reactiveSequence.Subscribe(delegate { if (cameraZoomingOutCoroutine != null) { StopCoroutine(cameraZoomingOutCoroutine); } }); if (lineEditor != null) { reactiveSequence.Subscribe(sequence => lineEditor.SetSequence(sequence)); } sequenceIndex.Subscribe(index => SetPromptHighlight(index)); sequenceIndex.Subscribe(index => AnimateCameraFollow(index)); var toggleEditStream = Observable.EveryUpdate().Where(_ => Input.GetKeyDown(toggleEditingKey)); toggleEditStream.Subscribe(_ => editing = !editing); toggleEditStream.Subscribe(_ => lineEditor.isEditing.Value = editing); toggleEditStream.Subscribe(_ => Debug.Log($"Line mode Editing set to {editing}")); if (lineEditor != null) { lineEditor.SetPromptsRef(prompts); } }
private void InitializeStageWatch() { deathCounter.Subscribe(count => { for (int i = titleSettings.NextStageCount.Length - 1; i >= 0; --i) { if (count < titleSettings.NextStageCount[i]) { continue; } stageReactiveProperty.Value = i + 1; return; } }); stageReactiveProperty.Subscribe(stage => { switch (stage) { case 0: break; case 1: EnemyPlayerCollisionSystem.Enabled = true; break; case 2: RainSystem.Enabled = true; break; case 3: Input1.Subscribe(ChangeWeapon1); Input2.Subscribe(ChangeWeapon2); 武器欄.SetActive(true); 武器名 = 武器欄.transform.Find(nameof(武器名)).GetComponent <TMPro.TMP_Text>(); break; case 4: // System.Buffer.BlockCopy(stage4EnemySpeed.Speeds, 0, enemySpeeds.Speeds, 0, enemySpeeds.Speeds.Length); break; case 5: // LastBossAppear(); break; default: break; } }); }
private void Awake() { UIPopUpHeart.SetUILobby(this); HeartArray = new GameObject[TOTAL_HEARTCOUNT]; HeartArray = SceneMainLobby.HeartArray; mUserData = new UserData(); mTime = new IntReactiveProperty(); mTime.Subscribe((time) => { Total_Timer = time; Min = Total_Timer / 60; Sec = Total_Timer % 60; SceneMainLobby.m_Timecontrol.text = string.Format("{0} :{1:D2}", Min, Sec); }); if (CUILobby.instance == null) { CUILobby.instance = this; } }
private void OnLoadComplete(List <MonsterDataModel> monsters, Dictionary <string, ElementDataModel> elements, Dictionary <string, Texture2D> images) { // Header of the view localizationService.GetString("title").Subscribe(x => view.header_title_text.text = x.ToUpper()); // Only changing the gems requires value the view will be updated with formatted text speedUpButtonText = new StringReactiveProperty(localizationService.GetString("speedup_button").Value); speedUpGemsRequired .Subscribe(gems => speedUpButtonText .Subscribe(x => view.speedup_button_text.text = string.Format(x, gems).ToUpper()) ); // When breeding time is updated the view will be notified breedingTimeLeftText = new StringReactiveProperty(localizationService.GetString("waiting").Value); breedingTimeLeft .Subscribe(t => breedingTimeLeftText .Subscribe(x => view.breeding_time_remaining_text.text = string.Format(x, "00:" + string.Format("{0:00}", t)).ToUpper()) ); view.OnSpeedUpClick += this.OnSpeedUpClick; view.OnLeftMonsterDescriptionClick += this.OnLeftInfoClick; view.OnRightMonsterDescriptionClick += this.OnRightInfoClick; }
// Start is called before the first frame update void Start() { var rp = new ReactiveProperty <int>(10); //値の代入と取り出し rp.Value = 20; var currentValu = rp.Value; rp.Subscribe(x => Debug.Log(x)); rp.Dispose(); rp.Value = 30; _intReactiveProperty.Subscribe(x => Debug.Log("IRP:" + x)); _intReactiveProperty.Value = 1000; _intReactiveProperty.Value = 2000; _stringReactiveProperty.Subscribe(s => Debug.Log("String:" + s)); _boolReactiveProperty.Subscribe(b => { if (b) { Debug.Log("Message True."); } else { Debug.Log("Message False."); } }); }
public Character( StatExpressionsInfo statExpressions, CharacterPlanetPawn pawn, IInputSource inputSource, CharacterStatus status, CharacterStateController stateController, CharacterStateController weaponStateController, int teamId, CharacterInfo info ) { this.statExpressions = statExpressions; this.status = status; this.health = new IntReactiveProperty( this.status.maxHealth.Value ); this.pawn = pawn; this.inputSource = inputSource; this.stateController = stateController; this.weaponStateController = weaponStateController; this.teamId = teamId; this.info = info; this.inventory = new BasicInventory( this ); pawn.SetCharacter( this ); this.stateController.Initialize( this ); 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 ); }
public AtomModel(JSONAtomModel model) { fromJSON(model); maxStockSubscriber = rMaxStock.Subscribe(_ => MaxStockUpgradePrice = (int)(AtomicWeight * MaxStock)); harvestRateSubscriber = rHarvestRate.Subscribe(_ => HarvestRateUpgradePrice = (int)(Mathf.Pow(5f, HarvestRate) * AtomicWeight)); }
public CardModel(IOwner owner, ICardTemplate template) : base(owner) { Template = template; _player = new ReactiveProperty <IPlayerModel>(owner as IPlayerModel); _power = new IntReactiveProperty(Template.Power); _health = new IntReactiveProperty(Template.Health); _manaCost = new IntReactiveProperty(Template.ManaCost); _items = new ReactiveCollection <IItemModel>(Template.Items); _abilities = new ReactiveCollection <EAbility>(Template.Abilities); _effects = new ReactiveCollection <IEffectModel>(Template.Effects); _health.Subscribe(h => { if (h <= 0) { Die(); } }); _effects.ObserveAdd().Subscribe(e => Info($"Added Effect {e} from {this}")).AddTo(this); _items.ObserveAdd().Subscribe(e => Info($"Added Item {e} from {this}")).AddTo(this); _abilities.ObserveAdd().Subscribe(e => Info($"Added Ability {e} from {this}")).AddTo(this); _effects.ObserveRemove().Subscribe(e => Info($"Removed Effect {e} from {this}")).AddTo(this); _items.ObserveRemove().Subscribe(e => Info($"Removed Item {e} from {this}")).AddTo(this); _abilities.ObserveRemove().Subscribe(e => Info($"Removed Ability {e} from {this}")).AddTo(this); }
public IntReactiveProperty Age = new IntReactiveProperty(0); //©иртпРап╩╞ // Start is called before the first frame update void Start() { //OnAgeChanged += age => { Debug.Log("inner received age changed"); }; Age.Subscribe(age => { Debug.Log("Inner received age changed: " + age); }); Age.Value = 10; }
internal void Setup(CompoundJSON compound, IntReactiveProperty amount) { disposables.Clear(); Compound = compound; _controlMessage.Index = compound.Index; amount.Subscribe(_ => OnAmountChange(_)).AddTo(disposables); Icon.Setup(compound); }
protected override void InitializeComponent(IUIContext context, bool isPlaying) { base.InitializeComponent(context, isPlaying); _value .Subscribe(v => PeerInput.text = v, Debug.LogError) .AddTo(this); if (!isPlaying) { return; } PeerInput .OnValueChangedAsObservable() .Subscribe(v => Value = v, Debug.LogError) .AddTo(this); _readOnly .Subscribe(v => PeerInput.readOnly = v, Debug.LogError) .AddTo(this); _characterLimit .Subscribe(v => PeerInput.characterLimit = v, Debug.LogError) .AddTo(this); _caretWidth .Subscribe(v => PeerInput.caretWidth = v, Debug.LogError) .AddTo(this); _placeholderText .Subscribe(UpdatePlaceholder, Debug.LogError) .AddTo(this); _textStyle .Select(v => v.ValueFor(this)) .Subscribe(v => v.Update(PeerText, DefaultTextStyle), Debug.LogError) .AddTo(this); _placeholderTextStyle .Select(v => v.ValueFor(this)) .Subscribe(v => v.Update(PeerPlaceholder, DefaultPlaceholderStyle), Debug.LogError) .AddTo(this); _background .Select(v => v.ValueFor(this)) .Subscribe(v => v.Update(PeerBackground, DefaultBackground), Debug.LogError) .AddTo(this); _selectionColor .Select(v => v.OrDefault(DefaultSelectionColor)) .Subscribe(v => PeerInput.selectionColor = v, Debug.LogError) .AddTo(this); _caretColor .Select(v => v.HasValue ? v : DefaultCaretColor) .Subscribe(v => { PeerInput.customCaretColor = v.HasValue; PeerInput.caretColor = v.OrDefault(Color.black); }, Debug.LogError) .AddTo(this); }
void Start() { Age.Subscribe(age => { Debug.LogError("Age change:" + age); }); Age.Value = 10; }
/// <summary> /// InspectorからのReactiveProperty /// </summary> private void ExcuteInspectorRP() { _intRp.Subscribe(x => { Debug.Log("int RP : " + x); }); _stringRp.Subscribe(x => { Debug.Log("string RP : " + x); }); }
// Use this for initialization void Start() { spawnNum .Subscribe(num => { }).AddTo(gameObject); Initialize(); }
void SubscribeToData() { currentView .DistinctUntilChanged() .Subscribe(SwitchToView); currentNavUnit .Subscribe(CalculateLatitudeFromNavUnit); HandleEndGame(); }
protected override void SubscribeObservables() { _MaxDigitNum.Subscribe(_num => PrepareNumberRenderers(_num)) .AddTo(Disposables); Observable.CombineLatest(_Value, _Digits, _Size, _Spacing, _MaxDigitNum, _PaddingMode, (_1, _2, _3, _4, _5, _6) => Unit.Default) .CombineLatest(_HorizontalPivot, _VerticalPivot, (_1, _2, _3) => Unit.Default) .Subscribe(_ => ApplyNumbers()) .AddTo(Disposables); }
void Start() { startTime = 0; time = 0; //unitTime = 2; GenerateNumberBall(max); circleNumber.Subscribe(num => { Debug.Log(num); if (num == 0 || num == 1) { GetComponent <NumberCircleView>().SetPrimeLabel(""); } else if (IsPrime(num)) { GetComponent <NumberCircleView>().SetPrimeLabel("素数"); GetComponent <NumberCircleView>().primeLabel.color = Color.red; } else { GetComponent <NumberCircleView>().SetPrimeLabel("合成数"); GetComponent <NumberCircleView>().primeLabel.color = Color.blue; } if (num >= 2 && num <= max) { GetComponent <NumberCircleView>().SetLabel(num); GameObject obj = NumberBallList.Where(ball => ball.GetComponent <NumberBall>().number == num) .First(); if (obj.GetComponent <NumberBallView>()) { NumberBallView view = obj.GetComponent <NumberBallView>(); if (view != null) { if (IsPrime(num)) { view.SetColor(Color.red); lineScript.SetColor(Color.red); } else { view.SetColor(Color.blue); obj.GetComponent <NumberBall>().isRotate = false; lineScript.SetColor(Color.blue); } } } } }); }
void Start() { items.Clear(); for (int i = 0; i < 10; i++) { items.Add(Instantiate(itemPrefab, content)); } selectedIndex.Subscribe(index => StaticData.model.selected.Value = index); StaticData.model.selected.Subscribe(index => StartCoroutine(MoveTo(GetItemPos(index), moveTime))); }
private void Start() { _collider = GetComponent <Collider>(); var fingerTips = GetComponentsInChildren <FingertipBehaviour>(); foreach (var value in fingerTips.Select(ft => ft.HasObject)) { value.Skip(1) .Subscribe(next => _isHolding.Value = next ? _isHolding.Value + 1 : _isHolding.Value - 1) .AddTo(this); } _isHolding .Subscribe(i => _collider.enabled = i <= 0) .AddTo(this); }
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)); }
void Start() { currentPage .Subscribe((pageIdx) => { int idx = 0; foreach (GameObject page in pages) { bool active = false; if (idx == pageIdx) { active = true; } page.SetActive(active); idx++; } }); }
public void Bind(IntReactiveProperty source, string desc, GameData gameData) { if (source != null) { _addButton.onClick.AddListener(() => { if (gameData.RemainingUpgrades.Value > 0) { source.Value++; gameData.RemainingUpgrades.Value--; } }); _removeButton.onClick.AddListener(() => { source.Value--; }); source.Subscribe(i => { _amountText.text = i.ToString(); }); _descText.text = desc; } }
// ------------------------------------------------------------------------------------------------- public void Awake() { _SnakeAcademy = FindObjectOfType(typeof(SnakeAcademy)) as SnakeAcademy; SetStateObject(); Observable.EveryUpdate().Where(_ => _IsPlay && !_State.GameOver).Subscribe ( _ => { _Timer += Time.deltaTime; } ).AddTo(this); Observable.EveryUpdate().Where(_ => _Timer > _SnakeAcademy.resetParameters["Speed"]).Subscribe ( _ => { _Timer = 0f; _State.Next(_Direction); if (_State.GameOver) { SetReward(-1f); Done(); } else if (_State.Eat) { SetReward(1f); _score.SetValueAndForceNotify(_score.Value + 1); } RenderState(); } ).AddTo(this); _score.Subscribe ( _value => { m_ScoreText.text = _value + ""; } ).AddTo(this); RenderState(); _IsPlay = true; }
void Start() { enemy = GetComponentInParent <Enemy>(); enemyText = GetComponentInChildren <Text>(); mainCamera = Camera.main.gameObject; enemy.OnTouchWithPlayer.Subscribe(_ => { touchCount.Value--; }); touchCount.Subscribe(x => enemyText.text = x.ToString()); this.UpdateAsObservable().Subscribe(_ => { transform.LookAt(mainCamera.transform); }); }
public override void Initialize() { base.Initialize(); _weaponSlot = equipmentSlots.First(es => es.ItemSubType == ItemSubType.Weapon); inventory.SharedModel.DimmedFunc.Value = inventoryItem => inventoryItem.ItemBase.Value.ItemType == ItemType.Costume || inventoryItem.ItemBase.Value.ItemType == ItemType.Material; inventory.SharedModel.SelectedItemView .Subscribe(SubscribeInventorySelectedItem) .AddTo(gameObject); inventory.OnDoubleClickItemView .Subscribe(itemView => { if (itemView is null || itemView.Model is null || itemView.Model.Dimmed.Value) { return; } Equip(itemView.Model); }) .AddTo(gameObject); inventory.OnResetItems.Subscribe(SubscribeInventoryResetItems).AddTo(gameObject); _stageId.Subscribe(SubscribeStage).AddTo(gameObject); questButton.OnClickAsObservable().Subscribe(_ => QuestClick(false)).AddTo(gameObject); Game.Event.OnRoomEnter.AddListener(b => Close()); foreach (var slot in equipmentSlots) { slot.ShowUnlockTooltip = true; } foreach (var slot in consumableSlots) { slot.ShowUnlockTooltip = true; } }
public override void Start() { NextScene.Where(scene => !string.IsNullOrEmpty(scene)).Subscribe(s => GetComponent <FadeScreen>().OutConfig.SceneToLoad = s).AddTo(this); base.Start(); ActiveMenu.Subscribe(active => { if (active == 0) { TransitionHelper.TransitionIn(Wheels); } else { TransitionHelper.TransitionOut(Wheels); } Menus.ForEach(m => m.Shown.Value = false); Menus[active].Shown.Value = true; }).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; } }); }
// Use this for initialization void Start() { // Change text when score is changed score.SubscribeToText(scoreText); // Add animation ( we use LeanTween for this because it's a simple library that just works ) score.Subscribe(_ => LeanTween.scale(scoreText.gameObject, Vector3.one, 0.2f).setFrom(Vector3.one * 0.5f).setEase(LeanTweenType.easeOutBack)); /* * // Two above lines can also be written as follows : * score.Subscribe(x => { * scoreText.Text = x.toString(); * LeanTween.scale(scoreText.gameObject, Vector3.one, 0.2f).setFrom(Vector3.one*0.5f).setEase(LeanTweenType.easeOutBack) * }); */ // Button actions ------------------------ addButton.onClick.AddListener(() => { score.Value++; }); }
private void Awake() { _score.Subscribe(x => _textScore.text = "SCORE : " + x); _level.Subscribe(x => _textLevel.text = "LEVEL : " + x); if (_saveData.Data.isTutorialShown) { // チュートリアル閲覧済みの場合は、カウントダウンから開始 StartCountDown(); } else { // チュートリアルを見ていない場合、チュートリアル表示 _state.Value = GameState.Tutorial; Observable .Timer(TimeSpan.FromSeconds(0.5f)) .Subscribe(_ => OnTutorialOpen()) .AddTo(this); } }
// Use this for initialization void Start() { PlayerOneScore = new IntReactiveProperty(0); PlayerTwoScore = new IntReactiveProperty(0); PlayerOneName = new StringReactiveProperty("Player A"); PlayerTwoName = new StringReactiveProperty("Player B"); PlayerOneScore.Subscribe( score => PlayerOneScoreDisplay.text = score.ToString()); PlayerTwoScore.Subscribe( score => PlayerTwoScoreDisplay.text = score.ToString()); PlayerOneName.Subscribe( name => PlayerOneNameDisplay.text = name); PlayerTwoName.Subscribe( name => PlayerTwoNameDisplay.text = name); PlayerOneGoal .OnTriggerEnter2DAsObservable () .Where (collision => collision.gameObject.CompareTag("Puck")) .Subscribe (_ => PlayerTwoScore.Value += 1); PlayerTwoGoal .OnTriggerEnter2DAsObservable () .Where (collision => collision.gameObject.CompareTag("Puck")) .Subscribe (_ => PlayerOneScore.Value += 1); PlayerOneGoal .OnTriggerExit2DAsObservable () .Merge (PlayerTwoGoal.OnTriggerExit2DAsObservable()) .Where (ev => ev.gameObject.CompareTag("Puck")) .Delay (TimeSpan.FromSeconds (0.5)) .Subscribe(ev => { ev.gameObject .OnDestroyAsObservable () .Delay (TimeSpan.FromSeconds (1)) .Subscribe (_ => Instantiate (PuckPrefab)); ev.gameObject.SetActive (false); Destroy (ev.gameObject); }); }