Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
0
        private static void readNeededSkills(WeaponCategory.typ typ, Country country, ThreadingObservableCollection <WeaponModel> weaponModels, ThreadingObservableCollection <Technology> technologies)
        {
            GlobalInfos global   = GlobalInfos.getInstance();
            string      filename = @"units\models\" + country.Shortcut + " - ";

            switch (typ)
            {
            case WeaponCategory.typ.air:
                filename += "Planes.txt";
                break;

            case WeaponCategory.typ.land:
                filename += "Arm.txt";
                break;

            case WeaponCategory.typ.naval:
                filename += "Ships.txt";
                break;
            }
            TextFile file = global.getPath(filename);

            if (file == null)
            {
                return;
            }
            string[]     lines     = file.Lines;
            WeaponModel  m         = null;
            List <Skill> skillList = new List <Skill>();

            foreach (string line in lines)
            {
                string[] splittedLine = line.Split('=');
                if (splittedLine.Length > 1)
                {
                    if (line.IndexOf('{') != -1)
                    {
                        string modelDesc = splittedLine[0].Trim();
                        if (weaponModels.Any(x => x.Country.Shortcut == country.Shortcut && x.WeaponCategory.Shortcut + "." + x.Stage == modelDesc))
                        {
                            m = weaponModels.First(x => x.Country.Shortcut == country.Shortcut && x.WeaponCategory.Shortcut + "." + x.Stage == modelDesc);
                        }
                        continue;
                    }
                    if (m == null)
                    {
                        continue;
                    }
                    string techShortcut = splittedLine[0].Trim();
                    if (technologies.Any(x => x.Shortcut == techShortcut))
                    {
                        Skill s = new Skill();
                        s.Stage      = splittedLine[1].Trim();
                        s.Technology = technologies.First(x => x.Shortcut == techShortcut);
                        skillList.Add(s);
                    }
                }
                if (line.IndexOf('}') != -1)
                {
                    if (m != null)
                    {
                        m.refreshSkillList(skillList);
                    }
                    m = null;
                    skillList.Clear();
                    continue;
                }
            }
        }