|
|
|
@ -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(); |
|
|
|
@ -71,3 +76,37 @@ void State_MainMenu::OnUserUpdate(AiL*game){ |
|
|
|
|
void State_MainMenu::Draw(AiL*game){ |
|
|
|
|
TitleScreen::Draw(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const ZoneData&State_MainMenu::ChooseRandomFocusArea(){ |
|
|
|
|
//std::vector<ZoneData>
|
|
|
|
|
if(game->GetZones().count("Focus Area")>0){ |
|
|
|
|
const std::vector<ZoneData>&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; |
|
|
|
|
} |