コード例 #1
0
        public void Parse_TmxFileNoTranslationUnits_To_TmxFileObject_Test()
        {
            // Assign
            AbstractTmxParser parser   = new TmxParser();
            TmxFile           expected = MockObjects.VALID_en_TmxFile;

            // Act
            TmxFile result = parser.ParseFile(MockObjects.NO_TRANSLATION_UNITS_TmxFilePath);

            // Assert
            // -- Assert FileInfo
            Assert.AreEqual(MockObjects.NO_TRANSLATION_UNITS_TmxFilePath, result.FileInfo);
            // -- Assert Language code
            Assert.AreEqual("Unkown", result.LanguageCode);
            // -- Assert Data
            // ---- Assert version
            Assert.AreEqual(expected.Data.Version, result.Data.Version);
            // ---- Assert header
            Assert.AreEqual(expected.Data.Header.CreationToolVersion, result.Data.Header.CreationToolVersion);
            Assert.AreEqual(expected.Data.Header.DataType, result.Data.Header.DataType);
            Assert.AreEqual(expected.Data.Header.SegmentType, result.Data.Header.SegmentType);
            Assert.AreEqual(expected.Data.Header.AdminLanguage, result.Data.Header.AdminLanguage);
            Assert.AreEqual(expected.Data.Header.SourceLanguage, result.Data.Header.SourceLanguage);
            Assert.AreEqual(expected.Data.Header.OriginalTranslationMemoryFormat, result.Data.Header.OriginalTranslationMemoryFormat);
            Assert.AreEqual(expected.Data.Header.CreationTool, result.Data.Header.CreationTool);
            // ---- Assert body
            // ------ Assert TranslationUnits
            Assert.AreEqual(0, result.Data.Body.TranslationUnits.Count);
        }
コード例 #2
0
    public void LevelLoad(string level)
    {
        LevelReset();
        m_brickGO.SetActive(true);
        TextAsset m_textAsset = Resources.Load("Levels/" + level) as TextAsset;

        if (m_textAsset == null)
        {
            Debug.LogErrorFormat("File not found {0}", level);
            return;
        }
        else
        {
            Debug.Log("Loading level " + level);
        }
        TmxParser tmx = new TmxParser();

        tmx.ParseFile(m_textAsset.text);

        for (int j = 0; j < tmx.m_height; j++)
        {
            for (int i = 0; i < tmx.m_width; i++)
            {
                int brick_id   = tmx.m_brickData [j * tmx.m_width + i];
                int powerup_id = tmx.m_powerupData [j * tmx.m_width + i];
                if (brick_id != 0)
                {
                    AddBrick(i, j, brick_id, powerup_id);
                }
            }
        }
        m_brickGO.SetActive(false);
        m_powerupGO.SetActive(false);
        //tmx.Dump();
    }
コード例 #3
0
    public void Build()
    {
        TileMap      tilemap = TmxParser.Parser(Application.dataPath + TmxFileRelativePath);
        List <Layer> layers  = tilemap.Layers;

        int index = 0;

        for (int i = 0; i < layers.Count; i++)
        {
            Layer layer = layers[i];
            if (layer.GetType() == typeof(TileSetLayer))
            {
                TileLayerRenderer tilelayer = Instantiate(Prefab);
                tilelayer.transform.position  = new Vector3(transform.position.x, transform.position.y, -index);
                tilelayer.TmxFileRelativePath = TmxFileRelativePath;
                tilelayer.FilterMode          = FilterMode;
                tilelayer.WrapMode            = WrapMode;
                tilelayer.TileSet             = TileSet;
                tilelayer.IndexLayer          = index;
                tilelayer.transform.parent    = transform;
                index++;
            }
            else if (layer.GetType() == typeof(ObjectGroupLayer))
            {
                // TODO
            }
            else if (layer.GetType() == typeof(ImageLayer))
            {
                // TODO
            }
        }
    }
