Example #1
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 #2
0
        public void Invade(Player invader)
        {
            player.RemoveCity(this);
            invader.AddCity(this);
            player = invader;

            foreach (Case field in fields.ToList())
            {
                if (field.HasUnits)
                {
                    // The case is occupied by the enemy and cannot be used as a field.
                    RemoveField(field);
                    field.Free();
                }
                else
                {
                    // Changes the occupant of the field.
                    field.Use(this);
                }
            }
        }
Example #3
0
        public void Invade(Player invader)
        {
            player.RemoveCity(this);
            invader.AddCity(this);
            player = invader;

            foreach (Case field in fields.ToList())
            {
                if (field.HasUnits)
                {
                    // The case is occupied by the enemy and cannot be used as a field.
                    RemoveField(field);
                    field.Free();
                }
                else
                {
                    // Changes the occupant of the field.
                    field.Use(this);
                }
            }
        }