Ejemplo n.º 1
0
        unsafe static byte[] SaveLayout(ref LayOut data)
        {
            byte[] buff = new byte[4096];
            fixed(byte *pb = &buff[0])
            {
                float *pf = (float *)pb;

                *pf = data.role.origin.x;
                pf++;
                *pf = data.role.origin.y;
                pf++;
                int *head = (int *)pf;

                pf += 22;//offset=96
                int p = (int)pf;
                int c = 0;

                c = SaveData(ref data.land, p);
                *head = c;
                head++;
                p += c * 20;
                c  = SaveData(ref data.needle, p);
                *head = c;
                head++;
                p += c * 20;
                c  = SaveData(ref data.record, p);
                *head = c;
                head++;
                p += c * 20;
            }

            return(buff);
        }
Ejemplo n.º 2
0
 public static void View(int index)
 {
     view          = level[index];
     role.location = level[index].role.origin;
     role.origin   = level[index].role.origin;
     SetCurrentLayout(ref view);
 }
Ejemplo n.º 3
0
 public static void LoadLayOut(LayOut l)
 {
     buff_land = l.land;
     LoadLand(ref buff_land, iid.land);
     buff_needle = l.needle;
     LoadNeedle(ref buff_needle, iid.needle);
     role.origin   = l.role.origin;
     role.location = role.origin;
     role.motion.x = 0;
     role.motion.y = 0;
 }
Ejemplo n.º 4
0
 static void SetCurrentLayout(ref LayOut lay)
 {
     if (lay.land != null)
     {
         LoadLand(ref lay.land, iid.land);
     }
     if (lay.needle != null)
     {
         LoadNeedle(ref lay.needle, iid.needle);
     }
     if (lay.record != null)
     {
         LoadRecord(ref lay.record, iid.record);
     }
     GetPoints(role.location, ref role.points);
     CaculRect_PosA(ref buff_img[role.imgid].vertex, role.location, 0.0675f, 0.12f, 0);
 }
Ejemplo n.º 5
0
        public static async void LoadAppLayout(string name, LoadLayout t)
        {
            Uri u = new Uri("ms-appx:///Maps/" + name);
            RandomAccessStreamReference rass = RandomAccessStreamReference.CreateFromUri(u);
            IRandomAccessStream         ir   = await rass.OpenReadAsync();

            Stream s = ir.AsStream();

            byte[] buff = new byte[s.Length];
            s.Read(buff, 0, buff.Length);
            int c = buff.Length / 4096;

            LayOut[] l = new LayOut[c];
            for (int i = 0; i < c; i++)
            {
                l[i] = LoadLayout(ref buff, i * 4096);
            }
            t(l);
        }
Ejemplo n.º 6
0
        public static void ReplaceLayout(ref LayOut l, string name, int index)
        {
            string path = ApplicationData.Current.LocalFolder.Path;

            path += "\\" + name + ".map";
            byte[]     t = SaveLayout(ref l);
            FileStream fs;

            if (File.Exists(path))
            {
                fs = File.OpenWrite(path);
                fs.Seek(index * 4096, SeekOrigin.Current);
                fs.Write(t, 0, 4096);
            }
            else
            {
                fs = File.Create(path, 4096);
                fs.Write(t, 0, 4096);
            }
            fs.Dispose();
        }
Ejemplo n.º 7
0
        unsafe static LayOut LoadLayout(ref byte[] data, int offset)
        {
            LayOut l = new LayOut();

            fixed(byte *pb = &data[offset])
            {
                float *pf = (float *)pb;

                l.role.origin.x = *pf;
                pf++;
                l.role.origin.y = *pf;
                pf++;
                int *head = (int *)pf;

                pf += 22;//offset=96
                int p = (int)pf;
                int c = *head;

                LandDate[] t = new LandDate[c];
                LoadData(ref data, ref t, p);
                l.land = t;
                head++;
                p += c * 20;
                c  = *head;
                t  = new LandDate[c];
                LoadData(ref data, ref t, p);
                l.needle = t;
                head++;
                p += c * 20;
                c  = *head;
                t  = new LandDate[c];
                LoadData(ref data, ref t, p);
                l.record = t;
            }

            return(l);
        }