|
|
|
@ -39,9 +39,7 @@ bool Crawler::OnUserCreate(){ |
|
|
|
|
|
|
|
|
|
InitializeLevel("assets/Campaigns/1_1.tmx",CAMPAIGN_1_1); |
|
|
|
|
|
|
|
|
|
std::cout<<"Player loading."<<std::endl; |
|
|
|
|
player=std::make_unique<Warrior>(); |
|
|
|
|
std::cout<<"Player loaded."<<std::endl; |
|
|
|
|
|
|
|
|
|
//Initialize Camera.
|
|
|
|
|
camera=Camera2D{WINDOW_SIZE}; |
|
|
|
@ -50,7 +48,6 @@ bool Crawler::OnUserCreate(){ |
|
|
|
|
camera.SetWorldBoundary({0,0},WORLD_SIZE*24); |
|
|
|
|
camera.EnableWorldBoundary(false); |
|
|
|
|
|
|
|
|
|
std::cout<<"Camera loaded."<<std::endl; |
|
|
|
|
//Graphics
|
|
|
|
|
GFX_Warrior_Sheet.Load("assets/nico-warrior.png"); |
|
|
|
|
GFX_Slime_Sheet.Load("assets/slime.png"); |
|
|
|
@ -77,7 +74,6 @@ bool Crawler::OnUserCreate(){ |
|
|
|
|
GFX_ChainLightning.Load("assets/chain_lightning.png"); |
|
|
|
|
GFX_LightningSplash.Load("assets/lightning_splash_effect.png"); |
|
|
|
|
GFX_Meteor.Load("assets/meteor.png"); |
|
|
|
|
std::cout<<"Images loaded."<<std::endl; |
|
|
|
|
|
|
|
|
|
//Animations
|
|
|
|
|
sig::Animation::InitializeAnimations(); |
|
|
|
@ -86,9 +82,7 @@ bool Crawler::OnUserCreate(){ |
|
|
|
|
view=TileTransformedView{GetScreenSize(),{1,1}}; |
|
|
|
|
|
|
|
|
|
LoadLevel(CAMPAIGN_1_1); |
|
|
|
|
std::cout<<"Done Loading."<<std::endl; |
|
|
|
|
//ChangePlayerClass(WARRIOR);
|
|
|
|
|
std::cout<<"Set player class."<<std::endl; |
|
|
|
|
ChangePlayerClass(WARRIOR); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -753,7 +747,7 @@ void Crawler::SetupWorldShake(float duration){ |
|
|
|
|
|
|
|
|
|
void Crawler::InitializeLevel(std::string mapFile,MapName map){ |
|
|
|
|
TMXParser level(mapFile); |
|
|
|
|
std::cout<<"Done parsing."<<std::endl; |
|
|
|
|
|
|
|
|
|
size_t slashMarker = mapFile.find_last_of('/'); |
|
|
|
|
std::string baseDir=mapFile.substr(0,slashMarker+1); |
|
|
|
|
MAP_DATA[map]=level.GetData(); |
|
|
|
@ -762,7 +756,6 @@ void Crawler::InitializeLevel(std::string mapFile,MapName map){ |
|
|
|
|
std::string baseSourceDir=tag.data["source"].substr(slashMarkerSourceDir+1); |
|
|
|
|
if(MAP_TILESETS.find("assets/maps/"+baseSourceDir)==MAP_TILESETS.end()){ |
|
|
|
|
TSXParser tileset(baseDir+tag.data["source"]); |
|
|
|
|
std::cout<<"Done parsing tex. "<<std::endl; |
|
|
|
|
Renderable*r=new Renderable(); |
|
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].tileset=r; |
|
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].foregroundTiles=tileset.GetData().ForegroundTileData; |
|
|
|
@ -770,10 +763,8 @@ void Crawler::InitializeLevel(std::string mapFile,MapName map){ |
|
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].collision=tileset.GetData().CollisionData; |
|
|
|
|
MAP_TILESETS["assets/maps/"+baseSourceDir].staircaseTiles=tileset.GetData().StaircaseData; |
|
|
|
|
r->Load("assets/maps/"+tileset.GetData().ImageData.data["source"]); |
|
|
|
|
std::cout<<"Done loading. "<<std::endl; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
std::cout<<"Function done. "<<std::endl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Crawler::LoadLevel(MapName map){ |
|
|
|
@ -781,7 +772,7 @@ void Crawler::LoadLevel(MapName map){ |
|
|
|
|
foregroundTileGroups.clear(); |
|
|
|
|
currentLevel=map; |
|
|
|
|
WORLD_SIZE={MAP_DATA[map].MapData.width,MAP_DATA[map].MapData.height}; |
|
|
|
|
std::cout<<"Setup world size."<<std::endl; |
|
|
|
|
|
|
|
|
|
for(auto key:MAP_DATA[map].SpawnerData){ |
|
|
|
|
SpawnerTag&spawnData=MAP_DATA[map].SpawnerData[key.first]; |
|
|
|
|
std::vector<std::pair<MonsterName,vf2d>>monster_list; |
|
|
|
@ -795,7 +786,7 @@ void Crawler::LoadLevel(MapName map){ |
|
|
|
|
} |
|
|
|
|
SPAWNER_LIST.push_back(MonsterSpawner{{spawnData.ObjectData.GetFloat("x"),spawnData.ObjectData.GetFloat("y")},spawnerRadius*2,monster_list,spawnData.upperLevel}); |
|
|
|
|
} |
|
|
|
|
std::cout<<"Spawner lists done."<<std::endl; |
|
|
|
|
|
|
|
|
|
std::set<vi2d>foregroundTilesAdded,upperForegroundTilesAdded; |
|
|
|
|
for(int x=0;x<WORLD_SIZE.x;x++){ |
|
|
|
|
for(int y=0;y<WORLD_SIZE.y;y++){ |
|
|
|
@ -877,7 +868,7 @@ void Crawler::LoadLevel(MapName map){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
std::cout<<"Done preparing tilesheet reads"<<std::endl; |
|
|
|
|
|
|
|
|
|
int counter=0; |
|
|
|
|
bridgeLayerIndex=-1; |
|
|
|
|
for(LayerTag&layer:MAP_DATA[map].LayerData){ |
|
|
|
@ -886,10 +877,10 @@ void Crawler::LoadLevel(MapName map){ |
|
|
|
|
} |
|
|
|
|
counter++; |
|
|
|
|
} |
|
|
|
|
std::cout<<"Bridge Layer indexing done."<<std::endl; |
|
|
|
|
|
|
|
|
|
player->upperLevel=false; //Assume player starts on lower level.
|
|
|
|
|
player->SetPos(MAP_DATA[map].MapData.playerSpawnLocation); |
|
|
|
|
std::cout<<"Player spawn info set."<<std::endl; |
|
|
|
|
|
|
|
|
|
pathfinder.Initialize(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -982,24 +973,26 @@ std::map<std::string,std::vector<geom2d::rect<int>>>&Crawler::GetZoneData(MapNam |
|
|
|
|
void Crawler::ChangePlayerClass(Class cl){ |
|
|
|
|
switch(cl){ |
|
|
|
|
case WARRIOR:{ |
|
|
|
|
player.reset(new Warrior()); |
|
|
|
|
player.reset(new Warrior(player.get())); |
|
|
|
|
}break; |
|
|
|
|
case THIEF:{ |
|
|
|
|
player.reset(new Thief()); |
|
|
|
|
player.reset(new Thief(player.get())); |
|
|
|
|
}break; |
|
|
|
|
case TRAPPER:{ |
|
|
|
|
player.reset(new Trapper()); |
|
|
|
|
player.reset(new Trapper(player.get())); |
|
|
|
|
}break; |
|
|
|
|
case RANGER:{ |
|
|
|
|
player.reset(new Ranger()); |
|
|
|
|
player.reset(new Ranger(player.get())); |
|
|
|
|
}break; |
|
|
|
|
case WIZARD:{ |
|
|
|
|
player.reset(new Wizard()); |
|
|
|
|
player.reset(new Wizard(player.get())); |
|
|
|
|
}break; |
|
|
|
|
case WITCH:{ |
|
|
|
|
player.reset(new Witch()); |
|
|
|
|
player.reset(new Witch(player.get())); |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
sig::Animation::SetupPlayerAnimations(); |
|
|
|
|
GetPlayer()->InitializeClassAbilities(); |
|
|
|
|
GetPlayer()->UpdateIdleAnimation(DOWN); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|