コード例 #1
0
        public void ReadEnemy(string path)
        {
            try
            {
                XDocument xDoc = XDocument.Load(path);
                foreach (XElement enem in xDoc.Root.Elements())
                {
                    EnemyComp x_enemy = new EnemyComp();
                    x_enemy.id   = enem.Attribute("id").Value;
                    x_enemy.Addr = enem.Attribute("address").Value;
                    RePoint r = new RePoint();
                    x_enemy.Position  = r.Point(float.Parse(enem.Element("position").Attribute("x").Value), float.Parse(enem.Element("position").Attribute("y").Value));
                    x_enemy.isScaning = bool.Parse(enem.Element("isscan").Value);
                    x_enemy.isVisible = bool.Parse(enem.Element("isvisible").Value);
                    x_enemy.Money     = int.Parse(enem.Element("money").Value);
                    foreach (XElement sx in enem.Element("services").Elements("service"))
                    {
                        ServiceX service = new ServiceX(int.Parse(sx.Element("timestart").Value), int.Parse(sx.Element("port").Value));
                        service.id   = sx.Attribute("id").Value;
                        service.Desc = sx.Element("name").Value;
                        switch (sx.Element("type").Value)
                        {
                        case "NONE": service.Type = TypeServiceX.NONE;
                            break;

                        case "FTP": service.Type = TypeServiceX.FTP;
                            break;

                        case "FIREWALL": service.Type = TypeServiceX.FIREWALL;
                            break;

                        case "ATM": service.Type = TypeServiceX.ATM;
                            break;

                        case "PROXY": service.Type = TypeServiceX.PROXY;
                            break;

                        case "SSH": service.Type = TypeServiceX.SSH;
                            break;

                        default: service.Type = TypeServiceX.NONE;
                            break;
                        }
                        service.Pass       = sx.Element("pass").Value;
                        service.isHackPass = bool.Parse(sx.Element("ishackpass").Value);
                        foreach (XElement fx in sx.Element("files").Elements("file"))
                        {
                            FileX file = null;
                            switch (fx.Attribute("type").Value)
                            {
                            case "TXT": file = new FileTxtX();
                                break;

                            case "SCRIPT": file = new FileScriptX();
                                break;

                            case "EXPLOIT": file = new FileExploitX();
                                break;

                            case "DATA": file = new FileDataX();
                                break;

                            case "SSHKEY": file = new FileSSHKeyX();
                                break;

                            default: file = new FileX();
                                break;
                            }
                            file.id       = fx.Attribute("id").Value;
                            file.Capacity = int.Parse(fx.Attribute("capacity").Value);
                            file.Name     = fx.Attribute("name").Value;
                            file.AddText(fx.Value);
                            service.AddFile(file);
                        }
                        x_enemy.AddService(service);
                    }
                    X_Enemies.Add(x_enemy);
                }
            }
            catch (Exception ex) { LOG.Error("ERROR LOAD comp.xml: {" + ex.Message + "}"); }
        }
