Beispiel #1
0
 public Bitmap GetMap(mapObject[,] map)
 {
     using (Graphics g = Graphics.FromImage(MainBt))
     {
         g.Clear(Color.Black);
         g.DrawImage(back, new Point(0, 0));
         //DrawGrid(MainBt);
         for (int i = 0; i < map.GetLength(0); i++)
         {
             for (int j = 0; j < map.GetLength(1); j++)
             {
                 switch (map[i, j])
                 {
                     case mapObject.Asteroid:
                         g.DrawImage(AsteroidPicture, new Point(i * MapStruct.BlockSize + 5, j * MapStruct.BlockSize + MapStruct.Shift + 5));
                         break;
                     case mapObject.Planet:
                         g.DrawImage(planetPicture, new Point(i * MapStruct.BlockSize + 2, j * MapStruct.BlockSize + MapStruct.Shift + 2));
                         break;
                     case mapObject.Chest:
                         g.DrawImage(ChestPicture, new Point(i * MapStruct.BlockSize + 2, j * MapStruct.BlockSize + MapStruct.Shift + 2));
                         break;
                     case mapObject.PlanetYou:
                         g.DrawRectangle(penYou, i * MapStruct.BlockSize, j * MapStruct.BlockSize + MapStruct.Shift, MapStruct.BlockSize, MapStruct.BlockSize);
                         g.DrawImage(planetPicture, new Point(i * MapStruct.BlockSize + 2, j * MapStruct.BlockSize + MapStruct.Shift + 2));
                         break;
                     case mapObject.PlanetEnemy:
                         g.DrawRectangle(penEnemyPlanet, i * MapStruct.BlockSize, j * MapStruct.BlockSize + MapStruct.Shift, MapStruct.BlockSize, MapStruct.BlockSize);
                         g.DrawImage(planetPicture, new Point(i * MapStruct.BlockSize + 2, j * MapStruct.BlockSize + MapStruct.Shift + 2));
                         break;
                     case mapObject.DestroyerYou:
                         g.DrawRectangle(new Pen(Color.Purple, 1.5f), i * MapStruct.BlockSize, j * MapStruct.BlockSize + MapStruct.Shift, MapStruct.BlockSize, MapStruct.BlockSize);
                         g.DrawImage(DestroyerPicture, new Point(i * MapStruct.BlockSize + 4, j * MapStruct.BlockSize + MapStruct.Shift + 4));
                         break;
                     case mapObject.ColonistYou:
                         g.DrawRectangle(new Pen(Color.Purple, 1.5f), i * MapStruct.BlockSize, j * MapStruct.BlockSize + MapStruct.Shift, MapStruct.BlockSize, MapStruct.BlockSize);
                         g.DrawImage(ColonistPicture, new Point(i * MapStruct.BlockSize + 4, j * MapStruct.BlockSize + MapStruct.Shift + 4));
                         break;
                     case mapObject.DestroyerEnemy:
                         g.DrawRectangle(penEnemyShip, i * MapStruct.BlockSize, j * MapStruct.BlockSize + MapStruct.Shift, MapStruct.BlockSize, MapStruct.BlockSize);
                         g.DrawImage(DestroyerPicture, new Point(i * MapStruct.BlockSize + 4, j * MapStruct.BlockSize + MapStruct.Shift + 4));
                         break;
                     default:
                         break;
                 }
             }
         }
         return MainBt;
     }
 }
Beispiel #2
0
 private void InitPlanets(mapObject[,] map)
 {
     List<string> temp = new List<string> { "Ферос", "Иден Прайм", "Мавигон", "Тучанка", "Палавен", "Сур'Кеш", "Сильва", "Солярис", "Сион", "Велес", "Элата" };
     int indexName = 0;
     Random r = new Random();
     for (int i = 0; i < map.GetLength(0); i++)
     {
         for (int j = 0; j < map.GetLength(1); j++)
         {
             if (map[i, j] == mapObject.Planet)
                 planets.Add(new Point(i, j), new Planet(new Point(i, j), temp[indexName++], r.Next(2, 7), r.Next(2, 4), r.Next(1, 5), r.Next(50, 100)));
         }
     }
 }