示例#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;
                }

            });
        }
示例#2
0
文件: Unit.cs 项目: eske/INSAWars
 /// <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;
 }
示例#3
0
文件: City.cs 项目: eske/INSAWars
 /// <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;
 }
示例#4
0
 public override Head CreateHead(Case position, Player player)
 {
     return new InfoHead(position, player);
 }
示例#5
0
文件: Head.cs 项目: eske/INSAWars
 public Head(Case position, Player player)
     : base(position, player)
 {
 }
示例#6
0
文件: Teacher.cs 项目: eske/INSAWars
 public Teacher(Case location, Player player)
     : base(location, player)
 {
 }
示例#7
0
文件: InfoHead.cs 项目: eske/INSAWars
 public InfoHead(Case location, Player player)
     : base(location, player)
 {
 }
示例#8
0
文件: City.cs 项目: eske/INSAWars
        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);
                }
            }
        }
示例#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);
 }
示例#10
0
 public abstract Teacher CreateTeacher(Case position, Player player);
示例#11
0
 public abstract Student CreateStudent(Case position, Player player);
示例#12
0
 public abstract Head CreateHead(Case position, Player player);
示例#13
0
 public GameOverEventArgs(Player winner)
 {
     _winner = winner;
 }
示例#14
0
文件: Student.cs 项目: eske/INSAWars
 public Student(Case location, Player player)
     : base(location, player)
 {
 }
示例#15
0
 public override Student CreateStudent(Case position, Player player)
 {
     return new InfoStudent(position, player);
 }
示例#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);
        }
示例#17
0
 public override Teacher CreateTeacher(Case position, Player player)
 {
     return new InfoTeacher(position, player);
 }
示例#18
0
文件: EIIHead.cs 项目: eske/INSAWars
 public EIIHead(Case location, Player player)
     : base(location, player)
 {
 }