예제 #1
0
        internal void Load(string filename)
        {
            _cells.Clear();

            List <SCellInfo> cells = JsonToFile <List <SCellInfo> > .Load(Environment.CurrentDirectory, filename + Form1.FileExt);

            if (cells == null || !cells.Any())
            {
                _owner.AddLogToConsole($"{filename} was empty", ELogLevel.IMPORTANT_INFO);
                return;
            }

            cells.ForEach(c =>
            {
                var cellcoord    = new Vector2i(c.x, c.y);
                CTileDescr descr = _owner.GetTileDescrByTerrein(c.tile);
                if (descr != null)
                {
                    _cells.Add(cellcoord, new CCell(this, cellcoord, descr));
                }
                else
                {
                    _owner.AddLogToConsole($"Can't find descr for {c.tile} in {cellcoord}", ELogLevel.WARNING);
                }
            });

            _owner.AddLogToConsole($"{filename} was loaded", ELogLevel.IMPORTANT_INFO);
        }
예제 #2
0
 void LoadSettings()
 {
     try
     {
         _settings = JsonToFile <CAppSettings> .Load(Environment.CurrentDirectory, "TerrainTilerSettings.dat");
     }
     catch (Exception ex)
     {
         _settings = new CAppSettings();
         AddLogToConsole(string.Format("Can't parse settings: {0}", ex), Color.Red);
         return;
     }
 }