コード例 #1
0
    private void Start()
    {
        _status       = FindObjectOfType <PlayingStatus>();
        _pauseManager = FindObjectOfType <PauseManager>();

        sight.enabled = false;
        this.UpdateAsObservable()
        .Where(_ => !_pauseManager.isPause)
        .Where(_ => _status.IsPlaying().Value)
        .Where(_ => Input.GetMouseButton(0))
        .ThrottleFirst(TimeSpan.FromSeconds(weapon.Interval))
        .Subscribe(_ =>
        {
            Fire();
        })
        .AddTo(gameObject);

        currentIndex
        .Subscribe(index =>
        {
            weapon = weapons[index];
        });

        this.UpdateAsObservable()
        .Where(_ => _status.IsPlaying().Value)
        .Where(_ => Input.GetKeyDown(KeyCode.E))
        .Subscribe(_ =>
        {
            if (currentIndex.Value + 1 <= weapons.Count)
            {
                currentIndex.Value++;
            }
            else
            {
                currentIndex.Value = 0;
            }
        });
    }
コード例 #2
0
 private void Update()
 {
     if (_status.IsPlaying().Value)
     {
         // Targetが自機より左側にある
         var vector = target.position - transform.position;
         if (vector.x < 0)
         {
             var toScale = renderer.transform.localScale;
             toScale.x = Mathf.Abs(toScale.x) * -1;
             renderer.transform.localScale = toScale;
         }
         else
         {
             var toScale = renderer.transform.localScale;
             toScale.x = Mathf.Abs(toScale.x);
             renderer.transform.localScale = toScale;
         }
     }
 }