Exemple #1
0
        void IXleSerializable.WriteData(XleSerializationInfo info)
        {
            if (EntryPoints == null)
            {
                EntryPoints = new List <EntryPoint>();
            }
            while (EntryPoints.Count > 0 && EntryPoints.Last().Location == Point.Zero)
            {
                EntryPoints.RemoveAt(EntryPoints.Count - 1);
            }

            info.Write("MapName", mMapName);
            info.Write("ExtenderName", ExtenderName);

            info.Write("MapID", mMapID);
            info.Write("TileSet", mTileSet);
            info.Write("TileImage", mTileImage);
            info.Write("OutsideTile", mOutsideTile);
            info.Write("Events", mEvents.ToArray());
            info.Write("EntryPoints", EntryPoints);

            if (HasRoofs)
            {
                info.Write("Roofs", Roofs);
            }
            if (HasGuards)
            {
                info.Write("Guards", Guards);
            }

            WriteData(info);
        }
Exemple #2
0
        protected override void ReadData(XleSerializationInfo info)
        {
            mWidth  = info.ReadInt32("Width");
            mHeight = info.ReadInt32("Height");

            mData = info.ReadInt32Array("MapData");
        }
 public override void Serialize(XleSerializationInfo info, RectangleF value)
 {
     info.Write("X", value.X, true);
     info.Write("Y", value.Y, true);
     info.Write("Width", value.Width, true);
     info.Write("Height", value.Height, true);
 }
Exemple #4
0
        void IXleSerializable.WriteData(XleSerializationInfo info)
        {
            List <TileInfo> tiles = new List <TileInfo>();

            if (mTiles.Count == 0)
            {
                info.Write("Tiles", new int[] { });
            }
            else
            {
                tiles.Capacity = mTiles.Keys.Max() + 1;
                for (int i = 0; i < mTiles.Keys.Max() + 1; i++)
                {
                    tiles.Add(TileInfo.Normal);
                }

                foreach (int key in mTiles.Keys)
                {
                    tiles[key] = mTiles[key];
                }

                info.Write("Tiles", tiles.Select(x => (int)x).ToArray(), NumericEncoding.Csv);
            }
            info.Write("TileGroups", TileGroups);
        }
Exemple #5
0
 protected override void ReadData(XleSerializationInfo info)
 {
     MapID            = info.ReadInt32("MapID");
     mAsk             = info.ReadBoolean("AskUser");
     TargetEntryPoint = info.ReadInt32("TargetEntryPoint");
     mCommandText     = info.ReadString("CommandText", "");
 }
 public override RectangleF Deserialize(XleSerializationInfo info)
 {
     return(new RectangleF(
                info.ReadFloat("X"),
                info.ReadFloat("Y"),
                info.ReadFloat("Width"),
                info.ReadFloat("Height")));
 }
Exemple #7
0
        protected override void ReadData(XleSerializationInfo info)
        {
            base.ReadData(info);

            mBuyRaftMap  = info.ReadInt32("BuyRaftMap", 0);
            mBuyRaftPt.X = info.ReadInt32("BuyRaftX", 0);
            mBuyRaftPt.Y = info.ReadInt32("BuyRaftY", 0);
        }
Exemple #8
0
        protected override void WriteData(XleSerializationInfo info)
        {
            base.WriteData(info);

            info.Write("BuyRaftMap", mBuyRaftMap);
            info.Write("BuyRaftX", mBuyRaftPt.X);
            info.Write("BuyRaftY", mBuyRaftPt.Y);
        }
Exemple #9
0
 public override Point Deserialize(XleSerializationInfo info)
 {
     return(new Point()
     {
         X = info.ReadInt32("X"),
         Y = info.ReadInt32("Y"),
     });
 }
Exemple #10
0
 public override Vector2 Deserialize(XleSerializationInfo info)
 {
     return(new Vector2()
     {
         X = info.ReadFloat("X"),
         Y = info.ReadFloat("Y"),
     });
 }
Exemple #11
0
 void IXleSerializable.WriteData(XleSerializationInfo info)
 {
     info.Write("GuardDefaultAttack", DefaultAttack);
     info.Write("GuardDefaultDefense", DefaultDefense);
     info.Write("GuardDefaultHP", DefaultHP);
     info.Write("GuardDefaultColor", DefaultColor.ToArgb());
     info.Write("Guards", mGuards);
 }
