public T GetMapElementByName <T>(string name) { if (typeof(T) == typeof(IMapElement)) { return((T)MapElements.FirstOrDefault(x => x.Key == name)); } else { return((T)MapPath.FirstOrDefault(x => x.Key == name)); } }
/// <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"); }