diff --git a/Crawler/Ability.cpp b/Crawler/Ability.cpp index ba0b7ca6..db0141a3 100644 --- a/Crawler/Ability.cpp +++ b/Crawler/Ability.cpp @@ -13,6 +13,6 @@ PrecastData::PrecastData(float castTime,float range,float size) InputGroup Ability::DEFAULT; Ability::Ability() - :name("???"),shortName("???"),cooldown(0),COOLDOWN_TIME(0),input(&DEFAULT){}; -Ability::Ability(std::string name,std::string shortName,float cooldownTime,int manaCost,InputGroup*input,std::string icon,Pixel barColor1,Pixel barColor2,PrecastData precastInfo,bool canCancelCast) - :name(name),shortName(shortName),cooldown(0),COOLDOWN_TIME(cooldownTime),manaCost(manaCost),input(input),icon("Ability Icons/"+icon),barColor1(barColor1),barColor2(barColor2),precastInfo(precastInfo),canCancelCast(canCancelCast){} \ No newline at end of file + :name("???"),shortName("???"),description("???"),cooldown(0),COOLDOWN_TIME(0),input(&DEFAULT){}; +Ability::Ability(std::string name,std::string shortName,std::string description,float cooldownTime,int manaCost,InputGroup*input,std::string icon,Pixel barColor1,Pixel barColor2,PrecastData precastInfo,bool canCancelCast) + :name(name),shortName(shortName),description(description),cooldown(0),COOLDOWN_TIME(cooldownTime),manaCost(manaCost),input(input),icon("Ability Icons/"+icon),barColor1(barColor1),barColor2(barColor2),precastInfo(precastInfo),canCancelCast(canCancelCast){} \ No newline at end of file diff --git a/Crawler/Ability.h b/Crawler/Ability.h index 3e2da7f3..b373e5e1 100644 --- a/Crawler/Ability.h +++ b/Crawler/Ability.h @@ -20,6 +20,7 @@ struct PrecastData{ struct Ability{ std::string name=""; std::string shortName=""; + std::string description=""; float cooldown=0; float COOLDOWN_TIME=0; int manaCost=0; @@ -32,5 +33,5 @@ struct Ability{ static InputGroup DEFAULT; Ability(); //NOTE: icon expects the actual name relative to the "Ability Icons" directory for this constructor! - Ability(std::string name,std::string shortName,float cooldownTime,int manaCost,InputGroup*input,std::string icon,Pixel barColor1=VERY_DARK_RED,Pixel barColor2=DARK_RED,PrecastData precastInfo={},bool canCancelCast=false); + Ability(std::string name,std::string shortName,std::string description,float cooldownTime,int manaCost,InputGroup*input,std::string icon,Pixel barColor1=VERY_DARK_RED,Pixel barColor2=DARK_RED,PrecastData precastInfo={},bool canCancelCast=false); }; \ No newline at end of file diff --git a/Crawler/CharacterInfoWindow.cpp b/Crawler/CharacterInfoWindow.cpp index 1e7e5b67..26e6b28f 100644 --- a/Crawler/CharacterInfoWindow.cpp +++ b/Crawler/CharacterInfoWindow.cpp @@ -4,23 +4,37 @@ #include "Menu.h" #include "MenuLabel.h" #include "CharacterRotatingDisplay.h" +#include "ClassInfo.h" INCLUDE_game INCLUDE_GFX +INCLUDE_DATA typedef Attribute A; void Menu::InitializeClassInfoWindow(){ Menu*classInfoWindow=CreateMenu(CLASS_INFO,CENTERED,game->GetScreenSize()-vi2d{64,64}); - MenuLabel*label=new MenuLabel(CLASS_INFO,{{0,8},{classInfoWindow->size.x,16}},"Warrior",2,true,true); + Menu*classSelectionWindow=Menu::menus[CLASS_SELECTION]; + ClassInfo data=classutils::GetClassInfo(classSelectionWindow->S(A::CLASS_SELECTION)); + + MenuLabel*label=new MenuLabel(CLASS_INFO,{{0,8},{classInfoWindow->size.x,16}},data.className,2,true,true); classInfoWindow->AddComponent("Class Name",label); - CharacterRotatingDisplay*classDisplay=new CharacterRotatingDisplay(CLASS_INFO,{{0,0},{72,120}},GFX["knight_full_render1.png"].Decal()); + CharacterRotatingDisplay*classDisplay=new CharacterRotatingDisplay(CLASS_INFO,{{0,0},{72,120}},GFX[data.classFullImgName].Decal()); classInfoWindow->AddComponent("Rotating Character Display",classDisplay); - MenuLabel*baseStatsLabel=new MenuLabel(CLASS_INFO,{{2*classInfoWindow->size.x/3,classInfoWindow->pos.y+20},{classInfoWindow->size.x/3,16}},"Base Stats",1,true,true); + vf2d baseStatsLabelPos={classInfoWindow->size.x/3,classInfoWindow->pos.y+20}; + vf2d labelSize={2*classInfoWindow->size.x/3,16}; + + MenuLabel*baseStatsLabel=new MenuLabel(CLASS_INFO,{baseStatsLabelPos,labelSize},"Base Stats",1,true,true); + MenuLabel*healthDisplayLabel=new MenuLabel(CLASS_INFO,{baseStatsLabelPos+vf2d{0,16*1+8},labelSize},"Health: "+std::to_string(data.baseHealth)+" + "+std::to_string(data.healthGrowthRate).substr(0,3)+" per level",1,false,true); + MenuLabel*atkDisplayLabel=new MenuLabel(CLASS_INFO,{baseStatsLabelPos+vf2d{0,16*2+8},labelSize},"Attack: "+std::to_string(data.baseAtk)+" + "+std::to_string(data.atkGrowthRate).substr(0,3)+" per level",1,false,true); classInfoWindow->AddComponent("Base Stats Text",baseStatsLabel); + classInfoWindow->AddComponent("Health Display Text",healthDisplayLabel); + classInfoWindow->AddComponent("Attack Display Text",atkDisplayLabel); + + } \ No newline at end of file diff --git a/Crawler/Class.h b/Crawler/Class.h index 155f44af..059bfd1e 100644 --- a/Crawler/Class.h +++ b/Crawler/Class.h @@ -3,6 +3,8 @@ #include "Animation.h" #include "olcPixelGameEngine.h" +#undef GetClassInfo + //Classes have bit-wise operator capabilities. enum Class{ ANY=0, diff --git a/Crawler/ClassInfo.h b/Crawler/ClassInfo.h new file mode 100644 index 00000000..b81324db --- /dev/null +++ b/Crawler/ClassInfo.h @@ -0,0 +1,74 @@ +#pragma once +#include +#include "Player.h" + +INCLUDE_DATA + +struct ClassInfo{ + std::string className; + std::string classFullImgName; + int baseHealth; + int baseAtk; + float healthGrowthRate; + float atkGrowthRate; + Ability*ability1; + Ability*ability2; + Ability*ability3; + Ability*rightClickAbility; +}; + +class classutils{ +public: + static inline ClassInfo GetClassInfo(std::string className){ + ClassInfo data{ + DATA.GetProperty(className+".ClassName").GetString(), + DATA.GetProperty(className+".FullRender").GetString(), + DATA.GetProperty(className+".BaseHealth").GetInt(), + DATA.GetProperty(className+".BaseAtk").GetInt(), + float(DATA.GetProperty(className+".HealthGrowthRate").GetReal()), + float(DATA.GetProperty(className+".AtkGrowthRate").GetReal()) + }; + + if(className=="Warrior"){ + data.rightClickAbility=&Warrior::rightClickAbility; + data.ability1=&Warrior::ability1; + data.ability2=&Warrior::ability2; + data.ability3=&Warrior::ability3; + }else + if(className=="Wizard"){ + data.rightClickAbility=&Wizard::rightClickAbility; + data.ability1=&Wizard::ability1; + data.ability2=&Wizard::ability2; + data.ability3=&Wizard::ability3; + }else + if(className=="Ranger"){ + data.rightClickAbility=&Ranger::rightClickAbility; + data.ability1=&Ranger::ability1; + data.ability2=&Ranger::ability2; + data.ability3=&Ranger::ability3; + }else + if(className=="Trapper"){ + data.rightClickAbility=&Trapper::rightClickAbility; + data.ability1=&Trapper::ability1; + data.ability2=&Trapper::ability2; + data.ability3=&Trapper::ability3; + }else + if(className=="Witch"){ + data.rightClickAbility=&Witch::rightClickAbility; + data.ability1=&Witch::ability1; + data.ability2=&Witch::ability2; + data.ability3=&Witch::ability3; + }else + if(className=="Thief"){ + data.rightClickAbility=&Thief::rightClickAbility; + data.ability1=&Thief::ability1; + data.ability2=&Thief::ability2; + data.ability3=&Thief::ability3; + }else{ + std::cout<<"WARNING! Could not get class info for non-existent class "+className+"!"; + throw; + } + + return data; + } +}; \ No newline at end of file diff --git a/Crawler/ClassSelectionWindow.cpp b/Crawler/ClassSelectionWindow.cpp index d728b030..52b4f124 100644 --- a/Crawler/ClassSelectionWindow.cpp +++ b/Crawler/ClassSelectionWindow.cpp @@ -9,4 +9,6 @@ typedef Attribute A; void Menu::InitializeClassSelectionWindow(){ Menu*classSelectionWindow=CreateMenu(CLASS_SELECTION,CENTERED,game->GetScreenSize()-vi2d{4,4}); + + classSelectionWindow->S(A::CLASS_SELECTION)="Warrior"; //Default selected class. } \ No newline at end of file diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 4078fd3b..4b956a11 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -140,7 +140,6 @@ bool Crawler::OnUserCreate(){ LoadLevel(LEVEL_NAMES["starting_map"_S]); InitializeClasses(); ChangePlayerClass(WARRIOR); - //Warrior::ability4=Ranger::ability1; //Class ability swapping demonstration. GameState::Initialize(); diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj index 6214bd90..8485afcf 100644 --- a/Crawler/Crawler.vcxproj +++ b/Crawler/Crawler.vcxproj @@ -266,6 +266,7 @@ + diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters index 75671faf..0b679bef 100644 --- a/Crawler/Crawler.vcxproj.filters +++ b/Crawler/Crawler.vcxproj.filters @@ -198,6 +198,9 @@ Header Files\Interface + + Header Files + diff --git a/Crawler/GameState.cpp b/Crawler/GameState.cpp index 4c775df6..2be5b39d 100644 --- a/Crawler/GameState.cpp +++ b/Crawler/GameState.cpp @@ -6,5 +6,5 @@ void GameState::Initialize(){ NEW_STATE(States::GAME_RUN,State_GameRun); NEW_STATE(States::MAIN_MENU,State_MainMenu); - GameState::ChangeState(States::GAME_RUN); + GameState::ChangeState(States::MAIN_MENU); } \ No newline at end of file diff --git a/Crawler/Menu.cpp b/Crawler/Menu.cpp index 8314c59a..4a5901a8 100644 --- a/Crawler/Menu.cpp +++ b/Crawler/Menu.cpp @@ -30,8 +30,8 @@ void Menu::InitializeMenus(){ InitializeTestMenu(); InitializeTestSubMenu(); InitializeInventoryWindow(); - InitializeClassInfoWindow(); InitializeClassSelectionWindow(); + InitializeClassInfoWindow(); InitializeMainMenuWindow(); for(MenuType type=TEST;type