Пример #1
0
        public override void Populate()
        {
            var txtFileLines = File.ReadAllLines(Install.GetPath("roof.txt"));
            var typeNames = txtFileLines[1].Split(Separators);
            TileCategory category = null;
            for (int i = 2; i < txtFileLines.Length; i++)
            {
                var infos = txtFileLines[i].Split('\t');

                if (infos[1] == "0")
                {
                    category = new TileCategory(Int32.Parse(infos[2]));
                    category.Name = infos.Last();
                    Categories.Add(category);
                }
                var style = new TileStyle();
                category.AddStyle(style);
                style.Name = infos.Last();
                style.Index = Int32.Parse(infos[1]);
                for (int j = 3; j < typeNames.Length - 2; j++)
                {
                    if (infos[j] != "0")
                    {
                        var tile = new TileRoof { Id = short.Parse(infos[j]) };
                        style.AddTile(tile);
                       tile.ChangeRoofPosition(j-2);
                    }
                }
                
            }
        }
Пример #2
0
        public override void Populate()
        {
            var txtFileLines = File.ReadAllLines(Install.GetPath("doors.txt"));
            var typeNames = txtFileLines[1].Split(Separators);

            for (int i = 2; i < txtFileLines.Length; i++)
            {
                var infos = txtFileLines[i].Split('\t');
                var category = new TileCategory();
                category.Name = infos.Last();

                var style = new TileStyle();
                category.AddStyle(style);

                for (int j = 1; j < typeNames.Length - 2; j++)
                {
                    if (infos[j] != "0")
                    {
                        var tile = new TileDoor { Id = short.Parse(infos[j]) };
                        style.Tiles.Add(tile);
                    }
                }
                Categories.Add(category);

            }
            TilesCategorySDKModule.Supp.PositionCheck(Categories);
        }
Пример #3
0
 public void SubstitueWallCat(TileCategory InWalls, TileCategory OutWalls)
 {
     _multi.SubStitueWallCat(InWalls,OutWalls);
 }
Пример #4
0
 public void SetCategory(TileCategory category)
 {
     _myCategory = category;
 }
