예제 #1
0
    private static void PackQuest(StreamPacker sp, Quest q)
    {
        sp.WriteString(q.name);
        sp.WriteInt(q.uniqueId);
        sp.WriteString(q.description);
        sp.WriteString(q.handinDescription);
        sp.WriteString(q.afterDescription);
        sp.WriteString(q.questevent);
        sp.WriteString(q.activeevent);
        sp.WriteObjects(q.playerCommands);
        sp.WriteString(q.questrequirement);
        sp.WriteBool(q.open);
        sp.WriteBool(q.completed);
        sp.WriteString(q.status);
        sp.WriteFloat(q.lastEffected - Time.time);

        sp.WriteInt(q.objectives.Count);
        foreach (Objective o in q.objectives)
        {
            sp.WriteString(o.description);
            sp.WriteString(o.doneDescription);
            sp.WriteString(o.locationObject);
            sp.WriteInt(o.count);
            sp.WriteBool(o.optional);
            sp.WriteString(o.objectiveevent);
            sp.WriteString(o.questevent);
            sp.WriteString(o.activeevent);
            sp.WriteObjects(o.playerCommands);
            sp.WriteString(o.questrequirement);
            sp.WriteBool(o.completed);
            sp.WriteBool(o.open);
        }
    }
예제 #2
0
 public void Pack(StreamPacker sp)
 {
     sp.WriteString(objectName);
     sp.WriteString(method);
     sp.WriteStrings(paramaters);
     sp.WriteBool(assignment);
 }
예제 #3
0
    override public void Pack(StreamPacker sp)
    {
        sp.WriteInt(conversations.Length);

        foreach (Conversation c in conversations)
        {
            sp.WriteInt(c.id);
            sp.WriteInt(c.returnId);
            sp.WriteInt(c.uniqueId);
            sp.WriteString(c.text);
            sp.WriteString(c.repeattext);
            sp.WriteBool(c.once);
            sp.WriteBool(c.fallthrough);
            sp.WriteString(c.questevent);
            sp.WriteObjects(c.playerCommands);
            sp.WriteString(c.questrequirement);
            sp.WriteString(c.environmentalrequirement);
            sp.WriteBool(c._available);
            sp.WriteBool(c._seen);

            sp.WriteInt(c.options.Length);
            foreach (Option o in c.options)
            {
                sp.WriteString(o.text);
                sp.WriteInt(o.destinationId);
                sp.WriteBool(o._available);
                sp.WriteBool(o.choosenb4);
                sp.WriteBool(o.quest);
            }
        }
    }
예제 #4
0
    public static void Save(StreamPacker sp)
    {
        // Pack all quests
        List<Quest> quests=Parley.GetInstance().GetCompletedQuests();
        sp.WriteInt(quests.Count);
        foreach(Quest q in quests){
            PackQuest(sp,q);
        }

        quests=Parley.GetInstance().GetCurrentQuests();
        sp.WriteInt(quests.Count);
        foreach(Quest q in quests){
            PackQuest(sp,q);
        }
        sp.WriteString("Pack1");

        // Pack all events
        HashSet<string> questEvents=Parley.GetInstance().GetQuestEventSet();
        string[] allEvents=new string[questEvents.Count];
        int c=0;
        foreach (string s in questEvents){
            allEvents[c++]=s;
        }
        sp.WriteStrings(allEvents);

        sp.WriteString("Pack2");

        // Pack all active quest events
        sp.WriteInt(Parley.GetInstance().GetActiveEvents().Count);
        foreach (string s in Parley.GetInstance().GetActiveEvents()){
            sp.WriteString(s);
        }
        sp.WriteString("Pack3");
    }
 public override void Pack(StreamPacker sp)
 {
     PackTransform(gameObject.transform,sp);
     if (rigidbody!=null){
         PackRigidbody(rigidbody,sp);
     }
 }
        public void PackingWorks(LzwGifToolsTestCase testCase)
        {
            StreamPacker packer      = new StreamPacker(testCase.LzwMinimumCodeSize);
            List <byte>  packedBytes = packer.Pack(testCase.LzwCompressedCodeStream);

            CollectionAssert.AreEqual(testCase.PackedBytes, packedBytes);
        }
