예제 #1
0
            public void VisitNextHouse(char direction)
            {
                House nextHouse = null;

                switch (direction)
                {
                case '^':
                    nextHouse = new House(CurrentHouse.X, CurrentHouse.Y + 1);
                    break;

                case 'v':
                    nextHouse = new House(CurrentHouse.X, CurrentHouse.Y - 1);
                    break;

                case '<':
                    nextHouse = new House(CurrentHouse.X - 1, CurrentHouse.Y);
                    break;

                case '>':
                    nextHouse = new House(CurrentHouse.X + 1, CurrentHouse.Y);
                    break;
                }

                if (!Houses.Any(h => h.X == nextHouse.X && h.Y == nextHouse.Y))
                {
                    Houses.Add(nextHouse);
                }

                CurrentHouse = nextHouse;
            }
        public void AddNewHouse(HousingAssociation association, double monthlyRent, double maximumAllowedMonthlyRent, double monthlyMaintenanceExpenses, double marketValue, double mutationProbability,
                                int lifeSpan, double sustainability)
        {
            var newHouse = new House(GetNewNumber(), association, monthlyRent, maximumAllowedMonthlyRent, monthlyMaintenanceExpenses, marketValue, mutationProbability, lifeSpan, sustainability);

            Houses.Add(newHouse);
        }
 public void Apply(Models.EphemerisResult ephemerisResult)
 {
     DateUTC               = ephemerisResult.DateUTC;
     JulianDay             = ephemerisResult.JulianDay;
     EphemerisTime         = ephemerisResult.EphemerisTime;
     SideralTime           = ephemerisResult.SideralTime;
     MeanEclipticObliquity = ephemerisResult.MeanEclipticObliquity;
     TrueEclipticObliquity = ephemerisResult.TrueEclipticObliquity;
     NutationLongitude     = ephemerisResult.NutationLongitude;
     NutationObliquity     = ephemerisResult.NutationObliquity;
     Planets.Clear();
     foreach (var p in ephemerisResult.Planets)
     {
         Planets.Add(p);
     }
     Houses.Clear();
     foreach (var h in ephemerisResult.Houses)
     {
         Houses.Add(h);
     }
     ASMCs.Clear();
     foreach (var h in ephemerisResult.ASMCs)
     {
         ASMCs.Add(h);
     }
 }
