public WARActorCell Init() { objects.ObserveAdd().Subscribe(PlaceObjectOnCell); highlighted.Subscribe(onHighlightedChanged); return(this); }
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); } }
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)); }); }
protected override void Awake() { base.Awake(); var button = GetComponent <Button>(); var open = new BoolReactiveProperty(false); open.Subscribe(isOpen => { m_Tray.gameObject.SetActive(isOpen); m_ClickAwayRect.gameObject.SetActive(isOpen); }) .AddTo(this); button.OnPointerClickAsObservable() .Subscribe(ignored => { open.Value = !open.Value; }) .AddTo(this); m_Controller.color.Subscribe(color => { var sprite = Array.Find(m_Colors, c => c.name == Enum.GetName(typeof(CatalogueColorEnum), color).ToLower()); m_Image.sprite = sprite; open.Value = false; }).AddTo(this); m_ClickAwayRect.OnPointerClickAsObservable() .Subscribe(ignored => { open.Value = false; }) .AddTo(this); }
private void OnEnable() { ConnectSocket(); _isConnectedObserver = _isConnected.Subscribe(status => { if (status) { return; } _reconnectObserver = Observable.Interval(TimeSpan.FromSeconds(5)) .TakeUntil(_isConnected.Where(connected => connected)) .Subscribe(observer => { _activeClients = new List <UnityUser>(); ConnectSocket(); Debug.Log("Trying to reconnect " + _socket.State); }); }); _serverJsonObserver = _serverJson.Subscribe(value => { _activeClients = value?.FromJson <List <UnityUser> >(); var currentUser = _activeClients.Find(u => u.Id == SystemInfo.deviceUniqueIdentifier); _activeObject = string.IsNullOrEmpty(currentUser.LockedAsset) ? null : AssetDatabase.LoadMainAssetAtPath(currentUser.LockedAsset); Repaint(); }); }
// 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 void SetupOneCardAi() { IsStartAi.Subscribe(value => { if (value) { Debug.Log("ai start"); var cardIndex = 0; var playerId = TurnSystem.GetInstance().PlayerNowTurn.Value; var isPut = PlayerSystem.GetInstance().GetPlayerIsPutCard(playerId); Observable.Interval(TimeSpan.FromSeconds(0.5f)) .TakeWhile(_ => RandomCard(playerId, ref cardIndex) >= 0) .Subscribe(i => { var card = PlayerSystem.GetInstance().GetPlayerCard(playerId, cardIndex); PlayerSystem.GetInstance().PlayerPutCard(DeckTag.PUT_DECK, playerId, cardIndex, true); RuleSystem.GetInstance().CheckSpecialCard(card, isPut); }, () => { IsStartAi.Value = false; TurnSystem.GetInstance().EndTurn(); }); } }); }
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() { var canvasGroup = GetComponent<CanvasGroup>(); GetComponentInChildren<Text>().text = String.Format("P{0}", player.number); confirmed.Subscribe(value => { if (value) { canvasGroup.alpha = 1.0f; } else { canvasGroup.alpha = 0.5f; } }).AddTo(this); }
private IntReactiveProperty repeatsRemaining; //iterations left before advancing levelIndex public override void Initialize(DrumSequence firstSequence, int selfIndex, OnSequenceComplete sequenceCallback, List <Color> colorMap) { this.selfIndex = selfIndex; sequenceCompleteCallback = sequenceCallback; uiParent = transform.GetChild(0).gameObject; prompts = new List <DrumGamePrompt>(); promptPrefab.SetActive(false); this.colorMap = colorMap; arcHighlighter.Initialize(); reactiveSequence = new ReactiveProperty <DrumSequence>(firstSequence); repeatsRemaining = new IntReactiveProperty(reactiveSequence.Value.repetitions); sequenceIndex = new IntReactiveProperty(0); isVisible = new BoolReactiveProperty(); isActive = new BoolReactiveProperty(); isActive.Subscribe(active => ToggleActivePromptHighlight(active)); isActive.Subscribe(active => firstFrameActive = 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(sequence => arcHighlighter.DrawArcs(sequence.keys.Count)); sequenceIndex.Subscribe(index => SetPromptHighlight(index)); repeatsRemaining.Subscribe(remaining => SetRepeatsText(remaining)); baseX = highlightPivotT.rotation.eulerAngles.x; baseY = highlightPivotT.rotation.eulerAngles.y; }
public void SetUIShootProperty(BoolReactiveProperty prop) { #if !UNITY_EDITOR if (m_UIShoot != null) { m_UIShoot.Dispose(); } #endif m_UIShoot = prop; #if !UNITY_EDITOR m_UIShoot.Subscribe(ChangeShootState); #endif }
private void Start() { Visual.SetActive(true); VisualBig.SetActive(false); EvolutionOn.Subscribe(_ => { if (_) { StartCoroutine("Wait"); } }); }
private void Awake() { mainCamera = Camera.main; undoIndexStack = new Stack <int>(); redoIndexStack = new Stack <int>(); undoCoordStack = new Stack <Vector3>(); redoCoordStack = new Stack <Vector3>(); isEditing = new BoolReactiveProperty(); isEditing.Subscribe(DropPromptWhenEditEnds); }
public virtual void Start() { transition = GetComponent <TransitionRx>(); Selected.Subscribe(s => { GoButton.gameObject.SetActive(!s); CancelButton.gameObject.SetActive(s); }).AddTo(this); Selectable.Subscribe(s => { transition.Shown.Value = s; GoButton.interactable = s; CancelButton.interactable = s; }).AddTo(this); }
protected override void InitializeComponent(IUIContext context, bool isPlaying) { base.InitializeComponent(context, isPlaying); if (!isPlaying) { return; } _opaque .Subscribe(v => PeerImage.enabled = v, Debug.LogError) .AddTo(this); _background .Subscribe(v => v.Update(PeerImage, DefaultBackground), Debug.LogError) .AddTo(this); }
private void Awake() { Deselect(); Selected.Subscribe(x => { if (x) { Select(); } else { Deselect(); } }).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() { GetComponent <Button>().onClick.AddListener(ButtonClick); mAnimator = GetComponent <Animator>(); IsBig.Subscribe(_ => { if (IsBig.Value) { mAnimator.Play("ItemClickAnimation", 0, 0f); } else { mAnimator.Play("NarrowAnimation", 0, 0f); } }); SimpleEventSystem.GetEvent <ListItemButton>().Subscribe(_ => { IsBig.Value = false; }).AddTo(this); }
void Start() { isToggleConnect = false; btn01.transform.GetChild(1).Hide(); btn02.transform.GetChild(1).Hide(); isTog01.Subscribe(_ => { if (_) { btn01.transform.GetChild(1).Show(); btn01.transform.GetChild(0).Hide(); str01 = strOn1; } else { btn01.transform.GetChild(0).Show(); btn01.transform.GetChild(1).Hide(); str01 = strOff1; } MainControl.Instance().SendMsg(str01); }); isTog02.Subscribe(_ => { if (_) { btn01.transform.GetChild(1).Show(); btn01.transform.GetChild(0).Hide(); str02 = strOn2; } else { btn01.transform.GetChild(0).Show(); btn01.transform.GetChild(1).Hide(); str02 = strOff2; } MainControl.Instance().SendMsg(str02); }); btn01.onClick.AddListener(() => { isTog01.Value = !isTog01.Value; }); btn02.onClick.AddListener(() => { isTog02.Value = !isTog02.Value; }); }
public void Start() { TimeObject.canvasRenderer.SetAlpha(0); TimeBackObject.canvasRenderer.SetAlpha(0); IsShowTimeBar.Subscribe(value => { if (value) { TimeBackObject.CrossFadeAlpha(0.6f, 2, false); TimeObject.CrossFadeAlpha(1, 2, false); var pos = TimeBackObject.transform.position; TimeBackObject.transform.DOMove(new Vector3(pos.x, pos.y + 30), 1); pos = TimeObject.transform.position; TimeObject.transform.DOMove(new Vector3(pos.x, pos.y + 30), 1); } else { TimeBackObject.CrossFadeAlpha(0, 1, false); TimeObject.CrossFadeAlpha(0, 1, false); TimeBackObject.transform.DOScale(TimeBackObject.transform.localScale * 2, 1); TimeObject.transform.DOScale(TimeObject.transform.localScale * 2, 1) .OnComplete(() => { TimeBackObject.transform.Translate(0, -30, 0); TimeObject.transform.Translate(0, -30, 0); TimeBackObject.transform.localScale /= 2; TimeObject.transform.localScale /= 2; }); } }); this.UpdateAsObservable().Subscribe(_ => { var scale = TurnNowTime / TurnShowTime; TimeObject.fillAmount = scale; TurnUpdate(); }); }
// Use this for initialization void Start() { // Rigidbody _rig = GetComponent <Rigidbody>(); // Animatior _anim = GetComponent <Animator>(); _movement = this.FixedUpdateAsObservable() .Select(unit => { // Move (turn) var x = Input.GetAxis("Horizontal"); transform.localRotation = Quaternion.Euler(0, x * 20, 0); // Run var y = Mathf.Clamp(Input.GetAxis("Vertical"), 0, 1); // Jump _isJump.Value = Input.GetAxis("Jump") != 0; // Animations _anim.SetFloat("Speed", y); _anim.SetFloat("height", transform.position.y); return(new Vector3(x, 0, y)); }); _movement.Where(vector3 => vector3 != Vector3.zero) .Subscribe((vector3) => { // _rig.AddForce(vector3 * 1000); transform.Translate(vector3 * 0.1f); }); _isJump.Subscribe(b => { _anim.SetBool("isJump", b); if (transform.position.y < 0.1f) { _rig.AddForce(Vector3.up * 10000); } }); }
private void Awake() { GameModel.Set(new GameDebug()); IsDebug.Subscribe(_ => GameModel.Get <GameDebug>().isActive = _); _gameControllers = new List <IGameInit>(); _player = AddController <PlayerController>(); _galaxy = AddController <GalaxyController>(); _star = AddController <StarController>(); _planet = AddController <PlanetController>(); _life = AddController <LifeController>(); AddController <UnitPaymentService>(); AddController <UnitFactory>(); AddController <UnitController>(); AddController <SkillController>(); AddController <SkillPaymentService>(); AddController <CompoundController>(); AddController <CompoundPaymentService>(); //AddController<BuildingController>(); //AddController<BuildingPaymentService>(); AddController <HexUpdateCommand>(); AddController <HexScoreUpdateCommand>(); AddController <PlanetGenerateCommand>(); AddController <PlanetPropsUpdateCommand>(); AddController <UnitDefenseUpdateCommand>(); AddController <SkillCommand>(); AddController <UnitEquipCommand>(); AddController <UnitUseCompoundCommand>(); AddController <LiveSkill>(); AddController <MoveSkill>(); AddController <CloneSkill>(); AddController <MineSkill>(); for (int i = 0; i < _gameControllers.Count; i++) { _gameControllers[i].Init(); } }
protected override void InitializeComponent(IUIContext context, bool isPlaying) { base.InitializeComponent(context, isPlaying); if (!isPlaying) { return; } _tracker = new InteractionHandler <DraggableHeader>( this, new PointerPresenceTracker <DraggableHeader>(this), new PointerDragTracker <DraggableHeader>(this)); _tracker.Initialize(); _interactable .Subscribe(v => _tracker.Interactable = v, Debug.LogError) .AddTo(this); }
void Start() { menuScreenManager = GetComponentInParent <MenuScreenManager>(); trackGrid = new GridCollection <Track>(trackList.tracks, Columns); selectedTrack.Value = trackGrid.First(); selectionConfirmed.Subscribe(confirmed => { if (confirmed) { confirmPrompt.Show(); TrackManager.Instance.track = selectedTrack.Value; } else { TrackManager.Instance.track = null; confirmPrompt.Hide(); } }); }
public override void Initialize(PersonProvider provider) { base.Initialize(provider); this.provider = provider; killSelfTime = provider.KillTime; InMitsu.Subscribe(x => { if (!x) { currentVelocityBonus = velocityDefaultE; direction.Value = new Vector2(Random.Range(-1, 1), Random.Range(-1, 1)); } }).AddTo(gameObject); direction .Select(x => x * currentVelocityBonus) .Subscribe(dir => rb2D.velocity = dir).AddTo(gameObject); DiedAsync.First().Subscribe(async _ => { anim.Play("Die"); provider.people.Remove(this); await UniTask.Delay(System.TimeSpan.FromMilliseconds(1100)); Destroy(gameObject); }, () => { }).AddTo(gameObject); transform.ObserveEveryValueChanged(t => t.position) .Where(p => p.x > 32 || p.x < -32 || p.y > 24 || p.y < -24) .Subscribe(_ => { // エリアから出たら、原点(0. 0)あたりにもどる var pos = new Vector2(Random.Range(-20, 20), Random.Range(-10, 10)); direction.Value = (pos - (Vector2)transform.position).normalized; }).AddTo(gameObject); isCatastorophy.Where(x => x).Subscribe(_ => transform.DOLocalMove(Vector3.zero, 10)).AddTo(gameObject); }
// Use this for initialization void Start() { rb = GetComponent <Rigidbody>(); initMass = rb.mass; DOTween.Init(); isLaunched .Subscribe(value => { if (value) { gameManager.gameState = GameState.Bowling; if (launchType == BallLaunchType.EARTH) { GetComponentInParent <SpinFree>().spin = false; StartCoroutine("ShakeCamera"); } } }); }
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); }
public static void MakerUiHideLagFix(CustomControl __instance) { var customControl = Traverse.Create(__instance); var hideFrontUi = customControl.Field("_hideFrontUI"); var oldHide = hideFrontUi.GetValue <BoolReactiveProperty>(); oldHide.Dispose(); var newHide = new BoolReactiveProperty(false); hideFrontUi.SetValue(newHide); var cvsSpace = customControl.Field("cvsSpace").GetValue <Canvas>(); var objFrontUiGroup = customControl.Field("objFrontUIGroup").GetValue <GameObject>(); var frontCanvasGroup = objFrontUiGroup.GetComponent <CanvasGroup>(); //Modified code from CustomControl.Start -> _hideFrontUI.Subscribe anonymous method newHide.Subscribe(hideFront => { if (__instance.saveMode) { return; } //Instead of enabling/disabling the CanvasGroup Gameobject, just hide it and make it non-interactive //This way we get the same effect but for no cost for load/unload frontCanvasGroup.alpha = hideFront ? 0f : 1f; frontCanvasGroup.interactable = !hideFront; frontCanvasGroup.blocksRaycasts = !hideFront; if (cvsSpace) { cvsSpace.enabled = !hideFront; } __instance.ChangeMainCameraRect(!hideFront ? CustomControl.MainCameraMode.Custom : CustomControl.MainCameraMode.View); }); }
protected override void InitializeComponent(IUIContext context, bool isPlaying) { base.InitializeComponent(context, isPlaying); if (!isPlaying) { return; } var layout = this.GetOrAddComponent <LayoutElement>(); layout.ignoreLayout = true; var image = this.GetOrAddComponent <Image>(); image.color = Color.clear; UpdatePosition(RectTransform); _cursor.Value = Cursor; _tracker = new InteractionHandler <ResizeHandle>( this, new PointerPresenceTracker <ResizeHandle>(this), new PointerDragTracker <ResizeHandle>(this)); _tracker.Initialize(); _interactable .Subscribe(v => _tracker.Interactable = v, Debug.LogError) .AddTo(this); OnDrag .Where(_ => Target != null) .Subscribe(Resize, Debug.LogError) .AddTo(this); }
private void Start() { _isPlayable .Subscribe(isPlay => { OnPlayableChanged(isPlay); }).AddTo(gameObject); _isAlive .Subscribe(x => { if (!x) { Die(); } }).AddTo(gameObject); col.OnCollisionEnter2DAsObservable() .Subscribe(_ => _isStop.Value = true); col.OnCollisionExit2DAsObservable() .Subscribe(_ => _isStop.Value = false); transform.ObserveEveryValueChanged(t => t.position) .Where(_ => IsPlayable.Value) .Subscribe(pos => { if (pos != Vector3.zero) { anim.SetTrigger("Walk"); } else { anim.SetTrigger("Idle"); } }).AddTo(gameObject); }