コード例 #1
0
 public Parser(Queue server, GuiV1 g)
 {
     this.zähler = server.Count;
     this.makeArray(server);
     gui = g;
     //this.parsen(server);
 }
コード例 #2
0
 public Receiver(TcpClient client, Parser p, GuiV1 gui)
 {
     this.client = client;
     tcpStream   = client.GetStream();
     buffer      = new Queue();
     parse       = p;
     g           = gui;
 }
コード例 #3
0
        //Mess parsen
        private void parsMes(Queue serv)
        {
            while (!temp[0].Equals("end"))
            {
                temp = serv.Dequeue().ToString().Split(':');
                text2.Add(temp[0], temp[1]);
            }
            Message mes = new Message(text2);

            //gui.textBox1.Text = testmes.getMessage();
            gui = getGui();
            gui.setTextBox1(mes.getMessage());
            text2.Clear();

            mes.toString();
            //text2.Add(temp[0], temp[1]);
        }
コード例 #4
0
        //Time parsen
        private void parsTime(Queue serv)
        {
            long time = 0;

            while (!temp[0].Equals("end"))
            {
                time = long.Parse(serv.Dequeue().ToString());
                temp = serv.Dequeue().ToString().Split(':');
            }

            Time testtime = new Time(time);

            gui = getGui();
            gui.setTextBox1(testtime.toString());
            text2.Clear();
            Console.WriteLine(testtime.toString());
        }
