示例#1
0
        private PersistentObject _LoadPersistentObject(XmlElement PropertyElement)
        {
            PersistentObject Result = null;

            if (PropertyElement.InnerText.Trim().Length > 0)
            {
                var Identifier = _LoadObjectReference(PropertyElement);

                Result = _GameLoader.GetPersistentObject(Identifier);
                if (Result == null)
                {
                    var ObjectElement = _GameLoader.GetObjectElement(Identifier);

                    Result = Activator.CreateInstance(_AssertElementAndGetType(ObjectElement)) as PersistentObject;
                    if (Result == null)
                    {
                        throw new FormatException();
                    }
                    _GameLoader.AddPersistentObject(Identifier, Result);

                    var LoadObjectStore = new LoadObjectStore(_GameLoader, ObjectElement);

                    Result.Load(LoadObjectStore);
                }
            }

            return(Result);
        }
示例#2
0
        public void Load(Game Game)
        {
            try
            {
                var ButtonOfficeElement = _Document.DocumentElement;

                if (ButtonOfficeElement == null)
                {
                    throw new FormatException();
                }
                if (ButtonOfficeElement.Attributes["version"] == null)
                {
                    throw new FormatException();
                }
                if (ButtonOfficeElement.Attributes["version"].Value != Data.SaveGameFileVersion)
                {
                    throw new FormatException($"The save game file version is \"{ButtonOfficeElement.Attributes["version"].Value}\" but should be \"{Data.SaveGameFileVersion}\".");
                }

                var GameElement = ButtonOfficeElement.SelectSingleNode($"//button-office/object[@type='{typeof(Game).AssemblyQualifiedName}']") as XmlElement;
                var ObjectStore = new LoadObjectStore(this, GameElement);

                Game.Load(ObjectStore);
            }
            catch (FormatException Exception)
            {
                throw new GameLoadException(Exception);
            }
        }
示例#3
0
 public override void Load(LoadObjectStore ObjectStore)
 {
     // read these at first, so we can initialize the free space and minimum/maximum per floor
     _HighestFloor = ObjectStore.LoadInt32Property("highest-floor");
     _LeftBorder   = ObjectStore.LoadInt32Property("left-border");
     _LowestFloor  = ObjectStore.LoadInt32Property("lowest-floor");
     _RightBorder  = ObjectStore.LoadInt32Property("right-border");
     _InitializeFreeSpaceAndMinimumMaximum();
     foreach (var BrokenThing in ObjectStore.LoadObjects("broken-things"))
     {
         _BrokenThings.Add(BrokenThing);
     }
     foreach (var Building in ObjectStore.LoadBuildings("buildings"))
     {
         _AddBuilding(Building);
     }
     _CatStock = ObjectStore.LoadUInt32Property("cat-stock");
     _Cents    = ObjectStore.LoadUInt64Property("cents");
     _Minutes  = ObjectStore.LoadDoubleProperty("minutes");
     _NextCatAtNumberOfEmployees = ObjectStore.LoadUInt32Property("next-cat-at-number-of-employees");
     foreach (var Person in ObjectStore.LoadPersons("persons"))
     {
         _AddPerson(Person);
     }
 }
示例#4
0
        public Object LoadProperty(String PropertyName)
        {
            var PropertyElement = _GetPropertyElement(_Element, PropertyName);
            var Result          = Activator.CreateInstance(_AssertElementAndGetType(PropertyElement));

            if (Result is IPersistable)
            {
                var ObjectStore = new LoadObjectStore(_GameLoader, PropertyElement);

                (Result as IPersistable).Load(ObjectStore);
            }
            else if (Result is ObjectReference)
            {
                var Identifier = _LoadObjectReference(PropertyElement);

                Result = _GameLoader.GetPersistentObject(Identifier);
                if (Result == null)
                {
                    var ObjectElement = _GameLoader.GetObjectElement(Identifier);

                    Result = Activator.CreateInstance(_AssertElementAndGetType(ObjectElement));
                    if (Result == null)
                    {
                        throw new FormatException();
                    }
                    _GameLoader.AddPersistentObject(Identifier, Result as PersistentObject);

                    var ObjectStore = new LoadObjectStore(_GameLoader, ObjectElement);

                    (Result as PersistentObject).Load(ObjectStore);
                }
            }

            return(Result);
        }
示例#5
0
 public override void Load(LoadObjectStore ObjectStore)
 {
     base.Load(ObjectStore);
     foreach (var Desk in ObjectStore.LoadDesks("cleaning-targets"))
     {
         _CleaningTargets.Enqueue(Desk);
     }
 }
示例#6
0
 public override void Load(LoadObjectStore ObjectStore)
 {
     base.Load(ObjectStore);
     _Computer   = ObjectStore.LoadComputerProperty("computer");
     _Janitor    = ObjectStore.LoadJanitorProperty("janitor");
     _Office     = ObjectStore.LoadOfficeProperty("office");
     _Person     = ObjectStore.LoadPersonProperty("person");
     _Rectangle  = ObjectStore.LoadRectangleProperty("rectangle");
     _TrashLevel = ObjectStore.LoadDoubleProperty("trash-level");
 }
