Exemplo n.º 1
0
        void Start()
        {
            queried.AsObservable()
            .Subscribe(flag =>
            {
                Color targetColor = flag ? queriedColor : defaultColor;
                GetComponentInChildren <SpriteRenderer>()
                .DOColor(targetColor, 0.5f);
            }).AddTo(this);

            selected.AsObservable()
            .Subscribe(flag =>
            {
                Color targetColor = flag ? selectedColor : queried.Value ? queriedColor : defaultColor;
                GetComponentInChildren <SpriteRenderer>()
                .DOColor(targetColor, 0.5f);
            }).AddTo(this);
        }
Exemplo n.º 2
0
        public MainWindowViewModel()
        {
            var vGenWrapper = new VGenWrapper();

            HidManager      = new HidManager();
            _gamepadManager = new GamepadManager(vGenWrapper, HidManager);
            _gamepadManager.ErrorOccuredEvent += (_, message) => { Log(message); };

            IsRunning.AsObservable().Where(b => !b).Subscribe(_ => _runningGamepadsDisposable?.Dispose());
        }
Exemplo n.º 3
0
    void Start()
    {
        reticle    = GameObject.FindWithTag("ReticleImage").GetComponent <Image>();
        mainCamera = GameObject.FindWithTag("MainCamera").GetComponent <Camera>();

        var aimPos = new ReactiveProperty <Vector3>();

        aimPos.Value = transform.position;

        aimPos.AsObservable()
        .Subscribe(_ =>
                   reticle.transform.position = RectTransformUtility.WorldToScreenPoint(mainCamera, aimPos.Value));
    }
Exemplo n.º 4
0
    void Start()
    {
        UnderAttack = new ReactiveProperty <bool>();
        _lastAdded  = DateTimeOffset.Now;

        if (IsEnemy)
        {
            _targetTransform = _castle.transform;
        }
        else
        {
            _targetTransform = EnemyTransform;
        }

        this.UpdateAsObservable().Where(x => CurrentEnemy != null && _targetTransform != CurrentEnemy.transform).Subscribe(
            x =>
        {
            _targetTransform = CurrentEnemy.transform;
            _anim.SetBool("Attacking", true);
            GetComponent <AudioSource>().Play();
        });

        this.UpdateAsObservable().Where(x => CurrentEnemy == null && _targetTransform != _castle.transform && IsEnemy).Subscribe(
            x =>
        {
            _targetTransform = CurrentEnemy.transform;
            GetComponent <AudioSource>().Stop();
        });

        _health = new ReactiveProperty <int>(StartingHealth);
        if (_animate)
        {
            _anim = GetComponentInChildren <Animator>();
        }

        _nav = GetComponent <NavMeshAgent>();

        _health.AsObservable().Where(i => i <= 0).Subscribe(x => Destroy(gameObject));

        this.UpdateAsObservable()
        .Timestamp()
        .Where(x => !(_animate && _anim.GetBool("Attacking")))
        .Where(x => x.Timestamp >= _lastAdded.AddSeconds(0.2))
        .Subscribe(x =>
        {
            Pathfind();
            _lastAdded = x.Timestamp;
        });

        StartCoroutine(LateStart());
    }
Exemplo n.º 5
0
 public override void Start()
 {
     base.Start();
     BossLife = new ReactiveProperty <int>(10);
     //ボスライフゲージ更新処理
     BossLife.AsObservable().Subscribe(bossLife =>
     {
         BossLifeSlider.value = bossLife * 0.1f;
     });
     //ボスのライフがゼロになったらゲームクリア処理
     BossLife.AsObservable().Where(bosslife => bosslife <= 0).Subscribe(bossLife =>
     {
         //ボス討伐後ゲームクリア処理
         GameClearImage.rectTransform.DOAnchorPosY(0, 1.0f);
         gameObject.SetActive(false);
         ShotButton.interactable = false;
         SoundController.Instance.FadePlayBGM(0.5f, 4);
         //全発射するオブジェクトを停止する
         foreach (var ObstableCon in FindObjectsOfType <ObstableController>())
         {
             ObstableCon.gameObject.SetActive(false);
         }
     });
 }
