internal OgmoTileLayerSettings(ContentReader reader)
     : base(reader)
 {
     this.ExportTileIDs = reader.ReadBoolean();
     this.ExportTileSize = reader.ReadBoolean();
     this.MultipleTilesets = reader.ReadBoolean();
 }
예제 #2
0
        protected internal override SpriteFont Read(
            ContentReader input,
            SpriteFont existingInstance
            )
        {
            if (existingInstance != null)
            {
                // Read the texture into the existing texture instance
                input.ReadObject <Texture2D>(existingInstance.textureValue);

                /* Discard the rest of the SpriteFont data as we are only
                 * reloading GPU resources for now
                 */
                input.ReadObject <List <Rectangle> >();
                input.ReadObject <List <Rectangle> >();
                input.ReadObject <List <char> >();
                input.ReadInt32();
                input.ReadSingle();
                input.ReadObject <List <Vector3> >();
                if (input.ReadBoolean())
                {
                    input.ReadChar();
                }
                return(existingInstance);
            }
            else
            {
                // Create a fresh SpriteFont instance
                Texture2D        texture        = input.ReadObject <Texture2D>();
                List <Rectangle> glyphs         = input.ReadObject <List <Rectangle> >();
                List <Rectangle> cropping       = input.ReadObject <List <Rectangle> >();
                List <char>      charMap        = input.ReadObject <List <char> >();
                int            lineSpacing      = input.ReadInt32();
                float          spacing          = input.ReadSingle();
                List <Vector3> kerning          = input.ReadObject <List <Vector3> >();
                char?          defaultCharacter = null;
                if (input.ReadBoolean())
                {
                    defaultCharacter = new char?(input.ReadChar());
                }
                return(new SpriteFont(
                           texture,
                           glyphs,
                           cropping,
                           charMap,
                           lineSpacing,
                           spacing,
                           kerning,
                           defaultCharacter
                           ));
            }
        }