コード例 #4
0
 private void ReadTmxFile()
 {
     Debug.Log("> Read Tmx File [" + Application.dataPath + TmxFileRelativePath + "]");
     tileMap        = TmxParser.Parser(Application.dataPath + TmxFileRelativePath);
     numberTilesX   = tileMap.Width;
     numberTilesY   = tileMap.Height;
     tileResolution = tileMap.TileWidth;
 }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the TmxDocument class.
        /// </summary>
        /// <param name="html">The HTML to parse.</param>
        internal TmxDocument(string html, bool wantSpaces, bool addLineBreaks)
        {
            this.nodes = new TmxNodeCollection(null);

            TmxParser parser = new TmxParser();
            parser.RemoveEmptyElementText = !wantSpaces;
            this.nodes = parser.Parse(html, addLineBreaks);
        }
コード例 #6
0
        public void Parse_InvalidTmxFile_To_TmxFileObject_Test()
        {
            // Assign
            AbstractTmxParser parser = new TmxParser();

            // Act
            TmxFile result = parser.ParseFile(MockObjects.INVALID_TmxFilePath);

            // Assert
            Assert.IsNull(result);
        }
コード例 #7
0
        public void Parse_EmptyTmxFile_To_TmxFileObject_Test()
        {
            // Assign
            AbstractTmxParser parser = new TmxParser();

            // Act
            TmxFile result = parser.ParseFile(MockObjects.EMPTY_TmxFilePath);

            // Assert
            Assert.IsNull(result);
        }
コード例 #8
0
        public void Parse_NonExistTmxFile_To_TmxFileObject_Test()
        {
            // Assign
            AbstractTmxParser parser = new TmxParser();

            // Act
            TmxFile result = parser.ParseFile(MockObjects.NonEXIST_TmxFilePath);

            // Assert
            Assert.IsNull(result);
        }
コード例 #9
0
        public void Parse_Valid_pseudo_TmxFile_To_TmxFileObject_Test()
        {
            // Assign
            AbstractTmxParser parser   = new TmxParser();
            TmxFile           expected = MockObjects.VALID_pseudo_TmxFile;

            // Act
            TmxFile result = parser.ParseFile(MockObjects.VALID_pseudo_TmxFilePath);

            // Assert
            // -- Assert FileInfo
            Assert.AreEqual(expected.FileInfo, result.FileInfo);
            // -- Assert Language code
            Assert.AreEqual(expected.LanguageCode, result.LanguageCode);
            Assert.AreNotEqual("Unkown", result.LanguageCode);
            // -- Assert Data
            // ---- Assert version
            Assert.AreEqual(expected.Data.Version, result.Data.Version);
            // ---- Assert header
            Assert.AreEqual(expected.Data.Header.CreationToolVersion, result.Data.Header.CreationToolVersion);
            Assert.AreEqual(expected.Data.Header.DataType, result.Data.Header.DataType);
            Assert.AreEqual(expected.Data.Header.SegmentType, result.Data.Header.SegmentType);
            Assert.AreEqual(expected.Data.Header.AdminLanguage, result.Data.Header.AdminLanguage);
            Assert.AreEqual(expected.Data.Header.SourceLanguage, result.Data.Header.SourceLanguage);
            Assert.AreEqual(expected.Data.Header.OriginalTranslationMemoryFormat, result.Data.Header.OriginalTranslationMemoryFormat);
            Assert.AreEqual(expected.Data.Header.CreationTool, result.Data.Header.CreationTool);
            // ---- Assert body
            // ------ Assert TranslationUnits
            foreach (TranslationUnit expectedTU in expected.Data.Body.TranslationUnits)
            {
                TranslationUnit unit = result.Data.Body.TranslationUnits
                                       .First <TranslationUnit>(
                    tu => tu.TranslationUnitId == expectedTU.TranslationUnitId
                    );

                Assert.IsNotNull(unit);
                Assert.AreEqual(expectedTU.TranslationUnitId, unit.TranslationUnitId);

                // ------ Assert TranslationUnitVariant
                foreach (TranslationUnitVariant expectedTUV in expectedTU.TranslationUnitVariants)
                {
                    TranslationUnitVariant unitVar = unit.TranslationUnitVariants
                                                     .First <TranslationUnitVariant>(
                        tuv => tuv.Segment == expectedTUV.Segment
                        );

                    Assert.IsNotNull(unitVar);
                    Assert.AreEqual(expectedTUV.Language, unitVar.Language);
                    Assert.AreEqual(expectedTUV.Segment, unitVar.Segment);
                }
            }
        }
