Пример #1
0
 private Player()
 {
     _frames = new List<ImageUnit[]>();
     _keysImage = new ImageUnit[3];
     try
     {
         ImageUnit character = new ImageUnit(_characterImageName);
         for (int row = 0; row < RowFrame; row++)
         {
             ImageUnit[] tmp = new ImageUnit[ColFrame];
             for (int col = 0; col < ColFrame; col++)
             {
                 Rectangle rect = new Rectangle(col * Floor.ObjectSize, row * Floor.ObjectSize, Floor.ObjectSize, Floor.ObjectSize);
                 tmp[col] = character.GetSubImage(rect);
             }
             _frames.Add(tmp);
         }
         _keysImage[0] = MapObjectFactory.CreateMapObject(MapObjectType.YellowKey).Frames[0];
         _keysImage[1] = MapObjectFactory.CreateMapObject(MapObjectType.BlueKey).Frames[0];
         _keysImage[2] = MapObjectFactory.CreateMapObject(MapObjectType.RedKey).Frames[0];
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
 }
 static MapObjectFactory()
 {
     ImageUnit img = new ImageUnit(FloorImageName);
     _objectInCol = img.Width / Floor.ObjectSize;
     _objectInRow = img.Height / Floor.ObjectSize;
     _dataSet = new List<List<ImageUnit>>();
     for (int row = 0; row < _objectInRow; row++)
     {
         if (row <= 7) // Item
         {
             for (int col = 0; col < _objectInCol; col++)
             {
                 Rectangle rect = new Rectangle(col * Floor.ObjectSize, row * Floor.ObjectSize, Floor.ObjectSize, Floor.ObjectSize);
                 _dataSet.Add(new List<ImageUnit>() { img.GetSubImage(rect) });
             }
         }
         else if (row == 8) // Shop
         {
             List<ImageUnit> frames = new List<ImageUnit>();
             for (int col = 0; col < 2; col++)
             {
                 Rectangle rect = new Rectangle(col * Floor.ObjectSize, row * Floor.ObjectSize, Floor.ObjectSize, Floor.ObjectSize);
                 frames.Add(img.GetSubImage(rect));
             }
             // TODO: Set Shop
             _dataSet.Add(frames);
             for (int col = 2; col < 4; col++)
             {
                 Rectangle rect = new Rectangle(col * Floor.ObjectSize, row * Floor.ObjectSize, Floor.ObjectSize, Floor.ObjectSize);
                 _dataSet.Add(new List<ImageUnit>() { img.GetSubImage(rect) });
             }
         }
         else // NPC & Monster
         {
             List<ImageUnit> frames = new List<ImageUnit>();
             for (int col = 0; col < _objectInCol - 1; col++)
             {
                 Rectangle rect = new Rectangle(col * Floor.ObjectSize, row * Floor.ObjectSize, Floor.ObjectSize, Floor.ObjectSize);
                 frames.Add(img.GetSubImage(rect));
             }
             _dataSet.Add(frames);
         }
     }
 }