예제 #3
0
        protected internal override IndexBuffer Read(
            ContentReader input,
            IndexBuffer existingInstance
            )
        {
            IndexBuffer indexBuffer = existingInstance;
            bool        sixteenBits = input.ReadBoolean();
            int         dataSize    = input.ReadInt32();

            byte[] data = input.ReadBytes(dataSize);
            if (indexBuffer == null)
            {
                if (sixteenBits)
                {
                    indexBuffer = new IndexBuffer(
                        input.GraphicsDevice,
                        IndexElementSize.SixteenBits,
                        dataSize / 2,
                        BufferUsage.None
                        );
                }
                else
                {
                    indexBuffer = new IndexBuffer(
                        input.GraphicsDevice,
                        IndexElementSize.ThirtyTwoBits,
                        dataSize / 4,
                        BufferUsage.None
                        );
                }
            }

            indexBuffer.SetData(data);
            return(indexBuffer);
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the Tower class.
        /// </summary>
        /// <param name="reader">The Content Reader for Castle XML Files</param>
        public Tower(ContentReader reader)
        {
            id = reader.ReadInt32();
              hasCannon = reader.ReadBoolean();
              var position = reader.ReadObject<Vector2>();
              x = (int)position.X;
              y = (int)position.Y;
              height = reader.ReadSingle();
              corners = reader.ReadInt32();
              radius = reader.ReadSingle();
              coverRadius = reader.ReadSingle();
              coverHeight = reader.ReadSingle();
              viewDirection = new Vector3(x, coverHeight + 2, y + 1);

              wallTexture = reader.ReadExternalReference<Texture2D>();
              coverTexture = reader.ReadExternalReference<Texture2D>();

              ////InitTowerGraphics();

              if (HasCannon)
              {
            hasCannon = true;
            cannon = new Cannon(X, coverHeight, Y, null);
              }
        }
예제 #5
0
 protected internal override T?Read(ContentReader input, T?existingInstance)
 {
     if (input.ReadBoolean())
     {
         return(input.ReadObject <T>(elementReader));
     }
     return(null);
 }
예제 #6
0
 protected internal override DualTextureEffect Read(ContentReader input, DualTextureEffect existingInstance)
 {
     return(new DualTextureEffect(input.GraphicsDevice)
     {
         Texture = input.ReadExternalReference <Texture>() as Texture2D,
         Texture2 = input.ReadExternalReference <Texture>() as Texture2D,
         DiffuseColor = input.ReadVector3(),
         Alpha = input.ReadSingle(),
         VertexColorEnabled = input.ReadBoolean()
     });
 }
예제 #7
0
 public static void DeveloperID(ref Dictionary<string, object> devTypes, ContentReader reader, object obj)
 {
     if (reader.ReadBoolean())
     {
         string key = reader.ReadString();
         if (devTypes != null)
         {
             devTypes.Add(key, obj);
         }
     }
 }
예제 #8
0
        protected internal override IndexBuffer Read(ContentReader input, IndexBuffer existingInstance)
        {
            bool flag  = input.ReadBoolean();
            int  count = input.ReadInt32();

            byte[]      data        = input.ReadBytes(count);
            IndexBuffer indexBuffer = new IndexBuffer(input.GraphicsDevice, flag ? IndexElementSize.SixteenBits : IndexElementSize.ThirtyTwoBits, count / (flag ? 2 : 4), BufferUsage.None);

            indexBuffer.SetData <byte>(data);
            return(indexBuffer);
        }
예제 #9
0
        protected internal override DualTextureEffect Read(ContentReader input, DualTextureEffect existingInstance)
        {
            DualTextureEffect effect = new DualTextureEffect(input.GetGraphicsDevice());

            effect.Texture            = input.ReadExternalReference <Texture>() as Texture2D;
            effect.Texture2           = input.ReadExternalReference <Texture>() as Texture2D;
            effect.DiffuseColor       = input.ReadVector3();
            effect.Alpha              = input.ReadSingle();
            effect.VertexColorEnabled = input.ReadBoolean();
            return(effect);
        }
예제 #10
0
 protected internal override T?Read(ContentReader input, T?existingInstance)
 {
     if (input.ReadBoolean())
     {
         return(new T?(input.ReadObject <T>(this.elementReader)));
     }
     else
     {
         return(new T?());
     }
 }
예제 #11
0
        internal Layer(ContentReader reader)
        {
            ScaleX = 1f;
            ScaleY = 1f;

            Id = reader.ReadInt16();
            Name = reader.ReadString();
            Visible = reader.ReadBoolean();
            Opacity = reader.ReadSingle();
            Properties = new PropertyCollection(reader);
        }
예제 #12
0
        protected internal override AlphaTestEffect Read(ContentReader input, AlphaTestEffect existingInstance)
        {
            var effect = new AlphaTestEffect(input.GraphicsDevice);

            effect.Texture            = input.ReadExternalReference <Texture>() as Texture2D;
            effect.AlphaFunction      = (CompareFunction)input.ReadInt32();
            effect.DiffuseColor       = input.ReadVector3();
            effect.Alpha              = input.ReadSingle();
            effect.VertexColorEnabled = input.ReadBoolean();
            return(effect);
        }
예제 #13
0
 protected internal override AlphaTestEffect Read(ContentReader input, AlphaTestEffect existingInstance)
 {
     return(new AlphaTestEffect(input.GraphicsDevice)
     {
         Texture = input.ReadExternalReference <Texture>() as Texture2D,
         AlphaFunction = (CompareFunction)input.ReadInt32(),
         ReferenceAlpha = (int)input.ReadUInt32(),
         DiffuseColor = input.ReadVector3(),
         Alpha = input.ReadSingle(),
         VertexColorEnabled = input.ReadBoolean()
     });
 }
        protected internal override IndexBuffer Read(ContentReader input, IndexBuffer existingInstance)
        {
            var sixteenBits = input.ReadBoolean();
            var dataSize    = input.ReadInt32();
            var data        = input.ReadBytes(dataSize);

            var buffer = new IndexBuffer(input.GraphicsDevice,
                                         sixteenBits ? IndexElementSize.SixteenBits : IndexElementSize.ThirtyTwoBits,
                                         dataSize / (sixteenBits ? 2 : 4), BufferUsage.None);

            buffer.SetData(data);
            return(buffer);
        }
예제 #15
0
        protected internal override BasicEffect Read(ContentReader input, BasicEffect existingInstance)
        {
            BasicEffect basicEffect = new BasicEffect(input.GraphicsDevice);
            Texture2D   texture2D   = input.ReadExternalReference <Texture>() as Texture2D;

            if (texture2D != null)
            {
                basicEffect.Texture        = texture2D;
                basicEffect.TextureEnabled = true;
            }
            basicEffect.DiffuseColor       = input.ReadVector3();
            basicEffect.EmissiveColor      = input.ReadVector3();
            basicEffect.SpecularColor      = input.ReadVector3();
            basicEffect.SpecularPower      = input.ReadSingle();
            basicEffect.Alpha              = input.ReadSingle();
            basicEffect.VertexColorEnabled = input.ReadBoolean();
            return(basicEffect);
        }
예제 #16
0
        protected internal override SpriteFont Read(ContentReader input, SpriteFont existingInstance)
        {
            Texture2D texture = input.ReadObject <Texture2D>();

            texture.IsSpriteFontTexture = true;
            List <Rectangle> glyphs         = input.ReadObject <List <Rectangle> >();
            List <Rectangle> cropping       = input.ReadObject <List <Rectangle> >();
            List <char>      charMap        = input.ReadObject <List <char> >();
            int            lineSpacing      = input.ReadInt32();
            float          spacing          = input.ReadSingle();
            List <Vector3> kerning          = input.ReadObject <List <Vector3> >();
            char?          defaultCharacter = null;

            if (input.ReadBoolean())
            {
                defaultCharacter = new char?(input.ReadChar());
            }
            return(new SpriteFont(texture, glyphs, cropping, charMap, lineSpacing, spacing, kerning, defaultCharacter));
        }
        protected internal override IndexBuffer Read(ContentReader input, IndexBuffer existingInstance)
        {
            IndexBuffer indexBuffer = existingInstance;

            bool sixteenBits = input.ReadBoolean();
            int  dataSize    = input.ReadInt32();

            byte[] data = input.ContentManager.GetScratchBuffer(dataSize);
            input.Read(data, 0, dataSize);

            if (indexBuffer == null)
            {
                indexBuffer = new IndexBuffer(input.GraphicsDevice,
                                              sixteenBits ? IndexElementSize.SixteenBits : IndexElementSize.ThirtyTwoBits,
                                              dataSize / (sixteenBits ? 2 : 4), BufferUsage.None);
            }

            indexBuffer.SetData(data, 0, dataSize);
            return(indexBuffer);
        }
예제 #18
0
        internal ObjectPool(ContentReader reader)
            : this()
        {
            _manager = reader.ContentManager;

            //int version = reader.ReadInt16();
            int id = reader.ReadInt32();
            string texAsset = reader.ReadString();

            Properties = new PropertyCollection(reader);

            int objCount = reader.ReadInt32();
            for (int i = 0; i < objCount; i++) {
                int objId = reader.ReadInt32();
                string name = reader.ReadString();

                ObjectClass objClass = new ObjectClass(this, objId, name) {
                    Origin = new Point(reader.ReadInt32(), reader.ReadInt32()),
                    MaskBounds = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()),
                    TexRotated = reader.ReadBoolean(),
                    TexX = reader.ReadInt32(),
                    TexY = reader.ReadInt32(),
                    TexWidth = reader.ReadInt32(),
                    TexHeight = reader.ReadInt32(),
                    TexOriginalWidth = reader.ReadInt32(),
                    TexOriginalHeight = reader.ReadInt32(),
                    TexOffsetX = reader.ReadInt32(),
                    TexOffsetY = reader.ReadInt32(),
                    Properties = new PropertyCollection(reader),
                };

                _objects.Add(objId, objClass);
            }

            _texture = _manager.Load<Texture2D>(texAsset);
        }
 internal OgmoGridLayerSettings(ContentReader reader)
     : base(reader)
 {
     this.ExportAsObjects = reader.ReadBoolean();
     this.NewLine = reader.ReadString();
 }
