Ejemplo n.º 1
0
        private void PrasePatterns(GameObject goWorld, JsonWorld jsonWorld)
        {
            using (new ChDir(assetPath))
            {
                foreach (var pattern in jsonWorld.patterns)
                {
                    // Find all files in this directory that match the pattern
                    using (new ChDir(assetPath))
                    {
                        foreach (var f in Directory.GetFiles(".", "*.tmx"))
                        {
                            var matches = Regex.Matches(f, pattern.regexp);
                            if (matches.Count >= 1 && matches[0].Groups.Count >= 3)
                            {
                                var x = matches[0].Groups[1].Value.ToInt();
                                var y = matches[0].Groups[2].Value.ToInt();

                                var map = new JsonMap
                                {
                                    fileName = f,
                                    x        = (x * pattern.multiplierX) + pattern.offsetX,
                                    y        = (y * pattern.multiplierY) + pattern.offsetY
                                };

                                InstantiateMap(goWorld, map);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void ParseMaps(GameObject goWorld, JsonWorld jsonWorld)
 {
     using (new ChDir(assetPath))
     {
         foreach (var map in jsonWorld.maps)
         {
             InstantiateMap(goWorld, map);
         }
     }
 }
Ejemplo n.º 3
0
        private void ParseJsonAsset(GameObject goWorld)
        {
            var       json      = File.ReadAllText(assetPath);
            JsonWorld jsonWorld = null;

            try
            {
                jsonWorld = JsonUtility.FromJson <JsonWorld>(json);
            }
            catch (Exception ex)
            {
                ReportError("World file has broken JSON syntax.\n{0}", ex.Message);
                return;
            }

            ParseMaps(goWorld, jsonWorld);
            PrasePatterns(goWorld, jsonWorld);
        }