示例#1
0
文件: ActionMap.cs 项目: r2d2m/xgoap
        void ActionHandler.Effect <T>(object action, GameAI <T> client)
        {
            switch (action)
            {
            case string noArg:
                if (noArg == INITIAL_STATE)
                {
                    return;
                }
                Print($"No-arg: {noArg} @{frameCount}");
                Map(noArg, client).Invoke(client, NoArg);
                return;

            case System.Action method:
                Print($"Delegate: {method.Method.Name} @{frameCount}");
                method();
                return;

            case null:
                client.Idle();
                return;

            default:
                throw new ArgumentException(UNKNOWN_ARG + action);
            }
        }
示例#2
0
文件: ActionMap.cs 项目: r2d2m/xgoap
        MethodInfo Map <T>(string name, GameAI <T> client) where T : class
        {
            map = map ?? new Dictionary <string, MethodInfo>();
            MethodInfo method;

            map.TryGetValue(name, out method);
            if (method == null)
            {
                map[name] = method = client.GetType().GetMethod(name);
            }
            return(method);
        }