Пример #5
0
 public void SetCategory(TileCategory category)
 {
     _myCategory = category;
 }
        public void Populate()
        {
            if(CheckFromTxt)
            {
                foreach (var factory in Factories)
                {

                    factory.Populate();
                }
            }
            foreach (var fact in Factories)
            {
                Categories.Add(fact.Categories);
            }


            var walls = TileData.ItemTable.Where(itemData => itemData.Flags.HasFlag(TileFlag.Wall) && itemData.Height == 20 && !itemData.Name.Contains("arc")&&!itemData.Flags.HasFlag(TileFlag.Window)&& !itemData.Flags.HasFlag(TileFlag.Door)).ToList();
            var windows = TileData.ItemTable.Where(itemData => itemData.Flags.HasFlag(TileFlag.Wall) && itemData.Height == 20 && itemData.Flags.HasFlag(TileFlag.Window)).ToList();
            var halfWalls = TileData.ItemTable.Where(itemData => itemData.Flags.HasFlag(TileFlag.Wall) && itemData.Height == 10 && !itemData.Flags.HasFlag(TileFlag.Window)).ToList();
            var quarterWalls = TileData.ItemTable.Where(itemData => itemData.Flags.HasFlag(TileFlag.Wall) && itemData.Height == 5 && !itemData.Flags.HasFlag(TileFlag.Window)).ToList();
            var archs = TileData.ItemTable.Where(itemData => itemData.Flags.HasFlag(TileFlag.Wall) && itemData.Name.Contains("arc")).ToList();
            var roof = TileData.ItemTable.Where(itemData => itemData.Flags.HasFlag(TileFlag.Roof)).ToList();
            
            var wallCategory = new TileCategory(){Name = "wall"};
            var windowCategory = new TileCategory() {Name = "window"};
            var halfCategory = new TileCategory() {Name = "half"};
            var quarterCategory = new TileCategory() {Name = "quarter"};
            var arcsCategory = new TileCategory() { Name = "arch" };
            var roofCategory = new TileCategory() {Name = "roof"};

            var style = new TileStyle();
            
            var lists = Misc.Categories.Union(Walls.Categories).ToList();
            
            if(!CheckFromTxt)
                lists.Clear();

            var listcat = new List<TileCategory>();

            
            FullEmptyCategoriesTxTChecked(lists, walls, wallCategory);
            FullEmptyCategoriesTxTChecked(lists, quarterWalls, quarterCategory);
            FullEmptyCategoriesTxTChecked(lists, halfWalls, halfCategory);
            FullEmptyCategoriesTxTChecked(lists, windows, windowCategory);
            FullEmptyCategoriesTxTChecked(lists, archs, arcsCategory);
            FullEmptyCategoriesTxTChecked(lists,roof,roofCategory);
            
            foreach (var s in wallCategory.Styles)
            {
                var category = new TileCategory() {Name = s.Name};
                category.AddStyle(s);
                
                var half = Selector(halfCategory, s);
                var quarter = Selector(quarterCategory, s);
                var window = Selector(windowCategory, s);
                var arch = Selector(arcsCategory, s);
                var r = Selector(roofCategory, s);
                
                if(half!= null)
                    category.AddStyle(half);
                if(quarter != null)
                    category.AddStyle(quarter);
                if(window!=null)
                    category.AddStyle(window);
                if(arch!=null)
                    category.AddStyle(arch);
                if(r!=null)
                    category.AddStyle(r);
               
                listcat.Add(category);
                }

            listcat.Add(RemoveDuplicates(listcat,windowCategory));
            listcat.Add(RemoveDuplicates(listcat, roofCategory));
            listcat.Add(RemoveDuplicates(listcat, halfCategory));
            listcat.Add(RemoveDuplicates(listcat, quarterCategory));
            listcat.Add(RemoveDuplicates(listcat, arcsCategory));
            
            Categories.Add(listcat);
        }
        private TileCategory RemoveDuplicates(List<TileCategory> listcat,TileCategory cat )
        {
            var styles = StylesSelector(listcat, cat);

            foreach (TileStyle tileStyle in styles)
            {
                cat.Styles.Remove(tileStyle);
            }
            return cat;
        }
 private List<TileStyle> StylesSelector(List<TileCategory> listcat,TileCategory category )
 {
     return (from cat in listcat
             from s in category.Styles
             where cat.FindStyleByName(s.Name) != null
             select s).ToList();
 }
 private TileStyle Selector (TileCategory tileCategory, TileStyle s)
 {
     var style = from sh in tileCategory.Styles
                where sh.Name.Split(separator, StringSplitOptions.RemoveEmptyEntries).Last() == s.Name.Split(separator, StringSplitOptions.RemoveEmptyEntries).Last()
                select sh;
     return style.FirstOrDefault();
 }
        private void FullEmptyCategoriesTxTChecked(IEnumerable<TileCategory> list, IEnumerable<ItemData> datalist, TileCategory tileCategory)
        {
            var style = new TileStyle();
            foreach (ItemData itemData in datalist)
            {
                Tile tile = null;
                int number = itemData.Id;
                
                var tiles = from cat in list
                            let t = cat.FindTile(number)
                            where t != null
                            select t;
                tile = tiles.FirstOrDefault();
                if (tile == null)
                {
                    string name = string.Format("{0}-{1}", tileCategory.Name,
                                                    itemData.Name.Replace(tileCategory.Name, "").Split(separator2,
                                                                                                       StringSplitOptions
                                                                                                           .
                                                                                                           RemoveEmptyEntries)
                                                        .FirstOrDefault());
                   
                    if (string.IsNullOrEmpty(style.Name) || style.Name != name)
                    {
                        if (style.Tiles.Count > 0 && tileCategory.FindStyleByName(style.Name) == null)
                        {
                           tileCategory.AddStyle(style);
                        }

                        
                        var st2 = tileCategory.FindStyleByName(name);
                        if (st2 == null) style = new TileStyle {Name = name};
                        else style = st2;
                    }
                    style.AddTile(new Tile() {Id = number, Name = itemData.Name});
                }
            }
            tileCategory.AddStyle(style);
        }