Exemplo n.º 1
0
    public RecrdngSerial Serialize()
    {
        RecrdngSerial rtn = new RecrdngSerial();

        rtn.Vehicles = new RecordableVehicleSerial[Recordables.Count()];
        int i = 0;

        foreach (RecordableVehicle rv in  Recordables)
        {
            rtn.Vehicles[i] = rv.Serialize();
            i++;
        }
        int SavedFrameCount = EndFrame - StartFrame;

        rtn.Data = new RecFrameDataSerial[SavedFrameCount, Recordables.Count()];

        for (int f = 0; f < SavedFrameCount; f++)
        {
            for (int r = 0; r < Recordables.Count(); r++)
            {
                rtn.Data[f, r] = this.Data[f + StartFrame][r].Serialize();
            }
        }
        return(rtn);
    }
Exemplo n.º 2
0
    public Recrdng(string filename)
    {
        Filename = filename;
        BinaryFormatter bf = new BinaryFormatter();

        if (File.Exists(Application.persistentDataPath + "/" + Filename))
        {
            FileStream    file      = File.Open(Application.persistentDataPath + "/" + Filename, FileMode.Open);
            RecrdngSerial rs        = (RecrdngSerial)bf.Deserialize(file);
            int           _vehCount = rs.Data.GetLength(1);
            Main.Instance.Vehicles = rs.Vehicles.ToList();
            FrameCount             = rs.Data.GetLength(0);
            Data = new List <List <RecFrameData> >();
            for (int f = 0; f < FrameCount; f++)
            {
                List <RecFrameData> lf = new List <RecFrameData>();
                for (int v = 0; v < _vehCount; v++)
                {
                    RecFrameData       rfd  = new RecFrameData();
                    RecFrameDataSerial rfds = rs.Data[f, v];
                    rfd.VId       = rfds.VId;
                    rfd.FAV       = (sbyte)rfds.FAngularVelocity;
                    rfd.RAV       = (sbyte)rfds.RAngularVelocity;
                    rfd.FLSprL    = rfds.FLSprL;
                    rfd.FRSprL    = rfds.FRSprL;
                    rfd.RLSprL    = rfds.RLSprL;
                    rfd.RRSprL    = rfds.RRSprL;
                    rfd.FLGnd     = rfds.FLGnd;
                    rfd.FRGnd     = rfds.FRGnd;
                    rfd.RLGnd     = rfds.RLGnd;
                    rfd.RRGnd     = rfds.RRGnd;
                    rfd.Pos       = rfds.Pos.V3;
                    rfd.Rot       = rfds.Rot.Decode;
                    rfd.XMovement = rfds.XMovement;
                    if (rfds.Events != null)
                    {
                        rfd.Events = rfds.Events.ToList();
                    }
                    //rfd.Event = new RecEvent {Type = (RecEventType)rfds.EventType, Data = rfds.EventData };
                    lf.Add(rfd);
                }
                Data.Add(lf);
            }
            file.Close();
            CurrFrame = 0;
        }
    }