Exemplo n.º 1
0
        private void LoadContinents() 
        {
            foreach( XmlNode n in xml.SelectNodes("/Risk/Continent") )
            {
                BoardContinent c = new BoardContinent( n.Attributes["name"].Value, Int32.Parse(n.Attributes["pointValue"].Value), this);

                foreach (XmlNode cn in n.ChildNodes)
                {
                    BoardTerritory t = new BoardTerritory(cn.Attributes["name"].Value, c, this);
                    Territories.Add(t);
                    c.AddTerritory(t);
                }
                
                Continents.Add(c);
            }

            // Load the Adjacent Territories

            foreach (BoardTerritory t in Territories)
            {
                foreach (XmlNode n in xml.SelectNodes("/Risk/Continent/Territory[@name='" + t.Name + "']"))
                {
                    foreach (XmlNode cn in n.ChildNodes)
                    {
                        t.AddAdjacentTerritory(Territories.Where(x => x.Name == cn.Attributes["name"].Value).Single());
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="xmlPath"></param>
        public RiskGame( string xmlPath )
        {
            Board = new RiskBoard(xmlPath);
            Players = new List<RiskPlayer>();
            PlayerTerritories = new List<PlayerTerritory>();

            BoardTerritory[] tempArray = new BoardTerritory[Board.Territories.Count];
            Board.Territories.CopyTo(tempArray);
            UnassignedTerritories = tempArray.ToList();

            CurrentPlayerIndex = -1;

            State = new NotStarted(this);
        }
Exemplo n.º 3
0
 public void AddAdjacentTerritory( BoardTerritory t )
 {
     AdjacentTerritories.Add(t);
 }
Exemplo n.º 4
0
 public void AddTerritory(BoardTerritory t)
 {
     Territories.Add(t);
 }
Exemplo n.º 5
0
 public PlayerTerritory(BoardTerritory t, RiskPlayer p, int troops)
 {
     boardTerritory = t;
     Player = p;
     Troops = troops;
 }