/// <summary>
        /// Jeżeli element jest dodany to zwracamy jego klucz
        /// </summary>
        /// <param name="el"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public string AddElementOnMap(StandardElements el, string name)
        {
            if (!MapElements.Exists(x => x.Key == name))
            {
                if (el == StandardElements.Gun)
                {
                    MapElements.Add(new Gun(name));
                    return(name);
                }
                else if (el == StandardElements.SpawnPiont)
                {
                    if (MapElements.FirstOrDefault(x => x.GetType() == typeof(SpawnPoint)) == null)
                    {
                        MapElements.Add(new SpawnPoint(name));
                        return(name);
                    }
                    else
                    {
                        return("There is already spawn point");
                    }
                }
            }

            if (el == StandardElements.ReverseIce)
            {
                if (MapPath.FirstOrDefault(x => x.Key == name) == null)
                {
                    MapPath.Add(new RegularIce(name));
                    return(name);
                }
                else
                {
                    return("There is already spawn point");
                }
            }
            else if (el == StandardElements.NormalIce)
            {
                if (MapPath.FirstOrDefault(x => x.Key == name) == null)
                {
                    MapPath.Add(new RegularIce(name));
                    return(name);
                }
                else
                {
                    return("There is already spawn point");
                }
            }

            return("Coś poszło nie tak");
        }
Exemple #2
0
        private void Init(DataTemplate template)
        {
            Random random = new Random(DateTime.Now.Millisecond);

            foreach (var info in _mapPointsInfo)
            {
                var mapPointViewModel = new MapPointViewModel(info)
                {
                    Count = _mapNameToCount[info.Name]
                };
                mapPointViewModel.Zoom          = Zoom;
                mapPointViewModel.MapPointColor = new SolidColorBrush(Color.FromRgb(
                                                                          (byte)random.Next(1, 255),
                                                                          (byte)random.Next(1, 255),
                                                                          (byte)random.Next(1, 255)));
                PlaceList.Add(mapPointViewModel);
                _mapNameToMapPoint.Add(mapPointViewModel.Name, mapPointViewModel);

                var mapCustomElement = new MapCustomElement()
                {
                    Content         = mapPointViewModel,
                    ContentTemplate = template,
                };

                _mapNameToMapElement.Add(info.Name, mapCustomElement);

                mapCustomElement.MouseLeftButtonDown += OnMapCustomElementClick;

                BindingOperations.SetBinding(mapCustomElement, MapCustomElement.LocationProperty,
                                             new Binding("Location")
                {
                    Source = mapPointViewModel
                });

                MapElements.Add(mapCustomElement);
            }
        }