Exemplo n.º 6
0
    private void OnEnable()
    {
        disposables = new CompositeDisposable();

        transform.UpdateAsObservable().Subscribe((_) =>
        {
            distance.Value = Vector3.Distance(transform.position, target.transform.position);
        }).AddTo(disposables);

        var stream = distance.AsObservable().Where(y =>
                                                   y > FollowDistance)
                     .Subscribe((x) =>
        {
            transform.LookAt(target.transform.position);
            transform.position += transform.forward * Time.deltaTime * distance.Value * 3;
        }).AddTo(disposables);
    }
Exemplo n.º 7
0
        void Start()
        {
            SelectedAssignmentID.AsObservable()
            .Subscribe(id => {
                showDetail.Value = id >= 0;
            });
            InfoCardSelected(-1);

            tagSelector.tagMask.AsObservable()
            .Subscribe(mask => UpdateQueried(QueryDefault(mask)));

            listByName.AsObservable()
            .Subscribe(byName => {
                if (!byName)
                {
                    UpdateQueried(QueryDefault(tagSelector.tagMask.Value));
                }
                else
                {
                    Search();
                }
            });

            queriedByEntity.AsObservable()
            .Where(flag => !flag)
            .Subscribe(flag => {
                if (!listByName.Value)
                {
                    UpdateQueried(QueryDefault(tagSelector.tagMask.Value));
                }
                else
                {
                    Search();
                }
            });

            searchInputField.onEndEdit
            .AddListener((s) => Search());

            mapSystem.SubjectAssignmentEntityRendererClicked.AsObservable()
            .Subscribe(ent => {
                AssignmentEntity entity = mapSystem.assignmentEntityDictionary[ent.aeID];
                UpdateQueried(QueryByList(entity.assignmentIDList));
            });
        }
Exemplo n.º 8
0
 public IObservable <List <ICheckPointPassenger> > CheckPointPassengersAsObservable()
 {
     return(players.AsObservable()
            .WhereNotNull()
            .Select(x => x.Select(y => y.GetComponent <ICheckPointPassenger>()).ToList()));
 }
Exemplo n.º 9
0
 private void InitSelectedUpgrade()
 {
     _selectedUpgrade.AsObservable().Subscribe(_ => OnSelectedUpgradeChanged()).AddTo(_shopComponent);
 }
