Ejemplo n.º 1
0
 public static void UnpackRigidbody(Rigidbody rb,StreamUnpacker su)
 {
     rb.velocity=new Vector3(su.ReadFloat(),su.ReadFloat(),su.ReadFloat());
     rb.angularVelocity=new Vector3(su.ReadFloat(),su.ReadFloat(),su.ReadFloat());
     rb.drag=su.ReadFloat();
     rb.angularDrag=su.ReadFloat();
 }
Ejemplo n.º 2
0
 public void Unpack(StreamUnpacker sp)
 {
     objectName = sp.ReadString();
     method     = sp.ReadString();
     paramaters = sp.ReadStrings();
     assignment = sp.ReadBool();
 }
Ejemplo n.º 3
0
 public static void UnpackRigidbody(Rigidbody rb, StreamUnpacker su)
 {
     rb.velocity        = new Vector3(su.ReadFloat(), su.ReadFloat(), su.ReadFloat());
     rb.angularVelocity = new Vector3(su.ReadFloat(), su.ReadFloat(), su.ReadFloat());
     rb.drag            = su.ReadFloat();
     rb.angularDrag     = su.ReadFloat();
 }
Ejemplo n.º 4
0
 public override void Unpack(StreamUnpacker su)
 {
     UnpackTransform(gameObject.transform,su);
     if (rigidbody!=null){
         UnpackRigidbody(rigidbody,su);
     }
 }
        public void UnpackingWorks(LzwGifToolsTestCase testCase)
        {
            StreamUnpacker unpacker = new StreamUnpacker(testCase.LzwMinimumCodeSize);
            List <int>     lzwCompressedCodeStream = unpacker.Unpack(testCase.PackedBytes);

            CollectionAssert.AreEqual(testCase.LzwCompressedCodeStream, lzwCompressedCodeStream);
        }
Ejemplo n.º 6
0
    public void Load(string file)
    {
        FileStream fs = new FileStream(file, FileMode.Open);

        StreamUnpacker su=new StreamUnpacker(fs);

        // Save Parley
        ParleySaveLoad.Load(su);

        Debug.Log(su.ReadString());
        // Save all the Objects
        foreach (GameObject go in packableObjects){
            PackUnpackableBehaviour[] pus=(PackUnpackableBehaviour[])go.GetComponents<PackUnpackableBehaviour>();
            Debug.Log("Parley: Loading details for object "+go.name);
            if (pus!=null && pus.Length>0){
                foreach (PackUnpackableBehaviour pu in pus){
                    Debug.Log("Parley: Loading details for script "+pu.GetType().Name);
                    Debug.Log("Parley: Saved Was "+su.ReadString());
                    pu.Unpack(su);
                }
            }
            pus=(PackUnpackableBehaviour[])go.GetComponentsInChildren<PackUnpackableBehaviour>(true);
            if (pus!=null && pus.Length>0){
                foreach (PackUnpackableBehaviour pu in pus){
                    Debug.Log("Parley: Loading details for script "+pu.GetType().Name);
                    Debug.Log("Parley: Saved Was "+su.ReadString());
                    pu.Unpack(su);
                }
            }
        }

        fs.Close();
    }
Ejemplo n.º 7
0
 override public void Unpack(StreamUnpacker su)
 {
     UnpackTransform(gameObject.transform, su);
     if (rigidbody != null)
     {
         UnpackRigidbody(rigidbody, su);
     }
 }
Ejemplo n.º 8
0
 public override void Unpack(StreamUnpacker su)
 {
     SaveLoadTransform.UnpackTransform(gameObject.transform, su);
     showgold        = su.ReadBool();
     gold            = su.ReadFloat();
     showwildflowers = su.ReadBool();
     wildflowers     = su.ReadInt();
     broadcastjumps  = su.ReadBool();
 }
        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);
        }
        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);
        }
Ejemplo n.º 11
0
    public static void Load(StreamUnpacker su)
    {
        // Reset Scene quests
        Parley.GetInstance().LoadSceneQuests();

        int n = su.ReadInt();

        Parley.GetInstance().GetCompletedQuests().Clear();
        for (int t = 0; t < n; t++)
        {
            Parley.GetInstance().GetCompletedQuests().Add(UnpackQuest(su));
        }

        n = su.ReadInt();
        Parley.GetInstance().GetCurrentQuests().Clear();
        for (int t = 0; t < n; t++)
        {
            Parley.GetInstance().GetCurrentQuests().Add(UnpackQuest(su));
        }

        // Bring quests in line
        Parley.GetInstance().SyncQuests();

        Debug.LogError(su.ReadString());

        // Unpack all events
        string[]         allEvents   = su.ReadStrings();
        HashSet <string> questEvents = Parley.GetInstance().GetQuestEventSet();

        questEvents.Clear();
        foreach (string s in allEvents)
        {
            questEvents.Add(s);
        }

        Debug.LogError(su.ReadString());

        int activeEvents = su.ReadInt();

        Parley.GetInstance().GetActiveEvents().Clear();
        for (int t = 0; t < activeEvents; t++)
        {
            Parley.GetInstance().GetActiveEvents().Add(su.ReadString());
        }
        Debug.LogError(su.ReadString());
    }
