Ejemplo n.º 1
0
        CCTileMapInfo()
        {
            Tilesets                = new List <CCTileSetInfo>();
            Layers                  = new List <CCTileLayerInfo>();
            ObjectGroups            = new List <CCTileMapObjectGroup>(4);
            MapProperties           = new Dictionary <string, string>();
            TileProperties          = new Dictionary <short, Dictionary <string, string> >();
            TileAnimations          = new Dictionary <short, List <CCTileAnimationKeyFrame> >();
            tileDataCompressionType = CCTileDataCompressionType.None;
            currentParentElement    = CCTileMapProperty.None;
            currentFirstGID         = 0;

            // Associating xml elements of tmx file with parse actions
            mapFileElementActions = new Dictionary <string, Tuple <Action, Action> >
            {
                { "map", Tuple.Create <Action, Action>(ParseMapElement, ParseMapEndElement) },
                { "tileset", Tuple.Create <Action, Action>(ParseTilesetElement, ParseTilesetEndElement) },
                { "tile", Tuple.Create <Action, Action>(ParseTileElement, ParseTileEndElement) },
                { "animation", Tuple.Create <Action, Action>(ParseTileAnimationElement, ParseTileAnimationEndElement) },
                { "frame", Tuple.Create <Action, Action>(ParseTileAnimationKeyFrameElement, ParseTileAnimationKeyFrameEndElement) },
                { "layer", Tuple.Create <Action, Action>(ParseLayerElement, ParseLayerEndElement) },
                { "objectgroup", Tuple.Create <Action, Action>(ParseObjectGroupElement, ParseObjectGroupEndElement) },
                { "image", Tuple.Create <Action, Action>(ParseImageElement, ParseImageEndElement) },
                { "data", Tuple.Create <Action, Action>(ParseDataElement, ParseDataEndElement) },
                { "object", Tuple.Create <Action, Action>(ParseObjectElement, ParseObjectEndElement) },
                { "property", Tuple.Create <Action, Action>(ParsePropertyElement, ParsePropertyEndElement) },
                { "polygon", Tuple.Create <Action, Action>(ParsePolygonElement, ParsePolygonEndElement) },
                { "polyline", Tuple.Create <Action, Action>(ParsePolylineElement, ParsePolylineEndElement) },
                { "ellipse", Tuple.Create <Action, Action>(ParseEllipseElement, ParseEllipseEndElement) },
            };
        }
Ejemplo n.º 2
0
        void ParseDataElement()
        {
            string encoding = currentAttributeDict.ContainsKey(DataElementEncoding)
                ? currentAttributeDict[DataElementEncoding] : String.Empty;
            string compression = currentAttributeDict.ContainsKey(DataElementCompression)
                ? currentAttributeDict[DataElementCompression] : String.Empty;

            if (encoding == DataElementBase64)
            {
                tileDataCompressionType = tileDataCompressionType | CCTileDataCompressionType.Base64;
                storingCharacters       = true;

                if (compression == DataElementGzip)
                {
                    tileDataCompressionType = tileDataCompressionType | CCTileDataCompressionType.Gzip;
                }
                else if (compression == DataElementZlib)
                {
                    tileDataCompressionType = tileDataCompressionType | CCTileDataCompressionType.Zlib;
                }
                else if (compression != String.Empty)
                {
                    throw new NotImplementedException(
                              String.Format("CCTileMapInfo: ParseDataElement: Unsupported compression method {0}", compression));
                }
            }

            else if (encoding != String.Empty)
            {
                throw new NotImplementedException("CTileMapInfo: ParseDataElement: Only base64 encoded maps are supported");
            }
        }
Ejemplo n.º 3
0
        void ParseDataElement()
        {
            string encoding = currentAttributeDict.ContainsKey(DataElementEncoding) 
                ? currentAttributeDict[DataElementEncoding] : String.Empty;
            string compression = currentAttributeDict.ContainsKey(DataElementCompression) 
                ? currentAttributeDict[DataElementCompression] : String.Empty;

            if (encoding == DataElementBase64) 
            {
                tileDataCompressionType = tileDataCompressionType | CCTileDataCompressionType.Base64;
                storingCharacters = true;

                if (compression == DataElementGzip) {
                    tileDataCompressionType = tileDataCompressionType | CCTileDataCompressionType.Gzip;
                } else if (compression == DataElementZlib) {
                    tileDataCompressionType = tileDataCompressionType | CCTileDataCompressionType.Zlib;
                } else if (compression != String.Empty) {
                    throw new NotImplementedException (
                        String.Format ("CCTileMapInfo: ParseDataElement: Unsupported compression method {0}", compression));
                }
            } 
            else if (encoding == DataElementCsv) 
            {
                tileDataCompressionType = CCTileDataCompressionType.Csv;
                storingCharacters = true;
            }

            else if(encoding != String.Empty)
                throw new NotImplementedException("CTileMapInfo: ParseDataElement: Only base64 encoded maps are supported");
        }
Ejemplo n.º 4
0
        CCTileMapInfo()
        {
            Tilesets = new List<CCTileSetInfo>();
            Layers = new List<CCTileLayerInfo>();
            ObjectGroups = new List<CCTileMapObjectGroup>(4);
            MapProperties = new Dictionary<string, string>();
            TileProperties = new Dictionary<short, Dictionary<string, string>>();
            TileAnimations = new Dictionary<short, List<CCTileAnimationKeyFrame>>();
            tileDataCompressionType = CCTileDataCompressionType.None;
            currentParentElement = CCTileMapProperty.None;
            currentFirstGID = 0;

            // Associating xml elements of tmx file with parse actions
            mapFileElementActions = new Dictionary<string, Tuple<Action,Action>>
            {
                { "map", Tuple.Create<Action,Action>(ParseMapElement, ParseMapEndElement) },
                { "tileset", Tuple.Create<Action,Action>(ParseTilesetElement, ParseTilesetEndElement) },
                { "tile", Tuple.Create<Action,Action>(ParseTileElement, ParseTileEndElement) },
                { "animation", Tuple.Create<Action,Action>(ParseTileAnimationElement, ParseTileAnimationEndElement) },
                { "frame", Tuple.Create<Action,Action>(ParseTileAnimationKeyFrameElement, ParseTileAnimationKeyFrameEndElement) },
                { "layer", Tuple.Create<Action,Action>(ParseLayerElement, ParseLayerEndElement) },
                { "objectgroup", Tuple.Create<Action,Action>(ParseObjectGroupElement, ParseObjectGroupEndElement) },
                { "image", Tuple.Create<Action,Action>(ParseImageElement, ParseImageEndElement) },
                { "data", Tuple.Create<Action,Action>(ParseDataElement, ParseDataEndElement) },
                { "object", Tuple.Create<Action,Action>(ParseObjectElement, ParseObjectEndElement) },
                { "property", Tuple.Create<Action,Action>(ParsePropertyElement, ParsePropertyEndElement) },
                { "polygon", Tuple.Create<Action,Action>(ParsePolygonElement, ParsePolygonEndElement) },
                { "polyline", Tuple.Create<Action,Action>(ParsePolylineElement, ParsePolylineEndElement) },
                { "ellipse", Tuple.Create<Action,Action>(ParseEllipseElement, ParseEllipseEndElement) },
            };
        }