Exemplo n.º 10
0
    void Start()
    {
        var weaponSys = GetComponent <WeaponSystem>();

        var targetTransform = new ReactiveProperty <Vector3>();

        targetTransform.Value = aimTarget.transform.position;

        var bulletcounter = new ReactiveProperty <int>();

        bulletcounter.Value = bulletCount;

        var APcounter = new ReactiveProperty <int>();

        APcounter.Value = AP;

        var weapon = defaultWeapon;

        bulletUI = GameObject.Find("BulletUI").GetComponent <Text>();
        APUI     = GameObject.Find("AP").GetComponent <Text>();

        bulletUI.text = $"Bullet {bulletcounter.Value} / {bulletCount}";
        APUI.text     = $"AP {APcounter.Value}";

        _rigidbody = GetComponent <Rigidbody>();

        weaponSys.SetWeapon(weapon);

        // カーソル固定
        Cursor.lockState = CursorLockMode.Locked;

        // 弾の発射
        this.UpdateAsObservable()
        .Where(_ => Input.GetMouseButton(0) && canShot)
        .Subscribe(_ =>
        {
            weaponSys.Fire(transform);
            bulletcounter.Value--;
            bulletUI.text = $"Bullet {bulletcounter.Value} / {bulletCount}";
        });

        // リロード
        float reloadTimer = 0f;

        this.UpdateAsObservable()
        .Where(_ => Input.GetKeyDown(KeyCode.Q))
        .Subscribe(_ => isReload = true);

        this.UpdateAsObservable()
        .Where(_ => isReload)
        .Subscribe(_ =>
        {
            canShot      = false;
            reloadTimer += Time.deltaTime;
            if (reloadTimer > 1)
            {
                isReload            = false;
                canShot             = true;
                bulletcounter.Value = bulletCount;
                bulletUI.text       = $"Bullet {bulletcounter.Value} / {bulletCount}";
                reloadTimer         = 0;
            }
        });

        // 視点移動
        this.UpdateAsObservable()
        .Where(_ => Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0)
        .Subscribe(_ => AimingSystem());

        // 移動
        var boostDirection = new Vector3();

        this.UpdateAsObservable()
        .Where(_ => Input.GetAxis("Horizontal") < 0)
        .Subscribe(_ =>
        {
            this.transform.Translate(movementVelocity * -1f, 0, 0);
            boostDirection = transform.right * -1;
        });

        this.UpdateAsObservable()
        .Where(_ => Input.GetAxis("Horizontal") > 0)
        .Subscribe(_ =>
        {
            this.transform.Translate(movementVelocity, 0, 0);
            boostDirection = transform.right;
        });

        this.UpdateAsObservable()
        .Where(_ => Input.GetAxis("Vertical") < 0)
        .Subscribe(_ =>
        {
            this.transform.Translate(0, 0, movementVelocity * -1f);
            boostDirection = transform.forward * -1;
        });

        this.UpdateAsObservable()
        .Where(_ => Input.GetAxis("Vertical") > 0)
        .Subscribe(_ =>
        {
            this.transform.Translate(0, 0, movementVelocity);
            boostDirection = transform.forward;
        });

        this.UpdateAsObservable()
        .Where(_ => Input.GetKeyDown(KeyCode.Space))
        .Subscribe(_ => _rigidbody.AddForce(boostDirection * boostVelocity, ForceMode.Impulse));

//        this.UpdateAsObservable()
//            .Where(_ => Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
//            .Subscribe(_ => MovementSystem());

        // ブースト
        this.UpdateAsObservable()
        .Where(_ => Input.GetKeyDown(KeyCode.LeftShift))
        .Subscribe(_ => _rigidbody.AddForce(Vector3.up * quickJumpVelocity, ForceMode.Impulse));
        this.UpdateAsObservable()
        .Where(_ => Input.GetKey(KeyCode.LeftShift))
        .Subscribe(_ => _rigidbody.AddForce(Vector3.up * jumpVelocity, ForceMode.Acceleration));

        // 弾切れ判定
        bulletcounter.AsObservable()
        .Subscribe(_ =>
        {
            if (bulletcounter.Value < 1)
            {
                canShot = false;
            }

            //Debug.Log(bulletcounter.Value);
        });

        // 自分の命中
        this.OnTriggerEnterAsObservable()
        .Where(x => x.CompareTag("bullet"))
        .Subscribe(_ =>
        {
            APcounter.Value -= 350;
            APUI.text        = $"AP {APcounter.Value}";
        });

        // エイム方向をみる
        targetTransform.AsObservable()
        .Subscribe(_ => transform.LookAt(aimTarget.transform));
    }
Exemplo n.º 11
0
    public void LateInitialize()
    {
        if (ShouldLoginImmediately)
        {
            Login();
            ShouldLoginImmediately = false;
        }
        if (base.Inited)
        {
            Singleton <CloudSyncRunner> .Instance.CloudSync("init_pf");

            return;
        }
        UniRx.IObservable <bool> first = from should in ConnectivityService.InternetConnectionAvailable.CombineLatest(PlayerData.Instance.LifetimePrestiges, (bool net, int prestiges) => net && string.IsNullOrEmpty(LoggedOnPlayerId.Value) && prestiges > 0)
                                         where should
                                         select should;

        UniRx.IObservable <bool> observable = from should in ConnectivityService.InternetConnectionAvailable.CombineLatest(PersistentSingleton <FacebookAPIService> .Instance.IsLoggedToFB, (bool net, bool fb) => net && fb)
                                              where should
                                              select should;

        first.Merge(observable).Subscribe(delegate
        {
            Login();
        });
        MainThreadDispatcher.StartCoroutine(QueueRoutine());
        (from chunk in PlayerData.Instance.LifetimeChunk
         select(chunk != 0) ? Observable.Never <bool>() : m_hasCommandsInFlight.AsObservable()).Switch().Subscribe(delegate(bool inFlight)
        {
            if (BindingManager.Instance != null)
            {
                BindingManager.Instance.SystemPopup.SetActive(inFlight);
            }
        });
        LoggedOnPlayerId.Subscribe(delegate(string loggedID)
        {
            PlayerData.Instance.PFId.Value = loggedID;
        });
        LoggedOnPlayerId.CombineLatest(PlayerData.Instance.DisplayName, (string id, string dn) => dn).Subscribe(delegate(string name)
        {
            PlayFabService playFabService = this;
            GetAccountInfo(delegate(JSONObject json)
            {
                string a = json.asJSONObject("AccountInfo").asJSONObject("TitleInfo").asString("DisplayName", () => string.Empty);
                if (name != string.Empty && a != name)
                {
                    playFabService.UpdateUserDisplayName(name, null, null);
                }
                else if (name == string.Empty && a == string.Empty)
                {
                    (from fbname in Singleton <FacebookRunner> .Instance.PlayerName.AsObservable().Take(1)
                     where !string.IsNullOrEmpty(fbname)
                     select fbname).Subscribe(delegate(string fbname)
                    {
                        playFabService.UpdateUserDisplayName(fbname, null, null);
                    });
                }
            }, null);
        });
        base.Inited = true;
    }
