public void Load() { string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal); path = Path.Combine(path, "Psuedo3DRacer/Tracks/"); int num = currentTrackLoaded; if (File.Exists(Path.Combine(path, "Track" + num.ToString("000") + ".trk"))) { Track.FileName = "Track" + num.ToString("000") + ".trk"; XmlSerializer xmls = new XmlSerializer(typeof(Track)); using (FileStream stream = new FileStream(Path.Combine(path, Track.FileName), FileMode.Open)) { Track = (Track)xmls.Deserialize(stream); } foreach (string s in Track.PackedSegments) { Segment seg = Segment.FromString(s); Track.TrackSegments.Add(seg); } ControlPoints = Track.ControlPoints; Track.LoadContent(Content); Track.LoadHorizon(Content, parallaxManager); ResetCars(); selectedPoint = 0; currentTrackLoaded++; if (!File.Exists(Path.Combine(path, "Track" + currentTrackLoaded.ToString("000") + ".trk"))) currentTrackLoaded = 0; } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { Camera = new Camera(GraphicsDevice, GraphicsDevice.Viewport); spriteBatch = new SpriteBatch(GraphicsDevice); texGrid = Content.Load<Texture2D>("grid"); texBlank = Content.Load<Texture2D>("blank"); handleSphere = Content.Load<Model>("spherelowpoly"); spriteFont = Content.Load<SpriteFont>("font"); sphereTransforms = new Matrix[handleSphere.Bones.Count]; handleSphere.CopyAbsoluteBoneTransformsTo(sphereTransforms); drawEffect = new BasicEffect(GraphicsDevice) { World = Camera.worldMatrix, View = Camera.viewMatrix, Projection = Camera.projectionMatrix, TextureEnabled = true }; drawAlphaEffect = new AlphaTestEffect(GraphicsDevice) { World = Camera.worldMatrix, View = Camera.viewMatrix, Projection = Camera.projectionMatrix, ReferenceAlpha = 254, AlphaFunction = CompareFunction.Greater }; Track = Track.BuildFromControlPoints(ControlPoints); Track.LoadContent(Content); parallaxManager = new ParallaxManager(GraphicsDevice.Viewport); Track.LoadHorizon(Content, parallaxManager); ResetCars(); //car = new Car(0, Track, Color.Red); //car.LoadContent(Content, 0); }