Exemplo n.º 1
0
        public static GameObjectModel Load(XmlDocument xmlDocument, XmlNode rootNode)
        {
            string modelName = rootNode.Attributes["name"].Value;

            GameObjectModel gom = new GameObjectModel(modelName);

            gom.LoadTransformations(xmlDocument, rootNode["Transformations"]);
            gom.CompileTransformations();
            gom.CalculateBoundingBox();

            return(gom);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create an empty map with the default name of "new_map"
        /// </summary>
        public Map(Grid grid, GameObjectModel groundModel)
        {
            _pathName = "Contents/Map/new_map.map";

            _models = new LinkedList <GameObjectModel>();
            _grid   = grid;

            _models.AddLast(groundModel);

            _xmlDocument = new XmlDocument();

            XmlNode xmlDec = _xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", null);

            _xmlDocument.AppendChild(xmlDec);

            _rootNode = _xmlDocument.CreateElement(MAP_MAGIC_STRING);
            _xmlDocument.AppendChild(_rootNode);

            _picker = new Picker(_grid);
        }
Exemplo n.º 3
0
        public void Load()
        {
            _xmlDocument = new XmlDocument();
            _xmlDocument.Load(_pathName + ".map");

            _rootNode = _xmlDocument.DocumentElement;

            if (_rootNode.Name != MAP_MAGIC_STRING)
            {
                throw new ApplicationException("Attempted to load an invalid map file.");
            }

            _grid = Grid.Load(_xmlDocument, _rootNode["Grid"]);

            _models = new LinkedList <GameObjectModel>();
            XmlNodeList models = _xmlDocument.GetElementsByTagName("Model");

            foreach (XmlNode model in models)
            {
                GameObjectModel gom = GameObjectModel.Load(_xmlDocument, model);
                Game1.console.Log(gom.Name + ": " + gom.BoundingBox.ToString());
                _models.AddLast(gom);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Add a new background model to the map
 /// </summary>
 /// <param name="gom"></param>
 public void AddModel(GameObjectModel gom)
 {
     _models.AddLast(gom);
 }