Ejemplo n.º 12
0
    private static Quest UnpackQuest(StreamUnpacker su)
    {
        Quest q = new Quest();

        q.name              = su.ReadString();
        q.uniqueId          = su.ReadInt();
        q.description       = su.ReadString();
        q.handinDescription = su.ReadString();
        q.afterDescription  = su.ReadString();
        q.questevent        = su.ReadString();
        q.activeevent       = su.ReadString();
        q.playerCommands    = (Command[])su.ReadObjects(typeof(Command));

        q.questrequirement = su.ReadString();
        q.open             = su.ReadBool();
        q.completed        = su.ReadBool();
        q.status           = su.ReadString();
        q.lastEffected     = Time.time + su.ReadFloat();

        int n = su.ReadInt();

        for (int t = 0; t < n; t++)
        {
            Objective o = new Objective();
            q.objectives.Add(o);
            o.description      = su.ReadString();
            o.doneDescription  = su.ReadString();
            o.locationObject   = su.ReadString();
            o.count            = su.ReadInt();
            o.optional         = su.ReadBool();
            o.objectiveevent   = su.ReadString();
            o.questevent       = su.ReadString();
            o.activeevent      = su.ReadString();
            o.playerCommands   = (Command[])su.ReadObjects(typeof(Command));
            o.questrequirement = su.ReadString();
            o.completed        = su.ReadBool();
            o.open             = su.ReadBool();
        }
        return(q);
    }
Ejemplo n.º 13
0
    override public void Unpack(StreamUnpacker su)
    {
        int cnum = su.ReadInt();

        conversations = new Conversation[cnum];
        for (int t = 0; t < cnum; t++)
        {
            Conversation c = new Conversation();
            conversations[t]           = c;
            c.id                       = su.ReadInt();
            c.returnId                 = su.ReadInt();
            c.uniqueId                 = su.ReadInt();
            c.text                     = su.ReadString();
            c.repeattext               = su.ReadString();
            c.once                     = su.ReadBool();
            c.fallthrough              = su.ReadBool();
            c.questevent               = su.ReadString();
            c.playerCommands           = (Command[])su.ReadObjects(typeof(Command));
            c.questrequirement         = su.ReadString();
            c.environmentalrequirement = su.ReadString();
            c._available               = su.ReadBool();
            c._seen                    = su.ReadBool();

            int onum = su.ReadInt();
            c.options = new Option[onum];

            for (int u = 0; u < onum; u++)
            {
                Option o = new Option();
                c.options[u]    = o;
                o.text          = su.ReadString();
                o.destinationId = su.ReadInt();
                o._available    = su.ReadBool();
                o.choosenb4     = su.ReadBool();
                o.quest         = su.ReadBool();
            }
        }

        UpdateQuestIcon(true);
    }
Ejemplo n.º 14
0
    public static void Load(StreamUnpacker su)
    {
        // Reset Scene quests
        Parley.GetInstance().LoadSceneQuests();

        int n=su.ReadInt();
        Parley.GetInstance().GetCompletedQuests().Clear();
        for (int t=0;t<n;t++){
            Parley.GetInstance().GetCompletedQuests().Add(UnpackQuest(su));
        }

        n=su.ReadInt();
        Parley.GetInstance().GetCurrentQuests().Clear();
        for (int t=0;t<n;t++){
            Parley.GetInstance().GetCurrentQuests().Add(UnpackQuest(su));
        }

        // Bring quests in line
        Parley.GetInstance().SyncQuests();

        Debug.LogError(su.ReadString());

        // Unpack all events
        string[] allEvents=su.ReadStrings();
        HashSet<string> questEvents=Parley.GetInstance().GetQuestEventSet();
        questEvents.Clear();
        foreach (string s in allEvents){
            questEvents.Add(s);
        }

        Debug.LogError(su.ReadString());

        int activeEvents=su.ReadInt();
        Parley.GetInstance().GetActiveEvents().Clear();
        for (int t=0;t<activeEvents;t++){
            Parley.GetInstance().GetActiveEvents().Add(su.ReadString());
        }
        Debug.LogError(su.ReadString());
    }
