private void Start()
        {
            // ジャンプボタン
            this.UpdateAsObservable()
            .Select(_ => UnityEngine.Input.GetButtonDown("Jump"))
            .DistinctUntilChanged()
            .Subscribe(x => _jumpButtonPushed.Value = x);

            // 食べるボタン
            this.UpdateAsObservable()
            .Select(_ => UnityEngine.Input.GetButtonDown("Eat"))
            .DistinctUntilChanged()
            .Subscribe(x => _eatButtonPushed.Value = x);

            // 射撃ボタン
            this.UpdateAsObservable()
            .Select(_ => UnityEngine.Input.GetButton("Shot"))
            .DistinctUntilChanged()
            .Subscribe(x => _shotButtonPushed.Value = x);

            // 左右
            this.UpdateAsObservable()
            .Select(_ => UnityEngine.Input.GetAxis("Horizontal"))
            .Subscribe(x => _moveHorizontal.SetValueAndForceNotify(x));

            // このコンポーネントが破棄された時点でObservableも破棄
            _jumpButtonPushed.AddTo(this);
            _eatButtonPushed.AddTo(this);
            _shotButtonPushed.AddTo(this);
            _moveHorizontal.AddTo(this);
        }
    private void Start()
    {
        playerHit.OnDeath
        .Subscribe(_ => currentState.Value = GameState.Finish);

        currentState.AddTo(this);
    }
Beispiel #3
0
        public void Start()
        {
            if (_list.Orientation == NavigationOrientation.None)
            {
                throw new InvalidOperationException(
                          $"ListControl is missing orientation value on gameObject {_list.gameObject.ToHierarchyPath()}");
            }

            _list.Views
            .CombineLatest(ChosenIndex, (views, selectedIndex) => new { views, selectedIndex })
            .Subscribe(x =>
            {
                _chosenView.Value = x.views.GetAtOrDefault(x.selectedIndex);

                if (_list.IsSelfOrDescendantSelected.Value)
                {
                    _chosenView.Value?.Select();
                }
            })
            .AddTo(_disposables);

            SubscribeToUpdateFocusables(ChosenView);

            _disposables.AddTo(_list);
            _chosenView.AddTo(_list);
            ChosenIndex.AddTo(_list);
        }
        public StageEventListRootPageViewModel(INavigationService navigationService, IFilterGroupingStageEvent eventUsecase)
        {
            _eventUsecase = eventUsecase;

            Title.AddTo(this.Disposable);
            SelectedSegment.AddTo(this.Disposable);
            FavStateObservable.AddTo(this.Disposable);

            SelectedSegment.Subscribe(selectedSegment =>
            {
                _eventUsecase.UpdateFilterConditions(SelectedSegment.Value, FavStateObservable.Value, PlaceId);
            }).AddTo(this.Disposable);

            FavButtonClickCommand = new DelegateCommand(() =>
            {
                FavStateObservable.Value = !FavStateObservable.Value;
                _eventUsecase.UpdateFilterConditions(SelectedSegment.Value, FavStateObservable.Value, PlaceId);
            });

            IconSource = FavStateObservable.Select((isFavActive) =>
            {
                return($@"ion_ios_heart{(isFavActive ? "" : "_outline")}");
            }).ToReadOnlyReactiveProperty("ion_ios_heart").AddTo(this.Disposable);

            Plannings = _eventUsecase.Plannings.ToReadOnlyReactiveCollection().AddTo(this.Disposable);

            SelectedItemCommand = new AsyncReactiveCommand <IPlanning>();
            SelectedItemCommand.Subscribe(async(item) =>
            {
                await navigationService.NavigateAsync(
                    nameof(PlanningDetailPageViewModel).GetViewNameFromRule(),
                    PlanningDetailPageViewModel.GetNavigationParameter(item.Id, item.PlanningType));
            }).AddTo(this.Disposable);
        }
Beispiel #5
0
        private void Start()
        {
            _gameStateManager.CurrentState
            .FirstOrDefault(x => x == GameState.FINISHED)
            .Subscribe(_ => _isResultShowing.Value = true);

            _isResultShowing.AddTo(this);
        }
        public void SetTag(Tag tag)
        {
            Tag = tag;

            Text            = new ReactiveProperty <string>(tag.Name);
            BackgroundColor = new ReactiveProperty <SolidColorBrush>(tag.BackgroundColorBrush);
            TextColor       = new ReactiveProperty <SolidColorBrush>(tag.TextColorBrush);

            Text.AddTo(m_Disposables);
            BackgroundColor.AddTo(m_Disposables);
            TextColor.AddTo(m_Disposables);
        }
