Ejemplo n.º 1
0
        public static GameObjectList LoadFromNode(XmlNode node, Scene scene)
        {
            GameObjectList gameObjectList = new GameObjectList();

            Serialable.BeginSupportingDelayBinding();
            foreach (XmlNode gameObject in node.ChildNodes)
            {
                GameObject newGameObject = (GameObject)(Serialable.DoUnserial(gameObject));
                gameObjectList.AddGameObject(newGameObject);
            }
            Serialable.EndSupportingDelayBinding();
            return(gameObjectList);
        }
Ejemplo n.º 2
0
 public Object Unserial(Pointer _pointer, SerialAttribute _attribute, XmlNode _fieldNode, Dictionary <Pointer, string> _delayBindingTable)
 {
     if (_attribute.GetIsReference() ==
         SerialAttribute.AttributePolicy.PolicyReference)
     {
         _delayBindingTable.Add(_pointer, ((XmlElement)_fieldNode).GetAttribute("value"));
         return(null);
     }
     else if (_attribute.GetIsReference() ==
              SerialAttribute.AttributePolicy.PolicyCopy)
     {
         Serialable obj = Serialable.DoUnserial(_fieldNode);
         return(obj);
     }
     return(null);
 }
Ejemplo n.º 3
0
        /**
         * @brief load bttree from file
         **/
        public static BTTree Load(string _filepath)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(_filepath);

            BTTree newBTTree = new BTTree();

            XmlNode nodeBTTree   = doc.SelectSingleNode("BTTree");
            XmlNode nodeRoot     = nodeBTTree.SelectSingleNode("Root");
            XmlNode nodeRealRoot = nodeRoot.FirstChild;

            Serialable.BeginSupportingDelayBinding();
            newBTTree.m_root = Serialable.DoUnserial(nodeRealRoot) as BTNode;
            Serialable.EndSupportingDelayBinding(true);
            return(newBTTree);
        }
Ejemplo n.º 4
0
        /**
         * @brief create a scene from an XML file
         *
         * @param node the XML node
         * @param game the game engine
         *
         * @result scene
         * */
        public static Scene LoadScene(string _filename) // node is the current node
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(_filename);
            XmlNode node = doc.SelectSingleNode("Scene");

            Scene newScene = new Scene();

            // working list
            newScene._renderList = new RenderList();
            //newScene._colliderList = new ColliderList();
            newScene.m_physicsSystem = new PhysicsSystem();
            newScene.m_shadowSystem  = new ShadowSystem(Mgr <CatProject> .Singleton);
            newScene._renderList.SetShadowRender(newScene.m_shadowSystem);
            newScene._uiRenderer = new UIRenderer();
            newScene.m_physicsSystem.Initialize();

            if (Mgr <GameEngine> .Singleton._gameEngineMode == GameEngine.GameEngineMode.MapEditor)
            {
                newScene._debugDrawableList = new DebugDrawableList();
                newScene._debugDrawableList.AddItem(newScene);

                newScene._selectableList = new RepeatableList <ISelectable>();
            }
            // bind to current scene
            //Mgr<Scene>.Singleton = newScene;

            // init scene basic list
            // load and construct scene here
            XmlNode    basic      = node.SelectSingleNode("SceneBasic");
            XmlElement sceneBasic = (XmlElement)basic;

            newScene.setYAngle(float.Parse(sceneBasic.GetAttribute("viewAngle")));
            String playerGameObjectName = sceneBasic.GetAttribute("playerGameObjectName");

            XmlElement XBound = (XmlElement)sceneBasic.SelectSingleNode("XBound");

            newScene._XBound = new Vector2(float.Parse(XBound.GetAttribute("min")),
                                           float.Parse(XBound.GetAttribute("max")));

            XmlElement YBound = (XmlElement)sceneBasic.SelectSingleNode("YBound");

            newScene._YBound = new Vector2(float.Parse(YBound.GetAttribute("min")),
                                           float.Parse(YBound.GetAttribute("max")));

            XmlElement ZBound = (XmlElement)sceneBasic.SelectSingleNode("ZBound");

            newScene._ZBound = new Vector2(float.Parse(ZBound.GetAttribute("min")),
                                           float.Parse(ZBound.GetAttribute("max")));

            // camera
            XmlNode nodeCamera = node.SelectSingleNode(typeof(Camera).ToString());

            Serialable.BeginSupportingDelayBinding();
            Camera camera = Serialable.DoUnserial((XmlElement)nodeCamera) as Camera;

            Serialable.EndSupportingDelayBinding();
            //Mgr<Camera>.Singleton = camera;
            newScene.m_camera = camera;
            newScene.m_camera.UpdateView();
            newScene.m_camera.UpdateProjection();

            // postprocess manager
            XmlNode nodePostProcessManager =
                node.SelectSingleNode(typeof(PostProcessManager).ToString());

            Serialable.BeginSupportingDelayBinding();
            newScene.m_postProcessManager =
                Serialable.DoUnserial((XmlElement)nodePostProcessManager) as PostProcessManager;
            Serialable.EndSupportingDelayBinding();

            // gameObjects
            XmlNode gameObjects = node.SelectSingleNode("GameObjects");

            newScene._gameObjectList = GameObjectList.LoadFromNode(gameObjects, newScene);

            PostLoadScene(newScene);

            return(newScene);
        }