Example #1
0
        public override void Populate()
        {
            var txtFileLines = File.ReadAllLines(DataManager.Location.LocalPath + "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 = uint.Parse(infos[j]) };
                        style.List.Add(tile);
                    }
                }
                Categories.Add(category);

            }
            TilesCategorySDKModule.Supp.PositionCheck(Categories);
        }
        private void FullEmptyCategoriesTxTChecked(IEnumerable<TileCategory> list, IEnumerable<ModelItemData> datalist, TileCategory tileCategory)
        {
            var style = new TileStyle();
            foreach (var itemData in datalist)
            {
                Tile tile;
                uint number = itemData.EntryId;

                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.List.Count > 0 && tileCategory.FindStyleByName(style.Name) == null)
                        {
                            tileCategory.AddStyle(style);
                        }


                        var st2 = tileCategory.FindStyleByName(name);
                        style = st2 ?? new TileStyle { Name = name };
                    }
                    switch (tileCategory.TypeTile)
                    {
                        case TypeTile.Wall:
                            {
                                style.AddTile(new TileWall() { Id = number, Name = itemData.Name });
                                break;
                            }
                        case TypeTile.Roofs:
                            {
                                style.AddTile(new TileRoof() { Id = number, Name = itemData.Name });
                                break;
                            }
                        case TypeTile.Floor:
                            {
                                style.AddTile(new TileFloor() { Id = number, Name = itemData.Name });
                                break;
                            }
                        default:
                            {
                                style.AddTile(new Tile { Id = number, Name = itemData.Name });
                                break;
                            }
                    }

                }
            }
            tileCategory.AddStyle(style);
        }
        public void Populate()
        {
            if(CheckFromTxt)
            {
                foreach (var factory in Factories)
                {

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


            var walls = DataManager.GetItemTile().Where(itemData => itemData.Flags.HasFlag(TileFlag.Wall) && itemData.Height >= 15 && !itemData.Name.Contains("arc")&&!itemData.Flags.HasFlag(TileFlag.Window)&& !itemData.Flags.HasFlag(TileFlag.Door)).ToList();
            var windows = DataManager.GetItemTile().Where(itemData => itemData.Flags.HasFlag(TileFlag.Wall) && itemData.Height >= 15 && itemData.Flags.HasFlag(TileFlag.Window)).ToList();
            var halfWalls = DataManager.GetItemTile().Where(itemData => itemData.Flags.HasFlag(TileFlag.Wall) && itemData.Height >= 10 && itemData.Height <15 && !itemData.Flags.HasFlag(TileFlag.Window)).ToList();
            var quarterWalls = DataManager.GetItemTile().Where(itemData => itemData.Flags.HasFlag(TileFlag.Wall) && itemData.Height >= 5  && itemData.Height <10 && !itemData.Flags.HasFlag(TileFlag.Window)).ToList();
            var archs = DataManager.GetItemTile().Where(itemData => itemData.Flags.HasFlag(TileFlag.Wall) && itemData.Name.Contains("arc")).ToList();
            var roof = DataManager.GetItemTile().Where(itemData => itemData.Flags.HasFlag(TileFlag.Roof)).ToList();
            var floors = DataManager.GetItemTile().Where(itemData => itemData.Flags.HasFlag(TileFlag.Surface)).ToList();

            var wallCategory = new TileCategory(){Name = "wall",TypeTile = TypeTile.Wall};
            var windowCategory = new TileCategory() {Name = "window", TypeTile = TypeTile.Wall};
            var halfCategory = new TileCategory() {Name = "half",TypeTile = TypeTile.Wall};
            var quarterCategory = new TileCategory() {Name = "quarter",TypeTile = TypeTile.Wall};
            var arcsCategory = new TileCategory() { Name = "arch" ,TypeTile = TypeTile.Wall};
            var roofCategory = new TileCategory() {Name = "roof",TypeTile = TypeTile.Roofs};
            var floorcategory = new TileCategory() {Name = "floor", TypeTile = TypeTile.Floor};

            var lists = Misc.Categories.Union(Walls.Categories).Union(Roofs.Categories).Union(Floors.Categories).ToList();
            
            if(!CheckFromTxt)
                lists.Clear();

            var listcat = new ObservableCollection<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);
            FullEmptyCategoriesTxTChecked(lists,floors,floorcategory);

            foreach (var s in wallCategory.List)
            {
                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);
        }