public objDraw(Model mesh, Texture2D tex, WorldObject parent, Matrix World)
 {
     myParent = parent; myTex = tex; myMesh = mesh; myWorld = World;
 }
示例#2
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// 
 /// Kaushik: The content pipeline in XNA is pretty complicated. Essentially
 /// your files are converted to an easily understood file, which are then
 /// loaded on run-time - this you don't "load" a file as you normally would.
 /// The reason I have my code split into three projects (Content, Library, and
 /// game) is because I need to have references to each of the other ones - if
 /// I did it with two projects, they'd reference each other, and you'd get a
 /// compile error. I can go into more on the content pipeline if you want -
 /// this project won't really be dealing with it too much, except for maybe one
 /// or two things (levels, for example).
 /// 
 /// Also, the way I do loading is a little different than the way XNA does
 /// loading (because it commandeers all the threads to do loading, and so the
 /// game "freezes"). I do it dynamically - so, eventually I'll have a "load manager"
 /// which will watch what files I've loaded, unload some of them, and load
 /// more in - this is sort of a work-around manual garbage collector at a more
 /// abstract level. The load manager is multi-threaded, so I can run a
 /// simple loading screen while it's loading. As such this method isn't really
 /// my "load" function - it loads the bare necessisities, and gets the real
 /// loading process started.
 /// </summary>
 protected override void LoadContent()
 {
     // Create a new SpriteBatch, which can be used to draw textures.
     spriteBatch = new SpriteBatch(GraphicsDevice);
     playerShip.Mesh = LevelLoader.LoadInitially("scuttlebutmk2", "Model") as Model;
     playerShip.MeshTexture = LevelLoader.LoadInitially("simpleShipTex", "Texture2D") as Texture2D;
     playerShip.Initalize();
     LevelMap sampleMap = LevelMap.sampleLevelMap();
     LevelLoader.LoadLevel(sampleMap);
     while (!LevelLoader.HasFinishedLoading()) ;
     for (int i = 0; i < sampleMap.myObjectsWithProperties.GetLength(0); i++)
     {
         switch (sampleMap.myObjectsWithProperties[i][0])
         {
             case "WorldObject":
                 WorldObject newWorldObj = new WorldObject();
                 newWorldObj.Mesh = LevelLoader.loadedAssets[sampleMap.myObjectsWithProperties[i][1]].Value as Model;
                 newWorldObj.MeshTexture = LevelLoader.loadedAssets[sampleMap.myObjectsWithProperties[i][2]].Value as Texture2D;
                 newWorldObj.Initalize();
                 mainGameObjects.Add(newWorldObj);
                 break;
         }
     }
     //WorldObject rock = new WorldObject();
     ////rock.Mesh = Content.Load<Model>("simpleAsteroid");
     //rock.MeshTexture = playerShip.MeshTexture;
     //string loadedType = LevelLoader.loadedAssets["simpleAsteroid"].Key;
     //switch(loadedType)
     //{
     //    case "Model":
     //        rock.Mesh = LevelLoader.loadedAssets["simpleAsteroid"].Value as Model;
     //        break;
     //}
     //rock.Initalize();
     //mainGameObjects.Add(rock);
     // TODO: use this.Content to load your game content here
 }