Ejemplo n.º 15
0
    public void Load(string file)
    {
        FileStream fs = new FileStream(file, FileMode.Open);

        StreamUnpacker su = new StreamUnpacker(fs);

        // Save Parley
        ParleySaveLoad.Load(su);

        Debug.Log(su.ReadString());
        // Save all the Objects
        foreach (GameObject go in packableObjects)
        {
            PackUnpackableBehaviour[] pus = (PackUnpackableBehaviour[])go.GetComponents <PackUnpackableBehaviour>();
            Debug.Log("Parley: Loading details for object " + go.name);
            if (pus != null && pus.Length > 0)
            {
                foreach (PackUnpackableBehaviour pu in pus)
                {
                    Debug.Log("Parley: Loading details for script " + pu.GetType().Name);
                    Debug.Log("Parley: Saved Was " + su.ReadString());
                    pu.Unpack(su);
                }
            }
            pus = (PackUnpackableBehaviour[])go.GetComponentsInChildren <PackUnpackableBehaviour>(true);
            if (pus != null && pus.Length > 0)
            {
                foreach (PackUnpackableBehaviour pu in pus)
                {
                    Debug.Log("Parley: Loading details for script " + pu.GetType().Name);
                    Debug.Log("Parley: Saved Was " + su.ReadString());
                    pu.Unpack(su);
                }
            }
        }

        fs.Close();
    }
Ejemplo n.º 16
0
 override public void Unpack(StreamUnpacker sp)
 {
     gameObject.SetActive(sp.ReadBool());
     bridge.rigidbody.useGravity = !gameObject.activeSelf;
 }
Ejemplo n.º 17
0
 public override void Unpack(StreamUnpacker sp)
 {
     gameObject.SetActive(sp.ReadBool());
 }
Ejemplo n.º 18
0
    public static void Load(Stream inputStream)
    {
        StreamUnpacker su = new StreamUnpacker(inputStream);

        Load(su);
    }
Ejemplo n.º 19
0
    private static Quest UnpackQuest(StreamUnpacker su)
    {
        Quest q=new Quest();
        q.name=su.ReadString();
        q.uniqueId=su.ReadInt();
        q.description=su.ReadString();
        q.handinDescription=su.ReadString();
        q.afterDescription=su.ReadString();
        q.questevent=su.ReadString();
        q.activeevent=su.ReadString();
        q.playerCommands=(Command[])su.ReadObjects(typeof(Command));

        q.questrequirement=su.ReadString();
        q.open=su.ReadBool();
        q.completed=su.ReadBool();
        q.status=su.ReadString();
        q.lastEffected=Time.time+su.ReadFloat();

        int n=su.ReadInt();
        for (int t=0;t<n;t++){
            Objective o=new Objective();
            q.objectives.Add(o);
            o.description=su.ReadString();
            o.doneDescription=su.ReadString();
            o.locationObject=su.ReadString();
            o.count=su.ReadInt();
            o.optional=su.ReadBool();
            o.objectiveevent=su.ReadString();
            o.questevent=su.ReadString();
            o.activeevent=su.ReadString();
            o.playerCommands=(Command[])su.ReadObjects(typeof(Command));
            o.questrequirement=su.ReadString();
            o.completed=su.ReadBool();
            o.open=su.ReadBool();
        }
        return q;
    }
Ejemplo n.º 20
0
 public static void UnpackTransform(Transform packTransform, StreamUnpacker su)
 {
     packTransform.localPosition = new Vector3(su.ReadFloat(), su.ReadFloat(), su.ReadFloat());
     packTransform.localScale    = new Vector3(su.ReadFloat(), su.ReadFloat(), su.ReadFloat());
     packTransform.localRotation = new Quaternion(su.ReadFloat(), su.ReadFloat(), su.ReadFloat(), su.ReadFloat());
 }
Ejemplo n.º 21
0
 public static void Load(Stream inputStream)
 {
     StreamUnpacker su=new StreamUnpacker(inputStream);
     Load (su);
 }
 public abstract void Unpack(StreamUnpacker sp);
Ejemplo n.º 23
0
 public static void UnpackTransform(Transform packTransform,StreamUnpacker su)
 {
     packTransform.localPosition=new Vector3(su.ReadFloat(),su.ReadFloat(),su.ReadFloat());
     packTransform.localScale=new Vector3(su.ReadFloat(),su.ReadFloat(),su.ReadFloat());
     packTransform.localRotation=new Quaternion(su.ReadFloat(),su.ReadFloat(),su.ReadFloat(),su.ReadFloat());
 }
