public Scenario(string file) { byte[] fileData = DDResource.Load(file); string text = SCommon.ToJString(fileData, true, true, true, true); string[] lines = SCommon.TextToLines(text); foreach (string line in lines) { if (line == "") // ? 空行 { continue; } if (line[0] == ';') // ? コメント行 { continue; } string[] tokens = SCommon.Tokenize(line, " ", false, true); this.Commands.Add(new ScenarioCommand() { Tokens = tokens, }); } }
private static string[] ReadScenarioLines(string name) { if (string.IsNullOrEmpty(name)) { throw new DDError(); } byte[] fileData; { const string DEVENV_SCENARIO_DIR = "シナリオデータ"; const string DEVENV_SCENARIO_SUFFIX = ".txt"; if (Directory.Exists(DEVENV_SCENARIO_DIR)) { string file = Path.Combine(DEVENV_SCENARIO_DIR, name + DEVENV_SCENARIO_SUFFIX); fileData = File.ReadAllBytes(file); } else { string file = SCENARIO_FILE_PREFIX + name + SCENARIO_FILE_SUFFIX; fileData = DDResource.Load(file); } } string text = SCommon.ToJString(fileData, true, true, true, true); text = text.Replace('\t', ' '); // タブスペースと空白 -> 空白に統一 string[] lines = SCommon.TextToLines(text); return(lines); }
private static DDHashedData GetDefaultThumbnail() { if (_defaultThumbnail == null) { _defaultThumbnail = new DDHashedData(DDResource.Load(@"dat\SaveData_DefaultThumbnail.png")); } return(_defaultThumbnail); }
public void Load() { string[] lines = SCommon.TextToLines(SCommon.ENCODING_SJIS.GetString(DDResource.Load(this.MapFile))); int c = 0; lines = lines.Where(line => line != "" && line[0] != ';').ToArray(); // 空行とコメント行を除去 int w = int.Parse(lines[c++]); int h = int.Parse(lines[c++]); if (w < 1 || SCommon.IMAX < w) { throw new DDError(); } if (h < 1 || SCommon.IMAX < h) { throw new DDError(); } this.Table = new MapCell[w, h]; for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { MapCell cell = new MapCell(); if (c < lines.Length) { string[] tokens = SCommon.Tokenize(lines[c++], "\t"); int d = 0; d++; // Skip cell.TileName = Common.GetElement(tokens, d++, GameConsts.TILE_NONE); cell.Tile = TileCatalog.Create(cell.TileName); cell.EnemyName = Common.GetElement(tokens, d++, GameConsts.ENEMY_NONE); // 新しい項目をここへ追加.. this.Table[x, y] = cell; } else { cell.TileName = GameConsts.TILE_NONE; cell.Tile = new Tile_None(); cell.EnemyName = GameConsts.ENEMY_NONE; } this.Table[x, y] = cell; } } this.W = w; this.H = h; this.WallName = Common.GetElement(lines, c++, GameConsts.NAME_DEFAULT); this.MusicName = Common.GetElement(lines, c++, GameConsts.NAME_DEFAULT); this.穴に落ちたら死亡 = int.Parse(Common.GetElement(lines, c++, "1")) != 0; }
public static void INIT() { using (MemoryStream mem = new MemoryStream(DDResource.Load(@"Etoile\G4YokoActTM\World.csv"))) using (StreamReader memReader = new StreamReader(mem, StringTools.ENCODING_SJIS)) using (CsvFileReader reader = new CsvFileReader(memReader)) { Rows = reader.ReadToEnd(); } W = ArrayTools.Largest(Rows.Select(row => row.Length), IntTools.Comp); H = Rows.Length; }
public World(string startMapName) { using (WorkingDir wd = new WorkingDir()) { string file = wd.MakePath(); File.WriteAllBytes(file, DDResource.Load(@"res\World\World.csv")); using (CsvFileReader reader = new CsvFileReader(file)) { this.MapNameTableRows = reader.ReadToEnd(); } } this.CurrPoint = this.GetPoint(startMapName); }
public static string LastLoadedFile = null; // null == 未読み込み public static Map Load(string file) { LastLoadedFile = file; string[] lines = FileTools.TextToLines(Encoding.UTF8.GetString(DDResource.Load(file))); int c = 0; int w = int.Parse(lines[c++]); int h = int.Parse(lines[c++]); Map map = new Map(w, h); for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { if (lines.Length <= c) { goto endLoad; } MapCell cell = map.GetCell(x, y); var tokens = new BluffList <string>(lines[c++].Split('\t')).FreeRange(""); // 項目が増えても良いように -> FreeRange("") int d = 0; cell.Kind = (MapCell.Kind_e) int.Parse(tokens[d++]); cell.SurfacePicture = MapTileManager.GetTile(tokens[d++]); cell.TilePicture = MapTileManager.GetTile(tokens[d++]); // 新しい項目をここへ追加... } } while (c < lines.Length) { // memo: Save()時にプロパティ部分も上書きされるので注意してね。 var tokens = lines[c++].Split("=".ToArray(), 2); string name = tokens[0]; string value = tokens[1]; map.AddProperty(name, value); } endLoad: return(map); }
public World(string worldName, string startMapName) { string worldFile = GameCommon.GetWorldFile(worldName); using (WorkingDir wd = new WorkingDir()) { string file = wd.MakePath(); File.WriteAllBytes(file, DDResource.Load(worldFile)); using (CsvFileReader reader = new CsvFileReader(file)) { this.MapNameTableRows = reader.ReadToEnd(); } } this.CurrPoint = this.GetPoint(startMapName); this.WorldName = worldName; }
public void Load() { I3Color[,] bmp = Common.ReadBmpFile(DDResource.Load(this.MapFile), out this.W, out this.H); this.Table = new MapCell[this.W, this.H]; for (int x = 0; x < this.W; x++) { for (int y = 0; y < this.H; y++) { int index = SCommon.IndexOf(MapCell.Kind_e_Colors, v => v == bmp[x, y]); #if true if (index == -1) // ? 未知の色 { index = (int)MapCell.Kind_e.EMPTY; } #else // @ 2020.12.x // ペイントなどで編集して不明な色が混入してしまうことを考慮して、EMPTY に矯正するようにしたいが、 // 移植によるバグ混入検出のため、当面はエラーで落とす。 // -- 止め @ 2021.1.x // if (index == -1) // ? 未知の色 { throw null; } #endif this.Table[x, y] = new MapCell() { Parent = this, Self_X = x, Self_Y = y, Kind = (MapCell.Kind_e)index, ColorPhase = DDUtils.Random.Real(), }; } } }
public void Test01() { ProcMain.WriteLog(Encoding.ASCII.GetString(DDResource.Load(@"Fairy\Donut3\Resource テスト用\Dummy01.txt"))); ProcMain.WriteLog(Encoding.ASCII.GetString(DDResource.Load(@"Fairy\Donut3\Resource テスト用\Dummy02.txt"))); ProcMain.WriteLog(Encoding.ASCII.GetString(DDResource.Load(@"Fairy\Donut3\Resource テスト用\Dummy03.txt"))); }
public void Test01() { ProcMain.WriteLog(Encoding.ASCII.GetString(DDResource.Load(@"Resource テスト用 DummyData\Dummy01.txt"))); ProcMain.WriteLog(Encoding.ASCII.GetString(DDResource.Load(@"Resource テスト用 DummyData\Dummy02.txt"))); ProcMain.WriteLog(Encoding.ASCII.GetString(DDResource.Load(@"Resource テスト用 DummyData\Dummy03.txt"))); }
public static Map Load(string file) { file = Path.Combine(@"Etoile\G4Dungeon\Map", file); string[] lines = FileTools.TextToLines(StringTools.ENCODING_SJIS.GetString(DDResource.Load(file))); int c = 0; string[] mapLines; { List <string> dest = new List <string>(); while (c < lines.Length) { string line = lines[c++]; if (line == "") { break; } dest.Add(line); } mapLines = dest.ToArray(); } Dictionary <string, string> mapScripts = DictionaryTools.Create <string>(); while (c < lines.Length) { string line = lines[c++]; if (line.StartsWith(";")) // ? コメント { continue; } if (line == "") { break; } var tokens = line.Split("=".ToArray(), 2); string name = tokens[0].Trim(); string value = tokens[1].Trim(); if (Regex.IsMatch(name, @"^[0-9A-Za-z]{2}(:[2468])?$") == false) { throw new DDError(); } if (value == "") { throw new DDError(); } mapScripts.Add(name, value); } Map map = LoadMap(mapLines, mapScripts); while (c < lines.Length) { string line = lines[c++]; if (line.StartsWith(";")) // ? コメント { continue; } var tokens = line.Split("=".ToArray(), 2); string name = tokens[0].Trim(); string value = tokens[1].Trim(); if (name == "") { throw new DDError(); } if (value == "") { throw new DDError(); } map.AddProperty(name, value); } return(map); }
public Scenario(string name) { if (string.IsNullOrEmpty(name)) { throw new DDError(); } this.Name = name; this.Pages.Clear(); byte[] fileData; { const string DEVENV_SCENARIO_DIR = "シナリオデータ"; const string DEVENV_SCENARIO_SUFFIX = ".txt"; if (Directory.Exists(DEVENV_SCENARIO_DIR)) { string file = Path.Combine(DEVENV_SCENARIO_DIR, name + DEVENV_SCENARIO_SUFFIX); fileData = File.ReadAllBytes(file); } else { string file = SCENARIO_FILE_PREFIX + name + SCENARIO_FILE_SUFFIX; fileData = DDResource.Load(file); } } string text = JString.ToJString(fileData, true, true, true, true); text = text.Replace('\t', ' '); // タブスペースと空白 -> 空白に統一 string[] lines = FileTools.TextToLines(text); ScenarioPage page = null; foreach (string fLine in lines) { string line = fLine.Trim(); if (line == "") { continue; } if (line[0] == ';') // ? コメント行 { continue; } if (line[0] == '/') { page = new ScenarioPage() { Subtitle = line.Substring(1) }; this.Pages.Add(page); } else if (page == null) { throw new DDError("シナリオの先頭は /xxx でなければなりません。"); } else if (line[0] == '!') { string[] tokens = line.Substring(1).Split(' ').Where(v => v != "").ToArray(); page.Commands.Add(new ScenarioCommand(tokens)); } else { page.Lines.Add(line); } } this.各ページの各行の長さ調整(); }