Beispiel #7
0
        public UnitViewModel(Unit unit)
        {
            Unit         = unit;
            Name         = new ReactiveProperty <string>(Unit.Name);
            Icon         = new ReactiveProperty <BitmapImage>(Unit.Icon);
            IsSelect     = new ReactiveProperty <bool>(false);
            IsVisibility = new ReactiveProperty <Visibility>(Visibility.Visible);

            Name.AddTo(m_Disposables);
            Icon.AddTo(m_Disposables);
            IsSelect.AddTo(m_Disposables);
            IsVisibility.AddTo(m_Disposables);
        }
        private void Start()
        {
            this.UpdateAsObservable()
            .Select(_ => Input.GetKey(KeyCode.Z))
            .DistinctUntilChanged()
            .Subscribe(x => _onActionPushed.Value = x);

            this.UpdateAsObservable()
            .Select(_ =>
                    new Vector3(Input.GetAxisRaw("Horizontal1"), Input.GetAxisRaw("Vertical1"), 0))
            .Subscribe(x => _moveDirection.SetValueAndForceNotify(x));

            _onActionPushed.AddTo(this);
            _moveDirection.AddTo(this);
        }
Beispiel #9
0
        private void Start()
        {
            _timeManager.ReadyTime
            .Where(x => x == 0)
            .Take(1)
            .Subscribe(x => { _currentState.Value = GameState.BATTLE; })
            .AddTo(this);

            _timeManager.RemainingTime
            .Where(x => x == 0)
            .Take(1)
            .Subscribe(x => { _currentState.Value = GameState.FINISHED; });

            _currentState.AddTo(this);
        }
Beispiel #10
0
        private void Start()
        {
            timeManager = GetComponent <TimeManager>();

            timeManager.ReadyTime
            .Where(x => x == 0)
            .Take(1)
            .Subscribe(x => { _currentState.Value = GameState.Battle; })
            .AddTo(this);

            timeManager.RemainingTime
            .Where(x => x == 0)
            .Take(1)
            .Subscribe(x => { _currentState.Value = GameState.Finished; })
            .AddTo(this);

            _currentState.AddTo(this);
        }
Beispiel #11
0
        public DownloadIconViewModel(Window window)
        {
            var downloader = new IconDownloader();

            if (downloader.RequiredDownloadCount == 0)
            {
                MessageBox.Show("キャラアイコンはすべて揃っています。\n不足している場合、先にデータベースの更新を行ってください。");
                window.Close();
                return;
            }

            DownloadNum       = new ReactiveProperty <int>();
            DownloadNum.Value = downloader.RequiredDownloadCount;

            DownloadCompleteNum            = new ReactiveProperty <int>();
            downloader.OnCompleteDownload += () =>
            {
                DownloadCompleteNum.Value++;
                if (DownloadCompleteNum.Value >= DownloadNum.Value)
                {
                    Database.I.RefreshUnitIcons();
                    if (isFailed)
                    {
                        MessageBox.Show("一部アイコンのダウンロードに失敗しました。再度アイコン更新を行ってください。\nダウンロードに成功したアイコンを適用するにはこのソフトを再起動してください。");
                    }
                    else
                    {
                        MessageBox.Show("アイコンのダウンロードが完了しました。\nこのソフトを再起動してください。");
                    }
                    window.Close();
                }
            };
            downloader.OnFailedDonwload += () =>
            {
                isFailed = true;
            };

            DownloadNum.AddTo(m_Disposables);

            downloader.DownloadIcons();
        }
        public UserAttackRouteViewModel(UserAttackRoute route, Action <UserAttackRoute> onOpenRoute, Window window)
        {
            Id = route.Id;

            AttackParties = new ReactiveCollection <AttackRouteListElementViewModel>();
            AttackParties.AddRange(route.RouteParties.Select(x => new AttackRouteListElementViewModel(x, null)));

            Comment = new ReactiveProperty <string>(route.Comment);

            OpenRoute = new ReactiveCommand();
            OpenRoute.Subscribe(() =>
            {
                onOpenRoute?.Invoke(route);
                window.Close();
            });

            DeleteRoute = new ReactiveCommand();
            DeleteRoute.Subscribe(() => Database.I.RemoveAttackRoute(route));

            Comment.AddTo(m_Disposables);
        }
        private async UniTaskVoid SetUpAsync()
        {
            var core = GetComponent <PlayerCore>();

            // wait for initializing of player
            await core.InitializedAsync;

            var id = 1 + (int)core.Id;

            var useButton = "Action" + id;
            var hori      = "Horizontal" + id;
            var vert      = "Vertical" + id;

            this.UpdateAsObservable()
            .Select(_ => Input.GetButton(useButton))
            .DistinctUntilChanged()
            .Subscribe(x => _onActionPushed.Value = x);

            this.UpdateAsObservable()
            .Select(_ => new Vector3(Input.GetAxis(hori), -Input.GetAxis(vert), 0))
            .Subscribe(x => { _moveDirection.SetValueAndForceNotify(x); });
            _onActionPushed.AddTo(this);
            _moveDirection.AddTo(this);
        }
