public void LoadPlayer() { try { Player = new ClassPlayer(); var serializer = new XmlSerializer(typeof(ClassPlayer)); using (var reader = XmlReader.Create(@"..\Resources\Players.xml")) { Player = (ClassPlayer)serializer.Deserialize(reader); } textBox1.Text = Player.FirstName; BestEver1 = Player.BestEver1; BestEver2 = Player.BestEver2; BestEver3 = Player.BestEver3; if (BestEver1 != long.MaxValue) { label14.Text = (BestEver1 / 1000F).ToString(); } if (BestEver2 != long.MaxValue) { label15.Text = (BestEver2 / 1000F).ToString(); } if (BestEver3 != long.MaxValue) { label16.Text = (BestEver3 / 1000F).ToString(); } } catch { } }
public Player(string name, int maxhp, int maxmana, int atk, int def, ClassPlayer classPlayer) : base(name, maxhp, maxmana, atk, def) { Basedef = def; BaseAtk = atk; StaticName = Name; ClassPlayer = classPlayer; IsDead = false; StaticHp = maxhp; StaticMana = maxmana; StaticMaxMana = maxmana; StaticMaxHp = maxhp; }