Exemple #1
0
        protected override IEnumerator OnStart()
        {
            image            = this.GetComponent <Image>();
            button           = this.GetComponent <Button>();
            _textMeshProText = _textMeshProText.GetComponentFromDescendants(this, nameof(_textMeshProText));

            button.OnClickAsObservable().Subscribe(__ => OnChooseLevel()).AddTo(this);
            this.ObserveEveryValueChanged(x => x.level).Subscribe(x =>
            {
                if (isOn)
                {
                    _textMeshProText.text = x.ToString();
                }
                else
                {
                    _textMeshProText.text = "X";
                }
            }).AddTo(this);
            yield return(null);
        }
Exemple #2
0
        protected override IEnumerator AfterStart()
        {
            this.RegisterSelf(this);

            _plusTextMeshProText = _plusTextMeshProText.GetComponentFromDescendants(this, nameof(_plusTextMeshProText));
            _plusSkillButton     = _plusSkillButton.GetComponentFromChildren(this, nameof(_plusSkillButton));
            yield return(BrickMgrM.WaitModule <IPropertyTag>());

            yield return(null);

            // ----------------------
            //按下按键尝试释放
            _plusSkillButton.OnClickAsObservable().Subscribe(__ =>
            {
                MessageBroker.Default.Publish(new SkillTag_TryPlusSkill());
                MessageBroker.Default.Publish(new PropTag_ModifyPlusCount {
                    value = -1
                });
            }).AddTo(this);
            // ----------------------
            //更新数字
            BrickMgrM.PropertyModule.plusCount.current.SubscribeWithState(_plusTextMeshProText, (x, t) => t.text = x.ToString()).AddTo(this);
        }