Example #1
0
        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;
        }
Example #2
0
 /// <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;
     }
 }
Example #3
0
        /// <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;
        }
Example #4
0
        /// <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();
        }
Example #5
0
 /// <summary>
 /// Adds a city.
 /// </summary>
 /// <param name="city"></param>
 public void AddCity(City city)
 {
     cities.Add(city);
     OnPropertyChanged("CitiesCount");
 }
Example #6
0
        /// <summary>
        /// Removes a city.
        /// </summary>
        /// <param name="city"></param>
        public void RemoveCity(City city)
        {
            cities.Remove(city);
            OnPropertyChanged("CitiesCount");

            if (LoseCondition())
            {
                Lose();
            }
        }