public void Serialize(UserItems user) { FileStream fs = new FileStream("user.xml", FileMode.Create, FileAccess.Write); XmlSerializer xml = new XmlSerializer(typeof(UserItems)); xml.Serialize(fs, user); fs.Close(); }
public void DeSerialize(UserItems user) { FileStream fs = new FileStream("user.xml", FileMode.Open, FileAccess.Read); XmlSerializer xml = new XmlSerializer(typeof(UserItems)); user = xml.Deserialize(fs) as UserItems; fs.Close(); }
static void Main(string[] args) { Console.Title = "SNAKE FOR PP2"; Console.WriteLine("Enter your name:"); string username = Console.ReadLine(); UserItems user = new UserItems(username, 0); Console.CursorVisible = false; Game game = new Game(user); game.Start(); }
public Game(UserItems user) { this.user = user; g_objects = new List <GameObject>(); snake = new Snake(20, 20, "(", ConsoleColor.White); food = new Food(0, 0, "@", ConsoleColor.Red); wall = new Wall("#", ConsoleColor.Green); wall.LoadLevel(); while (food.IsCollisionwithObject(snake) || food.IsCollisionwithObject(wall)) { food.Generate(); } g_objects.Add(snake); g_objects.Add(food); g_objects.Add(wall); isAlive = true; }