예제 #4
0
        async Task ExecuteLoadHousesCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Houses.Clear();
                var items = await DataStore.GetItemsAsync(true);

                foreach (var House in items)
                {
                    Houses.Add(House);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="worksheet"></param>
        public void AttachHouses(Worksheet worksheet)
        {
            Range wr = worksheet.Range["A1"].CurrentRegion;

            foreach (Range row in wr.Rows)
            {
                IntegraHouses newentity = new IntegraHouses();
                newentity.Attach(row);
                Houses.Add(newentity);
            }
        }
예제 #6
0
 void OnSelectedStreetChanged()
 {
     if (_selectedStreet != null)
     {
         var data = core.GetStreetHouses(SelectedStreet.Id);
         foreach (var item in data)
         {
             Houses.Add(item);
         }
     }
 }
예제 #7
0
        /// <summary>
        /// Monster Locations, Generators<para />
        /// This will be called from a separate task from our constructor. Use thread safety when interacting with this landblock.
        /// </summary>
        private void CreateWorldObjects()
        {
            var objects        = DatabaseManager.World.GetCachedInstancesByLandblock(Id.Landblock);
            var shardObjects   = DatabaseManager.Shard.GetStaticObjectsByLandblock(Id.Landblock);
            var factoryObjects = WorldObjectFactory.CreateNewWorldObjects(objects, shardObjects);

            actionQueue.EnqueueAction(new ActionEventDelegate(() =>
            {
                // for mansion linking
                var houses = new List <House>();

                foreach (var fo in factoryObjects)
                {
                    WorldObject parent = null;
                    if (fo.WeenieType == WeenieType.House)
                    {
                        var house = fo as House;
                        Houses.Add(house);

                        if (fo.HouseType == HouseType.Mansion)
                        {
                            houses.Add(house);
                            house.LinkedHouses.Add(houses[0]);

                            if (houses.Count > 1)
                            {
                                houses[0].LinkedHouses.Add(house);
                                parent = houses[0];
                            }
                        }
                    }

                    AddWorldObject(fo);
                    fo.ActivateLinks(objects, shardObjects, parent);

                    if (fo.PhysicsObj != null)
                    {
                        fo.PhysicsObj.Order = 0;
                    }
                }

                CreateWorldObjectsCompleted = true;

                _landblock.SortObjects();
            }));
        }
        private void LoadTestData()
        {
            House house = new House(Guid.NewGuid(), "г. Оренбург, ул. Чкалова, д. 32", "*****@*****.**", "admin");

            Person person = new Person(Guid.NewGuid(), "Данил", "Кушмухаметов", "*****@*****.**", "user", house);

            CreatePersonRequest request1 = new CreatePersonRequest(Guid.NewGuid(), "Пользователь", "1", "*****@*****.**", "user", house);
            CreatePersonRequest request2 = new CreatePersonRequest(Guid.NewGuid(), "Пользователь", "2", "*****@*****.**", "user", house);

            NewsPost newsPost1 = new NewsPost(Guid.NewGuid(), "В Оренбурге завершены поиски без вести пропавшего пенсионера",
                                              "О том, что Андрей Боженков найден, сообщили в ПСО «ОренСпас» со ссылкой на родственников.\n" +
                                              "Накануне, 12 июня, мужчина сам вернулся домой. С ним все в порядке. Жизни и здоровью пенсионера ничто не угрожает." +
                                              " В причинах его ухода из дома разбираются сотрудники полиции. Проводится проверка.",
                                              null, DateTime.UtcNow, house);
            NewsPost newsPost2 = new NewsPost(Guid.NewGuid(), "В Оренбурге завершены поиски без вести пропавшего пенсионера",
                                              "О том, что Андрей Боженков найден, сообщили в ПСО «ОренСпас» со ссылкой на родственников.\n" +
                                              "Накануне, 12 июня, мужчина сам вернулся домой. С ним все в порядке. Жизни и здоровью пенсионера ничто не угрожает." +
                                              " В причинах его ухода из дома разбираются сотрудники полиции. Проводится проверка.",
                                              null, DateTime.UtcNow, house);
            NewsPost newsPost3 = new NewsPost(Guid.NewGuid(), "В Оренбурге завершены поиски без вести пропавшего пенсионера",
                                              "О том, что Андрей Боженков найден, сообщили в ПСО «ОренСпас» со ссылкой на родственников.\n" +
                                              "Накануне, 12 июня, мужчина сам вернулся домой. С ним все в порядке. Жизни и здоровью пенсионера ничто не угрожает." +
                                              " В причинах его ухода из дома разбираются сотрудники полиции. Проводится проверка.",
                                              null, DateTime.UtcNow, house);

            Meeting meeting = new Meeting(Guid.NewGuid(), "Уборка прилегающей территории", DateTime.UtcNow.AddHours(5), "Описание мероприятия", null, house);

            Voting  voting   = new Voting(Guid.NewGuid(), "Голосование 1", house);
            Variant variant1 = new Variant(Guid.NewGuid(), "Первый вариант", voting);
            Variant variant2 = new Variant(Guid.NewGuid(), "Второй вариант", voting);
            Variant variant3 = new Variant(Guid.NewGuid(), "Третий вариант", voting);

            Houses.Add(house);
            People.Add(person);
            CreatePersonRequests.AddRange(new CreatePersonRequest[] { request1, request2 });
            News.AddRange(new NewsPost[] { newsPost1, newsPost2, newsPost3 });
            Meetings.Add(meeting);
            Votings.Add(voting);
            Variants.AddRange(new Variant[] { variant1, variant2, variant3 });

            SaveChanges();
        }
예제 #9
0
파일: City.cs 프로젝트: Eugene-El/MyCity
        private void CityGeneration(int peopleCount)
        {
            CityMap = new CityMap();

            RainEvent += CityMap.MakeRainnyMap;
            SunEvent  += CityMap.MakeSunnyMap;

            for (int i = 0; i < peopleCount; i++)
            {
                AddPerson(new Person(Rand), Reason.PersonArived);
            }

            for (int i = 0; i < 4; i++)
            {
                Houses.Add(House.GenerateHouse(Rand));
            }



            Live();
        }
예제 #10
0
        public void AddHouse(int x, int y)
        {
            for (int i = 0; i < Houses.Count; i++)
            {
                if (Math.Abs(Houses[i].X - x) < House.R * 2 && Math.Abs(Houses[i].Y - y) < House.R * 2)
                {
                    return;
                }
            }


            House house = new House(x, y);

            TimeTickEvent       += house.TimeTick;
            house.EndBuild      += EndBuild;
            house.NeedBuild     += NeedBuild;
            house.NeedRoof      += NeedRoof;
            house.NeedResources += NeedResources;
            Houses.Add(house);
            NeedBuild(house);
        }
예제 #11
0
        /// <summary>
        ///     Adds a house with the specified properties.
        /// </summary>
        /// <param name="owner">The owner, which must not be <c>null</c>.</param>
        /// <param name="name">The name, which must not be <c>null</c> and logged in.</param>
        /// <param name="x">The first X coordinate.</param>
        /// <param name="y">The first Y coordinate.</param>
        /// <param name="x2">The second X coordinate, which must be at least the first.</param>
        /// <param name="y2">The second Y coordinate, which must be at least the second.</param>
        /// <returns>The resulting house.</returns>
        public override House AddHouse(TSPlayer owner, string name, int x, int y, int x2, int y2)
        {
            Debug.Assert(name != null, "Name must not be null.");
            Debug.Assert(owner != null, "Owner must not be null.");
            Debug.Assert(owner.User != null, "Owner must be logged in.");
            Debug.Assert(x2 >= x, "Second X coordinate must be at least the first.");
            Debug.Assert(y2 >= y, "Second Y coordinate must be at least the first.");

            lock ( locker )
            {
                TShock.Regions.AddRegion(
                    x, y, x2 - x + 1, y2 - y + 1, $"__House<>{owner.User.Name}<>{name}", owner.User.Name,
                    Main.worldID.ToString(), 100);
                NonQuery(
                    "INSERT INTO Houses (OwnerName, Name, WorldId, X, Y, X2, Y2, LastTaxed)" +
                    "VALUES (@0, @1, @2, @3, @4, @5, @6, @7)",
                    owner.User.Name, name, Main.worldID, x, y, x2, y2, DateTime.UtcNow.ToString("s"));
                var house = new House(owner.User.Name, name, x, y, x2, y2);
                Houses.Add(house);
                return(house);
            }
        }
예제 #12
0
        /// <summary>
        /// Set the list with houses from the response
        /// </summary>
        /// <param name="url"></param>
        private async void SetHousesList(String url)
        {
            try
            {
                var service = new ThroneService();
                PagedResponse <List <House> > obj = await service.GetHousesAsync(url);

                if (obj.result != null)
                {
                    List <House> houses = obj.result;
                    foreach (House item in houses)
                    {
                        Houses.Add(item);
                    }
                }

                Buttons = obj.links;
            }
            catch (RedirectMainException)
            {
                NavigationService.Navigate(typeof(MainPage));
            }
        }
예제 #13
0
        async void GetHouses()
        {
            //IsBusy = true;
            try
            {
                var houseList = await remoteService.GetAllProperty();

                Houses.Clear();
                foreach (var item in houseList)
                {
                    if (item.ItemType.ToLower() == "house")
                    {
                        if (Houses.Count < 3)
                        {
                            Houses.Add(item);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
예제 #14
0
파일: Map.cs 프로젝트: Herhangi/HerhangiOT
        private static bool ParseTileArea(NodeStruct node, FileLoader fileLoader)
        {
            byte type;

            MemoryStream props;

            if (!fileLoader.GetProps(node, out props))
            {
                return(false);
            }

            int baseX = props.ReadUInt16();
            int baseY = props.ReadUInt16();
            int baseZ = props.ReadByte();

            NodeStruct nodeTile = fileLoader.GetChildNode(node, out type);

            while (nodeTile != null)
            {
                if (type != (byte)OtbmNodeTypes.Tile && type != (byte)OtbmNodeTypes.HouseTile)
                {
                    Logger.Log(LogLevels.Error, "NOT TILE OR HOUSETILE");
                    return(false);
                }

                if (!fileLoader.GetProps(nodeTile, out props))
                {
                    return(false);
                }

                int pX = baseX + props.ReadByte();
                int pY = baseY + props.ReadByte();
                int pZ = baseZ;

                TileFlags tileFlags   = TileFlags.None;
                bool      isHouseTile = false;
                Item      groundItem  = null;
                House     house       = null;
                Tile      tile        = null;

                if (type == (byte)OtbmNodeTypes.HouseTile)
                {
                    //TODO: HOUSES
                    uint houseId = props.ReadUInt32();

                    if (!Houses.ContainsKey(houseId))
                    {
                        Houses.Add(houseId, new House {
                            HouseId = houseId
                        });
                    }

                    house = Houses[houseId];
                    tile  = new HouseTile(pX, pY, pZ, house);
                    house.AddTile((HouseTile)tile);
                    isHouseTile = true;
                }

                int attribute;
                while ((attribute = props.ReadByte()) != -1)
                {
                    switch ((OtbmAttributes)attribute)
                    {
                    case OtbmAttributes.TileFlags:
                        TileFlags flags = (TileFlags)props.ReadUInt32();

                        if (flags.HasFlag(TileFlags.ProtectionZone))
                        {
                            tileFlags |= TileFlags.ProtectionZone;
                        }
                        else if (flags.HasFlag(TileFlags.NoPvpZone))
                        {
                            tileFlags |= TileFlags.NoPvpZone;
                        }
                        else if (flags.HasFlag(TileFlags.PvpZone))
                        {
                            tileFlags |= TileFlags.PvpZone;
                        }

                        if (flags.HasFlag(TileFlags.NoLogout))
                        {
                            tileFlags |= TileFlags.NoLogout;
                        }
                        break;

                    case OtbmAttributes.Item:
                        Item item = Item.CreateItem(props);
                        if (item == null)
                        {
                            return(false);
                        }

                        if (isHouseTile && item.IsMovable)
                        {
                            Logger.Log(LogLevels.Warning, "Moveable item found in house: " + house.HouseId);
                            item.DecrementReferenceCounter();
                        }
                        else
                        {
                            if (item.Count <= 0)
                            {
                                item.Count = 1;
                            }

                            if (tile != null)
                            {
                                tile.InternalAddThing(item);
                                item.StartDecaying();
                                item.IsLoadedFromMap = true;
                            }
                            else if (item.IsGroundTile)
                            {
                                groundItem = item;
                            }
                            else
                            {
                                tile = CreateTile(groundItem, item, pX, pY, pZ);
                                tile.InternalAddThing(item);
                                item.StartDecaying();
                                item.IsLoadedFromMap = true;
                            }
                        }
                        break;

                    default:
                        Logger.Log(LogLevels.Warning, "Unknown tile attribute on; X:" + pX + ", Y:" + pY + ", Z:" + pZ + "!");
                        return(false);
                    }
                }

                NodeStruct nodeItem = fileLoader.GetChildNode(nodeTile, out type);
                while (nodeItem != null)
                {
                    if (type != (byte)OtbmNodeTypes.Item)
                    {
                        return(false);
                    }

                    MemoryStream stream;
                    if (!fileLoader.GetProps(nodeItem, out stream))
                    {
                        return(false);
                    }

                    Item item = Item.CreateItem(stream);
                    if (item == null)
                    {
                        return(false);
                    }

                    //TODO: UNSERIALIZE

                    if (isHouseTile && item.IsMovable)
                    {
                        Logger.Log(LogLevels.Warning, "Moveable item found in house: " + house.HouseId);
                        item.DecrementReferenceCounter();
                    }
                    else
                    {
                        if (item.Count <= 0)
                        {
                            item.Count = 1;
                        }

                        if (tile != null)
                        {
                            tile.InternalAddThing(item);
                            item.StartDecaying();
                            item.IsLoadedFromMap = true;
                        }
                        else if (item.IsGroundTile)
                        {
                            groundItem = item;
                        }
                        else
                        {
                            tile = CreateTile(groundItem, item, pX, pY, pZ);
                            tile.InternalAddThing(item);
                            item.StartDecaying();
                            item.IsLoadedFromMap = true;
                        }
                    }

                    nodeItem = nodeItem.Next;
                }

                if (tile == null)
                {
                    tile = CreateTile(groundItem, null, pX, pY, pZ);
                }

                tile.SetFlag(tileFlags);
                SetTile(tile);

                nodeTile = fileLoader.GetNextNode(nodeTile, out type);
            }

            return(true);
        }
예제 #15
0
        /// <summary>
        ///     Loads the houses and shops.
        /// </summary>
        public override void Load()
        {
            lock ( locker )
            {
                Houses.Clear();
                using (var connection = new MySqlConnection(ConnectionString))
                    using (var command = QueryCommand(connection, "SELECT * FROM Houses WHERE WorldId = @0", Main.worldID))
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                var ownerName = reader.Get <string>("OwnerName");
                                var name      = reader.Get <string>("Name");
                                var x         = reader.Get <int>("X");
                                var y         = reader.Get <int>("Y");
                                var x2        = reader.Get <int>("X2");
                                var y2        = reader.Get <int>("Y2");
                                var debt      = (decimal)reader.Get <long>("Debt");
                                var lastTaxed = DateTime.Parse(reader.Get <string>("LastTaxed"));
                                var forSale   = reader.Get <int>("ForSale") == 1;
                                var salePrice = reader.Get <string>("SalePrice");

                                var house = new House(ownerName, name, x, y, x2, y2)
                                {
                                    Debt      = debt,
                                    LastTaxed = lastTaxed,
                                    ForSale   = forSale,
                                    SalePrice = salePrice
                                };
                                using (var connection2 = new MySqlConnection(ConnectionString))
                                    using (var command2 = QueryCommand(connection2,
                                                                       "SELECT Username FROM HouseHasUser " +
                                                                       "WHERE OwnerName = @0 AND HouseName = @1 AND WorldId = @2",
                                                                       ownerName, name, Main.worldID))
                                        using (var reader2 = command2.ExecuteReader())
                                        {
                                            while (reader2.Read())
                                            {
                                                var username = reader2.Get <string>("Username");
                                                house.AllowedUsernames.Add(username);
                                            }
                                        }
                                Houses.Add(house);
                            }
                        }

                Shops.Clear();
                using (var connection = new MySqlConnection(ConnectionString))
                    using (var command = QueryCommand(connection, "SELECT * FROM Shops WHERE WorldID = @0", Main.worldID))
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                var ownerName = reader.Get <string>("OwnerName");
                                var name      = reader.Get <string>("Name");
                                var x         = reader.Get <int>("X");
                                var y         = reader.Get <int>("Y");
                                var x2        = reader.Get <int>("X2");
                                var y2        = reader.Get <int>("X2");
                                var chestX    = reader.Get <int>("ChestX");
                                var chestY    = reader.Get <int>("ChestY");
                                var isOpen    = reader.Get <int>("IsOpen") == 1;
                                var message   = reader.Get <string>("Message");

                                var shop = new Shop(ownerName, name, x, y, x2, y2, chestX, chestY)
                                {
                                    IsOpen  = isOpen,
                                    Message = message
                                };
                                using (var connection2 = new MySqlConnection(ConnectionString))
                                    using (var command2 = QueryCommand(connection2,
                                                                       "SELECT * FROM ShopHasItem WHERE OwnerName = @0 AND ShopName = @1 AND WorldId = @2",
                                                                       ownerName, name, Main.worldID))
                                        using (var reader2 = command2.ExecuteReader())
                                        {
                                            while (reader2.Read())
                                            {
                                                var index     = reader2.Get <int>("ItemIndex");
                                                var itemId    = reader2.Get <int>("ItemId");
                                                var stackSize = reader2.Get <int>("StackSize");
                                                var prefixId  = (byte)reader2.Get <int>("PrefixId");
                                                shop.Items.Add(new ShopItem(index, itemId, stackSize, prefixId));
                                            }
                                        }
                                using (var connection2 = new MySqlConnection(ConnectionString))
                                    using (var command2 = QueryCommand(connection2,
                                                                       "SELECT * FROM ShopHasPrice WHERE OwnerName = @0 AND ShopName = @1 AND WorldId = @2",
                                                                       ownerName, name, Main.worldID))
                                        using (var reader2 = command2.ExecuteReader())
                                        {
                                            while (reader2.Read())
                                            {
                                                var itemId          = reader2.Get <int>("ItemId");
                                                var unitPriceString = reader2.Get <string>("UnitPrice");
                                                shop.UnitPrices[itemId] = new PriceInfo(unitPriceString);
                                            }
                                        }
                                Shops.Add(shop);
                            }
                        }

                //load in tax collectors.
                TaxCollectors.Clear();
                TaxCollectorNames.Clear();
                using (var connection = new MySqlConnection(ConnectionString))
                    using (var command = QueryCommand(connection, "SELECT * FROM TaxCollectors WHERE WorldID = @0", Main.worldID))
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                var playerName = reader.Get <string>("PlayerName");
                                var tc         = new TaxCollector(playerName);
                                TaxCollectors.Add(tc);
                                TaxCollectorNames.Add(playerName);
                            }
                        }
            }
        }
