Ejemplo n.º 1
0
        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;
                }

            });
        }
Ejemplo n.º 2
0
 /// <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;
 }
Ejemplo n.º 3
0
 /// <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;
 }
Ejemplo n.º 4
0
 public override Head CreateHead(Case position, Player player)
 {
     return new InfoHead(position, player);
 }
Ejemplo n.º 5
0
 public Head(Case position, Player player)
     : base(position, player)
 {
 }
Ejemplo n.º 6
0
 public Teacher(Case location, Player player)
     : base(location, player)
 {
 }
Ejemplo n.º 7
0
 public InfoHead(Case location, Player player)
     : base(location, player)
 {
 }
Ejemplo n.º 8
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);
                }
            }
        }
Ejemplo n.º 9
0
 /// <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);
 }
Ejemplo n.º 10
0
 public abstract Teacher CreateTeacher(Case position, Player player);
Ejemplo n.º 11
0
 public abstract Student CreateStudent(Case position, Player player);
Ejemplo n.º 12
0
 public abstract Head CreateHead(Case position, Player player);
Ejemplo n.º 13
0
 public GameOverEventArgs(Player winner)
 {
     _winner = winner;
 }
Ejemplo n.º 14
0
 public Student(Case location, Player player)
     : base(location, player)
 {
 }
Ejemplo n.º 15
0
 public override Student CreateStudent(Case position, Player player)
 {
     return new InfoStudent(position, player);
 }
Ejemplo n.º 16
0
        /// <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);
        }
Ejemplo n.º 17
0
 public override Teacher CreateTeacher(Case position, Player player)
 {
     return new InfoTeacher(position, player);
 }
Ejemplo n.º 18
0
 public EIIHead(Case location, Player player)
     : base(location, player)
 {
 }