Exemple #12
0
 void IXleSerializable.WriteData(XleSerializationInfo info)
 {
     info.Write("Tiles", Tiles.ToArray(), NumericEncoding.Csv);
     info.Write("AnimationTime", AnimationTime);
     info.WriteEnum("AnimationType", AnimationType, false);
     info.WriteEnum("GroupType", GroupType, false);
     info.Write("AnimateChance", AnimateChance);
 }
Exemple #13
0
        /// <summary>
        /// Deserializes an object from the XML data in the specified stream.
        /// </summary>
        /// <param name="inStream">The stream containing the XML data.</param>
        /// <returns>The deserialized object.</returns>
        public object Deserialize(Stream inStream)
        {
            XDocument doc = XDocument.Load(XmlReader.Create(inStream));

            XleSerializationInfo info = new XleSerializationInfo(Binder, TypeSerializers, doc);

            return(info.BeginDeserialize());
        }
Exemple #14
0
 void IXleSerializable.WriteData(XleSerializationInfo info)
 {
     info.Write("X", X);
     info.Write("Y", Y);
     info.Write("Width", Width);
     info.Write("Height", Height);
     info.Write("RoofData", mData, NumericEncoding.Csv);
 }
Exemple #15
0
 void IXleSerializable.ReadData(XleSerializationInfo info)
 {
     Tiles         = info.ReadList <int>("Tiles");
     AnimationType = info.ReadEnum <AnimationType>("AnimationType", Maps.AnimationType.Random);
     AnimationTime = info.ReadInt32("AnimationTime", 50);
     GroupType     = info.ReadEnum <GroupType>("GroupType", Maps.GroupType.None);
     AnimateChance = info.ReadInt32("AnimateChance", 100);
 }
Exemple #16
0
 public override Size Deserialize(XleSerializationInfo info)
 {
     return(new Size()
     {
         Width = info.ReadInt32("Width"),
         Height = info.ReadInt32("Height"),
     });
 }
Exemple #17
0
 void IXleSerializable.ReadData(XleSerializationInfo info)
 {
     mRect.X      = info.ReadInt32("X");
     mRect.Y      = info.ReadInt32("Y");
     mRect.Width  = info.ReadInt32("Width");
     mRect.Height = info.ReadInt32("Height");
     mData        = info.ReadInt32Array("RoofData");
 }
Exemple #18
0
        protected override void WriteData(XleSerializationInfo info)
        {
            base.WriteData(info);

            info.Write("MapID", MapID);
            info.Write("AskUser", mAsk);
            info.Write("TargetEntryPoint", TargetEntryPoint);
            info.Write("CommandText", mCommandText);
        }
Exemple #19
0
        void IXleSerializable.WriteData(XleSerializationInfo info)
        {
            info.Write("X", rect.X);
            info.Write("Y", rect.Y);
            info.Write("Width", rect.Width);
            info.Write("Height", rect.Height);
            info.Write("ExtenderName", ExtenderName);

            WriteData(info);
        }
Exemple #20
0
        void IXleSerializable.WriteData(XleSerializationInfo info)
        {
            info.Write("X", X);
            info.Write("Y", Y);
            info.Write("Color", Color.ToArgb());

            info.Write("HP", HP);
            info.Write("Attack", Attack);
            info.Write("Defense", Defense);
        }
Exemple #21
0
        void IXleSerializable.ReadData(XleSerializationInfo info)
        {
            X     = info.ReadInt32("X");
            Y     = info.ReadInt32("Y");
            Color = ColorX.FromArgb(info.ReadInt32("Color").ToString("X8"));

            HP      = info.ReadInt32("HP");
            Attack  = info.ReadInt32("Attack");
            Defense = info.ReadInt32("Defense");
        }
Exemple #22
0
 protected override void ReadData(XleSerializationInfo info)
 {
     mWidth             = info.ReadInt32("Width");
     mHeight            = info.ReadInt32("Height");
     mLevels            = info.ReadInt32("Levels");
     mData              = info.ReadArray <int>("Data");
     MaxMonsters        = info.ReadInt32("MaxMonsters");
     MonsterHealthScale = info.ReadInt32("MonsterHealthScale");
     MonsterDamageScale = info.ReadInt32("MonsterDamageScale");
 }