Exemplo n.º 12
0
        // Use this for initialization
        void Start()
        {
            this.UpdateAsObservable()
            .Where(__ => Input.GetKeyDown(KeyCode.F2))
            .Subscribe(__ =>
            {
                editorOn.Value = !editorOn.Value;
            });

            this.UpdateAsObservable()
            .Where(__ => editorOn.Value)
            .Where(__ => currentMode.Value == EditMode.NONE)
            .Where(__ => Input.GetKeyDown(KeyCode.F3))
            .Subscribe(__ =>
            {
                CreateNew(AEType.computer);
            });

            this.UpdateAsObservable()
            .Where(__ => editorOn.Value)
            .Where(__ => currentMode.Value == EditMode.NONE)
            .Where(__ => Input.GetKeyDown(KeyCode.F4))
            .Subscribe(__ =>
            {
                CreateNew(AEType.wall);
            });

            this.UpdateAsObservable()
            .Where(__ => this.currentMode.Value == EditMode.TRANSFORM)
            .Subscribe(__ =>
            {
                if (Input.GetKey(KeyCode.A))
                {
                    Vector3 screenToWorld             = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    selectedEntity.transform.position = new Vector3(screenToWorld.x, screenToWorld.y, selectedEntity.transform.position.z);
                }
                if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D))
                {
                    mousePos = Input.mousePosition;
                }
                else if (Input.GetKey(KeyCode.S))
                {
                    float deltaY = Input.mousePosition.y - mousePos.y;
                    selectedEntity.transform.Rotate(0, 0, deltaY * Time.deltaTime * 10);
                    mousePos = Input.mousePosition;
                }
                else if (Input.GetKey(KeyCode.D))
                {
                    float deltaX = Input.mousePosition.x - mousePos.x;
                    Vector2 size = selectedEntity.GetComponentInChildren <SpriteRenderer>().size;
                    selectedEntity.GetComponentInChildren <SpriteRenderer>().size = new Vector2(size.x + deltaX * Time.deltaTime, size.y);
                    mousePos = Input.mousePosition;
                }
            });

            editorOn.AsObservable()
            .Subscribe(flag =>
            {
                editorCanvas.SetActive(flag);
            });

            mapSystem.SubjectAssignmentEntityRendererClicked.AsObservable()
            .Where(__ => editorOn.Value)
            .Subscribe(ent =>
            {
                if (currentMode.Value == EditMode.NONE || selectedEntity != ent)
                {
                    currentMode.Value = EditMode.VALUES;
                    selectedEntity    = ent;
                    SubjectAssignmentEntityRendererSelected_Edit.OnNext(ent);
                }
                else
                {
                    if (currentMode.Value == EditMode.TRANSFORM)
                    {
                        Debug.Log("current mode :: values");
                        currentMode.Value = EditMode.VALUES;
                    }
                    else
                    {
                        Debug.Log("current mode :: transform");
                        currentMode.Value = EditMode.TRANSFORM;
                    }
                }
            });
        }
Exemplo n.º 13
0
 public IObservable <DungeonParameter> OnChangeParameterAsObservable()
 {
     return(_parameter.AsObservable());
 }
