generateMiniMap method

void generateMiniMap()

Implementation

void generateMiniMap() async{
  if(levelInfo[selectedLevel].objects.isEmpty && allTileImage == null || !updateMinMap) return;
  updateMinMap = false;
  TileAtlas tiles = TileAtlas();
  List<Offset> pos = [];
  List<Offset> text = [];

  if(levelInfo[selectedLevel].tileLayer.isNotEmpty && allTileImage != null){
    for(int j = 0; j < levelInfo[selectedLevel].tileLayer.length;j++){
      List<TileRects> tileRectes = levelInfo[selectedLevel].tileLayer[j].tiles;
      for(int i = 0; i < tileRectes.length; i++){
        if(tileRectes[i].position.isNotEmpty){
          Size size = levelInfo[selectedLevel].grid.boxSize;
          int j = tileRectes[i].position[0];
          int k = tileRectes[i].position[1];
          Vector3 position = Converter.toVector3(
            camera.position,
            Offset(
              j*size.width,
              k*size.height
            )
          );
          Offset newPosition = Converter.toOffset(camera.position,position);
          double scale = (levelInfo[selectedLevel].grid.boxSize.width/tileRectes[i].rect.width);
          tiles.rect.add(tileRectes[i].rect);
          tiles.transform.add(
            RSTransform.fromComponents(
              rotation: 0,
              scale: scale,
              anchorX: 0,
              anchorY: 0,
              translateX: newPosition.dx,
              translateY: newPosition.dy
            )
          );
        }
      }
    }
  }

  Size size = Size(levelInfo[selectedLevel].grid.boxSize.width*levelInfo[selectedLevel].grid.width,levelInfo[selectedLevel].grid.boxSize.height*levelInfo[selectedLevel].grid.height);
  await _generateImage(tiles,allTileImage,pos,text,allObjectImage,size).then((value){
    levelImage = value;
    //updateMinMap = true;
  });
}