diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 06dd43ad..97b2bd7b 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -2288,10 +2288,6 @@ const MapName&AiL::GetCurrentLevel()const{ return currentLevel; } -std::map>&AiL::GetZoneData(MapName map){ - return MAP_DATA[map].ZoneData; -} - void AiL::ChangePlayerClass(Class cl){ Ability itemAbility1=player->useItem1; Ability itemAbility2=player->useItem2; diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index 39203f70..019deb78 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -231,7 +231,6 @@ public: bool HasTileCollision(MapName map,vf2d pos,bool upperLevel=false); const MapName&GetCurrentLevel()const; bool IsBridgeLayer(LayerTag&layer); - std::map>&GetZoneData(MapName map); void PopulateRenderLists(); void ChangePlayerClass(Class cl); std::string GetString(std::string key); diff --git a/Adventures in Lestoria/ItemDrop.cpp b/Adventures in Lestoria/ItemDrop.cpp index c6fb63aa..64c73833 100644 --- a/Adventures in Lestoria/ItemDrop.cpp +++ b/Adventures in Lestoria/ItemDrop.cpp @@ -118,13 +118,13 @@ void ItemDrop::UpdateDrops(float fElapsedTime){ #pragma region Handle Upper/Lower Level Zone Intersecting if(drop.speed.mag()>0){ - std::map>&zoneData=game->GetZoneData(game->GetCurrentLevel()); - for(ZoneData&upperLevelZone:zoneData["UpperZone"]){ + const std::map>&zoneData=game->GetZones(game->GetCurrentLevel()); + for(const ZoneData&upperLevelZone:zoneData.at("UpperZone")){ if(geom2d::overlaps(upperLevelZone.zone,drop.pos)){ drop.upperLevel=true; } } - for(ZoneData&lowerLevelZone:zoneData["LowerZone"]){ + for(const ZoneData&lowerLevelZone:zoneData.at("LowerZone")){ if(geom2d::overlaps(lowerLevelZone.zone,drop.pos)){ drop.upperLevel=false; } diff --git a/Adventures in Lestoria/Monster.cpp b/Adventures in Lestoria/Monster.cpp index c70db3d4..ce6214a3 100644 --- a/Adventures in Lestoria/Monster.cpp +++ b/Adventures in Lestoria/Monster.cpp @@ -455,13 +455,13 @@ bool Monster::SetPos(vf2d pos){ return resultX||resultY; } void Monster::Moved(){ - std::map>&zoneData=game->GetZoneData(game->GetCurrentLevel()); - for(ZoneData&upperLevelZone:zoneData["UpperZone"]){ + const std::map>&zoneData=game->GetZones(game->GetCurrentLevel()); + for(const ZoneData&upperLevelZone:zoneData.at("UpperZone")){ if(geom2d::overlaps(upperLevelZone.zone,pos)){ upperLevel=true; } } - for(ZoneData&lowerLevelZone:zoneData["LowerZone"]){ + for(const ZoneData&lowerLevelZone:zoneData.at("LowerZone")){ if(geom2d::overlaps(lowerLevelZone.zone,pos)){ upperLevel=false; } diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index 86351966..e650d126 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -783,13 +783,13 @@ void Player::Moved(){ spawner.SetTriggered(true); } } - std::map>&zoneData=game->GetZoneData(game->GetCurrentLevel()); - for(ZoneData&upperLevelZone:zoneData["UpperZone"]){ + const std::map>&zoneData=game->GetZones(game->GetCurrentLevel()); + for(const ZoneData&upperLevelZone:zoneData.at("UpperZone")){ if(geom2d::overlaps(upperLevelZone.zone,pos)){ upperLevel=true; } } - for(ZoneData&lowerLevelZone:zoneData["LowerZone"]){ + for(const ZoneData&lowerLevelZone:zoneData.at("LowerZone")){ if(geom2d::overlaps(lowerLevelZone.zone,pos)){ upperLevel=false; } diff --git a/Adventures in Lestoria/State_MainMenu.cpp b/Adventures in Lestoria/State_MainMenu.cpp index fe8ca8f0..bc8bf673 100644 --- a/Adventures in Lestoria/State_MainMenu.cpp +++ b/Adventures in Lestoria/State_MainMenu.cpp @@ -41,6 +41,7 @@ All rights reserved. #include "TitleScreen.h" #include "Key.h" #include "ItemDrop.h" +#include "util.h" INCLUDE_game @@ -53,8 +54,12 @@ void State_MainMenu::OnStateChange(GameState*prevState){ void State_MainMenu::OnLevelLoad(){ game->GetPlayer()->SetIframes(999999.f); game->GetPlayer()->SetInvisible(true); + SelectAndMoveToNewFocusArea(); } void State_MainMenu::OnUserUpdate(AiL*game){ + game->GetPlayer()->ForceSetPos(game->GetPlayer()->GetPos()+cameraMoveDir*8*game->GetElapsedTime()); + lastMoveTime+=game->GetElapsedTime(); + if(lastMoveTime>8.f)SelectAndMoveToNewFocusArea(); TitleScreen::Update(); if(AiL::KEY_CONFIRM.Released()){ TitleScreen::Skip(); @@ -70,4 +75,38 @@ void State_MainMenu::OnUserUpdate(AiL*game){ }; void State_MainMenu::Draw(AiL*game){ TitleScreen::Draw(); -}; \ No newline at end of file +}; + +const ZoneData&State_MainMenu::ChooseRandomFocusArea(){ + //std::vector + if(game->GetZones().count("Focus Area")>0){ + const std::vector&zones=game->GetZones().at("Focus Area"); + newSelectedFocusAreaIndex=util::random()%zones.size(); + return zones[newSelectedFocusAreaIndex]; + }else ERR("WARNING! No focus areas included in the intro map!"); + + return game->GetZones().at("Focus Area")[0]; +} + +void State_MainMenu::SelectAndMoveToNewFocusArea(){ + const ZoneData&newFocusArea=ChooseRandomFocusArea(); + if(lastSelectedFocusAreaIndex==newSelectedFocusAreaIndex)return; + game->camera.MoveCamera(newFocusArea.zone.pos); + game->GetPlayer()->ForceSetPos(newFocusArea.zone.pos); + cameraMoveDir={}; + for(const XMLTag&tag:newFocusArea.properties){ + if(tag.data.at("name")=="Scroll Direction"){ + std::string_view dir=tag.data.at("value"); + if(dir=="NORTH"sv)cameraMoveDir={0.f,-1.f};else + if(dir=="NORTHEAST"sv)cameraMoveDir={1.f,-1.f};else + if(dir=="EAST"sv)cameraMoveDir={1.f,0.f};else + if(dir=="SOUTHEAST"sv)cameraMoveDir={1.f,1.f};else + if(dir=="SOUTH"sv)cameraMoveDir={0.f,1.f};else + if(dir=="SOUTHWEST"sv)cameraMoveDir={-1.f,1.f};else + if(dir=="WEST"sv)cameraMoveDir={-1.f,0.f};else + if(dir=="NORTHWEST"sv)cameraMoveDir={-1.f,-1.f}; + } + } + lastMoveTime=0.f; + lastSelectedFocusAreaIndex=newSelectedFocusAreaIndex; +} \ No newline at end of file diff --git a/Adventures in Lestoria/State_MainMenu.h b/Adventures in Lestoria/State_MainMenu.h index 4f427621..8bccbd4f 100644 --- a/Adventures in Lestoria/State_MainMenu.h +++ b/Adventures in Lestoria/State_MainMenu.h @@ -36,10 +36,18 @@ All rights reserved. */ #pragma endregion #include "GameState.h" +#include "TMXParser.h" class State_MainMenu:public GameState{ virtual void OnStateChange(GameState*prevState)override final; virtual void OnUserUpdate(AiL*game)override final; virtual void Draw(AiL*game)override final; virtual void OnLevelLoad()override final; + + const ZoneData&ChooseRandomFocusArea(); + vf2d cameraMoveDir; + float lastMoveTime=0.f; + size_t newSelectedFocusAreaIndex=0; + size_t lastSelectedFocusAreaIndex=0; + void SelectAndMoveToNewFocusArea(); }; \ No newline at end of file diff --git a/Adventures in Lestoria/TMXParser.h b/Adventures in Lestoria/TMXParser.h index 425a3d82..efd65fe2 100644 --- a/Adventures in Lestoria/TMXParser.h +++ b/Adventures in Lestoria/TMXParser.h @@ -98,6 +98,7 @@ struct SpawnerTag{ struct ZoneData{ geom2d::rectzone; bool isUpper=false; + std::vectorproperties; }; struct NPCData{ @@ -517,23 +518,19 @@ class TMXParser{ if(newTag.tag=="property"&¤tStagePlate!=nullptr){ currentStagePlate->properties[newTag.data["name"]]={newTag.data["name"],newTag.data["value"]}; }else + if(newTag.tag=="property"&&prevZoneData!=nullptr){ + //This is a property for a zone that doesn't fit into the other categories, we add it to the previous zone data encountered. + prevZoneData->properties.push_back(newTag); + }else if (newTag.tag=="object"&&newTag.data.find("type")!=newTag.data.end()){ //This is an object with a type that doesn't fit into other categories, we can add it to ZoneData. - if(parsedMapInfo.ZoneData.find(newTag.data["type"])!=parsedMapInfo.ZoneData.end()){ - std::vector&zones=parsedMapInfo.ZoneData.at(newTag.data["type"]); - float width=1.f; - float height=1.f; - if(newTag.data.count("width")>0)width=newTag.GetFloat("width"); - if(newTag.data.count("height")>0)height=newTag.GetFloat("height"); - zones.emplace_back(geom2d::rect{{newTag.GetInteger("x"),newTag.GetInteger("y")},{int(width),int(height)}}); - prevZoneData=&zones.back(); - } else { - if(newTag.data["width"].length()>0&&newTag.data["height"].length()>0){ //This ensures the zone is valid to begin with. - std::vector&zones=parsedMapInfo.ZoneData[newTag.data["type"]]; - zones.emplace_back(geom2d::rect{{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}}); - prevZoneData=&zones.back(); - } - } + std::vector&zones=parsedMapInfo.ZoneData[newTag.data["type"]]; + float width=1.f; + float height=1.f; + if(newTag.data.count("width")>0)width=newTag.GetFloat("width"); + if(newTag.data.count("height")>0)height=newTag.GetFloat("height"); + zones.emplace_back(geom2d::rect{{newTag.GetInteger("x"),newTag.GetInteger("y")},{int(width),int(height)}}); + prevZoneData=&zones.back(); }else{ #ifdef _DEBUG if(_DEBUG_MAP_LOAD_INFO)std::cout<<"Unsupported tag format! Ignoring."<<"\n"; diff --git a/Adventures in Lestoria/TODO.txt b/Adventures in Lestoria/TODO.txt index 3d2961b2..f65cddb2 100644 --- a/Adventures in Lestoria/TODO.txt +++ b/Adventures in Lestoria/TODO.txt @@ -13,8 +13,6 @@ March 30th -> Public Demo Release Add Bonus XP when completing a stage -- Title Screen setpieces - - Hide mouse cursor during controller play. Reveal it again during mouse play. - Auto aim causes retreat-type moves to aim away from the auto target, and prefer the direction the player's moving in. diff --git a/Adventures in Lestoria/Test.cpp b/Adventures in Lestoria/Test.cpp index 81613bb5..db82c2be 100644 --- a/Adventures in Lestoria/Test.cpp +++ b/Adventures in Lestoria/Test.cpp @@ -54,8 +54,8 @@ void Test::is(std::string conditionStr,bool testResult){ void Test::RunMapTests(){ is("There are two LowerBridgeCollision zones in Campaign I-I", - game->GetZoneData("CAMPAIGN_1_1").count("LowerBridgeCollision") - &&game->GetZoneData("CAMPAIGN_1_1").at("LowerBridgeCollision").size()>=2); + game->GetZones("CAMPAIGN_1_1").count("LowerBridgeCollision") + &&game->GetZones("CAMPAIGN_1_1").at("LowerBridgeCollision").size()>=2); for(auto&[key,value]:game->MAP_DATA){ is("A Map type has been selected for map "+key, value.GetMapType()!=""&&value.GetMapType()!="Unspecified"); diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 57b7b59b..57411b1a 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 7587 +#define VERSION_BUILD 7603 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/Campaigns/Intro_Map.tmx b/Adventures in Lestoria/assets/Campaigns/Intro_Map.tmx index dc96e38d..4f0977bd 100644 --- a/Adventures in Lestoria/assets/Campaigns/Intro_Map.tmx +++ b/Adventures in Lestoria/assets/Campaigns/Intro_Map.tmx @@ -1285,7 +1285,7 @@ - + @@ -1330,7 +1330,7 @@ - + @@ -1347,7 +1347,7 @@ - + @@ -1364,7 +1364,7 @@ - + @@ -1555,7 +1555,7 @@ - + diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 733fa5b3..4dcbab7c 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