Exemplo n.º 1
0
        private void InitLocationsByCoordinate(GeoCoordinate coordinate, bool onlyOpen)
        {
            var backOffice = new Business.BackOffice();

            int zone = 0;
            int notMatchableBarCount = 0;

            while (Locations.Count < _findNumberBarFromLocations && notMatchableBarCount < backOffice.Locations.Count)
            {
                notMatchableBarCount = 0;
                zone += 200;
                foreach (Location location in backOffice.Locations)
                {
                    var locationCoordinate = new GeoCoordinate(location.Latitude, location.Longitude);
                    if (location.IsValid && !Locations.Contains(location) && (!onlyOpen || onlyOpen && location.IsOpenNow))
                    {
                        if (coordinate.GetDistanceTo(locationCoordinate) < zone)
                        {
                            Locations.Add(location);
                        }
                    }
                    else
                    {
                        notMatchableBarCount++;
                    }
                }
            }
        }
 public void RemoveLocation(LocationToCheck location)
 {
     if (Locations.Contains(location))
     {
         Locations.Remove(location);
     }
 }
Exemplo n.º 3
0
 public static void RegisterLocation(MapPoint mp)
 {
     if (!mp.Internal && !Locations.Contains(mp))
     {
         Locations.Add(mp);
     }
 }
Exemplo n.º 4
0
 private static void UnregisterLocation(MapPoint mp)
 {
     if (Locations.Contains(mp))
     {
         Locations.Remove(mp);
     }
 }
Exemplo n.º 5
0
        private void RemoveLocation(long id)
        {
            var location = Locations.FirstOrDefault(movieLocation => movieLocation.Id == id);

            if (location != null && Locations.Contains(location))
            {
                Locations.Remove(location);
                _collectionManager.DeleteMediaLocation(location);
            }
        }
 public void RemoveRangeOfLocations(IEnumerable <LocationToCheck> locations)
 {
     foreach (LocationToCheck location in locations)
     {
         if (Locations.Contains(location))
         {
             Locations.Remove(location);
         }
     }
 }