コード例 #2
0
        public void ReadEvent(string path)
        {
            XDocument  xDoc = XDocument.Load(path);
            GameScript game = new GameScript();

            foreach (XElement ev in xDoc.Root.Elements("outs"))
            {
                EventGame Event = new EventGame(TypeInEventX.None, TypeOutEventX.None);
                foreach (XElement file in ev.Element("files").Elements("file"))
                {
                    FileX f = null;
                    switch (file.Attribute("type").Value)
                    {
                    case "TXT": f = new FileTxtX();
                        break;

                    case "SCRIPT": f = new FileScriptX();
                        break;

                    case "EXPLOIT": f = new FileExploitX();
                        break;

                    case "DATA": f = new FileDataX();
                        break;

                    case "SSHKEY": f = new FileSSHKeyX();
                        break;

                    default: f = new FileX();
                        break;
                    }
                    f.id       = file.Attribute("id").Value;
                    f.Capacity = int.Parse(file.Attribute("capacity").Value);
                    f.Name     = file.Attribute("name").Value;
                    f.AddText(file.Value);
                    Ev_File.Add(f);
                }
                foreach (XElement enem in ev.Element("enemies").Elements("enemy"))
                {
                    EnemyComp x_enemy = new EnemyComp();
                    x_enemy.id   = enem.Attribute("id").Value;
                    x_enemy.Addr = enem.Attribute("address").Value;
                    RePoint r = new RePoint();
                    x_enemy.Position  = r.Point(float.Parse(enem.Element("position").Attribute("x").Value), float.Parse(enem.Element("position").Attribute("y").Value));
                    x_enemy.isScaning = bool.Parse(enem.Element("isscan").Value);
                    x_enemy.isVisible = bool.Parse(enem.Element("isvisible").Value);
                    x_enemy.Money     = int.Parse(enem.Element("money").Value);
                    foreach (XElement sx in enem.Element("services").Elements("service"))
                    {
                        ServiceX service = new ServiceX(int.Parse(sx.Element("timestart").Value), int.Parse(sx.Element("port").Value));
                        service.id   = sx.Attribute("id").Value;
                        service.Desc = sx.Element("name").Value;
                        switch (sx.Element("type").Value)
                        {
                        case "NONE": service.Type = TypeServiceX.NONE;
                            break;

                        case "FTP": service.Type = TypeServiceX.FTP;
                            break;

                        case "FIREWALL": service.Type = TypeServiceX.FIREWALL;
                            break;

                        case "ATM": service.Type = TypeServiceX.ATM;
                            break;

                        case "PROXY": service.Type = TypeServiceX.PROXY;
                            break;

                        case "SSH": service.Type = TypeServiceX.SSH;
                            break;

                        default: service.Type = TypeServiceX.NONE;
                            break;
                        }
                        service.Pass       = sx.Element("pass").Value;
                        service.isHackPass = bool.Parse(sx.Element("ishackpass").Value);
                        foreach (XElement fx in sx.Element("files").Elements("file"))
                        {
                            FileX file = null;
                            switch (fx.Attribute("type").Value)
                            {
                            case "TXT": file = new FileTxtX();
                                break;

                            case "SCRIPT": file = new FileScriptX();
                                break;

                            case "EXPLOIT": file = new FileExploitX();
                                break;

                            case "DATA": file = new FileDataX();
                                break;

                            case "SSHKEY": file = new FileSSHKeyX();
                                break;

                            default: file = new FileX();
                                break;
                            }
                            file.id       = fx.Attribute("id").Value;
                            file.Capacity = int.Parse(fx.Attribute("capacity").Value);
                            file.Name     = fx.Attribute("name").Value;
                            file.AddText(fx.Value);
                            service.AddFile(file);
                        }
                        x_enemy.AddService(service);
                    }
                    Ev_Enemy.Add(x_enemy);
                }
                foreach (XElement m in ev.Element("mails").Elements("mail"))
                {
                    MailX mail = new MailX(m.Attribute("name").Value);
                    mail.ids = m.Attribute("id").Value;
                    mail.AddText(m.Value);
                    Ev_Mail.Add(mail);
                }
                foreach (XElement w in ev.Element("wanteds").Elements("wanted"))
                {
                    Ev_Wanted.Add(new E_Wanted(w.Attribute("id").Value, int.Parse(w.Value)));
                }
                foreach (XElement even in xDoc.Root.Element("ev").Elements("event"))
                {
                    TypeInEventX t_in    = TypeInEventX.None;
                    object       obj_inn = null;
                    switch (even.Element("in").Attribute("type").Value)
                    {
                    case "E_Scan":
                    {
                        t_in    = TypeInEventX.E_Scan;
                        obj_inn = FindEnemyId(even.Element("in").Element("enemy").Value);
                        break;
                    }

                    case "E_Crack":
                    {
                        t_in    = TypeInEventX.E_Crack;
                        obj_inn = FindEnemyId(even.Element("in").Element("enemy").Value);
                        break;
                    }

                    case "Time":
                    {
                        t_in    = TypeInEventX.Time;
                        obj_inn = int.Parse(even.Element("in").Element("time").Value);
                        break;
                    }

                    case "File":
                    {
                        t_in    = TypeInEventX.File;
                        obj_inn = FindFileId(even.Element("in").Element("file").Value);
                        break;
                    }

                    case "Wanted":
                    {
                        t_in    = TypeInEventX.Wanted;
                        obj_inn = int.Parse(even.Element("in").Element("wanted").Value);
                        break;
                    }

                    case "Connected":
                    {
                        t_in    = TypeInEventX.Connected;
                        obj_inn = FindEnemyId(even.Element("in").Element("enemy").Value);
                        break;
                    }

                    case "Service_off":
                    {
                        t_in    = TypeInEventX.Service_off;
                        obj_inn = FindServiceId(even.Element("in").Element("service").Value);
                        break;
                    }

                    default: t_in = TypeInEventX.None;
                        break;
                    }
                    object        obj_out = null;
                    TypeOutEventX t_out   = TypeOutEventX.None;
                    obj_out = FindEventOut(even.Element("out").Attribute("id").Value, out t_out);
                    X_Event.Add(game.AddEvent(t_in, t_out, obj_inn, obj_out));
                }
            }
        }