diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index e4f8ef7d..cd11758a 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -884,10 +884,11 @@ void Crawler::LoadLevel(MapName map){ } SPAWNER_LIST.push_back(MonsterSpawner{{spawnData.ObjectData.GetFloat("x"),spawnData.ObjectData.GetFloat("y")},spawnerRadius*2,monster_list,spawnData.upperLevel}); } - + //165,124 std::setforegroundTilesAdded,upperForegroundTilesAdded; for(int x=0;xIsForeground,TileRenderData tile,std::set&foregroundTilesIncluded,std::vector&groups){ - int layerID=layer.tag.GetInteger("id"); - if(IsForeground(tileSheet,tileSheetIndex)&&foregroundTilesIncluded.find({x,y})==foregroundTilesIncluded.end()){ + if(foregroundTilesIncluded.find({x,y})==foregroundTilesIncluded.end()&&IsForeground(tileSheet,tileSheetIndex)){ std::queuetileGroupChecks; TileGroup group; foregroundTilesIncluded.insert({x,y}); - group.originatingLayer=layerID; group.InsertTile(tile); - if(x>0)tileGroupChecks.push({x-1,y}); - if(x0)tileGroupChecks.push({x,y-1}); - if(y0&&foregroundTilesIncluded.find(vi2d{x,y}+vi2d{-1,0})==foregroundTilesIncluded.end())tileGroupChecks.push({x-1,y}); + if(x0&&foregroundTilesIncluded.find(vi2d{x,y}+vi2d{0,-1})==foregroundTilesIncluded.end())tileGroupChecks.push({x,y-1}); + if(ySprite()->width/24; @@ -920,45 +921,61 @@ void Crawler::LoadLevel(MapName map){ int tileSheetIndex=tileID-(tileSheet.firstgid-1); int tileSheetX=tileSheetIndex%tileSheetWidth; int tileSheetY=tileSheetIndex/tileSheetWidth; - TileRenderData tile={tileSheet.tileset.tileset->Decal(),vi2d{pos.x,pos.y}*24,vi2d{tileSheetX,tileSheetY}*24}; + TileRenderData tile={tileSheet.tileset.tileset->Decal(),vi2d{pos.x,pos.y}*24,vi2d{tileSheetX,tileSheetY}*24,layer2ID}; if(IsForeground(tileSheet,tileSheetIndex)){ foregroundTilesIncluded.insert({pos.x,pos.y}); group.InsertTile(tile); + hadForeground=true; } + layer2ID++; } + return hadForeground; }; IterateThroughOtherLayers({x,y}); while(!tileGroupChecks.empty()){ vi2d&pos=tileGroupChecks.front(); - tileGroupChecks.pop(); - int tileID=layer.tiles[pos.y][pos.x]-1; - TilesheetData tileSheet=GetTileSheet(currentLevel,tileID); - int tileSheetWidth=tileSheet.tileset.tileset->Sprite()->width/24; - int tileSheetHeight=tileSheet.tileset.tileset->Sprite()->height/24; - int tileSheetIndex=tileID-(tileSheet.firstgid-1); - int tileSheetX=tileSheetIndex%tileSheetWidth; - int tileSheetY=tileSheetIndex/tileSheetWidth; - TileRenderData tile={tileSheet.tileset.tileset->Decal(),pos*24,vi2d{tileSheetX,tileSheetY}*24}; - if(IsForeground(tileSheet,tileSheetIndex)&&foregroundTilesIncluded.find(pos)==foregroundTilesIncluded.end()){ - foregroundTilesIncluded.insert(pos); - group.InsertTile(tile); - if(pos.x>0)tileGroupChecks.push(pos+vi2d{-1,0}); - if(pos.x0)tileGroupChecks.push(pos+vi2d{0,-1}); - if(pos.y0&&foregroundTilesIncluded.find(targetPos)==foregroundTilesIncluded.end()){tileGroupChecks.push(targetPos);foregroundTilesIncluded.insert(targetPos);} + targetPos=pos+vi2d{1,0}; + if(pos.x0&&foregroundTilesIncluded.find(targetPos)==foregroundTilesIncluded.end()){tileGroupChecks.push(targetPos);foregroundTilesIncluded.insert(targetPos);} + targetPos=pos+vi2d{0,1}; + if(pos.yDecal(),vi2d{x,y}*24,vi2d{tileSheetX,tileSheetY}*24}; + TileRenderData tile={tileSheet.tileset.tileset->Decal(),vi2d{x,y}*24,vi2d{tileSheetX,tileSheetY}*24,layerID}; SetupTileGroups([&](TilesheetData sheet,int tileID){return IsForegroundTile(sheet,tileID);},tile,foregroundTilesAdded,foregroundTileGroups); SetupTileGroups([&](TilesheetData sheet,int tileID){return IsUpperForegroundTile(sheet,tileID);},tile,upperForegroundTilesAdded,upperForegroundTileGroups); #pragma endregion } + layerID++; + } + } + } + + for(TileGroup&group:foregroundTileGroups){ + for(TileRenderData&dat:group.GetTiles()){ + if(dat.pos==vi2d{165,124}*24){ + std::cout<>> ZoneData; LayerTag l = {newTag}; parsedMapInfo.LayerData.push_back(l); }else - if (newTag.tag=="object"&&newTag.data["type"]=="UpperSpawnGroup") { - parsedMapInfo.SpawnerData[newTag.GetInteger("id")]={newTag}; - parsedMapInfo.SpawnerData[newTag.GetInteger("id")].upperLevel=true; - } else if (newTag.tag=="object"&&newTag.data["type"]=="SpawnGroup") { parsedMapInfo.SpawnerData[newTag.GetInteger("id")]={newTag}; } else @@ -318,6 +314,23 @@ typedef std::map>> ZoneData; for(XMLTag&monster:accumulatedMonsterTags){ parsedMapInfo.SpawnerData[monster.GetInteger("spawnerLink")].monsters.push_back(monster); } + + for(auto&spawnerData:parsedMapInfo.SpawnerData){ + SpawnerTag&spawner=spawnerData.second; + for(auto&zoneData:parsedMapInfo.ZoneData){ + if(zoneData.first=="UpperZone"){ + std::vector>&zones=zoneData.second; + for(geom2d::rect&zone:zones){ + if(geom2d::overlaps(zone,geom2d::rect{{spawner.ObjectData.GetInteger("x"),spawner.ObjectData.GetInteger("y")},{spawner.ObjectData.GetInteger("width"),spawner.ObjectData.GetInteger("height")}})){ + spawner.upperLevel=true; + goto continueSpawnerLoop; + } + } + } + } + continueSpawnerLoop: + continue; + } std::cout<<"Parsed Map Data:\n"< - + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, diff --git a/Crawler/assets/config/MonsterStrategies.txt b/Crawler/assets/config/MonsterStrategies.txt index 2c357071..a26fe308 100644 --- a/Crawler/assets/config/MonsterStrategies.txt +++ b/Crawler/assets/config/MonsterStrategies.txt @@ -63,7 +63,7 @@ MonsterStrategy # How far away the monster starts shooting from Range = 800 # How often the enemy shoots. - ShootingSpeed = 0.6 + ShootingSpeed = 2 BulletSpeed = 450 BulletSize = 30 BulletColor = 0, 255, 0, 255