예제 #1
0
파일: Program.cs 프로젝트: xeonixen/CarGame
 static void Main(string[] args)
 {
     Car car = new Car();
     car.Name = "Epa";
     CarTools.SaveCarZip("test.zip", car);
     Car newCar = CarTools.LoadCarZip("test.zip");
     Console.WriteLine("Name: {0}", newCar.Name);
     Console.ReadLine();
 }
예제 #2
0
 public CarController()
 {
     physics = new Car();
     speed = rotation = 0f;
     position = new Vector2(500f, 50f);
     wheel1pos = new Vector2(0f, 0f);
     wheel2pos = new Vector2(0f, 0f);
     wheel1offset = new Vector2(60f, 17.0f);
     wheel2offset = new Vector2(-60f, 17.0f);
     wheelRotation = 0f;
     spring1 = spring2 = 0f;
 }
예제 #3
0
 public static void SaveCarXml(Stream stream, Car carToSave)
 {
     DataContractSerializer ser =
         new DataContractSerializer(typeof(Car));
     ser.WriteObject(stream, carToSave);
 }
예제 #4
0
 public static void SaveCarZip(string filename,Car carToSave)
 {
     Stream fileStream = File.Open(filename, FileMode.Create);
     GZipStream zipStream = new GZipStream(fileStream, CompressionMode.Compress);
     SaveCarXml(zipStream, carToSave);
     zipStream.Close();
     fileStream.Close();
 }
예제 #5
0
 public static void SaveCarXml(string filename, Car carToSave)
 {
     Stream stream = File.Open(filename, FileMode.Append);
     DataContractSerializer ser =
         new DataContractSerializer(typeof(Car));
     ser.WriteObject(stream, carToSave);
     stream.Close();
 }