Exemple #23
0
 protected override void WriteData(XleSerializationInfo info)
 {
     info.Write("Width", mWidth, true);
     info.Write("Height", mHeight, true);
     info.Write("Levels", mLevels, true);
     info.Write("Data", mData, NumericEncoding.Csv);
     info.Write("MaxMonsters", MaxMonsters);
     info.Write("MonsterHealthScale", MonsterHealthScale);
     info.Write("MonsterDamageScale", MonsterDamageScale);
 }
Exemple #24
0
        void IXleSerializable.ReadData(XleSerializationInfo info)
        {
            mGuards        = info.ReadList <Guard>("Guards");
            DefaultAttack  = info.ReadInt32("GuardDefaultAttack");
            DefaultColor   = ColorX.FromArgb(info.ReadInt32("GuardDefaultColor").ToString("X8"));
            DefaultDefense = info.ReadInt32("GuardDefaultDefense");
            DefaultHP      = info.ReadInt32("GuardDefaultHP");

            InitializeGuardData();
        }
Exemple #25
0
        void IXleSerializable.ReadData(XleSerializationInfo info)
        {
            Cheater = info.ReadBoolean("Cheater", false);

            mAttributes = (AttributeContainer)info.ReadObject("Attributes");
            food        = info.ReadDouble("Food");
            gold        = info.ReadInt32("Gold");
            goldBank    = info.ReadInt32("GoldInBank");
            timedays    = info.ReadDouble("TimeDays");
            timequality = info.ReadDouble("TimeQuality");

            onRaft = info.ReadInt32("OnRaft");
            rafts  = info.ReadList <RaftData>("Rafts");

            gamespeed     = info.ReadInt32("GameSpeed");
            map           = info.ReadInt32("Map");
            lastMap       = info.ReadInt32("LastMap");
            dungeon       = info.ReadInt32("Dungeon");
            hp            = info.ReadInt32("HP");
            level         = info.ReadInt32("Level");
            returnMap     = info.ReadInt32("ReturnMap");
            returnX       = info.ReadInt32("ReturnX");
            returnY       = info.ReadInt32("ReturnY");
            returnFacing  = info.ReadEnum <Direction>("ReturnFacing");
            x             = info.ReadInt32("X");
            y             = info.ReadInt32("Y");
            dungeonLevel  = info.ReadInt32("DungeonLevel");
            faceDirection = (Direction)info.ReadInt32("Facing");

            weapons = info.ReadList <WeaponItem>("Weapons");
            armor   = info.ReadList <ArmorItem>("Armor");

            currentArmorIndex  = info.ReadInt32("CurrentArmorIndex");
            currentWeaponIndex = info.ReadInt32("CurrentWeaponIndex");

            mItems = info.ReadObject <ItemContainer>("Item");
            hold   = info.ReadInt32("Hold");

            lastAttacked = info.ReadInt32("LastAttacked");
            VaultGold    = info.ReadInt32("VaultGold");

            chests = info.ReadArray <int>("Chests");

            loan    = info.ReadInt32("Loan");               // loan amount
            dueDate = info.ReadInt32("DueDate");            // time in days that the money is due

            mailTown = info.ReadInt32("MailTown");

            mName = info.ReadString("Name");

            StoryData = info.ReadObject <IXleSerializable>("StoryData");

            RenderColor = XleColor.White;
        }
Exemple #26
0
        void IXleSerializable.ReadData(XleSerializationInfo info)
        {
            rect.X       = info.ReadInt32("X");
            rect.Y       = info.ReadInt32("Y");
            rect.Width   = info.ReadInt32("Width");
            rect.Height  = info.ReadInt32("Height");
            ExtenderName = info.ReadString("ExtenderName", "");

            ReadData(info);

            AfterReadData();
        }
