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()); } } } }
/// <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); }
public void AddAdjacentTerritory( BoardTerritory t ) { AdjacentTerritories.Add(t); }
public void AddTerritory(BoardTerritory t) { Territories.Add(t); }
public PlayerTerritory(BoardTerritory t, RiskPlayer p, int troops) { boardTerritory = t; Player = p; Troops = troops; }