예제 #7
0
 override public void Pack(StreamPacker sp)
 {
     PackTransform(gameObject.transform, sp);
     if (rigidbody != null)
     {
         PackRigidbody(rigidbody, sp);
     }
 }
예제 #8
0
 public override void Pack(StreamPacker sp)
 {
     SaveLoadTransform.PackTransform(gameObject.transform, sp);
     sp.WriteBool(showgold);
     sp.WriteFloat(gold);
     sp.WriteBool(showwildflowers);
     sp.WriteInt(wildflowers);
     sp.WriteBool(broadcastjumps);
 }
예제 #9
0
 public static void PackRigidbody(Rigidbody rb, StreamPacker sp)
 {
     sp.WriteFloat(rb.velocity.x);
     sp.WriteFloat(rb.velocity.y);
     sp.WriteFloat(rb.velocity.z);
     sp.WriteFloat(rb.angularVelocity.x);
     sp.WriteFloat(rb.angularVelocity.y);
     sp.WriteFloat(rb.angularVelocity.z);
     sp.WriteFloat(rb.drag);
     sp.WriteFloat(rb.angularDrag);
 }
예제 #10
0
 public static void PackRigidbody(Rigidbody rb,StreamPacker sp)
 {
     sp.WriteFloat(rb.velocity.x);
     sp.WriteFloat(rb.velocity.y);
     sp.WriteFloat(rb.velocity.z);
     sp.WriteFloat(rb.angularVelocity.x);
     sp.WriteFloat(rb.angularVelocity.y);
     sp.WriteFloat(rb.angularVelocity.z);
     sp.WriteFloat(rb.drag);
     sp.WriteFloat(rb.angularDrag);
 }
        public void StreamPackingIsReversible(LzwGifToolsTestCase testCase)
        {
            StreamUnpacker unpacker = new StreamUnpacker(testCase.LzwMinimumCodeSize);
            StreamPacker   packer   = new StreamPacker(testCase.LzwMinimumCodeSize);

            List <int>  lzwCompressedCodeStream = unpacker.Unpack(testCase.PackedBytes);
            List <byte> packedBytes             = new List <byte>();

            packedBytes = packer.Pack(lzwCompressedCodeStream);

            CollectionAssert.AreEqual(testCase.PackedBytes, packedBytes);
        }
예제 #12
0
 public static void PackTransform(Transform packTransform, StreamPacker sp)
 {
     sp.WriteFloat(packTransform.localPosition.x);
     sp.WriteFloat(packTransform.localPosition.y);
     sp.WriteFloat(packTransform.localPosition.z);
     sp.WriteFloat(packTransform.localScale.x);
     sp.WriteFloat(packTransform.localScale.y);
     sp.WriteFloat(packTransform.localScale.z);
     sp.WriteFloat(packTransform.localRotation.x);
     sp.WriteFloat(packTransform.localRotation.y);
     sp.WriteFloat(packTransform.localRotation.z);
     sp.WriteFloat(packTransform.localRotation.w);
 }
예제 #13
0
 public static void PackTransform(Transform packTransform,StreamPacker sp)
 {
     sp.WriteFloat(packTransform.localPosition.x);
     sp.WriteFloat(packTransform.localPosition.y);
     sp.WriteFloat(packTransform.localPosition.z);
     sp.WriteFloat(packTransform.localScale.x);
     sp.WriteFloat(packTransform.localScale.y);
     sp.WriteFloat(packTransform.localScale.z);
     sp.WriteFloat(packTransform.localRotation.x);
     sp.WriteFloat(packTransform.localRotation.y);
     sp.WriteFloat(packTransform.localRotation.z);
     sp.WriteFloat(packTransform.localRotation.w);
 }
        public void AllMethodsWork(LzwGifToolsTestCase testCase)
        {
            LzwCompressor   compressor   = new LzwCompressor(testCase.LzwMinimumCodeSize);
            StreamPacker    packer       = new StreamPacker(testCase.LzwMinimumCodeSize);
            StreamUnpacker  unpacker     = new StreamUnpacker(testCase.LzwMinimumCodeSize);
            LzwDecompressor decompressor = new LzwDecompressor(testCase.LzwMinimumCodeSize);

            List <int>  lzwEncodedCodeStream  = compressor.Compress(testCase.CodeStream);
            List <byte> packedBytes           = packer.Pack(lzwEncodedCodeStream);
            List <int>  lzwEncodedCodeStream2 = unpacker.Unpack(packedBytes);
            List <int>  codeStream            = decompressor.Decompress(lzwEncodedCodeStream2);

            CollectionAssert.AreEqual(testCase.CodeStream, codeStream);
        }
