Exemple #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);
        }
Exemple #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,
                });
            }
        }