Ejemplo n.º 1
0
        public void 改值回调()
        {
            TriggerGroupElement <int>   i = new TriggerGroupElement <int>(2);
            TriggerGroupElement <float> j = new TriggerGroupElement <float>(1.0f);

            int          calledTimes = 0;
            TriggerGroup group       = new TriggerGroup(() => {
                calledTimes++;
            });

            group.AddTrigger(i);
            group.AddTrigger(j);

            group.Operate(opr => {
                opr.SetValue(i, 3);
            }
                          );

            Assert.AreEqual(calledTimes, 1);

            group.Operate(opr => {
                opr.SetValue(i, 5);
                opr.SetValue(j, 2f);
            }
                          );

            Assert.AreEqual(calledTimes, 2);

            group.Operate(value =>
            {
                int TestResult = i.GetValue();
            });

            Assert.AreEqual(calledTimes, 2);
        }
Ejemplo n.º 2
0
 public AnimProxy()
 {
     animFlusher = new TriggerGroup(Flush);
     animFlusher.AddTrigger(targetAnim);
     animFlusher.AddTrigger(anim);
     animFlusher.AddTrigger(animWrapMode);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 初始化接口
        /// </summary>
        /// <param name="control"></param>
        public PlayerPosBehaviour(IPosControl control)
        {
            posControl = control;
            currentPos = new Triggable <Vector2>(control.GetPos(), OnCurrentPosChanged);

            timeSpanCalculator = new TriggerGroup(RecalulateTimeSpan, OnBeforeChange);
            timeSpanCalculator.AddTrigger(targetPos);
            timeSpanCalculator.AddTrigger(speed);
        }