예제 #15
0
    static void ShowOne(uint val)
    {
        using (MemoryStream ms = new MemoryStream())
        {
            StreamPacker.PackUInt32(ms, val);
            ms.Position = 0;
            byte[] bytes = ms.ToArray();
            Console.Write("{0,7}: ", val);
            foreach (byte b in bytes)
            {
                Console.Write("{0,2:X} ", b);
            }
//			Console.WriteLine ();
        }
    }
예제 #16
0
    public static void Save(StreamPacker sp)
    {
        // Pack all quests
        List <Quest> quests = Parley.GetInstance().GetCompletedQuests();

        sp.WriteInt(quests.Count);
        foreach (Quest q in quests)
        {
            PackQuest(sp, q);
        }

        quests = Parley.GetInstance().GetCurrentQuests();
        sp.WriteInt(quests.Count);
        foreach (Quest q in quests)
        {
            PackQuest(sp, q);
        }
        sp.WriteString("Pack1");

        // Pack all events
        HashSet <string> questEvents = Parley.GetInstance().GetQuestEventSet();

        string[] allEvents = new string[questEvents.Count];
        int      c         = 0;

        foreach (string s in questEvents)
        {
            allEvents[c++] = s;
        }
        sp.WriteStrings(allEvents);

        sp.WriteString("Pack2");

        // Pack all active quest events
        sp.WriteInt(Parley.GetInstance().GetActiveEvents().Count);
        foreach (string s in Parley.GetInstance().GetActiveEvents())
        {
            sp.WriteString(s);
        }
        sp.WriteString("Pack3");
    }
예제 #17
0
    static void Check(ulong first, ulong count)
    {
        using (Stream strm = new MemoryStream((int)(count * 8)))
        {
            ulong i, j, k;

            for (i = 0, k = first; i < count; i++, k++)
            {
                StreamPacker.PackUInt64(strm, k);
            }

            strm.Position = 0;

            for (i = 0, k = first; i < count; i++, k++)
            {
                j = StreamPacker.UnpackInt64(strm);
                if (j != k)
                {
                    throw new Exception(string.Format("failed on {0}: {1}", k, j));
                }
            }
        }
    }
예제 #18
0
    public void Save(string file)
    {
        FileStream fs = new FileStream(file, FileMode.Create);

        StreamPacker sp = new StreamPacker(fs);

        // Save Parley
        ParleySaveLoad.Save(sp);

        sp.WriteString("All is well");

        // Save all the Objects
        foreach (GameObject go in packableObjects)
        {
            PackUnpackableBehaviour[] pus = (PackUnpackableBehaviour[])go.GetComponents <PackUnpackableBehaviour>();
            if (pus != null && pus.Length > 0)
            {
                foreach (PackUnpackableBehaviour pu in pus)
                {
                    sp.WriteString(pu.GetType().Name);
                    pu.Pack(sp);
                }
            }
            pus = (PackUnpackableBehaviour[])go.GetComponentsInChildren <PackUnpackableBehaviour>(true);
            if (pus != null && pus.Length > 0)
            {
                foreach (PackUnpackableBehaviour pu in pus)
                {
                    sp.WriteString(pu.GetType().Name);
                    pu.Pack(sp);
                }
            }
        }

        fs.Close();
    }