예제 #20
0
        internal static SkinnedModelBasicEffect Read(ContentReader input)
        {
            Effect effect = input.ReadObject<Effect>();

            SkinnedModelBasicEffect basicEffect = new SkinnedModelBasicEffect(effect);

            basicEffect.material.EmissiveColor = input.ReadVector3();
            basicEffect.material.DiffuseColor = input.ReadVector3();
            basicEffect.material.SpecularColor = input.ReadVector3();
            basicEffect.material.SpecularPower = input.ReadSingle();

            basicEffect.DiffuseMapEnabled = input.ReadBoolean();
            basicEffect.NormalMapEnabled = input.ReadBoolean();
            basicEffect.SpecularMapEnabled = input.ReadBoolean();

            basicEffect.DiffuseMap = input.ReadExternalReference<Texture2D>();
            basicEffect.NormalMap = input.ReadExternalReference<Texture2D>();
            basicEffect.SpecularMap = input.ReadExternalReference<Texture2D>();

            basicEffect.lightEnabled = false;
            basicEffect.enabledLights = EnabledLights.One;

            return basicEffect;
        }
        internal static SkinnedModelBasicEffect Read(ContentReader input)
        {
            IGraphicsDeviceService graphicsDeviceService = (IGraphicsDeviceService)
                    input.ContentManager.ServiceProvider.GetService(typeof(IGraphicsDeviceService));

            GraphicsDevice graphicsDevice = graphicsDeviceService.GraphicsDevice;
            SkinnedModelBasicEffect basicEffect = new SkinnedModelBasicEffect(graphicsDevice,
                (EffectPool)null);

            basicEffect.material.EmissiveColor = input.ReadVector3();
            basicEffect.material.DiffuseColor = input.ReadVector3();
            basicEffect.material.SpecularColor = input.ReadVector3();
            basicEffect.material.SpecularPower = input.ReadSingle();

            basicEffect.DiffuseMapEnabled = input.ReadBoolean();
            basicEffect.NormalMapEnabled = input.ReadBoolean();
            basicEffect.SpecularMapEnabled = input.ReadBoolean();
            basicEffect.DiffuseMap = input.ReadObject<Texture2D>(); ;
            basicEffect.NormalMap = input.ReadObject<Texture2D>(); ;
            basicEffect.SpecularMap = input.ReadObject<Texture2D>(); ;

            basicEffect.lightEnabled = false;
            basicEffect.enabledLights = EnabledLights.One;

            return basicEffect;
        }
        internal static SkinnedModelBasicEffect Read(ContentReader input)
        {
            IGraphicsDeviceService graphicsDeviceService = (IGraphicsDeviceService)
                    input.ContentManager.ServiceProvider.GetService(typeof(IGraphicsDeviceService));

            GraphicsDevice graphicsDevice = graphicsDeviceService.GraphicsDevice;

            //ResourceContentManager cnt = new ResourceContentManager(input.ContentManager.ServiceProvider, Resource1.ResourceManager);            z
#if WINDOWS           
            SkinnedModelBasicEffect basicEffect = new SkinnedModelBasicEffect(graphicsDevice, Resource1.SkinnedModelEffect);
#else
            SkinnedModelBasicEffect basicEffect = new SkinnedModelBasicEffect(graphicsDevice, Resource1.SkinnedModelEffect2);
#endif
            

            input.ReadVector3();
            input.ReadVector3();
            input.ReadVector3();
            input.ReadSingle();

            basicEffect.DiffuseMapEnabled = input.ReadBoolean();
            basicEffect.NormalMapEnabled = input.ReadBoolean();
            basicEffect.SpecularMapEnabled = input.ReadBoolean();
            basicEffect.DiffuseMap = input.ReadObject<Texture2D>(); ;
            basicEffect.NormalMap = input.ReadObject<Texture2D>(); ;
            basicEffect.SpecularMap = input.ReadObject<Texture2D>(); ;            

            return basicEffect;
        }
        internal static SkinnedEffect Read(ContentReader input)
        {
            IGraphicsDeviceService graphicsDeviceService = (IGraphicsDeviceService)
                    input.ContentManager.ServiceProvider.GetService(typeof(IGraphicsDeviceService));

            GraphicsDevice graphicsDevice = graphicsDeviceService.GraphicsDevice;

            SkinnedEffect basicEffect = new SkinnedEffect(graphicsDevice);


            input.ReadVector3();
            input.ReadVector3();
            input.ReadVector3();
            input.ReadSingle();

            input.ReadBoolean();
            input.ReadBoolean();
            input.ReadBoolean();
            input.ReadObject<Texture2D>(); 
            input.ReadObject<Texture2D>(); 
            input.ReadObject<Texture2D>(); 

            return basicEffect;
        }
