Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 2
0
        public static ObservableCollection <WeaponModel> getWeaponModels(ThreadingObservableCollection <WeaponModel> ret, ThreadingObservableCollection <Country> countries, ThreadingObservableCollection <WeaponCategory> categories, ThreadingObservableCollection <Technology> technologies)
        {
            //ObservableCollection<WeaponModel> ret = new ObservableCollection<WeaponModel>();
            GlobalInfos global    = GlobalInfos.getInstance();
            TextFile    modelFile = global.getPath(@"localisation\models.csv");

            if (modelFile == null)
            {
                return(null);
            }
            string[] modelLines = modelFile.Lines;
            for (int i = 1; i < modelLines.Length; i++)
            {
                string line = modelLines[i];
                if (line.StartsWith("#"))
                {
                    continue;
                }
                WeaponModel model     = new WeaponModel(line);
                string[]    nameparts = model.Shortcut.Split('_');
                model.Country = countries.First(x => x.Shortcut == nameparts[0]);
                string Weapontyp = "";
                for (int j = 1; j < nameparts.Length - 1; j++)
                {
                    Weapontyp += nameparts[j];
                    if (j != nameparts.Length - 2)
                    {
                        Weapontyp += "_";
                    }
                }
                model.Stage = nameparts[nameparts.Length - 1];
                if (categories.Any(x => x.Shortcut == Weapontyp))
                {
                    model.WeaponCategory = categories.First(x => x.Shortcut == Weapontyp);
                    ret.Add(model);
                }
            }
            foreach (Country c in countries)
            {
                readNeededSkills(WeaponCategory.typ.air, c, ret, technologies);
                readNeededSkills(WeaponCategory.typ.land, c, ret, technologies);
                readNeededSkills(WeaponCategory.typ.naval, c, ret, technologies);
            }
            return(ret);
        }
Exemplo n.º 3
0
        public static ObservableCollection <Country> getCountries(ThreadingObservableCollection <Country> ret)
        {
            GlobalInfos global      = GlobalInfos.getInstance();
            TextFile    countryFile = global.getPath(@"\localisation\countries.csv");

            if (countryFile == null)
            {
                return(null);
            }
            //ObservableCollection<Country> ret = new ObservableCollection<Country>();
            var countryLines = countryFile.Lines.Where(x => !x.StartsWith("#"));

            for (int i = 1; i < countryLines.Count(); i++)
            {
                Country c = new Country(countryLines.ElementAt(i));
                ret.Add(c);
            }
            return(ret);
        }
Exemplo n.º 4
0
        public static ObservableCollection <Technologyname> getTechnologynames(ThreadingObservableCollection <Technologyname> ret, ThreadingObservableCollection <Country> countries, ThreadingObservableCollection <Technology> technologies)
        {
            //ObservableCollection<Technologyname> ret = new ObservableCollection<Technologyname>();
            GlobalInfos global       = GlobalInfos.getInstance();
            bool        isstart      = true;
            TextFile    technameFile = global.getPath(@"\localisation\technology.csv");

            if (technameFile == null)
            {
                return(null);
            }
            string[] technameLines = technameFile.Lines;
            //for (int i = 0; i < technameLines.Length; i++) {
            //    string line = technameLines[i];
            foreach (string line in technameLines)
            {
                string[] lineparts = line.Split(';');
                if (isstart)
                {
                    if (lineparts[0] == "# Tech Names")
                    {
                        isstart = false;
                    }
                }
                else
                {
                    if (lineparts[0] == "# Building Names")
                    {
                        break;
                    }
                    else
                    {
                        if (line.StartsWith("#"))
                        {
                            continue;
                        }
                        Technologyname t         = new Technologyname(line);
                        string[]       nameparts = t.Shortcut.Split('_');
                        if (!countries.Any(x => x.Shortcut == nameparts[0]))
                        {
                            continue;
                        }
                        t.Country = countries.First(x => x.Shortcut == nameparts[0]);
                        string Technology = "";
                        for (int j = 1; j < nameparts.Length - 1; j++)
                        {
                            Technology += nameparts[j];
                            if (j != nameparts.Length - 2)
                            {
                                Technology += "_";
                            }
                        }
                        if (!technologies.Any(x => x.Shortcut == Technology))
                        {
                            continue;
                        }
                        t.Technology = technologies.First(x => x.Shortcut == Technology);
                        t.Stage      = (nameparts[nameparts.Length - 1]);
                        ret.Add(t);
                    }
                }
            }
            return(ret);
        }
Exemplo n.º 5
0
        public static ObservableCollection <Technology> getTechnologies(ThreadingObservableCollection <Technology> ret, ThreadingObservableCollection <WeaponCategory> weaponCategories)
        {
            GlobalInfos global   = GlobalInfos.getInstance();
            TextFile    techFile = global.getPath(@"\localisation\technology.csv");

            if (techFile == null)
            {
                return(null);
            }
            bool   isstart = true;
            string typ     = "";

            //ObservableCollection<Technology> ret = new ObservableCollection<Technology>();
            string[] techLines   = techFile.Lines;
            Regex    infantryReg = new Regex("Infantry Techs");
            Regex    descReg     = new Regex("_desc");

            for (int i = 0; i < techLines.Length; i++)
            {
                string   line      = techLines[i];
                string[] lineparts = line.Split(';');
                if (isstart)
                {
                    if (infantryReg.IsMatch(lineparts[0]))
                    {
                        isstart = false;
                        typ     = "_Infantry Technologies.txt";
                    }
                }
                else if (!line.StartsWith("#") && i != 0)
                {
                    if (!descReg.IsMatch(lineparts[0]))
                    {
                        Technology tech = new Technology(line);
                        tech.Typ = typ;
                        findTyps_new(tech, weaponCategories);
                        ret.Add(tech);
                    }
                }
                else
                {
                    string typline = lineparts[0].Split('#')[1].Trim();
                    switch (typline)
                    {
                    case "Artillery Techs":
                        typ = "ArtilleryTechnologies.txt";
                        break;

                    case "Tech Names":
                        i = techLines.Length;
                        break;

                    case "Naval Techs":
                        typ = "Naval Technologies.txt";
                        break;

                    case "Armour Techs":
                        typ = "Armour Technologies.txt";
                        break;

                    case "Aircraft Techs":
                        typ = "Aircraft Technology.txt";
                        break;

                    case "Industry Techs":
                        typ = "_Industry Technologies.txt";
                        break;

                    case "Secret Weapons":
                        typ = "Secret Weapons.txt";
                        break;

                    case "Theoretical Research":
                        typ = "Theories.txt";
                        break;

                    case "Land Doctrine Techs":
                        typ = "Land Doctrines.txt";
                        break;

                    case "Naval Doctrine Techs":
                        typ = "Naval Doctrines.txt";
                        break;

                    case "Air Doctrine Techs":
                        typ = "Aircraftz Doctrines.txt";
                        break;
                    }
                }
            }
            return(ret);
        }