示例#1
0
        protected override void onModifierChanged(ITezValueModifier modifier, float old_value)
        {
            var config = modifier.modifierConfig;

            switch (config.assemble)
            {
            case TezValueModifierConfig.Assemble.SumBase:
                m_SumBase = m_SumBase - old_value + modifier.value;
                break;

            case TezValueModifierConfig.Assemble.SumTotal:
                m_SumTotal = m_SumTotal - old_value + modifier.value;
                break;

            case TezValueModifierConfig.Assemble.MultBase:
                m_MultBase = m_MultBase - old_value + modifier.value;
                break;

            case TezValueModifierConfig.Assemble.MultTotal:
                m_MultTotal = m_MultTotal - old_value + modifier.value;
                break;

            default:
                break;
            }
        }
        /// <summary>
        /// 移除一个Modifier
        /// 并返回被操作的Property
        /// </summary>
        public bool removeModifier(ITezValueModifier modifier, out ITezProperty property)
        {
            var target = modifier.modifierConfig.target;

            property = this.get <ITezProperty>(target);
            return((property != null) && property.removeModifier(modifier));
        }
示例#3
0
        protected override void onModifierRemoved(ITezValueModifier modifier)
        {
            var config = modifier.modifierConfig;

            switch (config.assemble)
            {
            case TezValueModifierConfig.Assemble.SumBase:
                m_SumBase -= modifier.value;
                break;

            case TezValueModifierConfig.Assemble.SumTotal:
                m_SumTotal -= modifier.value;
                break;

            case TezValueModifierConfig.Assemble.MultBase:
                m_MultBase -= modifier.value;
                break;

            case TezValueModifierConfig.Assemble.MultTotal:
                m_MultTotal -= modifier.value;
                break;

            default:
                break;
            }
        }
        /// <summary>
        /// 加入一个Modifier
        /// </summary>
        public void addModifier(ITezValueModifier modifier)
        {
            var target   = modifier.modifierConfig.target;
            var property = this.get <ITezProperty>(target);

            property?.addModifier(modifier);
        }
        protected sealed override void onModifierRemoved(ITezModifier modifier)
        {
            ITezValueModifier vm = (ITezValueModifier)modifier;

            this.onModifierRemoved(vm);
            vm.onValueChanged -= changeModifier;
        }
        /// <summary>
        /// 加入一个modifier
        /// 并返回被操作的property
        /// </summary>
        public bool addModifier(ITezValueModifier modifier, out ITezProperty property)
        {
            var target = modifier.modifierConfig.target;

            property = this.get <ITezProperty>(target);
            property?.addModifier(modifier);
            return(property != null);
        }
        public bool removeModifier(ITezValueModifier modifier)
        {
            var flag = m_ModifierCache.removeModifier(modifier);

            if (flag)
            {
                this.afterRemoveModifier(modifier);
            }
            return(flag);
        }
示例#8
0
 protected void notifyValueChanged(ITezValueModifier modifier, float old_value)
 {
     onValueChanged?.Invoke(modifier, old_value);
 }
 /// <summary>
 /// 成功删除modifier之后
 /// </summary>
 protected virtual void afterRemoveModifier(ITezValueModifier modifier)
 {
 }
 /// <summary>
 /// 加入Modifier之后
 /// </summary>
 protected virtual void afterAddModifier(ITezValueModifier modifier)
 {
 }
 public void addModifier(ITezValueModifier modifier)
 {
     m_ModifierCache.addModifier(modifier);
     this.afterAddModifier(modifier);
 }
 protected abstract void onModifierChanged(ITezValueModifier modifier, float old_value);
 protected abstract void onModifierRemoved(ITezValueModifier modifier);
 protected abstract void onModifierAdded(ITezValueModifier modifier);
 public void changeModifier(ITezValueModifier modifier, float old_value)
 {
     this.onModifierChanged(modifier, old_value);
     this.dirty = true;
 }
        protected override void onModifierClear(ITezModifier modifier)
        {
            ITezValueModifier vm = (ITezValueModifier)modifier;

            vm.onValueChanged -= changeModifier;
        }