예제 #1
0
        /// <summary>
        /// 添加一个任意状态到目标状态的转移, 并指定其条件与回调函数
        /// </summary>
        /// <param name="targetState"></param>
        /// <param name="condition"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public Translation AddAnyStateTranslation(string targetState, BDelegate <object, bool> .MethodNone condition, BDelegate <object, string> .MethodNone callback)
        {
            Translation t = new Translation("ANY", targetState, condition, callback);

            AnyStateTranslations.Add(t);
            return(t);
        }
예제 #2
0
        /// <summary>
        /// 指定目标状态, 条件, 回调函数后添加转移
        /// </summary>
        /// <param name="targetState"></param>
        /// <param name="condition"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public Translation AddTranslation(string targetState, BDelegate <object, bool> condition, BDelegate <object, string> callback)
        {
            callback = callback ?? new BDelegate <object, string>(() => targetState);
            Translation trans = new Translation(Name, targetState, condition, callback);

            _translations.Add(trans.Name, trans);
            return(trans);
        }
예제 #3
0
파일: C.cs 프로젝트: Anil1111/CSharping
        public void AMethod()
        {
            BDelegate bDelegate = new BDelegate(BMethod);

            Console.WriteLine("This is printed from AMethod()");
            bDelegate.Invoke(199);
            bDelegate(100);
        }
예제 #4
0
        public delegate void BDelegate(int value); //Its just like new object dec;aration like int, float, string, char

        public void AMethod()
        {
            BDelegate bDelegate = new BDelegate(BMethod);  //Delegate object instantation

            bDelegate(911);

            Console.WriteLine("This is printed from ");
        }
예제 #5
0
 /// <summary>
 /// 指定源状态与目标状态构建转移, 并设置其条件与回调函数
 /// </summary>
 /// <param name="fromState"></param>
 /// <param name="targetState"></param>
 /// <param name="condition"></param>
 /// <param name="callback"></param>
 public Translation(string fromState, string targetState, BDelegate <object, bool> condition, BDelegate <object, string> callback)
 {
     Name           = fromState + "TO" + targetState;
     FromState      = fromState;
     TargetState    = targetState;
     Condition      = condition;
     CallbackAction = callback;
 }
예제 #6
0
파일: Path.cs 프로젝트: black067/BFramework
 /// <summary>
 /// 检索路径, 且在每一步检索之后执行动作, 直到寻路结束
 /// </summary>
 /// <param name="action"></param>
 public STATE Find(BDelegate action)
 {
     for (; State == STATE.PROCESSING;)
     {
         FindSync();
         action.Execute();
     }
     return(State);
 }
예제 #7
0
            public static void ExpandedMath()
            {
                //数学拓展测试
                Console.WriteLine("#############\nMath Test");
                Vector vectorA = new Vector(1.51556f, 2, 3);
                Vector vectorB = new Vector(4, 5, 6);

                Console.WriteLine(vectorA + vectorB);
                Console.WriteLine(vectorA * vectorB);
                Console.WriteLine(vectorA / 3);
                Console.WriteLine(vectorA * 4.57f);
                Console.WriteLine(vectorA * 15484);
                Console.WriteLine(vectorA.Cross(vectorB));
                Console.WriteLine(vectorA.Dot(vectorB));

                Segments segments = new Segments(0, 3, 1, 1, 1, 1, 1);

                Console.WriteLine("var : {0}", segments);
                Console.WriteLine("Count = {0}", segments.Count);
                Console.WriteLine("Test{0} = {1}", 0, segments[0]);
                Console.WriteLine("Test{0} = {1}", 4, segments[4]);
                Console.WriteLine("Test{0} = {1}", 2, segments[2]);
                Console.WriteLine("Test{0} = {1}", 5, segments[5]);
                Console.WriteLine("Test{0} = {1}", 10, segments[10]);

                //限定条件数值
                Console.WriteLine("#############\nConditional Number Test");

                BDelegate <int, bool>[] conditions = new BDelegate <int, bool> [1];

                Conditional <int> conditional = new Conditional <int>(5, new BDelegate <int, bool>(delegate(int value)
                {
                    return(value > 10);
                }));

                Console.WriteLine(conditional.Value);
                conditional.Value = 15;
                Console.WriteLine(conditional.Value);
                conditional.Value = 6;
                Console.WriteLine(conditional.Value);

                Console.WriteLine("Conditional Number Test Over\n");
            }
예제 #8
0
 /// <summary>
 /// 构建一个动作行为
 /// </summary>
 /// <param name="method"></param>
 public Action(BDelegate <Cognition, STATUS> method)
 {
     _tick = method;
 }
예제 #9
0
 /// <summary>
 /// 使用字符串为名称,已有的委托新建一个状态
 /// </summary>
 /// <param name="name"></param>
 /// <param name="action"></param>
 public State(string name, BDelegate <object, string> action)
 {
     Name          = name;
     Action        = action;
     _translations = new Dictionary <string, Translation>();
 }
예제 #10
0
 /// <summary>
 /// 使用给定的名称与现有的方法新建状态
 /// </summary>
 /// <param name="name"></param>
 /// <param name="action"></param>
 public State(string name, BDelegate <object, string> .Method action) : this(name, new BDelegate <object, string>(action))
 {
 }
예제 #11
0
 /// <summary>
 /// 条件无参数, 回调有参数
 /// </summary>
 /// <param name="targetState"></param>
 /// <param name="conditionMethod"></param>
 /// <param name="callbackMethod"></param>
 /// <returns></returns>
 public Translation AddTranslation(string targetState, BDelegate <object, bool> .MethodNone conditionMethod, BDelegate <object, string> .Method callbackMethod)
 {
     callbackMethod = callbackMethod ?? (i => targetState);
     return(AddTranslation(targetState, new BDelegate <object, bool>(conditionMethod), new BDelegate <object, string>(callbackMethod)));
 }
예제 #12
0
    public void BegineBMethod()
    {
        BDelegate b_method = new BDelegate(B.b);

        b_method.BeginInvoke(BCallback, null);
    }
예제 #13
0
 /// <summary>
 /// 指定源状态与目标状态构建转移, 并设置其条件与回调函数
 /// </summary>
 /// <param name="fromState"></param>
 /// <param name="targetState"></param>
 /// <param name="conditionMethod"></param>
 /// <param name="callbackMethod"></param>
 public Translation(string fromState, string targetState, BDelegate <object, bool> .MethodNone conditionMethod, BDelegate <object, string> .Method callbackMethod) : this(fromState, targetState, new BDelegate <object, bool>(conditionMethod), new BDelegate <object, string>(callbackMethod))
 {
 }
예제 #14
0
 public void RegisterBool(BDelegate handler)
 {
     this.m_BDeleates.Add(handler.Method.Name, handler);
 }