Пример #1
0
        public static void /*ObservableCollection<WeaponCategory>*/ getWeaponCategories(ThreadingObservableCollection <WeaponCategory> ret)
        {
            //ObservableCollection<WeaponCategory> ret = new ObservableCollection<WeaponCategory>();
            bool        unitNames = false;
            GlobalInfos global    = GlobalInfos.getInstance();
            TextFile    unitFile  = global.getPath(@"\localisation\units.csv");

            if (unitFile == null)
            {
                return;
            }
            string[] typParts;// = line.Split(';');
            string[] unitLines = unitFile.Lines;
            for (int i = 0; i < unitLines.Length; i++)
            {
                string line = unitLines[i];
                if (!line.StartsWith("#") && unitNames)
                {
                    //if (!lineparts[0].EndsWith("short")) {
                    WeaponCategory c       = new WeaponCategory(line);
                    string         name    = c.Shortcut;
                    TextFile       typFile = global.getPath(@"units\" + name + ".txt");
                    if (typFile == null)
                    {
                        typFile = global.getPath(@"units\" + name.Split('_')[0] + ".txt");
                    }
                    //if (typFile == null) {
                    //    string[] typpart = name.Split('_');
                    //    typFile = global.getPath(@"units\" + typpart[0] + "_" + typpart[1] + ".txt");
                    //}
                    if (typFile == null)
                    {
                        continue;
                    }
                    string[] typLines = typFile.Lines;
                    Regex    r;
                    foreach (string typLine in typLines)
                    {
                        r = new Regex("type");
                        if (r.IsMatch(typLine))
                        {
                            typParts = typLine.Split('=');
                            c.setTyp(typParts[1].Trim());
                            break;
                        }
                    }
                    ret.Add(c);
                    //}
                }
                else if (line.StartsWith("# Unit Names"))
                {
                    unitNames = true;
                    i++;
                }
                else if (unitNames)
                {
                    break;
                }
            }
        }
Пример #2
0
 public void tasks()
 {
     /*Countries = */ Country.getCountries(Countries);
     WeaponCategory.getWeaponCategories(Categories);
     /*Technologies = */ Technology.getTechnologies(Technologies, Categories);
     /*Technologynames = */ Technologyname.getTechnologynames(Technologynames, Countries, Technologies);
     /*Models = */ WeaponModel.getWeaponModels(Models, Countries, Categories, Technologies);
     Models.Add(new WeaponModel());
     System.Diagnostics.Debug.WriteLine("Fertig");
 }
Пример #3
0
        private static void findTyps_new(Technology t, ObservableCollection <WeaponCategory> weaponCategories)
        {
            GlobalInfos global  = GlobalInfos.getInstance();
            TextFile    typFile = global.getPath(@"technologies\" + t.Typ);

            if (typFile == null)
            {
                return;
            }
            int           breckets   = -1;
            string        aktTech    = "";
            List <string> List_Lines = new List <string>();

            string[] typLines = typFile.Lines;
            for (int i = 0; i < typLines.Length; i++)
            {
                string line = typLines[i];
                Regex  r    = new Regex("\\b" + t.Shortcut + "( |=)");
                if (!r.IsMatch(line))
                {
                    continue;
                }
                aktTech = t.Shortcut;
                while (breckets != 0)
                {
                    if (line != "" && line != "\t" && line != "\t\t")
                    {
                        if (line.IndexOf('{') != -1)
                        {
                            if (breckets != -1)
                            {
                                breckets++;
                            }
                            else
                            {
                                breckets = 1;
                            }
                        }
                        if (line.IndexOf('}') != -1 && aktTech != "")
                        {
                            breckets--;
                        }
                        List_Lines.Add(line.Split('=')[0].Trim());
                    }
                    i++;
                    if (i < typLines.Length)
                    {
                        line = typLines[i];
                    }
                }
                if (List_Lines.Count > 0)
                {
                    break;
                }
            }
            int  tmpBreckets = 0;
            bool allow       = false;

            foreach (string line in List_Lines)
            {
                if (line.IndexOf('{') != -1)
                {
                    if (breckets != -1)
                    {
                        breckets++;
                    }
                    else
                    {
                        breckets = 1;
                    }
                }
                if (line.IndexOf('}') != -1)
                {
                    breckets--;
                }
                if (!allow)
                {
                    Regex r = new Regex("additional_offset");
                    if (r.IsMatch(line))
                    {
                        t.OnceTech = false;
                    }
                    else
                    {
                        r = new Regex("allow = {");
                        if (r.IsMatch(line))
                        {
                            allow       = true;
                            tmpBreckets = breckets;
                        }
                        else if (weaponCategories.Any(x => x.Shortcut == line))
                        {
                            WeaponCategory wt = weaponCategories.First(x => x.Shortcut == line);
                            wt.ListTechnologies.Add(t);
                            t.WeaponCategories.Add(wt);
                        }
                    }
                }
                if (tmpBreckets == breckets)
                {
                    allow = false;
                }
            }
        }