예제 #19
0
    public void Save(string file)
    {
        FileStream fs = new FileStream(file, FileMode.Create);

        StreamPacker sp=new StreamPacker(fs);

        // Save Parley
        ParleySaveLoad.Save(sp);

        sp.WriteString("All is well");

        // Save all the Objects
        foreach (GameObject go in packableObjects){
            PackUnpackableBehaviour[] pus=(PackUnpackableBehaviour[])go.GetComponents<PackUnpackableBehaviour>();
            if (pus!=null && pus.Length>0){
                foreach (PackUnpackableBehaviour pu in pus){
                    sp.WriteString(pu.GetType().Name);
                    pu.Pack(sp);
                }
            }
            pus=(PackUnpackableBehaviour[])go.GetComponentsInChildren<PackUnpackableBehaviour>(true);
            if (pus!=null && pus.Length>0){
                foreach (PackUnpackableBehaviour pu in pus){
                    sp.WriteString(pu.GetType().Name);
                    pu.Pack(sp);
                }
            }
        }

        fs.Close();
    }
 public abstract void Pack(StreamPacker sp);
예제 #21
0
 override public void Pack(StreamPacker sp)
 {
     sp.WriteBool(gameObject.activeSelf);
 }
예제 #22
0
    public static void Save(Stream outputStream)
    {
        StreamPacker sp = new StreamPacker(outputStream);

        Save(sp);
    }
예제 #23
0
    public override void Pack(StreamPacker sp)
    {
        sp.WriteInt(conversations.Length);

        foreach (Conversation c in conversations){
            sp.WriteInt(c.id);
            sp.WriteInt(c.returnId);
            sp.WriteInt(c.uniqueId);
            sp.WriteString(c.text);
            sp.WriteString(c.repeattext);
            sp.WriteBool(c.once);
            sp.WriteBool(c.fallthrough);
            sp.WriteString(c.questevent);
            sp.WriteObjects(c.playerCommands);
            sp.WriteString(c.questrequirement);
            sp.WriteString(c.environmentalrequirement);
            sp.WriteBool(c._available);
            sp.WriteBool(c._seen);

            sp.WriteInt(c.options.Length);
            foreach (Option o in c.options){
                sp.WriteString(o.text);
                sp.WriteInt(o.destinationId);
                sp.WriteBool(o._available);
                sp.WriteBool(o.choosenb4);
                sp.WriteBool(o.quest);
            }
        }
    }
예제 #24
0
 public override void Pack(StreamPacker sp)
 {
     sp.WriteBool(gameObject.activeSelf);
 }
예제 #25
0
 public abstract void Pack(StreamPacker sp);
예제 #26
0
    private static void PackQuest(StreamPacker sp,Quest q)
    {
        sp.WriteString(q.name);
        sp.WriteInt(q.uniqueId);
        sp.WriteString(q.description);
        sp.WriteString(q.handinDescription);
        sp.WriteString(q.afterDescription);
        sp.WriteString(q.questevent);
        sp.WriteString(q.activeevent);
        sp.WriteObjects(q.playerCommands);
        sp.WriteString(q.questrequirement);
        sp.WriteBool(q.open);
        sp.WriteBool(q.completed);
        sp.WriteString(q.status);
        sp.WriteFloat(q.lastEffected-Time.time);

        sp.WriteInt(q.objectives.Count);
        foreach (Objective o in q.objectives){
            sp.WriteString(o.description);
            sp.WriteString(o.doneDescription);
            sp.WriteString(o.locationObject);
            sp.WriteInt(o.count);
            sp.WriteBool(o.optional);
            sp.WriteString(o.objectiveevent);
            sp.WriteString(o.questevent);
            sp.WriteString(o.activeevent);
            sp.WriteObjects(o.playerCommands);
            sp.WriteString(o.questrequirement);
            sp.WriteBool(o.completed);
            sp.WriteBool(o.open);
        }
    }
예제 #27
0
 public static void Save(Stream outputStream)
 {
     StreamPacker sp=new StreamPacker(outputStream);
     Save(sp);
 }
예제 #28
0
 public void Pack(StreamPacker sp)
 {
     sp.WriteString(objectName);
     sp.WriteString(method);
     sp.WriteStrings(paramaters);
     sp.WriteBool(assignment);
 }