Exemplo n.º 7
0
        public void SelectLocation(Location location)
        {
            if (!Locations.Contains(location))
            {
                string errorMsg = "Failed to select a location. " + (location?.Name ?? "null") + " not found in the map.";
                DebugConsole.ThrowError(errorMsg);
                GameAnalyticsManager.AddErrorEventOnce("Map.SelectLocation:LocationNotFound", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
                return;
            }

            SelectedLocation   = location;
            SelectedConnection = Connections.Find(c => c.Locations.Contains(CurrentLocation) && c.Locations.Contains(SelectedLocation));
            OnLocationSelected?.Invoke(SelectedLocation, SelectedConnection);
        }
Exemplo n.º 8
0
    public override bool IsAtTarget(Vector2 position, out Vector2 actualTarget)
    {
        Vector2i rounded = Vector2i.FromVector2Round(position);

        if (Locations.Contains(rounded))
        {
            actualTarget = rounded.ToVector2();
            return(true);
        }
        else
        {
            actualTarget = Vector2.zero;
            return(false);
        }
    }
 /// <summary>
 /// Show a folder browser dialog to allow the user to select a location, and add it to Locations. Any exceptions would be fatal.
 /// </summary>
 private void AddLocation()
 {
     using (CommonDialog dialog = _folderBrowserDialog.GetNewFolderBrowserDialog())
     {
         DialogResult result = _folderBrowserDialog.ShowDialogWrapper(dialog);
         if (result == DialogResult.OK)
         {
             string       resultString       = _folderBrowserDialog.GetSelectedPathFromDialog(dialog);
             ScanLocation resultScanLocation = new ScanLocation(resultString);
             if (!Locations.Contains(resultScanLocation))
             {
                 Locations.Add(resultScanLocation);
             }
         }
     }
     ToggleButtons();
 }
Exemplo n.º 10
0
        public StacksContainer()
        {
            InitializeComponent();
            // Sets the Theme for Cairo
            string theme = Properties.Settings.Default.CairoTheme;

            if (theme != "Cairo.xaml")
            {
                ResourceDictionary CairoDictionary = (ResourceDictionary)XamlReader.Load(System.Xml.XmlReader.Create(AppDomain.CurrentDomain.BaseDirectory + theme));
                this.Resources.MergedDictionaries[0] = CairoDictionary;
            }
            try
            {
                this.deserialize();
            }
            catch {}

            Locations.CollectionChanged += new NotifyCollectionChangedEventHandler(locations_CollectionChanged);

            // Add some default folders on FirstRun
            if (Properties.Settings.Default.IsFirstRun == true)
            {
                // Check for Documents Folder
                String myDocsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                if (Directory.Exists(myDocsPath))
                {
                    SystemDirectory myDocsSysDir = new SystemDirectory(myDocsPath, Dispatcher.CurrentDispatcher);
                    // Don't duplicate defaults
                    if (!Locations.Contains(myDocsSysDir))
                    {
                        Locations.Add(myDocsSysDir);
                    }
                }
                // Check for Downloads folder
                String downloadsPath = System.Environment.GetEnvironmentVariable("USERPROFILE") + @"\Downloads";
                if (Directory.Exists(downloadsPath))
                {
                    SystemDirectory downloadsSysDir = new SystemDirectory(downloadsPath, Dispatcher.CurrentDispatcher);
                    // Don't duplicate defaults
                    if (!Locations.Contains(downloadsSysDir))
                    {
                        Locations.Add(downloadsSysDir);
                    }
                }
            }
        }
Exemplo n.º 11
0
        private async Task AddNewLocation(AddLocationMessage locationMessage)
        {
            if (Locations.Contains(new WeatherSummaryViewModel(locationMessage.Id)))
            {
                return;
            }

            LocationAnalytics.AddedALocation();
            var orderedSummary = new WeatherSummaryViewModel(locationMessage.Id, locationMessage.Name, Locations.Count);

            Locations.Add(orderedSummary);
            var summary = await openWeatherClient.GetWeatherSummariesFor(locationMessage.Id);

            if (summary.Any())
            {
                orderedSummary.UpdateWeather(summary.Single());
            }

            await localStorage.Save(Locations);
        }
Exemplo n.º 12
0
        private void ReceiveLocations(IEnumerable <WhereOnEarthLocation> locs, TwitterResponse resp)
        {
            if (resp.StatusCode == HttpStatusCode.OK && locs != null && locs.Any())
            {
                Deployment.Current.Dispatcher.InvokeIfRequired(() =>
                {
                    foreach (var loc in locs.OrderBy(x => x.Name))
                    {
                        if (!Locations.Contains(loc.Name))
                        {
                            Locations.Add(loc.Name);
                        }

                        if (!LocationMap.ContainsKey(loc.Name))
                        {
                            LocationMap.Add(loc.Name, loc.WoeId);
                        }
                    }
                    showLocations.RaiseCanExecuteChanged();
                });
            }
        }
Exemplo n.º 13
0
 public override long Cost(Point a, Point b)
 => Locations.Contains(b) ? 5 : 1;
Exemplo n.º 14
0
            public bool check(GameLocation loc)
            {
                bool ret = true;

                if (Children.Count > 0)
                {
                    if (ChildrenCombine != "and")
                    {
                        ret = false;
                    }

                    int totalMet = 0;
                    foreach (var child in Children)
                    {
                        bool childCheck = child.check(loc);
                        if (childCheck)
                        {
                            ++totalMet;
                        }

                        switch (ChildrenCombine)
                        {
                        case "and": ret = ret && childCheck; break;

                        case "or": ret = ret || childCheck; break;

                        case "xor": ret = ret ^ childCheck; break;
                        }
                    }

                    if (ChildrenCombine.StartsWith("atleast"))
                    {
                        ret = totalMet >= int.Parse(ChildrenCombine.Substring(7));
                    }
                    else if (ChildrenCombine.StartsWith("exactly"))
                    {
                        ret = totalMet == int.Parse(ChildrenCombine.Substring(7));
                    }
                    else if (ChildrenCombine != "and" && ChildrenCombine != "or" && ChildrenCombine != "xor")
                    {
                        throw new ArgumentException("Bad ChildrenCombine: " + ChildrenCombine);
                    }
                }
                else if (MinTimeOfDay != -1 && Game1.timeOfDay < MinTimeOfDay)
                {
                    ret = false;
                }
                else if (MaxTimeOfDay != -1 && Game1.timeOfDay > MaxTimeOfDay)
                {
                    ret = false;
                }
                else if (Seasons != null && Seasons.Count() > 0 && !Seasons.Contains(Game1.currentSeason))
                {
                    ret = false;
                }
                else if (Locations != null && Locations.Count() > 0 && !Locations.Contains(loc.Name))
                {
                    ret = false;
                }
                else if (Game1.random.NextDouble() >= Math.Max(0.15, (Math.Min(0.5, loc.map.Layers[0].LayerWidth * loc.map.Layers[0].LayerHeight / ChancePerTile))))
                {
                    ret = false;
                }
                else if (RequireDarkOut && !Game1.isDarkOut())
                {
                    ret = false;
                }
                else if (!AllowRain && Game1.isRaining)
                {
                    ret = false;
                }

                if (Not)
                {
                    ret = !ret;
                }
                return(ret);
            }
Exemplo n.º 15
0
        /// <summary>
        /// Load a previously saved campaign map from XML
        /// </summary>
        private Map(CampaignMode campaign, XElement element) : this()
        {
            Seed = element.GetAttributeString("seed", "a");
            Rand.SetSyncedSeed(ToolBox.StringToInt(Seed));
            foreach (XElement subElement in element.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "location":
                    int i = subElement.GetAttributeInt("i", 0);
                    while (Locations.Count <= i)
                    {
                        Locations.Add(null);
                    }
                    Locations[i] = new Location(subElement);
                    break;
                }
            }
            System.Diagnostics.Debug.Assert(!Locations.Contains(null));
            for (int i = 0; i < Locations.Count; i++)
            {
                Locations[i].Reputation ??= new Reputation(campaign.CampaignMetadata, $"location.{i}", -100, 100, Rand.Range(-10, 10, Rand.RandSync.Server));
            }

            foreach (XElement subElement in element.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "connection":
                    Point locationIndices = subElement.GetAttributePoint("locations", new Point(0, 1));
                    if (locationIndices.X == locationIndices.Y)
                    {
                        continue;
                    }
                    var connection = new LocationConnection(Locations[locationIndices.X], Locations[locationIndices.Y])
                    {
                        Passed     = subElement.GetAttributeBool("passed", false),
                        Difficulty = subElement.GetAttributeFloat("difficulty", 0.0f)
                    };
                    Locations[locationIndices.X].Connections.Add(connection);
                    Locations[locationIndices.Y].Connections.Add(connection);
                    connection.LevelData = new LevelData(subElement.Element("Level"));
                    string biomeId = subElement.GetAttributeString("biome", "");
                    connection.Biome =
                        LevelGenerationParams.GetBiomes().FirstOrDefault(b => b.Identifier == biomeId) ??
                        LevelGenerationParams.GetBiomes().FirstOrDefault(b => b.OldIdentifier == biomeId) ??
                        LevelGenerationParams.GetBiomes().First();
                    Connections.Add(connection);
                    break;
                }
            }

            int startLocationindex = element.GetAttributeInt("startlocation", -1);

            if (startLocationindex > 0 && startLocationindex < Locations.Count)
            {
                StartLocation = Locations[startLocationindex];
            }
            else
            {
                DebugConsole.AddWarning($"Error while loading the map. Start location index out of bounds (index: {startLocationindex}, location count: {Locations.Count}).");
                foreach (Location location in Locations)
                {
                    if (!location.Type.HasOutpost)
                    {
                        continue;
                    }
                    if (StartLocation == null || location.MapPosition.X < StartLocation.MapPosition.X)
                    {
                        StartLocation = location;
                    }
                }
            }
            int endLocationindex = element.GetAttributeInt("endlocation", -1);

            if (endLocationindex > 0 && endLocationindex < Locations.Count)
            {
                EndLocation = Locations[endLocationindex];
            }
            else
            {
                DebugConsole.AddWarning($"Error while loading the map. End location index out of bounds (index: {endLocationindex}, location count: {Locations.Count}).");
                foreach (Location location in Locations)
                {
                    if (EndLocation == null || location.MapPosition.X > EndLocation.MapPosition.X)
                    {
                        EndLocation = location;
                    }
                }
            }

            InitProjectSpecific();
        }
Exemplo n.º 16
0
 /// <summary>
 /// Indicates whether or not a <paramref name="location"/> is an occupied cell.
 /// </summary>
 /// <param name="location">The <see cref="Coordinates"/> of the location to check.</param>
 /// <returns>A value indicating the presence of this <see cref="Ship"/> at the <paramref name="location"/>.</returns>
 public bool IsAt(Coordinates location)
 {
     return(IsPlaced && Locations.Contains(location));
 }
Exemplo n.º 17
0
 public bool Contains(IGatherSpot item)
 {
     return(Locations.Contains(item));
 }