コード例 #1
0
 public JsonDialogInstruction(DialogTextInstruction inst, string speaker = null, string voice = null)
 {
     id           = inst.ID;
     lines        = inst.Text.Trim('\0').Split(new string[] { "@@" }, StringSplitOptions.None);
     this.speaker = string.IsNullOrEmpty(speaker) ? null : speaker;
     voiceFile    = string.IsNullOrEmpty(voice) ? null : voice;
 }
コード例 #2
0
ファイル: Scenario.cs プロジェクト: Anonym271/7scarlet-tools
        public static Scenario Load(string filename)
        {
            using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
                using (BinaryReader file = new BinaryReader(fs))
                {
                    List <Instruction> instructions = new List <Instruction>();

                    while (file.BaseStream.Position < file.BaseStream.Length)
                    {
                        short  length = file.ReadInt16();
                        short  opcode = file.ReadInt16();
                        byte[] data   = file.ReadBytes(length - 4);

                        Instruction inst = null;
                        switch (opcode)
                        {
                        case 0x0010:
                            inst = new DialogTextInstruction(
                                opcode,
                                BitConverter.ToInt32(data, 0),
                                Utility.GetStringWithoutZeros(data, 4, data.Length - 4));
                            break;

                        case 0x0018:
                            inst = new SpeakerNameInstruction(
                                opcode,
                                BitConverter.ToInt32(data, 0),
                                Utility.GetStringWithoutZeros(data, 4, data.Length - 4));
                            break;

                        case 0x0024:
                            inst = new VoiceFileInstruction(
                                opcode,
                                BitConverter.ToInt32(data, 0),
                                Utility.GetStringWithoutZeros(data, 4, data.Length - 4));
                            break;

                        default:
                            inst = new BinaryInstruction(opcode, data);
                            break;
                        }
                        instructions.Add(inst);
                    }

                    return(new Scenario(instructions));
                }
        }