Ejemplo n.º 1
0
        private void saveMap()
        {
            // Speichern der Datei:
            Translator tr = new Translator();

            List<ClassContainer> liste = new List<ClassContainer>();
            Map map2 = new Map();
            map2.solarsystems = systemList;
            map2.randomArea = loadedMap.randomArea;

            map2.systemcount = loadedMap.systemcount;
            map2.min_distance = loadedMap.min_distance;
            ClassContainer container2 = new ClassContainer();
            container2.objekt = map2;
            container2.type = ClassType.Map;
            liste.Add(container2);

            tr.writeData(liste, "created.map");
        }
Ejemplo n.º 2
0
        void network_OnTextRecieved(string input, byte[] byteInput, System.Net.Sockets.Socket client)
        {
            Translator tr = new Translator();
            Command com = tr.getCommand(byteInput);

            if (com.command == "response")
            {
                int UID = (int)com.Arguments[0];
                response.Add(UID, com);
            }
        }
Ejemplo n.º 3
0
        public void load(string filename)
        {
            if (File.Exists(filename))
            {
                Translator tr = new Translator();
                List<ClassContainer> list = tr.readData(filename);

                if (list.Count > 0)
                {
                    ClassContainer container = list[0];

                    if (container.type == ClassType.Map)
                    {
                        Map map = (Map)container.objekt;

                        setMap(map);

                    }
                }
                if (list.Count > 1)
                {
                    ClassContainer container = list[1];

                    if (container.objekt is List<Route>)
                    {
                        List<Route> routelist = (List<Route>)container.objekt;

                    }

                }

                handleData();

            }
            else
            {
                throw new GameException("Datei exsistiert nicht");
            }
        }
Ejemplo n.º 4
0
        public void TCP_TextRecieved(string input, byte[] byteInput, System.Net.Sockets.TcpClient client)
        {
            Translator tr = new Translator();
            Command com = tr.getCommand(byteInput);

            string arguments = "";
            foreach (Object ob in com.Arguments)
            {
                arguments += ob.ToString() + ", ";
            }

            log("Command Recieved: " + com.command + " (" + arguments + ")");

            if (com.command == "response")
            {
                int UID = (int)com.Arguments[0];
                response.Add(UID, com);
            }
            else
            {
                Command response = handleRequest(com, client);

                network.TCP_SendByteStream(tr.writeCommand(response), client);
            }
        }
Ejemplo n.º 5
0
        public void save(string filename)
        {
            Translator tr = new Translator();
            ClassContainer container = new ClassContainer();
            container.type = ClassType.Main;
            container.objekt = this;
            List<ClassContainer> list = new List<ClassContainer>();
            list.Add(container);

            tr.writeData(list, filename);
        }
Ejemplo n.º 6
0
        public void loaded()
        {
            config = new Data.Config("Config/config.xml");
            response = new Dictionary<int, Command>();
            userClientList = new Dictionary<User, System.Net.Sockets.TcpClient>();
            tr = new Translator();

            int serverPort = int.Parse(config["TCP/port"]);
            network = new TCP(serverPort, "GamePW");
            network.OnTextRecieved += new TCP.TextRecievedEvent(TCP_TextRecieved);
            network.OnClientConnected += new TCP.ClientConnectedEvent(TCP_ClientConnected);
            network.OnError += new TCP.TCPErrorEvent(TCP_Error);
            network.OnClientDisconnected += new TCP.ClientDisconnectedEvent(TCP_ClientDisconnected);

            printStatistics();

            log("Server bereit für Anfragen ...");
        }
Ejemplo n.º 7
0
        private void speichernToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog save = new SaveFileDialog();
                save.Filter = "Map-File | *.map";
                if (save.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    Translator tr = new Translator();
                    List<ClassContainer> list = new List<ClassContainer>();
                    Map map = new Map();
                    map.solarsystems = solarsystemMap;
                    map.randomArea = randomArea;

                    map.systemcount = int.Parse(Systemcount.Text);
                    map.min_distance = int.Parse(Min_distance.Text);

                    ClassContainer container = new ClassContainer();
                    container.objekt = map;
                    container.type = ClassType.Map;
                    list.Add(container);

                    tr.writeData(list, save.FileName);

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Fehler: " + ex.Message);
            }
        }
Ejemplo n.º 8
0
        private void ladenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Map-File | *.map";
            if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Translator tr = new Translator();
                List<ClassContainer> list = tr.readData(open.FileName);

                ClassContainer container = list[0];
                try
                {
                    Map map = (Map)container.objekt;

                    loadMap(map);

                }
                catch
                {
                    MessageBox.Show("Fehler beim Parsen der Map-Datei");
                }

            }
        }