Exemple #27
0
        void IXleSerializable.WriteData(XleSerializationInfo info)
        {
            if (Cheater)
            {
                info.Write("Cheater", Cheater);
            }

            info.Write("Attributes", mAttributes);
            info.Write("Food", food);
            info.Write("Gold", gold);
            info.Write("GoldInBank", goldBank);
            info.Write("TimeDays", timedays);
            info.Write("TimeQuality", timequality);

            info.Write("OnRaft", onRaft);
            info.Write("Rafts", rafts);

            info.Write("GameSpeed", gamespeed);
            info.Write("Map", map);
            info.Write("LastMap", lastMap);
            info.Write("Dungeon", dungeon);
            info.Write("HP", hp);
            info.Write("Level", level);
            info.Write("ReturnMap", returnMap);
            info.Write("ReturnX", returnX);
            info.Write("ReturnY", returnY);
            info.WriteEnum <Direction>("ReturnFacing", returnFacing, false);
            info.Write("X", x);
            info.Write("Y", y);
            info.Write("DungeonLevel", dungeonLevel);
            info.Write("Facing", (int)faceDirection);

            info.Write("CurrentArmorIndex", currentArmorIndex);
            info.Write("CurrentWeaponIndex", currentWeaponIndex);
            info.Write("Weapons", Weapons);
            info.Write("Armor", Armor);

            info.Write("Item", Items);
            info.Write("Hold", hold);

            info.Write("LastAttacked", lastAttacked);
            info.Write("VaultGold", VaultGold);

            info.Write("Chests", chests);

            info.Write("Loan", loan);                   // loan amount
            info.Write("DueDate", dueDate);             // time in days that the money is due

            info.Write("MailTown", mailTown);

            info.Write("Name", mName);
            info.Write("StoryData", StoryData);
        }
Exemple #28
0
        /// <summary>
        /// Serializes an object which implements IXleSerializable to the specified stream.
        /// </summary>
        /// <param name="outStream">The stream to write the XML data to.</param>
        /// <param name="objectGraph">The object to serialize.</param>
        public void Serialize(Stream outStream, IXleSerializable objectGraph)
        {
            if (objectType.GetTypeInfo().IsAssignableFrom(objectGraph.GetType().GetTypeInfo()) == false)
            {
                throw new ArgumentException("Object is not of type " + objectType.Name);
            }

            XleSerializationInfo info = new XleSerializationInfo(Binder, TypeSerializers);

            info.BeginSerialize(objectGraph);

            info.XmlDoc.Save(outStream);
        }
Exemple #29
0
        void IXleSerializable.ReadData(XleSerializationInfo info)
        {
            mMapName = info.ReadString("MapName");
            mMapID   = info.ReadInt32("MapID");

            ExtenderName = info.ReadString("ExtenderName", "");

            if (info.ContainsKey("EntryPoints"))
            {
                EntryPoints = info.ReadList <EntryPoint>("EntryPoints");
            }
            if (info.ContainsKey("Tileset"))
            {
                mTileImage = info.ReadString("Tileset");
            }
            else
            {
                mTileImage = info.ReadString("TileImage");
                mTileSet   = info.ReadObject <TileSet>("TileSet");
            }

            var defaultTile = info.ReadInt32("DefaultTile", 0);

            mOutsideTile = info.ReadInt32("OutsideTile", 0);

            if (mOutsideTile == 0)
            {
                mOutsideTile = defaultTile;
            }

            mEvents.AddRange(info.ReadArray <XleEvent>("Events"));

            if (info.ContainsKey("Roofs"))
            {
                Roofs = info.ReadList <Roof>("Roofs");
            }
            if (info.ContainsKey("Guards"))
            {
                Guards = info.ReadObject <GuardList>("Guards");
            }

            // read events
            ReadData(info);

            SetChestIDs();
        }
Exemple #30
0
        void IXleSerializable.ReadData(XleSerializationInfo info)
        {
            int[] tiles = info.ReadArray <int>("Tiles");

            for (int i = 0; i < tiles.Length; i++)
            {
                mTiles[i] = (TileInfo)tiles[i];
            }

            if (info.ContainsKey("TileGroups"))
            {
                TileGroups = info.ReadList <TileGroup>("TileGroups");
            }

            if (TileGroups == null)
            {
                TileGroups = new List <TileGroup>();
            }
        }