コード例 #5
0
        /*
         #######################################################################
         # Einzelne Parser Methoden
         #######################################################################
         */


        //Player Parsen
        private int parsPlayer(String[] temp, Queue serv)
        {
            while (!temp[0].Equals("end"))
            {
                temp = serv.Dequeue().ToString().Split(':');
                text2.Add(temp[0], temp[1]);
            }
            Player testplayer = new Player(text2);

            entmanager.addPlayer(testplayer);
            gui = getGui();
            //gui.setTextBox1("a");
            gui.setPlayerPanel(testplayer);
            Console.WriteLine("KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
            text2.Clear();
            return(testplayer.getId());
            //text2.Add(temp[0], temp[1]);
        }
コード例 #6
0
        public Connector(GuiV1 gui)
        {
            Console.WriteLine("Connect...");
            //client = new TcpClient("127.0.0.1", 23); //->Hercules
            //client = new TcpClient("85.214.103.114", 110);
            client = new TcpClient("127.0.0.1", 666);
            client.ReceiveBufferSize = 128000;
            Queue  serv   = new testMap().getTestMap();
            Parser parser = new Parser(serv, gui, true);

            //senter = new Sender(client);
            //senter.sendtext("get:map");
            //Parser parser = new Parser();
            empf   = new Receiver(client, parser, gui);
            senter = new Sender(client);

            receiveT = new Thread(new ThreadStart(empf.receive));
            senderT  = new Thread(new ThreadStart(senter.send));

            senter.isconnected = client.Connected;
            empf.isconnected   = client.Connected;
            receiveT.Start();
            senderT.Start();
        }
コード例 #7
0
        public void makeArray2(Queue server, GuiV1 g)
        {
            String[] liste;
            Queue    serv          = new Queue();
            string   replaceWith   = "|";
            string   removedBreaks = server.Dequeue().ToString().Replace("\r\n", replaceWith);
            Regex    myRegex       = new Regex(@"[|]");

            if (myRegex.IsMatch(removedBreaks))
            {
                liste = removedBreaks.Split('|');
                for (int i = 0; i < liste.Count(); i++)
                {
                    if (liste[i] != "")
                    {
                        //Console.WriteLine("#" + liste[i]);
                        serv.Enqueue(liste[i]);
                    }
                }
            }
            this.zähler = serv.Count;
            setGui(g);
            this.parsen(serv);
        }
コード例 #8
0
 public GameManager()
 {
     g = new GuiV1();
 }
コード例 #9
0
        private void parsUpdate(Queue serv)
        {
            Console.WriteLine("####################################################" + temp[0] + "  " + temp[1]);
            this.temp = serv.Dequeue().ToString().Split(':');
            if (this.temp[0].Equals("begin") && this.temp[1].Equals("player"))
            {
                while (!(this.temp[0].Equals("end") && this.temp[1].Equals("player")))
                {
                    try
                    {
                        this.temp = serv.Dequeue().ToString().Split(':');
                        text2.Add(this.temp[0], this.temp[1]);
                        Console.WriteLine(this.temp[0] + " : " + this.temp[1]);
                    }
                    catch {
                        Console.WriteLine("CATCH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                    }
                }
            }

            if (this.temp[0] == "begin" && this.temp[1] == "dragon")
            {
                while (!(this.temp[0] == "end" && this.temp[1] == "dragon"))
                {
                    this.temp = serv.Dequeue().ToString().Split(':');
                    text2.Add(this.temp[0], this.temp[1]);
                }
            }

            if (this.temp[0] == "begin" && this.temp[1] == "cell")
            {
                Regex   myRegex = new Regex(@"[:]{1}");
                String  gelesen = "";
                String  prop    = "";
                Boolean mehrere = false;

                while (!(this.temp[0] == "end" && this.temp[1] == "cell"))
                {
                    gelesen = serv.Dequeue().ToString();
                    if (myRegex.IsMatch(gelesen))
                    {
                        this.temp = gelesen.Split(':');
                        if (!gelesen.Equals("begin:props") && !gelesen.Equals("end:props"))
                        {
                            //Console.WriteLine(gelesen);
                            text2.Add(this.temp[0], this.temp[1]);
                        }
                    }

                    else
                    {
                        if (mehrere == false)
                        {
                            prop    = gelesen;
                            mehrere = true;
                        }

                        else
                        {
                            prop += "," + gelesen;
                        }
                    }
                }
                text2.Add("properties", prop);
            }
            Update del = new Update(text2, entmanager, maptest, gui);

            gui = getGui();
            for (int i = 0; i < entmanager.getallPlayerList().Count; i++)
            {
                gui.setPlayerPanel(entmanager.getallPlayerList().ElementAt(i));
            }

            for (int j = 0; j < entmanager.getallDragonList().Count; j++)
            {
                gui.setDragonPanel(entmanager.getallDragonList().ElementAt(j));
            }
            //g.setPlayerPanel(entmanager.getPlayer(this.id));
            text2.Clear();
        }
コード例 #10
0
        //Mapparsen
        private void parsMap(Queue serv)
        {
            //MAP: " begin :map" , " width : " INT, " he i ght : " , INT, " begin : c e l l s " , {MAPCELL} , " end : c e l l s " , " end :map"
            text2.Clear();
            temp = serv.Dequeue().ToString().Split(':');
            text2.Add(temp[0], temp[1]);
            temp = serv.Dequeue().ToString().Split(':');
            text2.Add(temp[0], temp[1]);

            int width = int.Parse(text2["width"]);

            Console.WriteLine("breite: " + width);
            int height = int.Parse(text2["height"]);
            int row    = 0;
            int col    = 0;
            int anz    = width * height;
            List <List <Mapcell> > cell = new List <List <Mapcell> >();

            String gelesen = serv.Dequeue().ToString();

            if (gelesen.Equals("begin:cells"))
            {
                gelesen = serv.Dequeue().ToString();
            }
            for (int i = 0; i <= anz; i++)
            {
                if (gelesen.Equals("begin:cell"))
                {
                    gelesen = serv.Dequeue().ToString();
                    temp    = gelesen.Split(':');
                    text3.Add(temp[0], temp[1]);
                    row     = int.Parse(temp[1]);
                    gelesen = serv.Dequeue().ToString();
                    temp    = gelesen.Split(':');
                    text3.Add(temp[0], temp[1]);
                    col     = int.Parse(temp[1]);
                    gelesen = serv.Dequeue().ToString();
                }
                if (gelesen.Equals("begin:props"))
                {
                    gelesen = serv.Dequeue().ToString();
                    //bla


                    String blubb = "";
                    ///Per regex schaun ob : drin falls nein dann string konkat
                    ///String copy = text;
                    Boolean mehrere = false;
                    Regex   myRegex = new Regex(@"[:]{1}");
                    while (!myRegex.IsMatch(gelesen))
                    {
                        if (mehrere == true)
                        {
                            blubb += "," + gelesen;
                        }
                        else
                        {
                            blubb   = gelesen;
                            mehrere = true;
                        }

                        gelesen = serv.Dequeue().ToString();
                    }


                    text3.Add("properties", blubb);
                    gelesen = serv.Dequeue().ToString();
                }
                if (gelesen.Equals("end:props"))
                {
                    gelesen = serv.Dequeue().ToString();
                }
                if (gelesen.Equals("end:cell"))
                {
                    cell.Add(new List <Mapcell>());
                    cell[row].Add(new Mapcell(text3));
                    //Mapcell mapc = new Mapcell(text3);
                    //mapc.toString();
                    text3.Clear();
                    gelesen = serv.Dequeue().ToString();
                }
            }//neuer fehler kp muss cshauen k ich geh aus teamviewrr
            maptest = new Map(text2, cell);


            gui = getGui();
            //gui.setTextBox1("a");
            gui.setMapPanel(maptest);
            //this.bla(maptest);
            maptest.toString();
        }
コード例 #11
0
 public void setGui(GuiV1 g)
 {
     this.gui = g;
 }
コード例 #12
0
        public Update(Dictionary <String, String> upd, EntityManager entmanager, Map map, GuiV1 gui)
        {
            if (upd.ContainsKey("type"))
            {
                if (upd["type"].Equals("Dragon"))
                {
                    this.id   = int.Parse(upd["id"]);
                    this.x    = int.Parse(upd["x"]);
                    this.y    = int.Parse(upd["y"]);
                    this.type = upd["type"];
                    this.busy = bool.Parse(upd["busy"]);
                    this.desc = upd["desc"];

                    Dragon d = new Dragon(this.id);
                    entmanager.addDragon(d);

                    entmanager.getDragon(this.id).setX(this.x);
                    entmanager.getDragon(this.id).setY(this.y);
                    entmanager.getDragon(this.id).setType(this.type);
                    entmanager.getDragon(this.id).setBusy(this.busy);
                    entmanager.getDragon(this.id).setdesc(this.desc);
                    entmanager.getDragon(this.id).toString();

                    g = gui;
                    g.setDragonPanel(entmanager.getDragon(this.id));
                    //entmanager.getDragon(this.id).toString();
                }

                if (upd["type"].Equals("Player"))
                {
                    this.id     = int.Parse(upd["id"]);
                    this.x      = int.Parse(upd["x"]);
                    this.y      = int.Parse(upd["y"]);
                    this.points = int.Parse(upd["points"]);
                    this.type   = upd["type"];
                    this.busy   = bool.Parse(upd["busy"]);
                    this.desc   = upd["desc"];

                    Player p = new Player(this.id);
                    entmanager.addPlayer(p);

                    entmanager.getPlayer(this.id).setX(this.x);
                    entmanager.getPlayer(this.id).setY(this.y);
                    entmanager.getPlayer(this.id).setPoints(this.points);
                    entmanager.getPlayer(this.id).setType(this.type);
                    entmanager.getPlayer(this.id).setBusy(this.busy);
                    entmanager.getPlayer(this.id).setdesc(this.desc);
                    Console.WriteLine("??????????????????????????????????????????????????");

                    g = gui;
                    g.setPlayerPanel(entmanager.getPlayer(this.id));
                    entmanager.getPlayer(this.id).toString();
                }
            }

            else if (upd.ContainsKey("row") && upd.ContainsKey("col"))
            {
                this.row  = int.Parse(upd["row"]);
                this.col  = int.Parse(upd["col"]);
                this.prop = upd["properties"];

                map.getMapcell(this.row, this.col).setProperties(prop);
                map.getMapcell(this.row, this.col).toString();
            }

            else
            {
                Console.WriteLine("Update-fehler");
            }
        }
コード例 #13
0
 public GuiManager()
 {
     gui = new GuiV1();
 }