コード例 #10
0
        public ConvertToXmlCommand()
        {
            // Register the actual command with a simple (optional) description.
            IsCommand("ConvertToXml", "Convert a TMD or TMC file to XML");

            // Add a longer description for the help on that specific command.
            //HasLongDescription("This can be used to quickly read a file's contents " +
            //"while optionally stripping out the ',' character.");

            // Required options/flags, append '=' to obtain the required value.
            HasRequiredOption("i|input=", "The full path of the input file.", i => InputFile = i);

            HasOption("o|output=", "The full path of the output file.", o => OutputFile = o);

            // Optional options/flags, append ':' to obtain an optional value, or null if not specified.
            //HasOption("s|strip:", "Strips ',' from the file before writing to output.",
            //    t => StripCommaCharacter = t == null ? true : Convert.ToBoolean(t));

            tmxParser = new TmxParser();
        }
コード例 #11
0
        public void Parse_TmxFileNoTranslationUnitVarients_To_TmxFileObject_Test()
        {
            // Assign
            AbstractTmxParser parser   = new TmxParser();
            TmxFile           expected = MockObjects.VALID_en_TmxFile;

            // Act
            TmxFile result = parser.ParseFile(MockObjects.NO_TRANSLATION_UNITS_VARIENTS_TmxFilePath);

            // Assert
            // -- Assert FileInfo
            Assert.AreEqual(MockObjects.NO_TRANSLATION_UNITS_VARIENTS_TmxFilePath, result.FileInfo);
            // -- Assert Language code
            Assert.AreEqual("Unkown", result.LanguageCode);
            // -- Assert Data
            // ---- Assert version
            Assert.AreEqual(expected.Data.Version, result.Data.Version);
            // ---- Assert header
            Assert.AreEqual(expected.Data.Header.CreationToolVersion, result.Data.Header.CreationToolVersion);
            Assert.AreEqual(expected.Data.Header.DataType, result.Data.Header.DataType);
            Assert.AreEqual(expected.Data.Header.SegmentType, result.Data.Header.SegmentType);
            Assert.AreEqual(expected.Data.Header.AdminLanguage, result.Data.Header.AdminLanguage);
            Assert.AreEqual(expected.Data.Header.SourceLanguage, result.Data.Header.SourceLanguage);
            Assert.AreEqual(expected.Data.Header.OriginalTranslationMemoryFormat, result.Data.Header.OriginalTranslationMemoryFormat);
            Assert.AreEqual(expected.Data.Header.CreationTool, result.Data.Header.CreationTool);
            // ---- Assert body
            // ------ Assert TranslationUnits
            foreach (TranslationUnit expectedTU in expected.Data.Body.TranslationUnits)
            {
                TranslationUnit unit = result.Data.Body.TranslationUnits
                                       .First <TranslationUnit>(
                    tu => tu.TranslationUnitId == expectedTU.TranslationUnitId
                    );

                Assert.IsNotNull(unit);
                Assert.AreEqual(expectedTU.TranslationUnitId, unit.TranslationUnitId);

                // ------ Assert TranslationUnitVariant
                Assert.AreEqual(0, unit.TranslationUnitVariants.Count);
            }
        }