コード例 #1
0
ファイル: Conditions.cs プロジェクト: Adosorken/queststudio
        public Condition Clone()
        {
            byte[] data = StructWriter.Convert(this);
            object obj  = QuestFile.CreateObject(this.getConditionType());

            StructReader.Convert(data, ref obj);
            return((Condition)obj);
        }
コード例 #2
0
        public Reward Clone()
        {
            byte[] data = StructWriter.Convert(this);
            object obj  = QuestFile.CreateObject(this.getRewardType());

            StructReader.Convert(data, ref obj);
            return((Reward)obj);
        }
コード例 #3
0
ファイル: QuestFile.cs プロジェクト: Adosorken/queststudio
        public bool Save(string Filename)
        {
            try
            {
                FileHandler fh = new FileHandler(Filename, FileHandler.FileOpenMode.Writing, Encoding.GetEncoding("EUC-KR"));

                fh.Write <int>(Version);
                fh.Write <int>(Blocks.Count);
                fh.Write <short>((short)Encoding.GetEncoding("EUC-KR").GetBytes(Title.Trim('\0') + '\0').Length);
                fh.Write <string>(Title.Trim('\0') + '\0');

                foreach (QuestBlock block in Blocks)
                {
                    fh.Write <int>(block.Triggers.Count);
                    fh.Write <short>((short)Encoding.GetEncoding("EUC-KR").GetBytes(block.Name.Trim('\0') + '\0').Length);
                    fh.Write <string>(block.Name.Trim('\0') + '\0');

                    foreach (QuestTrigger trigger in block.Triggers)
                    {
                        fh.Write <byte>(trigger.CheckNext ? (byte)1 : (byte)0);
                        fh.Write <int>(trigger.Conditions.Count);
                        fh.Write <int>(trigger.Rewards.Count);
                        fh.Write <short>((short)Encoding.GetEncoding("EUC-KR").GetBytes(trigger.Name.Trim('\0') + '\0').Length);
                        fh.Write <string>(trigger.Name.Trim('\0') + '\0');

                        foreach (Condition c in trigger.Conditions)
                        {
                            byte[] bytes = StructWriter.Convert(c);
                            fh.Write <int>(bytes.Length + 8);
                            fh.Write <int>((int)c.getConditionType());
                            fh.Write <byte[]>(bytes);
                        }

                        foreach (Reward r in trigger.Rewards)
                        {
                            byte[] bytes = StructWriter.Convert(r);
                            fh.Write <int>(bytes.Length + 8);
                            fh.Write <int>((int)r.getRewardType() | 0x01000000);
                            fh.Write <byte[]>(bytes);
                        }
                    }
                }
                fh.Close();

                this.FileName = Filename;
            }
            catch (Exception)
            {
                MessageBox.Show("Error:\nCannot open " + FileName + " for writing.");
                return(false);
            }
            return(true);
        }