Esempio n. 1
0
 public static void GenerateDroneMap()
 {
     for (int i = 0; i < DroneAreaSize.X; ++i)
     {
         List <int> line = new List <int>();
         for (int j = 0; j < DroneAreaSize.Y; ++j)
         {
             line.Add(0);
         }
         DroneMap1x1.Add(line);
     }
     IObject[] areaList = GlobalGame.GetObjectsByCustomId("Drone");
     for (int i = 0; i < areaList.Length; ++i)
     {
         Vector2 begin = areaList[i].GetWorldPosition() - DroneAreaBegin;
         begin.X = (int)begin.X / 8;
         begin.Y = (int)begin.Y / 8;
         for (float x = begin.X; x < begin.X + (float)areaList[i].GetSizeFactor().X; x += 1)
         {
             for (float y = begin.Y - (float)areaList[i].GetSizeFactor().Y + 1; y <= begin.Y; y += 1)
             {
                 DroneMap1x1[(int)x][(int)y] = 1;
             }
         }
     }
     for (int i = 0; i < DroneAreaSize.X; ++i)
     {
         for (int j = 0; j < DroneAreaSize.Y; ++j)
         {
             if (DroneMap1x1[i][j] > 0)
             {
                 if (DroneMap1x1[i + 1][j] > 0 && DroneMap1x1[i + 1][j + 1] > 0 && DroneMap1x1[i][j + 1] > 0)
                 {
                     DroneMap1x1[i][j] = 2;
                 }
                 else if (DroneMap1x1[i + 1][j] > 0 && DroneMap1x1[i + 1][j - 1] > 0 && DroneMap1x1[i][j - 1] > 0)
                 {
                     DroneMap1x1[i][j] = 2;
                 }
                 else if (DroneMap1x1[i - 1][j] > 0 && DroneMap1x1[i - 1][j - 1] > 0 && DroneMap1x1[i][j - 1] > 0)
                 {
                     DroneMap1x1[i][j] = 2;
                 }
                 else if (DroneMap1x1[i - 1][j] > 0 && DroneMap1x1[i - 1][j + 1] > 0 && DroneMap1x1[i][j + 1] > 0)
                 {
                     DroneMap1x1[i][j] = 2;
                 }
             }
         }
     }
 }