Example #1
0
 public void AddMap(int MapIndex, int mh, int mw, float[] fsp, float[] ssp, float[] fsr, float[] ssr)
 {
     lock (_mapsExpectant)
     {
         using (MapsContext db = new MapsContext())
         {
             Map _m = new Map()
             {
                 Id          = MapIndex,
                 MapHeight   = mh,
                 MapWidth    = mw,
                 SpawnPoints = new List <SpawnPoint>()
             };
             db.Maps.Add(_m);
             db.SaveChanges();
             SpawnPoint _newFirstSpawnPoint = new SpawnPoint()
             {
                 PositionX = fsp[0],
                 PositionY = fsp[1],
                 RotationX = fsr[0],
                 RotationY = fsr[1],
                 RotationZ = fsr[2],
                 RotationW = fsr[3],
                 Map       = _m
             };
             SpawnPoint _newSecondSpawnPoint = new SpawnPoint()
             {
                 PositionX = ssp[0],
                 PositionY = ssp[1],
                 RotationX = ssr[0],
                 RotationY = ssr[1],
                 RotationZ = ssr[2],
                 RotationW = ssr[3],
                 Map       = _m
             };
             _m.SpawnPoints = new List <SpawnPoint>()
             {
                 _newFirstSpawnPoint, _newSecondSpawnPoint
             };
             db.SpawnPoints.AddRange(new List <SpawnPoint>()
             {
                 _newFirstSpawnPoint, _newSecondSpawnPoint
             });
             db.SaveChanges();
         }
     }
 }
Example #2
0
 public Map GetMap(int mapIndex)
 {
     lock (_mapsExpectant)
     {
         int[] scale = new int[2];
         using (MapsContext db = new MapsContext())
         {
             foreach (Map m in db.Maps.Include(m => m.SpawnPoints))
             {
                 if (m.Id.Equals(mapIndex))
                 {
                     return(m);
                 }
             }
         }
         return(null);
     }
 }