Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        StaminaObservale.Subscribe(value =>
        {
            StaminaGauge.transform.localScale = new Vector3(value / staminaMax, StaminaGauge.transform.localScale.y, StaminaGauge.transform.localScale.z);
        }).AddTo(gameObject);

        IsStandingByObservable
        .Skip(1)
        .Subscribe(value =>
        {
            if (value)
            {
                Stamina -= Time.fixedDeltaTime * 2;
            }
        }).AddTo(gameObject);
    }
Exemplo n.º 2
0
        // Use this for initialization
        void Start()
        {
            var activeChanged = Shown.Skip(1);

            activeChanged.Where(active => active).Subscribe(active =>
            {
                TransitionHelper.TransitionIn(gameObject);
            }).AddTo(this);

            activeChanged.Where(active => !active).TakeUntilDestroy(this).Subscribe(active =>
            {
                TransitionHelper.TransitionOut(gameObject);
            }).AddTo(this);

            if (Shown.Value)
            {
                TransitionHelper.TransitionIn(gameObject);
            }
        }
Exemplo n.º 3
0
        void InitializeUGUI()
        {
            life            = new FloatReactiveProperty();
            UpperLeftCanvas = GameObject.Find(nameof(UpperLeftCanvas)).transform;
            Transform 体力, 気温, 殺害数;

            体力       = UpperLeftCanvas.Find(nameof(体力)).transform;
            残ライフ     = 体力.Find(nameof(残ライフ)).GetComponent <TMP_Text>();
            残中島敦     = 体力.Find(nameof(残中島敦)).GetComponent <RectTransform>();
            気温       = UpperLeftCanvas.Find(nameof(気温)).transform;
            現在気温     = 気温.Find(nameof(現在気温)).GetComponent <TMP_Text>();
            機体温度     = 気温.Find(nameof(機体温度)).GetComponent <TMP_Text>();
            致死温度     = 気温.Find(nameof(致死温度)).GetComponent <TMP_Text>();
            殺害数      = UpperLeftCanvas.Find(nameof(殺害数)).transform;
            駆逐数説明    = 殺害数.Find(nameof(駆逐数説明)).GetComponent <TMP_Text>();
            駆逐数      = 殺害数.Find(nameof(駆逐数)).GetComponent <TMP_Text>();
            ノルマ      = 殺害数.Find(nameof(ノルマ)).GetComponent <TMP_Text>();
            ノルマ.text = "体/" + titleSettings.ClearKillScore + "体";
            deathCounter.Subscribe(deadCount =>
            {
                var color   = Color.Lerp(zeroColor, clearColor, deadCount / (float)titleSettings.ClearKillScore);
                駆逐数.text    = deadCount.ToString();
                駆逐数説明.color = color;
                駆逐数.color   = color;
                ノルマ.color   = color;
            });
            nearToRespawn.Skip(1).Subscribe((bool _) =>
            {
                if (_)
                {
                    注意 = GameObject.Instantiate(respawnDisplay, UpperLeftCanvas);
                }
                else
                {
                    GameObject.Destroy(注意);
                }
            });
            this.UpdateAsObservable().Select(_ => Input.GetKeyDown(KeyCode.Backspace)).ThrottleFirst(System.TimeSpan.FromMilliseconds(200)).Where(_ => _).Subscribe(_ =>
            {
                UICamera.enabled = !UICamera.enabled;
            });
            cameraMoveObserver = this.UpdateAsObservable().Subscribe(_ =>
            {
                var deltaY = Input.mouseScrollDelta.y;
                if (deltaY != 0)
                {
                    var @position = mainCamera.transform.position;
                    @position.y   = System.Math.Max(0.5f, @position.y - deltaY);
                    mainCamera.transform.position = @position;
                }
            });
            playerMoveObserver = this.UpdateAsObservable().Where(_ => UICamera.enabled).Subscribe(_ =>
            {
                var settings = manager.GetComponentData <PlayerSettings>(player);
                if (cached.Temperature != settings.Temperature)
                {
                    var temperatureColor = Color.Lerp(normalColor, deathColor, settings.Temperature / settings.ThermalDeathPoint);
                    現在気温.color           = temperatureColor;
                    現在気温.text            = settings.Temperature.ToString();
                    機体温度.color           = temperatureColor;
                    致死温度.color           = temperatureColor;
                }
                if (cached.Life != settings.Life)
                {
                    life.Value     = settings.Life;
                    float t        = (float)settings.Life / (float)settings.MaxLife;
                    残ライフ.color     = Color.Lerp(deathColor, normalColor, t);
                    var siz        = 残中島敦.sizeDelta;
                    siz.x          = 500f * t;
                    残中島敦.sizeDelta = siz;
                }
                cached = settings;
            });
        }