示例#1
0
        public Settings(string file, Arguments args)
        {
            settingFile = file;
            Sections    = new Dictionary <string, object>()
            {
                { "Player", Player },
                { "Game", Game },
                { "Sound", Sound },
                { "Debug", Debug },
                { "Graphics", Graphics },
                { "Server", Server }
            };

            var err1 = FieldLoader.UnknownFieldAction;
            var err2 = FieldLoader.InvalidValueAction;

            try
            {
                var stream = Android.App.Application.Context.Assets.Open("Content/settings.yaml");
                //if (File.Exists(settingFile))
                {
                    var yaml = MiniYaml.DictFromStream(stream);
                    foreach (var kv in Sections)
                    {
                        if (yaml.ContainsKey(kv.Key))
                        {
                            LoadSectionYaml(yaml[kv.Key], kv.Value);
                        }
                    }
                }
            }
            finally
            {
            }
        }
示例#2
0
        public TileSet(IReadOnlyFileSystem fileSystem, string filePath)
        {
            var yaml = MiniYaml.DictFromStream(fileSystem.Open(filePath), filePath);

            //General Info
            FieldLoader.Load(this, yaml["General"]);

            //Terrain Types
            TerrainInfo = yaml["Terrain"].ToDictionary().Values.Select(y => new TerrainTypeInfo(y)).OrderBy(tt => tt.Type).ToArray();

            if (TerrainInfo.Length >= byte.MaxValue)
            {
                throw new InvalidOperationException("Too many terrain types.");
            }

            for (byte i = 0; i < TerrainInfo.Length; i++)
            {
                var tt = TerrainInfo[i].Type;
                if (terrainIndexByType.ContainsKey(tt))
                {
                    throw new InvalidOperationException("Duplicate terrain type '{0}' in '{1}'".F(tt, filePath));
                }

                terrainIndexByType.Add(tt, i);
            }

            defaultWalkableTerrainIndex = GetTerrainIndex("Clear");

            //Templates
            Templates = yaml["Templates"].ToDictionary().Values.Select(y => new TerrainTemplateInfo(this, y)).ToDictionary(t => t.Id).AsReadOnly();
        }