Beispiel #14
0
        public PlanningListRootPageViewModel(INavigationService navigationService, IFilterGroupingPlanning planningUsecase, IEventAggregator eventAggregator)
        {
            _planningUsecase = planningUsecase;

            Title.AddTo(this.Disposable);
            SelectedSegment.AddTo(this.Disposable);
            SearchQuery.AddTo(this.Disposable);
            FavStateObservable.AddTo(this.Disposable);

            PlanningType = SelectedSegment.Select((index) => index.SegmentedControlIndexToPlanningTypeEnum())
                           .ToReactiveProperty()
                           .AddTo(this.Disposable);

            SelectedSegment.Subscribe(selectedSegment =>
            {
                if (IsDirty)
                {
                    _planningUsecase.UpdateFilterConditions(SearchQuery.Value, PlanningType.Value, FavStateObservable.Value, PlaceId);
                }
            }).AddTo(this.Disposable);

            SearchQuery.Throttle(TimeSpan.FromMilliseconds(400)).ObserveOnUIDispatcher().Subscribe(query =>
            {
                if (IsDirty)
                {
                    _planningUsecase.UpdateFilterConditions(SearchQuery.Value, PlanningType.Value, FavStateObservable.Value, PlaceId);
                }
            }).AddTo(this.Disposable);

            FavButtonClickCommand = new DelegateCommand(() =>
            {
                FavStateObservable.Value = !FavStateObservable.Value;
                _planningUsecase.UpdateFilterConditions(SearchQuery.Value, PlanningType.Value, FavStateObservable.Value, PlaceId);
            });

            IconSource = FavStateObservable.Select((isFavActive) =>
            {
                return($@"ion_ios_heart{(isFavActive ? "" : "_outline")}");
            }).ToReadOnlyReactiveProperty("ion_ios_heart").AddTo(this.Disposable);

            Plannings = _planningUsecase.Plannings.ToReadOnlyReactiveCollection().AddTo(this.Disposable);

            SelectedItemCommand = new AsyncReactiveCommand <IPlanning>();
            SelectedItemCommand.Subscribe(async(item) =>
            {
                await navigationService.NavigateAsync(
                    nameof(PlanningDetailPageViewModel).GetViewNameFromRule(),
                    PlanningDetailPageViewModel.GetNavigationParameter(item.Id, item.PlanningType));
            }).AddTo(this.Disposable);

            OpenPlceDetailCommand = new AsyncReactiveCommand <string>();
            OpenPlceDetailCommand.Subscribe(async(placeName) =>
            {
                await navigationService.NavigateAsync("NavigationPage/DetailFloorPage", DetailFloorPageViewModel.GetNavigationParameter(placeName), true);
            }).AddTo(this.Disposable);

            eventAggregator.GetEvent <TabbedPageOpendEvent>().Subscribe((ev) =>
            {
                if (ev.Name != this.GetType().Name.Replace("ViewModel", ""))
                {
                    return;
                }
                if (!IsDirty)
                {
                    IsDirty = true;
                    _planningUsecase.UpdateFilterConditions(SearchQuery.Value, PlanningType.Value, FavStateObservable.Value, PlaceId);
                }
            }).AddTo(this.Disposable);
        }
Beispiel #15
0
        //private async UniTaskVoid SetUpAsync()
        private void SetUpAsync()
        {
            if (Application.isEditor)
            {
                this.UpdateAsObservable()
                .Select(_ => {
                    if (Input.GetMouseButtonDown(0))
                    {
                        return(TouchPhase.Began);
                    }
                    else if (Input.GetMouseButtonUp(0))
                    {
                        return(TouchPhase.Ended);
                    }
                    else if (Input.GetMouseButton(0))
                    {
                        return(TouchPhase.Moved);
                    }
                    else
                    {
                        return(TouchPhase.Ended);
                    }
                })
                .DistinctUntilChanged()
                .Subscribe(x =>
                           _onActionTouch.Value = x
                           );

                this.UpdateAsObservable()
                .Select(_ =>
                {
                    if (!Input.GetMouseButtonDown(0))
                    {
                        return(_onTouchObject.Value);
                    }
                    PointerEventData pointer    = new PointerEventData(EventSystem.current);
                    pointer.position            = Input.mousePosition;
                    List <RaycastResult> result = new List <RaycastResult>();
                    EventSystem.current.RaycastAll(pointer, result);
                    return(result.Count <= 0? null : result?[0].gameObject);
                })
                .DistinctUntilChanged()
                .Subscribe(x =>
                {
                    _onTouchObject.Value = x;
                    Debug.Log(x);
                }
                           );
            }
            else
            {
                this.UpdateAsObservable()
                .Select(_ => Input.touchCount > 0)
                .DistinctUntilChanged()
                .Subscribe(_ => {
                    _onActionTouch.Value = Input.GetTouch(0).phase;
                    Debug.Log("Touched!");
                });
            }
            _onTouchObject.AddTo(this);
            _onActionTouch.AddTo(this);
        }