示例#7
0
 public override void Load(LoadObjectStore ObjectStore)
 {
     base.Load(ObjectStore);
     _Bottom             = ObjectStore.LoadDoubleProperty("bottom");
     _Height             = ObjectStore.LoadDoubleProperty("height");
     _Left               = ObjectStore.LoadDoubleProperty("left");
     _MinutesUntilBroken = ObjectStore.LoadDoubleProperty("minutes-until-broken");
     _Office             = ObjectStore.LoadOfficeProperty("office");
     _Width              = ObjectStore.LoadDoubleProperty("width");
 }
示例#8
0
 public override void Load(LoadObjectStore ObjectStore)
 {
     base.Load(ObjectStore);
     _BackgroundColor = ObjectStore.LoadColorProperty("background-color");
     _BorderColor     = ObjectStore.LoadColorProperty("border-color");
     _Floor           = ObjectStore.LoadDoubleProperty("floor");
     _Height          = ObjectStore.LoadDoubleProperty("height");
     _Left            = ObjectStore.LoadDoubleProperty("left");
     _Width           = ObjectStore.LoadDoubleProperty("width");
 }
示例#9
0
 public override void Load(LoadObjectStore ObjectStore)
 {
     base.Load(ObjectStore);
     _BackgroundColor = ObjectStore.LoadColorProperty("background-color");
     _BorderColor     = ObjectStore.LoadColorProperty("border-color");
     _Height          = ObjectStore.LoadDoubleProperty("height");
     _Office          = ObjectStore.LoadOfficeProperty("office");
     _Width           = ObjectStore.LoadDoubleProperty("width");
     _X = ObjectStore.LoadDoubleProperty("x");
     _Y = ObjectStore.LoadDoubleProperty("y");
 }
示例#10
0
 public override void Load(LoadObjectStore ObjectStore)
 {
     base.Load(ObjectStore);
     Cat        = ObjectStore.LoadCatProperty("cat");
     FirstDesk  = ObjectStore.LoadDeskProperty("first-desk");
     FirstLamp  = ObjectStore.LoadLampProperty("first-lamp");
     FourthDesk = ObjectStore.LoadDeskProperty("fourth-desk");
     SecondDesk = ObjectStore.LoadDeskProperty("second-desk");
     SecondLamp = ObjectStore.LoadLampProperty("second-lamp");
     ThirdDesk  = ObjectStore.LoadDeskProperty("third-desk");
     ThirdLamp  = ObjectStore.LoadLampProperty("third-lamp");
 }
示例#11
0
 public override void Load(LoadObjectStore ObjectStore)
 {
     base.Load(ObjectStore);
     _ActionFraction       = ObjectStore.LoadDoubleProperty("action-fraction");
     _AnimationFraction    = ObjectStore.LoadDoubleProperty("animation-fraction");
     _AnimationState       = ObjectStore.LoadAnimationStateProperty("animation-state");
     _ArrivesAtMinute      = ObjectStore.LoadUInt64Property("arrives-at-minute");
     _ArrivesAtMinuteOfDay = ObjectStore.LoadUInt64Property("arrives-at-minute-of-day");
     _AtDesk          = ObjectStore.LoadBooleanProperty("at-desk");
     _BackgroundColor = ObjectStore.LoadColorProperty("background-color");
     _BorderColor     = ObjectStore.LoadColorProperty("border-color");
     _Desk            = ObjectStore.LoadDeskProperty("desk");
     _Height          = ObjectStore.LoadDoubleProperty("height");
     _LeavesAtMinute  = ObjectStore.LoadUInt64Property("leaves-at-minute");
     _LivingSide      = ObjectStore.LoadLivingSideProperty("living-side");
     _Name            = ObjectStore.LoadStringProperty("name");
     _Wage            = ObjectStore.LoadUInt64Property("wage");
     _Width           = ObjectStore.LoadDoubleProperty("width");
     _WorkMinutes     = ObjectStore.LoadUInt64Property("work-minutes");
     _X = ObjectStore.LoadDoubleProperty("x");
     _Y = ObjectStore.LoadDoubleProperty("y");
 }
示例#12
0
 public void Load(LoadObjectStore ObjectStore)
 {
     X = ObjectStore.LoadDoubleProperty("x");
     X = ObjectStore.LoadDoubleProperty("y");
 }
示例#13
0
 public override void Load(LoadObjectStore ObjectStore)
 {
     base.Load(ObjectStore);
     _BonusPromille = ObjectStore.LoadUInt64Property("bonus-promille");
 }
示例#14
0
 public override void Load(LoadObjectStore ObjectStore)
 {
     base.Load(ObjectStore);
     _RepairingTarget = ObjectStore.LoadObjectProperty("repairing-target");
 }
示例#15
0
 public override void Load(LoadObjectStore ObjectStore)
 {
     base.Load(ObjectStore);
     _MinutesUntilBroken = ObjectStore.LoadDoubleProperty("minutes-until-broken");
     _Rectangle          = ObjectStore.LoadRectangleProperty("rectangle");
 }