Beispiel #1
0
        protected void PrepareCoastalDistricts()
        {
            ProximityComputer <District> proximityComputer = new ProximityComputer <District>(base.Context.Districts);

            proximityComputer.StartingNodes = new List <District>(from d in base.Context.Districts.Values
                                                                  where d.Content == District.Contents.Ocean
                                                                  select d);
            ProximityComputer <District> proximityComputer2 = proximityComputer;

            if (proximityComputer2.StartingNodes.Count <= 0)
            {
                base.Context.IsOnlyLand = true;
                base.Context.Districts.Values.ToList <District>().ForEach(delegate(District d)
                {
                    d.CoastalSkeletonValue = 999;
                });
                return;
            }
            base.Context.IsOnlyLand = false;
            proximityComputer2.Execute();
            for (int i = 0; i < base.Context.Districts.Nodes; i++)
            {
                base.Context.Districts[i].CoastalSkeletonValue = proximityComputer2.ProximityGraph[i];
            }
            ProximityComputer <District> proximityComputer3 = new ProximityComputer <District>(base.Context.Districts);

            proximityComputer3.StartingNodes = new List <District>(from d in base.Context.Districts.Values
                                                                   where d.Content == District.Contents.Land
                                                                   select d);
            ProximityComputer <District> proximityComputer4 = proximityComputer3;

            proximityComputer4.Execute();
            for (int j = 0; j < base.Context.Districts.Nodes; j++)
            {
                District district = base.Context.Districts[j];
                if (district.CoastalSkeletonValue == 0)
                {
                    district.CoastalSkeletonValue = 1 - proximityComputer4.ProximityGraph[j];
                }
            }
        }
Beispiel #2
0
        protected void MakeIslands(int islandSize, int keepPercent)
        {
            CreateContinents.< > c__DisplayClass14_0 CS$ < > 8__locals1 = new CreateContinents.< > c__DisplayClass14_0();
            CS$ < > 8__locals1.< > 4__this = this;
            CreateContinents.< > c__DisplayClass14_0  CS$ < > 8__locals2 = CS$ < > 8__locals1;
            ProximityComputer <CreateContinents.Blob> proximityComputer  = new ProximityComputer <CreateContinents.Blob>(this.BlobGraph);

            proximityComputer.StartingNodes = new List <CreateContinents.Blob>(from c in this.Continents
                                                                               from b in c.Blobs
                                                                               select b);
            CS$ < > 8__locals2.proxer = proximityComputer;
            CS$ < > 8__locals1.proxer.Execute();
            CS$ < > 8__locals1.potentialIslands = new List <CreateContinents.Blob>(from b in this.CoreBlobs
                                                                                   where CS$ < > 8__locals1.proxer.Proximity(b) > 1
                                                                                   select b);
            List <CreateContinents.Blob> list = new List <CreateContinents.Blob>();

            while (CS$ < > 8__locals1.potentialIslands.Count > 0 && this.Continents.Count < 254)
            {
                List <CreateContinents.Blob> island = new List <CreateContinents.Blob>();
                CreateContinents.Blob        blob   = CS$ < > 8__locals1.potentialIslands.ElementAt(base.Context.Randomizer.Next(CS$ < > 8__locals1.potentialIslands.Count));
                CS$ < > 8__locals1.potentialIslands.Remove(blob);
                island.Add(blob);
                list.Clear();
                List <CreateContinents.Blob>        list2  = list;
                IEnumerable <CreateContinents.Blob> source = this.BlobGraph.Adjacents(blob);
                Func <CreateContinents.Blob, bool>  predicate;
                if ((predicate = CS$ < > 8__locals1.< > 9__3) == null)
                {
                    predicate = (CS$ < > 8__locals1.< > 9__3 = ((CreateContinents.Blob n) => CS$ < > 8__locals1.potentialIslands.Contains(n)));
                }
                list2.AddRange(source.Where(predicate));
                while (list.Count > 0)
                {
                    if (island.Sum((CreateContinents.Blob b) => b.Districts.Sum((District d) => d.Count)) >= islandSize)
                    {
                        break;
                    }
                    CreateContinents.Blob item = list.ElementAt(base.Context.Randomizer.Next(list.Count));
                    island.Add(item);
                    CS$ < > 8__locals1.potentialIslands.Remove(item);
                    list.Clear();
                    List <CreateContinents.Blob> list3 = list;
                    var source2 = from b in island
                                  from n in this.BlobGraph.Adjacents(b)
                                  select new
                    {
                        b,
                        n
                    };
                    var predicate2;
                    if ((predicate2 = CS$ < > 8__locals1.< > 9__6) == null)
                    {
                        predicate2 = (CS$ < > 8__locals1.< > 9__6 = (< > h__TransparentIdentifier0 => CS$ < > 8__locals1.potentialIslands.Contains(< > h__TransparentIdentifier0.n)));
                    }
                    list3.AddRange(from <> h__TransparentIdentifier0 in source2.Where(predicate2)
                                   select <> h__TransparentIdentifier0.n);
                }
                if (island.Count > 0)
                {
                    if (island.Sum((CreateContinents.Blob b) => b.Districts.Sum((District d) => d.Count)) < 3 * islandSize)
                    {
                        if (island.Sum((CreateContinents.Blob b) => b.Districts.Sum((District d) => d.Count)) > islandSize && base.Context.Randomizer.Next(100) < keepPercent)
                        {
                            CreateContinents.Continent continent = new CreateContinents.Continent(this.BlobGraph);
                            this.Continents.Add(continent);
                            island.ForEach(delegate(CreateContinents.Blob b)
                            {
                                b.Content = District.Contents.Land;
                            });
                            island.ForEach(delegate(CreateContinents.Blob b)
                            {
                                b.Districts.ForEach(delegate(District d)
                                {
                                    d.Content = District.Contents.Land;
                                });
                            });
                            continent.Blobs.UnionWith(island);
                            Func <CreateContinents.Blob, bool> < > 9__18;
                            CS$ < > 8__locals1.potentialIslands.RemoveAll(delegate(CreateContinents.Blob b)
                            {
                                IEnumerable <CreateContinents.Blob> source3 = CS$ < > 8__locals1.< > 4__this.BlobGraph.Adjacents(b);
                                Func <CreateContinents.Blob, bool> predicate3;
                                if ((predicate3 = < > 9__18) == null)
                                {
                                    predicate3 = (< > 9__18 = ((CreateContinents.Blob n) => island.Contains(n)));
                                }
                                return(source3.Any(predicate3));
                            });
                        }
                    }
                }
            }
        }