public CityView(City c) { _city = c; c.PropertyChanged += new PropertyChangedEventHandler(delegate(object sender, PropertyChangedEventArgs args) { var city = (City) sender; switch (args.PropertyName) { case "Food": Food = city.Food; break; case "Iron": Iron = city.Iron; break; case "Population": Population = city.Population; break; case "CanMakeStudent": break; case "CanMakeHead": break; case "CanMakeTeacher": break; default: break; } }); Food = c.Food; Iron = c.Iron; Population = c.Population; }
/// <summary> /// Makes the given city use this case as a field. /// </summary> /// <param name="city">The city the field belongs to.</param> public virtual void Use(City city) { if (status != CaseStatus.CITY) { City = city; status = CaseStatus.USED; Occupant = city.Player; } }
/// <summary> /// Builds a city on this case. If the case was used as a field by another city, it is removed. /// </summary> /// <param name="city">The city to build.</param> public virtual void BuildCity(City city) { if (status == CaseStatus.USED) { this._city.RemoveField(this); } City = city; status = CaseStatus.CITY; Occupant = city.Player; }
/// <summary> /// Builds a city on the case on which the given teacher stands. /// Note: this should not be in this class. Refactoring needed. /// </summary> /// <param name="name">Name of the city.</param> /// <param name="teacher">Teacher building the city.</param> public void BuildCity(Unit teacher) { Player player = teacher.Player; Case position = teacher.Location; City city = new City(position, player, map.TerritoryAround(position, City.Radius)); position.BuildCity(city); player.AddCity(city); // The teacher sacrifices himself to build the city (may he rest in peace). teacher.Kill(); }
/// <summary> /// Adds a city. /// </summary> /// <param name="city"></param> public void AddCity(City city) { cities.Add(city); OnPropertyChanged("CitiesCount"); }
/// <summary> /// Removes a city. /// </summary> /// <param name="city"></param> public void RemoveCity(City city) { cities.Remove(city); OnPropertyChanged("CitiesCount"); if (LoseCondition()) { Lose(); } }