Example #1
0
        private void AssignBiomes()
        {
            var   biomes    = LevelGenerationParams.GetBiomes();
            float zoneWidth = Width / generationParams.DifficultyZones;

            List <Biome> allowedBiomes = new List <Biome>(10);

            for (int i = 0; i < generationParams.DifficultyZones; i++)
            {
                allowedBiomes.Clear();
                allowedBiomes.AddRange(biomes.Where(b => b.AllowedZones.Contains(generationParams.DifficultyZones - i)));
                float zoneX = Width - zoneWidth * i;

                foreach (Location location in Locations)
                {
                    if (location.MapPosition.X < zoneX)
                    {
                        location.Biome = allowedBiomes[Rand.Range(0, allowedBiomes.Count, Rand.RandSync.Server)];
                    }
                }
            }
            foreach (LocationConnection connection in Connections)
            {
                if (connection.Biome != null)
                {
                    continue;
                }
                connection.Biome = connection.Locations[0].Biome;
            }

            System.Diagnostics.Debug.Assert(Locations.All(l => l.Biome != null));
            System.Diagnostics.Debug.Assert(Connections.All(c => c.Biome != null));
        }
Example #2
0
        private async void FirePlacesSearch(Task <WebServiceResults.Result> getResult, CancellationTokenSource onCancel)
        {
            try
            {
                WebServiceResults.Result result = await Task.Run(() => getResult, onCancel.Token);

                if (result != null)
                {
                    Locations.Clear();

                    foreach (var prediction in result.predictions.Where(newItem => Locations.All(oldItem => oldItem.Id != newItem.id)))
                    {
                        Locations.Add(new PlaceLocation()
                        {
                            Id       = prediction.place_id,
                            Location = prediction.description
                        });
                    }
                }
            }

            catch (TaskCanceledException ex)
            {
            }
        }
        public PointsToAbstractValue MakeMayBeNull()
        {
            Debug.Assert(NullState != NullAbstractValue.Null);
            if (NullState == NullAbstractValue.MaybeNull || ReferenceEquals(this, Unknown))
            {
                return(this);
            }
            else if (Locations.IsEmpty)
            {
                return(Unknown);
            }

            Debug.Assert(Locations.All(location => !location.IsNull));
            return(new PointsToAbstractValue(Locations, NullAbstractValue.MaybeNull));
        }
        internal PointsToAbstractValue MakeMayBeNull()
        {
            Debug.Assert(Kind != PointsToAbstractValueKind.KnownLValueCaptures);
            Debug.Assert(NullState != NullAbstractValue.Null);

            if (NullState == NullAbstractValue.MaybeNull)
            {
                return(this);
            }

            if (Locations.IsEmpty)
            {
                return(Unknown);
            }

            Debug.Assert(Locations.All(location => !location.IsNull));
            return(new PointsToAbstractValue(Locations, NullAbstractValue.MaybeNull));
        }
Example #5
0
 public bool IsValidFor(ImmutableBubbleBurstGrid grid)
 {
     return(Locations.All(location => grid[location.X, location.Y] == Colour));
 }
 private bool CanSave()
 {
     return(Locations == null || Locations.All(a => !a.HasErrors));
 }