public PlayerView(Player p) { Civilization = p.Civilization.ToString(); Name = p.Name; CitiesCount = p.CitiesCount; TeachersCount = p.Units.Where(u => u is Teacher).Count(); StudentsCount = p.Units.Where(u => u is Student).Count(); HeadCount = (p.HasHead ? 1 : 0); p.PropertyChanged += new PropertyChangedEventHandler(delegate(object sender, PropertyChangedEventArgs args) { switch (args.PropertyName) { case "CitiesCount": CitiesCount = ((Player)sender).CitiesCount; break; case "Units": TeachersCount = ((Player)sender).Units.Where(u => u is Teacher).Count(); StudentsCount = ((Player)sender).Units.Where(u => u is Student).Count(); HeadCount = (((Player)sender).HasHead ? 1 : 0); break; default: break; } }); }
/// <summary> /// Creates a new unit at the given location for the given player. /// </summary> /// <param name="location"></param> /// <param name="player"></param> public Unit(Case location, Player player) { this._location = location; this._player = player; RemainingHitPoints = HitPoints; RemainingMovementPoints = MovementPoints; HasAttacked = false; }
/// <summary> /// Creates a new city on a given case. /// </summary> /// <param name="position">The position of the city.</param> /// <param name="player">The player to whom the city belongs.</param> /// <param name="name">The name of the city (defined by the player).</param> public City(Case position, Player player, List<Case> territory) { this.position = position; this.player = player; this.fields = new List<Case>(); this.fields.Add(this.position); this.pendingProductions = new List<Unit>(); this.territory = territory; this.territory = territory.OrderBy(item => item.DistanceTo(position)).ToList(); _population = 1; _food = 0; _iron = 0; _requiredFood = 10; }
public override Head CreateHead(Case position, Player player) { return new InfoHead(position, player); }
public Head(Case position, Player player) : base(position, player) { }
public Teacher(Case location, Player player) : base(location, player) { }
public InfoHead(Case location, Player player) : base(location, player) { }
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); } } }
/// <summary> /// Initializes a player with default values : a teacher and a student. /// </summary> /// <param name="player"></param> /// <param name="map"></param> private void initPlayer(Player player, Map map) { Case position = map.FreePosition; Teacher teacher = player.Civilization.UnitFactory.CreateTeacher(position, player); Student student = player.Civilization.UnitFactory.CreateStudent(position, player); player.AddUnit(teacher); position.AddUnit(teacher); player.AddUnit(student); position.AddUnit(student); }
public abstract Teacher CreateTeacher(Case position, Player player);
public abstract Student CreateStudent(Case position, Player player);
public abstract Head CreateHead(Case position, Player player);
public GameOverEventArgs(Player winner) { _winner = winner; }
public Student(Case location, Player player) : base(location, player) { }
public override Student CreateStudent(Case position, Player player) { return new InfoStudent(position, player); }
/// <summary> /// Builds a new game. Builds the map and initializes the players according to the chosen settings. /// </summary> /// <returns>A new game, ready to run</returns> public Game Build() { Map map = mapGenerator.generate(mapConfig); List<Player> players = new List<Player>(); foreach (var entry in this.players) { Player player = new Player(entry.Value, entry.Key); players.Add(player); initPlayer(player, map); } return new Game(map, players); }
public override Teacher CreateTeacher(Case position, Player player) { return new InfoTeacher(position, player); }
public EIIHead(Case location, Player player) : base(location, player) { }