예제 #1
0
 public WeewarMap(XmlElement el)
 {
   Width = Int32.Parse(el.SelectSingleNode("width").InnerText);
   Height = Int32.Parse(el.SelectSingleNode("height").InnerText);
   XmlNodeList terrains = el.SelectNodes("terrains/terrain");
   foreach (XmlElement terrain in terrains)
   {
     Terrain t = new Terrain();
     t.Coordinate = new Coordinate(Int32.Parse(terrain.GetAttribute("x")), Int32.Parse(terrain.GetAttribute("y")));
     t.Type = Terrain.ToType(terrain.GetAttribute("type"));
     add(t);
   }
 }
예제 #2
0
파일: Eliza.cs 프로젝트: sticks/weewar.net
    private Game parseGame(XmlElement gameEle)
    {
      Game g = new Game();
      String att = gameEle.GetAttribute("inNeedOfAttention");
      g.IsInNeedOfAttention = att == "true";
      g.Name = gameEle.SelectSingleNode("name").InnerText;
      g.Id = Int32.Parse(gameEle.SelectSingleNode("id").InnerText);
      XmlNode map = gameEle.SelectSingleNode("map");

      if (map != null && map.InnerText != null)
        g.MapId = Int32.Parse(map.InnerText);
      g.Link = gameEle.SelectSingleNode("url").InnerText;
      g.RequiresAnInviteAccept = g.Link.Contains("join");
      if (gameEle.SelectSingleNode("factions") != null)
      {
        XmlNodeList factions = gameEle.SelectNodes("factions/faction");
        foreach (XmlElement faction in factions)
        {
          Faction f = new Faction();
          g.Factions.Add(f);
          f.PlayerName = faction.GetAttribute("playerName");
          f.State = faction.GetAttribute("state");
          if (!String.IsNullOrEmpty(faction.GetAttribute("credits")))
            f.Credits = Int32.Parse(faction.GetAttribute("credits"));
          foreach (XmlElement unit in faction.SelectNodes("unit"))
          {
            Unit u = new Unit();
            u.Coordinate = new Coordinate(Int32.Parse(unit.GetAttribute("x")), Int32.Parse(unit.GetAttribute("y")));
            u.Type = Unit.ToType(unit.GetAttribute("type"));
            u.Finished = "true" == unit.GetAttribute("finished");
            u.Quantity = Int32.Parse(unit.GetAttribute("quantity"));
            f.Units.Add(u);
          }
          foreach (XmlElement unit in faction.SelectNodes("terrain"))
          {
            Terrain t = new Terrain();
            t.Coordinate = new Coordinate(Int32.Parse(unit.GetAttribute("x")), Int32.Parse(unit.GetAttribute("y")));
            t.Type = Terrain.ToType(unit.GetAttribute("type"));
            t.Finished = "true" == unit.GetAttribute("finished");
            f.Terrains.Add(t);
          }
        }
      }
      return g;
    }
예제 #3
0
 public void add(Terrain t)
 {
   terrains.Add(t.Coordinate, t);
 }