예제 #24
0
파일: Map.cs 프로젝트: GarethIW/LDEngine
        internal Map(ContentReader reader)
        {
            // read in the basic map information
            Version = new Version(reader.ReadString());
            Orientation = (Orientation)reader.ReadByte();
            Width = reader.ReadInt32();
            Height = reader.ReadInt32();
            TileWidth = reader.ReadInt32();
            TileHeight = reader.ReadInt32();
            Properties = new PropertyCollection();
            Properties.Read(reader);

            // create a list for our tiles
            List<Tile> tiles = new List<Tile>();
            Tiles = new Collection<Tile>(tiles);

            // read in each tile set
            int numTileSets = reader.ReadInt32();
            for (int i = 0; i < numTileSets; i++)
            {
                // get the id and texture
                int firstId = reader.ReadInt32();
                string tilesetName = reader.ReadString();

                bool collisionSet = reader.ReadBoolean();

                Texture2D texture = reader.ReadExternalReference<Texture2D>();

                // read in each individual tile
                int numTiles = reader.ReadInt32();
                for (int j = 0; j < numTiles; j++)
                {
                    int id = firstId + j;

                    // Read the source rectangle from the file.
                    Rectangle source = reader.ReadObject<Rectangle>();

                    PropertyCollection props = new PropertyCollection();
                    props.Read(reader);

                    // Read in color data for collision purposes
                    // You'll probably want to limit this to just the tilesets that are used for collision
                    // I'm checking for the name of my tileset that contains wall tiles
                    // Color data takes up a fair bit of RAM
                    Color[] collisionData = null;
                    bool[] collisionBitData = null;
                    if (collisionSet)
                    {
                        int numOfBytes = TileWidth * TileHeight;
                        collisionData = new Color[numOfBytes];
                        collisionBitData = new bool[numOfBytes];

                        texture.GetData<Color>(
                            0,
                            source,
                            collisionData,
                            0,
                            numOfBytes
                        );

                        for (int col = 0; col < numOfBytes; col++)
                        {
                            if (collisionData[col].A > 0)
                            {
                                collisionBitData[col] = true;
                            }
                        }
                        collisionData = null;
                    }

                    Tile t = new Tile(texture, source, props, collisionBitData);
                    while (id >= tiles.Count)
                    {
                        tiles.Add(null);
                    }
                    tiles.Insert(id, t);
                }
            }

            // read in all the layers
            List<Layer> layers = new List<Layer>();
            Layers = new Collection<Layer>(layers);
            int numLayers = reader.ReadInt32();
            for (int i = 0; i < numLayers; i++)
            {
                Layer layer = null;

                // read generic layer data
                string type = reader.ReadString();
                string name = reader.ReadString();
                int width = reader.ReadInt32();
                int height = reader.ReadInt32();
                bool visible = reader.ReadBoolean();
                float opacity = reader.ReadSingle();
                PropertyCollection props = new PropertyCollection();
                props.Read(reader);

                // using the type, figure out which object to create
                if (type == "layer")
                {
                    int[] data = reader.ReadObject<int[]>();
                    layer = new TileLayer(name, width, height, visible, opacity, props, this, data);
                }
                else if (type == "objectgroup")
                {
                    List<MapObject> objects = new List<MapObject>();

                    // read in all of our objects
                    int numObjects = reader.ReadInt32();
                    for (int j = 0; j < numObjects; j++)
                    {
                        string objName = reader.ReadString();
                        string objType = reader.ReadString();
                        Rectangle objLoc = reader.ReadObject<Rectangle>();
                        List<Point> objPoints = reader.ReadObject<List<Point>>();
                        PropertyCollection objProps = new PropertyCollection();
                        objProps.Read(reader);

                        objects.Add(new MapObject(objName, objType, objLoc, objPoints, objProps));
                    }

                    layer = new MapObjectLayer(name, width, height, visible, opacity, props, objects);
                }
                else
                {
                    throw new Exception("Invalid type: " + type);
                }

                layers.Add(layer);
                namedLayers.Add(name, layer);
            }
        }
