예제 #1
0
파일: gm.cs 프로젝트: hpplinux/abelkhan
        private static void Main(string[] args)
        {
            if (args.Length <= 0)
            {
                log.log.error(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "non input start argv");
                return;
            }

            gm   _gm    = new gm(args);
            bool runing = true;

            Dictionary <String, handle> cmd_callback = new Dictionary <string, handle>();

            cmd_callback.Add("close", () => {
                _gm._center_proxy.close_clutter(_gm.gm_name);
            });

            Int64 old_tick = 0;
            Int64 tick     = 0;

            while (runing)
            {
                old_tick = tick;
                tick     = _gm.poll();

                _gm.output_cmd();

                string cmd = Console.ReadLine();
                if (cmd_callback.ContainsKey(cmd))
                {
                    cmd_callback[cmd]();
                }
                else
                {
                    Console.WriteLine("invalid gm cmd!");
                }

                Int64 tmp = tick - old_tick;
                if (tmp < 50)
                {
                    System.Threading.Thread.Sleep(15);
                }
            }
        }
예제 #2
0
파일: gm.cs 프로젝트: tuita520/abelkhan
        private static void Main(string[] args)
        {
            if (args.Length <= 0)
            {
                log.log.error(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "non input start argv");
                return;
            }

            string gm_name = null;

            string[] cmd = null;
            if (args.Length > 3)
            {
                gm_name = args[2];

                cmd = new string[2];
                for (int i = 3; i < args.Length; i++)
                {
                    cmd[i - 3] = args[i];
                }
            }
            else
            {
                Console.WriteLine("Enter gm name:");
                gm_name = Console.ReadLine();
            }

            gm   _gm    = new gm(args, gm_name);
            bool runing = true;

            Dictionary <String, handle> cmd_callback = new Dictionary <string, handle>();

            cmd_callback.Add("close", (string[] cmds) => {
                _gm._center_proxy.close_clutter(_gm.gm_name);
            });
            cmd_callback.Add("close_zone", (string[] cmds) => {
                _gm._center_proxy.close_zone(_gm.gm_name, Int64.Parse(cmds[1]));
            });
            cmd_callback.Add("reload", (string[] cmds) => {
                _gm._center_proxy.reload(_gm.gm_name, cmds[1]);
            });

            while (runing)
            {
                var tmp = _gm.poll();

                if (cmd != null)
                {
                    if (cmd_callback.ContainsKey(cmd[0]))
                    {
                        cmd_callback[cmd[0]](cmd);
                    }
                    else
                    {
                        Console.WriteLine("invalid gm cmd!");
                    }

                    System.Threading.Thread.Sleep(1500);
                    runing = false;
                }
                else
                {
                    _gm.output_cmd();

                    string   cmd1 = Console.ReadLine();
                    string[] cmds = cmd1.Split(' ');
                    if (cmd_callback.ContainsKey(cmds[0]))
                    {
                        cmd_callback[cmds[0]](cmds);
                    }
                    else
                    {
                        Console.WriteLine("invalid gm cmd!");
                    }
                }

                if (tmp < 50)
                {
                    System.Threading.Thread.Sleep(15);
                }
            }
        }