Example #1
0
        public Data()
        {
            Inventory = new ObservableCollection <Object>();

            if (File.Exists(@"GameMaster3000Money.txt") && File.ReadAllText(@"GameMaster3000Money.txt") != string.Empty)
            {
                Money = new money(int.Parse(File.ReadAllText(@"GameMaster3000Money.txt")));
            }
            else
            {
                Money = new money(0);
            }
            List <Type> types = new List <Type>
            {
                typeof(Object),
                typeof(Armor),
                typeof(Weapon)
            };

            if (File.Exists(@"GameMaster3000Inventory.txt"))
            {
                XmlSerializer xmlFormat = new XmlSerializer(Inventory.GetType(), types.ToArray());
                Stream        fStream   = new FileStream(path, FileMode.Open, FileAccess.Read);
                Inventory = (xmlFormat.Deserialize(fStream) as ObservableCollection <Object>);
                fStream.Close();
            }
            else
            {
                Inventory = new ObservableCollection <Object>();
            }
        }
Example #2
0
 internal void Repair(money m, int cost)
 {
     if (MaxStrength > Strength && m.Money - cost >= 0)
     {
         Strength++;
         m.Money -= cost;
     }
 }