예제 #16
0
        public static void Load()
        {
            BuildSets.Clear();
            Houses.Clear();
            Guardlines.Clear();

            FileInfo[] files  = _definitionsPath.GetFiles("*.txt").Where(s => !_ignored.Contains(s.Name)).ToArray();
            Bitmap[]   images = new Bitmap[files.Length];

            FileInfo[] icons = _iconsPath.GetFiles("*.png");

            for (int i = 0; i < files.Length; i++)
            {
                FileInfo definition = files[i];
                FileInfo icon       = icons.FirstOrDefault(s => s.Name.Contains(Path.GetFileNameWithoutExtension(definition.Name)));

                if (icon == null)
                {
                    continue;               // found an icon
                }
                Image img = Image.FromFile(icon.FullName);
                images[i] = new Bitmap(img.Width, img.Height, PixelFormat.Format32bppPArgb);

                using (Graphics g = Graphics.FromImage(images[i]))
                {
                    g.PageUnit          = GraphicsUnit.Pixel;
                    g.InterpolationMode = InterpolationMode.NearestNeighbor;
                    g.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                    g.SmoothingMode     = SmoothingMode.AntiAlias;
                    g.DrawImage(img, 0, 0, img.Width, img.Height);
                }

                string   setName  = Path.GetFileNameWithoutExtension(definition.Name);
                BuildSet buildSet = new BuildSet(setName, images[i], !_smarts.Contains(setName));
                bool     istown   = setName.ToLower() == "town";

                using (StreamReader reader = new StreamReader(definition.OpenRead()))
                {
                    while (!reader.EndOfStream)
                    {
                        string line = reader.ReadLine();

                        if (string.IsNullOrEmpty(line))
                        {
                            continue;
                        }

                        string[] parts = line.Split('\t');

                        if (parts.Length >= 5)
                        {
                            bool     enabled     = parts[0] == "+";
                            string   description = parts[1].TrimEnd().TrimStart();
                            Position position    = Position.Parse(parts[2] + "." + parts[3]);
                            int      map         = parts[4].ToInt();

                            BuildingEntry entry = new BuildingEntry(buildSet, description, position, map)
                            {
                                IsEnabled = enabled, IsTown = istown
                            };


                            if (parts.Length >= 6)
                            {
                                entry.ShowName = parts[5] == "true";
                            }

                            buildSet.Entries.Add(entry);
                        }
                    }
                }

                BuildSets.Add(buildSet);
            }

            // patch for towns
            BuildSet townSet = BuildSets.FirstOrDefault(s => s.Name.ToLower() == "town");

            if (townSet != null)
            {
                BuildSets.Remove(townSet);
                BuildSets.Add(townSet);
            }
            // end patch

            // load houses
            FileInfo housesDef = _definitionsPath.GetFiles().FirstOrDefault(s => s.Name == _ignored[1]);

            if (housesDef != null)
            {
                using (StreamReader reader = new StreamReader(housesDef.FullName))
                {
                    while (!reader.EndOfStream)
                    {
                        string line = reader.ReadLine();
                        if (string.IsNullOrEmpty(line))
                        {
                            continue;
                        }

                        string[] data = line.Split('\t');
                        if (data.Length <= 0 || data.Length < 5)
                        {
                            continue;
                        }


                        if (!ushort.TryParse(data[0], out ushort graphic))
                        {
                            graphic = ushort.Parse(data[0], NumberStyles.HexNumber);
                        }

                        Position loc   = Position.Parse(data[1] + "." + data[2]);
                        Size     size  = new Size(data[3].ToInt(), data[4].ToInt());
                        int      map   = data[5].ToInt();
                        string   descr = data[6];

                        HouseEntry house = new HouseEntry(descr, graphic, loc, size, map);

                        Houses.Add(house);
                    }
                }
            }
            else
            {
                new FileInfo(Path.Combine(_definitionsPath.FullName, _ignored[1])).Create().Close();
            }

            // load guardlines
            FileInfo guardlinesDef = _definitionsPath.GetFiles().FirstOrDefault(s => s.Name == _ignored[0]);

            if (guardlinesDef != null)
            {
                using (StreamReader reader = new StreamReader(guardlinesDef.FullName))
                {
                    while (!reader.EndOfStream)
                    {
                        string line = reader.ReadLine();
                        if (string.IsNullOrEmpty(line))
                        {
                            continue;
                        }

                        string[] data = line.Split('\t');
                        if (data.Length <= 0 || data.Length < 5)
                        {
                            continue;
                        }

                        if (data[0].StartsWith("#"))
                        {
                            continue;
                        }

                        Position loc = Position.Parse(data[0] + "." + data[1]);
                        // ignore data[2]
                        Size size = new Size(data[3].ToInt(), data[4].ToInt());
                        int  map  = data[5].ToInt();

                        GuardlineEntry guardline = new GuardlineEntry(loc, size, map);

                        Guardlines.Add(guardline);
                    }
                }
            }
            else
            {
                new FileInfo(Path.Combine(_definitionsPath.FullName, _ignored[0])).Create().Close();
            }


            ParseUOAM();
        }
예제 #17
0
파일: City.cs 프로젝트: Eugene-El/MyCity
 public void AddHouse(House house)
 {
     Houses.Add(house);
     Log("House bilded at " + house.Coords + " !", ConsoleColor.Green);
 }