Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            CommonLibrary.Parser.ParseCommandLine(args);
            long applicationId = CommonLibrary.Parser.ApplicationId;

            if (applicationId == 0)
            {
                applicationId = Network.Utils.GetIPBasedApplicationId();
            }
            float  sleepTime = 1000.0f / (float)CommonLibrary.Parser.FPS;
            string ipAddr    = CommonLibrary.Parser.ipAddr;

            Console.WriteLine("Client talking to Gateway.");
            Console.WriteLine("  ** application id = {0} **", applicationId);
            Console.WriteLine("  Press esc to update player position.\n\n");

            ushort port        = 11000;
            bool   setToOrigin = false;

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            MyPlayer player = new MyPlayer();
            Random   rand   = new Random();
            TalkingToGatewayController testClient = new TalkingToGatewayController(ipAddr, port, player, applicationId);

            player.Set(testClient);

            while (testClient.isLoggedIn == false)
            {
                Thread.Sleep(16);
                TimeSpan ts = stopWatch.Elapsed;

                if (ts.Seconds > 180)
                {
                    Console.WriteLine("unable to connect after 3 mins");
                    Console.WriteLine("press a key to exit");
                    while (!Console.KeyAvailable)
                    {
                        // Do something
                    }
                    Environment.Exit(0);
                }
            }

            player.SendRandomLocation(rand, setToOrigin);

            stopWatch.Start();
            ConsoleKey key = ConsoleKey.Backspace;

            ScriptItem script    = new ScriptItem();
            int        loopCount = 1;

            do
            {
                if (script.isComplete)
                {
                    script.Randomize(player, rand);
                }
                script.Act();
                Thread.Sleep((int)sleepTime);
                if (Console.KeyAvailable)
                {
                    key = Console.ReadKey(true).Key;
                }



                loopCount++;
            } while (key != ConsoleKey.Escape);

            testClient.Close();
        }
Ejemplo n.º 2
0
 public void Set(TalkingToGatewayController test)
 {
     testClient = test;
 }