/* ####################################################################### # 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]); }
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(); }
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"); } }