예제 #25
0
 protected internal override bool Read(ContentReader input, bool existingInstance)
 {
     return(input.ReadBoolean());
 }
예제 #26
0
파일: Map.cs 프로젝트: Wydra/WickedEngine
        internal Map(ContentReader reader)
        {
            // read in the basic map information
            Version = new Version(reader.ReadString());
            Orientation = (Orientation)reader.ReadByte();
            WidthInTiles = reader.ReadInt32();
            HeightInTiles = reader.ReadInt32();
            TileWidth = reader.ReadInt32();
            TileHeight = reader.ReadInt32();
            Properties = new PropertyCollection(reader);
            bool makeTilesUnique = reader.ReadBoolean();

            // create a list for our tiles
            List<Tile> tiles = new List<Tile>();
            Tiles = new ReadOnlyCollection<Tile>(tiles);

            // read in each tile set
            int numTileSets = reader.ReadInt32();
            for (int i = 0; i < numTileSets; i++)
            {
                // get the id and texture
                int firstId = reader.ReadInt32();
                Texture2D texture = reader.ReadExternalReference<Texture2D>();

                // read in each individual tile
                int numTiles = reader.ReadInt32();
                for (int j = 0; j < numTiles; j++)
                {
                    int id = firstId + j;
                    Rectangle source = reader.ReadObject<Rectangle>();
                    PropertyCollection props = new PropertyCollection(reader);

                    Tile t = new Tile(texture, source, props);
                    while (id >= tiles.Count)
                    {
                        tiles.Add(null);
                    }
                    tiles.Insert(id, t);
                }
            }

            // read in all the layers
            List<Layer> layers = new List<Layer>();
            Layers = new ReadOnlyCollection<Layer>(layers);
            int numLayers = reader.ReadInt32();
            for (int i = 0; i < numLayers; i++)
            {
                Layer layer = null;

                // read generic layer data
                string type = reader.ReadString();
                string name = reader.ReadString();
                int width = reader.ReadInt32();
                int height = reader.ReadInt32();
                bool visible = reader.ReadBoolean();
                float opacity = reader.ReadSingle();
                PropertyCollection props = new PropertyCollection(reader);

                // calculate the default layer depth of the layer
                float layerDepth = 1f - (LayerDepthSpacing * i);

                // using the type, figure out which object to create
                if (type == "layer")
                {
                    uint[] data = reader.ReadObject<uint[]>();
                    layer = new TileLayer(name, width, height, layerDepth, visible, opacity, props, this, data, makeTilesUnique);
                }
                else if (type == "objectgroup")
                {
                    List<MapObject> objects = new List<MapObject>();

                    // read in all of our objects
                    int numObjects = reader.ReadInt32();
                    for (int j = 0; j < numObjects; j++)
                    {
                        string objName = reader.ReadString();
                        string objType = reader.ReadString();
                        Rectangle objLoc = reader.ReadObject<Rectangle>();
                        PropertyCollection objProps = new PropertyCollection(reader);

                        objects.Add(new MapObject(objName, objType, objLoc, objProps));
                    }

                    layer = new MapObjectLayer(name, width, height, layerDepth, visible, opacity, props, objects);

                    // read in the layer's color
                    (layer as MapObjectLayer).Color = reader.ReadColor();
                }
                else
                {
                    throw new Exception("Invalid type: " + type);
                }

                layers.Add(layer);
                namedLayers.Add(name, layer);
            }
        }