Example #1
0
        public MainClass()
        {
            Application.Init();
            Console.WriteLine("ClarionApp V0.8");

            RandomGenerator rg        = new RandomGenerator();
            int             ws_width  = 800;
            int             ws_lenght = 600;

            try
            {
                ws = new WSProxy("localhost", 4011);

                String message = ws.Connect();


                if (ws != null && ws.IsConnected)
                {
                    Console.Out.WriteLine("[SUCCESS] " + message + "\n");
                    //ws.SendWorldReset();
                    ws.NewCreature(400, 200, 0, out creatureId, out creatureName);
                    ws.SendCreateLeaflet();

                    ws.NewBrick(4, 0, 0, -50, ws_lenght + 50);
                    ws.NewBrick(4, 0, ws_lenght, ws_width + 50, ws_lenght + 50);
                    ws.NewBrick(4, ws_width, ws_lenght, ws_width + 50, -50);
                    ws.NewBrick(4, ws_width, 0, -50, -50);

                    //while (true) {
                    int nu_of_jewels = 15;
                    for (int i = 0; i < nu_of_jewels; i++)
                    {
                        ws.NewJewel(rg.randomInt(0, 6), rg.randomInt(0, ws_width), rg.randomInt(0, ws_lenght));
                    }

                    int nu_of_foods = 8;
                    for (int i = 0; i < nu_of_foods; i++)
                    {
                        ws.NewFood(rg.randomInt(0, 2), rg.randomInt(0, ws_width), rg.randomInt(0, ws_lenght));
                    }
                    //Thread.Sleep(10000);
                    //}

                    if (!String.IsNullOrWhiteSpace(creatureId))
                    {
                        ws.SendStartCamera(creatureId);
                        ws.SendStartCreature(creatureId);
                    }

                    Console.Out.WriteLine("Creature created with name: " + creatureId + "\n");
                    agent = new ClarionAgent(ws, creatureId, creatureName);
                    agent.Run();
                    Console.Out.WriteLine("Running Simulation ...\n");
                }
                else
                {
                    Console.Out.WriteLine("The WorldServer3D engine was not found ! You must start WorldServer3D before running this application !");
                    System.Environment.Exit(1);
                }
            }
            catch (WorldServerInvalidArgument invalidArtgument)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Invalid Argument: {0}\n", invalidArtgument.Message));
            }
            catch (WorldServerConnectionError serverError)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Is is not possible to connect to server: {0}\n", serverError.Message));
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Unknown Error: {0}\n", ex.Message));
            }
            Application.Run();
        }
Example #2
0
        public MainClass()
        {
            Application.Init();
            Console.WriteLine("ClarionApp V0.8");
            try
            {
                ws = new WSProxy("localhost", 4011);

                String message = ws.Connect();

                if (ws != null && ws.IsConnected)
                {
                    Console.Out.WriteLine("[SUCCESS] " + message + "\n");
                    if (!skipReset)
                    {
                        ws.SendWorldReset();
                        ws.NewBrick(4, 747, 2, 800, 567);
                        ws.NewBrick(4, 50, -4, 747, 47);
                        ws.NewBrick(4, 49, 562, 796, 599);
                        ws.NewBrick(4, -2, 6, 50, 599);

                        // Create some food
                        ws.NewFood(0, 415, 212);
                        ws.NewFood(0, 237, 321);
                        ws.NewFood(0, 165, 440);

                        // Create 9 jewels of each color, to enable easy planning
                        ws.NewJewel(0, 200, 200);
                        ws.NewJewel(0, 200, 220);
                        ws.NewJewel(0, 200, 440);
                        ws.NewJewel(0, 420, 100);
                        ws.NewJewel(0, 420, 220);
                        ws.NewJewel(0, 420, 440);
                        ws.NewJewel(0, 640, 100);
                        ws.NewJewel(0, 640, 220);
                        ws.NewJewel(0, 640, 440);
                        ws.NewJewel(1, 200, 200);
                        ws.NewJewel(1, 140, 340);
                        ws.NewJewel(1, 140, 500);
                        ws.NewJewel(1, 340, 220);
                        ws.NewJewel(1, 340, 340);
                        ws.NewJewel(1, 340, 500);
                        ws.NewJewel(1, 600, 140);
                        ws.NewJewel(1, 600, 340);
                        ws.NewJewel(1, 600, 500);
                        ws.NewJewel(2, 250, 170);
                        ws.NewJewel(2, 250, 240);
                        ws.NewJewel(2, 250, 400);
                        ws.NewJewel(2, 440, 170);
                        ws.NewJewel(2, 440, 240);
                        ws.NewJewel(2, 440, 400);
                        ws.NewJewel(2, 530, 170);
                        ws.NewJewel(2, 530, 240);
                        ws.NewJewel(2, 530, 400);

                        ws.NewJewel(3, 260, 100);
                        ws.NewJewel(3, 260, 220);
                        ws.NewJewel(3, 260, 440);
                        ws.NewJewel(3, 500, 100);
                        ws.NewJewel(3, 500, 220);
                        ws.NewJewel(3, 480, 440);
                        ws.NewJewel(3, 700, 100);
                        ws.NewJewel(3, 700, 220);
                        ws.NewJewel(3, 700, 440);
                        ws.NewJewel(4, 200, 140);
                        ws.NewJewel(4, 200, 340);
                        ws.NewJewel(4, 200, 500);
                        ws.NewJewel(4, 400, 220);
                        ws.NewJewel(4, 400, 340);
                        ws.NewJewel(4, 400, 500);
                        ws.NewJewel(4, 660, 140);
                        ws.NewJewel(4, 660, 340);
                        ws.NewJewel(4, 660, 500);
                        ws.NewJewel(5, 310, 170);
                        ws.NewJewel(5, 310, 240);
                        ws.NewJewel(5, 310, 400);
                        ws.NewJewel(5, 500, 170);
                        ws.NewJewel(5, 500, 240);
                        ws.NewJewel(5, 500, 400);
                        ws.NewJewel(5, 590, 170);
                        ws.NewJewel(5, 590, 240);
                        ws.NewJewel(5, 590, 400);
                    }
                    ws.NewCreature(100, 100, 0, out creatureId, out creatureName);
                    ws.SendCreateLeaflet();

                    if (!String.IsNullOrWhiteSpace(creatureId))
                    {
                        ws.SendStartCamera(creatureId);
                        ws.SendStartCreature(creatureId);
                    }

                    Console.Out.WriteLine("Creature created with name: " + creatureId + "\n");
                    agent = new ClarionAgent(ws, creatureId, creatureName);
                    agent.Run();
                    Console.Out.WriteLine("Running Simulation ...\n");
                }
                else
                {
                    Console.Out.WriteLine("The WorldServer3D engine was not found ! You must start WorldServer3D before running this application !");
                    System.Environment.Exit(1);
                }
            }
            catch (WorldServerInvalidArgument invalidArtgument)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Invalid Argument: {0}\n", invalidArtgument.Message));
            }
            catch (WorldServerConnectionError serverError)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Is is not possible to connect to server: {0}\n", serverError.Message));
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(String.Format("[ERROR] Unknown Error: {0}\n", ex.Message));
            }
            Application.Run();
        }