Exemplo n.º 14
0
    void Start()
    {
        var manager = GameObject.FindWithTag("GameController").GetComponent <TotalGameManager>();

        float timer = 0;

        var reactiveAP = new ReactiveProperty <int>();

        reactiveAP.Value = AP;

        player = GameObject.FindWithTag("Player");

        agent = GetComponent <NavMeshAgent>();

        // プレイヤーに射線が通れば撃つ
        this.UpdateAsObservable()
        .Where(_ => find)
        .Subscribe(_ =>
        {
            timer += Time.deltaTime;
            if (timer > shotTimer)
            {
                Shot();
                timer = 0;
            }
        });

        // レイキャストで射線判定&移動
        this.UpdateAsObservable()
        .Subscribe(_ =>
        {
            var dist = Vector3.Distance(transform.position, player.transform.position);
            dir      = player.transform.position - transform.position;

            RaycastHit hit;
            if (Physics.Raycast(this.transform.position, dir.normalized, out hit, dist))
            {
                find = false;
            }
            else
            {
                find = true;
            }

            EnemyMove();

            transform.LookAt(player.transform.position);
        });

        // 被弾時のダメージ判定
        this.OnTriggerEnterAsObservable()
        .Where(x => x.CompareTag("bullet"))
        .Subscribe(_ => reactiveAP.Value -= 1000);

        // 撃破判定
        reactiveAP.AsObservable()
        .Where(_ => reactiveAP.Value < 0)
        .Subscribe(_ =>
        {
            manager.TranslateEnemyCount(-1);
            Destroy(gameObject);
        });
    }
        private void Start()
        {
            #region LocalFunctions

            void ObservableSubscribe()
            {
                void SpinButton()
                {
                    spinButton.onClick.AsObservable().Subscribe(_ => { TurnWheel(); });
                }

                void CurrentBet()
                {
                    var observable = _currentBet.AsObservable();

                    observable.SubscribeToText(currentBetText);
                    observable.Subscribe(_ =>
                    {
                        var winChances = new StringBuilder();
                        var fontSize   = winChancesText.fontSize;
                        for (int i = _wheelChancesSorted.Length - 1, j = 0; i >= 0; i--, j++)
                        {
                            winChances.AppendLine(
                                $"<size={fontSize - fontSize * j * FontSizeDecrease}>{i + 1}. ${betManager.CurrentBet * _wheelChancesSorted[i].Factor} ({_wheelChancesSorted[i].Probability * 100}%)</size>");
                        }

                        winChancesText.text = winChances.ToString();
                    });
                }

                void BetButtons()
                {
                    var observableMoreBetButton = moreBetButton.onClick.AsObservable();
                    var observableLessBetButton = lessBetButton.onClick.AsObservable();

                    observableMoreBetButton.Subscribe(_ =>
                    {
                        if (betManager.Next())
                        {
                            _currentBet.Value = betManager.CurrentBet;
                        }
                    });
                    observableLessBetButton.Subscribe(_ =>
                    {
                        if (betManager.Previous())
                        {
                            _currentBet.Value = betManager.CurrentBet;
                        }
                    });
                    Observable.Merge(
                        observableMoreBetButton,
                        observableLessBetButton
                        ).Subscribe(_ => { SetInteractableBetButtons(); });
                }

                void RunningState()
                {
                    _runningState.Subscribe(state =>
                    {
                        if (state)
                        {
                            gainMoneyText.text      = string.Empty;
                            spinButton.interactable = false;
                        }
                        else
                        {
                            currentMoneyText.text = _wheelFortune.CurrentMoney.MetricPrefix();
                            var gain                = _wheelFortune.WheelChances[_chosenWheelChanceIndex].Factor * _chosenBet;
                            gainMoneyText.text      = $"{(gain >= 0 ? "+" : "-")}{gain}";
                            spinButton.interactable = true;
                        }
                    });
                }

                void ExitGame()
                {
                    Observable.EveryUpdate()
                    .Where(_ => Input.GetKeyDown(KeyCode.Escape))
                    .Subscribe(_ =>
                    {
#if UNITY_EDITOR
                        EditorApplication.isPlaying = false;
#else
                        Application.Quit();
#endif
                    });
                }

                SpinButton();
                CurrentBet();
                BetButtons();
                RunningState();
                ExitGame();
            }

            #endregion

#if !UNITY_EDITOR
            OnValidate();
#endif

            ObservableSubscribe();
        }