예제 #1
0
        public static void CreateTestFromTrack(Track track)
        {
            var timeline = new linerider.Game.Timeline(
                track);

            timeline.Restart(track.GetStart(), 1);
            int framecount = 40 * 60 * 5;

            var filename = TRKWriter.SaveTrack(track, track.Name + ".test");

            if (System.IO.File.Exists(filename + ".result"))
            {
                System.IO.File.Delete(filename + ".result");
            }
            using (var f = System.IO.File.Create(filename + ".result"))
            {
                var bw = new BinaryWriter(f);
                bw.Write((int)framecount);
                var state = timeline.GetFrame(framecount);
                for (int i = 0; i < state.Body.Length; i++)
                {
                    bw.Write(state.Body[i].Location.X);
                    bw.Write(state.Body[i].Location.Y);
                }
            }
        }
예제 #2
0
        public static bool TestCompare(Track track, string dir)
        {
            var testfile = dir + track.Name + ".test.trk.result";

            if (!File.Exists(testfile))
            {
                return(false);
            }
            using (var file =
                       File.Open(testfile, FileMode.Open))
            {
                var br       = new BinaryReader(file);
                var frame    = br.ReadInt32();
                var timeline = new linerider.Game.Timeline(
                    track);
                timeline.Restart(track.GetStart(), 1);
                //track.Chunks.fg.PrintMetrics();
                var state = timeline.GetFrame(frame);
                for (int i = 0; i < state.Body.Length; i++)
                {
                    var x      = br.ReadDouble();
                    var y      = br.ReadDouble();
                    var riderx = state.Body[i].Location.X;
                    var ridery = state.Body[i].Location.Y;
                    if (x != riderx || y != ridery)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
예제 #3
0
        public static void ExportTrackData(Track track, string fn, int frames, ICamera camera)
        {
            var timeline = new linerider.Game.Timeline(
                track);

            timeline.Restart(track.GetStart(), 1);
            timeline.GetFrame(frames);
            camera.SetTimeline(timeline);
            List <RiderData> data = new List <RiderData>();

            for (int idx = 0; idx < frames; idx++)
            {
                var frame     = timeline.GetFrame(idx);
                var framedata = new RiderData();
                framedata.Frame  = idx;
                framedata.Points = new List <track_json.point_json>();
                for (int i = 0; i < frame.Body.Length; i++)
                {
                    var point = frame.Body[i];
                    framedata.Points.Add(new track_json.point_json()
                    {
                        x = point.Location.X,
                        y = point.Location.Y
                    });
                    var camframe = camera.GetFrameCamera(idx);
                    framedata.CameraCenter = new track_json.point_json()
                    {
                        x = camframe.X,
                        y = camframe.Y
                    };
                }
                data.Add(framedata);
            }

            using (var file = File.Create(fn))
            {
                var bytes = JsonSerializer.Serialize <List <RiderData> >(data);
                file.Write(bytes, 0, bytes.Length);
            }
        }