Ejemplo n.º 24
0
 override public void Unpack(StreamUnpacker sp)
 {
     gameObject.SetActive(sp.ReadBool());
 }
Ejemplo n.º 25
0
 public abstract void Unpack(StreamUnpacker sp);
Ejemplo n.º 26
0
 public void Unpack(StreamUnpacker sp)
 {
     objectName=sp.ReadString();
     method=sp.ReadString();
     paramaters=sp.ReadStrings();
     assignment=sp.ReadBool();
 }
Ejemplo n.º 27
0
        /// <summary>
        ///
        /// </summary>
        public static IStreamable GetStream(string i_productName, int i_index, string i_address, out int o_fixedSize, out bool o_isDynamic)
        {
            int rawSize = 0, offset = 0;
            //
            IStreamable stream = null;

            o_fixedSize = 0;
            o_isDynamic = false;
            //
            switch (i_productName)
            {
            case "X-Cobra Alpha 1":
            case "X-Swift Alpha 1":
                GetStreamPos(i_productName, ref rawSize, ref offset, ref o_fixedSize);
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
                stream = new SharedMemoryStream(i_address, rawSize, offset, o_fixedSize);
#elif UNITY_ANDROID
                // Firstly,read the bluetooth address from text file on Android platform.
                // You can download the bluetooth setting apk from :
                IniReader ir = IniReader.Open(Environment.SD_CARD_ROOT + "Ximmerse Runtime/Configs/Common.txt");
                if (ir == null)
                {
                    Log.e("StreamFactory", "No such file:" + Environment.SD_CARD_ROOT + "Ximmerse Runtime/Configs/Common.txt");
                }
                else
                {
                    i_address = ir.TryParseString(i_address + "@Address", i_address);
                }
                Log.e("StreamFactory", "i_address=" + i_address);
                stream = new VirtualStream(
                    new BleSerialPort(i_address),
                    offset, o_fixedSize
                    );
                o_isDynamic = true;
#endif
                break;

            case "X-Cobra Beta 0":
            case "X-Cobra Beta 2":
            case "X-Swift Alpha 0":
                GetStreamSize(i_productName, ref rawSize, ref o_fixedSize);
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
                BleSerialPort sp = new BleSerialPort(i_address);
#elif UNITY_ANDROID
                BleSerialPort sp = new BleSerialPort(i_address);
#endif
                StreamUnpacker unpacker = GetStreamUnpacker(i_productName, sp, rawSize, o_fixedSize);
                o_isDynamic = true; stream = unpacker;
                break;

            case "X-Cobra Alpha 0":
                if (XHawkServiceBase.main == null)
                {
                    Log.e("StreamFactory", "Initialize XimBlobTracking before DeviceBase");
                    return(null);
                }
                XHawkService usbSrv = XHawkServiceBase.main as XHawkService;
                GetStreamPos(i_productName, ref usbSrv.bleReadRawSize, ref usbSrv.bleReadOffset, ref usbSrv.bleReadSize);
                usbSrv.UpdateStreamPos(i_index);
                o_fixedSize = usbSrv.bleReadSize;
                o_isDynamic = true; stream = usbSrv.bleStreams[i_index];
                break;

            default:
                Log.e("StreamFactory", "Unknown device@" + i_productName);
                break;
            }
            return(stream);
        }
Ejemplo n.º 28
0
    public override void Unpack(StreamUnpacker su)
    {
        int cnum=su.ReadInt();
        conversations=new Conversation[cnum];
        for (int t=0;t<cnum;t++){
            Conversation c=new Conversation();
            conversations[t]=c;
            c.id=su.ReadInt();
            c.returnId=su.ReadInt();
            c.uniqueId=su.ReadInt();
            c.text=su.ReadString();
            c.repeattext=su.ReadString();
            c.once=su.ReadBool();
            c.fallthrough=su.ReadBool();
            c.questevent=su.ReadString();
            c.playerCommands=(Command[])su.ReadObjects(typeof(Command));
            c.questrequirement=su.ReadString();
            c.environmentalrequirement=su.ReadString();
            c._available=su.ReadBool();
            c._seen=su.ReadBool();

            int onum=su.ReadInt();
            c.options=new Option[onum];

            for (int u=0;u<onum;u++){
                Option o=new Option();
                c.options[u]=o;
                o.text=su.ReadString();
                o.destinationId=su.ReadInt();
                o._available=su.ReadBool();
                o.choosenb4=su.ReadBool();
                o.quest=su.ReadBool();
            }
        }

        UpdateQuestIcon(true);
    }