Exemplo n.º 1
0
        public static Playerdata CreateNewPlayer(string name, int xp)
        {
            Playerdata player = new Playerdata();

            player.PlayerName = name; Console.WriteLine("Name: " + name);
            player.PlayerXP   = xp; Console.WriteLine("XP: " + xp.ToString());

            return(player);
        }
Exemplo n.º 2
0
        public static void SavePlayer(Playerdata playertosave)
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Create(@"C:\Users\lharrison\Desktop\" + playertosave.PlayerName + ".plyr");

            bf.Serialize(file, playertosave);
            file.Close();
            Console.WriteLine("File Saved");
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Playerdata newplayer = CreateNewPlayer("Talon Chaar", 9001);

            SavePlayer(newplayer);
            LoadPlayer("Talon Chaar");

            Console.WriteLine("Debug stop");
        }
Exemplo n.º 4
0
        public static void LoadPlayer(string playername)
        {
            if (File.Exists(@"C:\Users\lharrison\Desktop\" + playername + ".plyr"))
            {
                BinaryFormatter bf         = new BinaryFormatter();
                FileStream      file       = File.Open(@"C:\Users\lharrison\Desktop\" + playername + ".plyr", FileMode.Open);
                Playerdata      playerdata = (Playerdata)bf.Deserialize(file);
                file.Close();

                Console.WriteLine("File read");
                Console.WriteLine("Read name: " + playerdata.PlayerName);
                Console.WriteLine("Read XP: " + playerdata.PlayerXP.ToString());
            }
        }