Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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,
                });
            }
        }
Esempio n. 3
0
        public static void INIT()
        {
            foreach (string file in DDResource.GetFiles())
            {
                try
                {
                    const string filePrefix = "Etoile\\G4YokoActTM\\MapTile\\";
                    const string fileSuffix = ".png";

                    if (
                        StringTools.StartsWithIgnoreCase(file, filePrefix) &&
                        StringTools.EndsWithIgnoreCase(file, fileSuffix)
                        )
                    {
                        string name = file.Substring(filePrefix.Length, file.Length - filePrefix.Length - fileSuffix.Length).Replace('\\', '/');

                        MapTile tile = new MapTile()
                        {
                            Name    = name,
                            Picture = DDPictureLoaders.Standard(file),
                        };

                        Add(tile);
                    }
                }
                catch (Exception e)
                {
                    throw new AggregateException("file: " + file, e);
                }
            }
        }
Esempio n. 4
0
        public static void Save(Map map, string file)
        {
            List <string> lines = new List <string>();
            int           w     = map.W;
            int           h     = map.H;

            lines.Add("" + w);
            lines.Add("" + h);

            for (int x = 0; x < w; x++)
            {
                for (int y = 0; y < h; y++)
                {
                    MapCell       cell   = map.GetCell(x, y);
                    List <string> tokens = new List <string>();

                    tokens.Add("" + (int)cell.Kind);
                    tokens.Add(cell.SurfacePicture.Name);
                    tokens.Add(cell.TilePicture.Name);

                    // 新しい項目をここへ追加...

                    lines.Add(string.Join("\t", tokens).TrimEnd());
                }
            }
            foreach (KeyValuePair <string, string> pair in map.GetProperties())
            {
                lines.Add(pair.Key + "=" + pair.Value);
            }
            DDResource.Save(file, Encoding.UTF8.GetBytes(FileTools.LinesToText(lines.ToArray())));
        }
Esempio n. 5
0
        public void Save()
        {
            List <string> lines = new List <string>();
            int           w     = this.W;
            int           h     = this.H;

            lines.Add(w.ToString());
            lines.Add(h.ToString());

            for (int x = 0; x < w; x++)
            {
                for (int y = 0; y < h; y++)
                {
                    MapCell cell = this.Table[x, y];

                    lines.Add(string.Join("\t", cell.TileName == GameConsts.TILE_NONE ? 0 : 1, cell.TileName, cell.EnemyName));
                }
            }
            lines.Add("");
            lines.Add("; WallName");
            lines.Add(this.WallName);
            lines.Add("");
            lines.Add("; MusicName");
            lines.Add(this.MusicName);
            lines.Add("");
            lines.Add("; 穴に落ちたら死亡 (1=有効, 0=無効)");
            lines.Add("" + (this.穴に落ちたら死亡 ? 1 : 0));

            DDResource.Save(this.MapFile, SCommon.ENCODING_SJIS.GetBytes(SCommon.LinesToText(lines.ToArray())));
        }
Esempio n. 6
0
 public void Test02()
 {
     foreach (string file in DDResource.GetFiles())
     {
         ProcMain.WriteLog("resource file ==> " + file);
     }
 }
Esempio n. 7
0
        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;
        }
Esempio n. 8
0
        private static DDHashedData GetDefaultThumbnail()
        {
            if (_defaultThumbnail == null)
            {
                _defaultThumbnail = new DDHashedData(DDResource.Load(@"dat\SaveData_DefaultThumbnail.png"));
            }

            return(_defaultThumbnail);
        }
Esempio n. 9
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;
 }
Esempio n. 10
0
        public void Save()
        {
            I3Color[,] bmp = new I3Color[this.W, this.H];

            for (int x = 0; x < this.W; x++)
            {
                for (int y = 0; y < this.H; y++)
                {
                    bmp[x, y] = MapCell.Kind_e_Colors[(int)this.Table[x, y].Kind];
                }
            }

            DDResource.Save(this.MapFile, Common.WriteBmpFile(bmp, this.W, this.H));
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        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;
        }
Esempio n. 14
0
        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(),
                    };
                }
            }
        }
Esempio n. 15
0
 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")));
 }
Esempio n. 16
0
        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.各ページの各行の長さ調整();
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
		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")));
		}