Exemple #1
0
    public override void LoadFrame(string binarySave)
    {
        byte[]              byteArray = Convert.FromBase64String(binarySave);
        MemoryStream        mf        = new MemoryStream(byteArray);
        BinaryFormatter     bf        = new BinaryFormatter();
        BulletBaseFrameSave data      = (BulletBaseFrameSave)bf.Deserialize(mf);

        id = new Guid(data.id);

        transform.position = VectorArrayConverter.arrayToVector3(data.position);
        transform.rotation = Quaternion.Euler(VectorArrayConverter.arrayToVector3(data.rotation));
        direction          = VectorArrayConverter.arrayToVector3(data.direction);

        speed = data.speed;
    }
Exemple #2
0
    public override string MakeFrame()
    {
        BinaryFormatter bf = new BinaryFormatter();
        MemoryStream    ms = new MemoryStream();

        BulletBaseFrameSave data = new BulletBaseFrameSave();

        data.id = new Byte[id.ToByteArray().Length];
        id.ToByteArray().CopyTo(data.id, 0);

        data.speed     = speed;
        data.position  = VectorArrayConverter.vector3ToArray(transform.position);
        data.rotation  = VectorArrayConverter.vector3ToArray(transform.rotation.eulerAngles);
        data.direction = VectorArrayConverter.vector3ToArray(transform.forward);

        bf.Serialize(ms, data);

        return(Convert.ToBase64String(ms.ToArray()));
    }