From 3cb8c43da1ae62327d3202b0f1fb01f712dae9da Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii Date: Wed, 26 Jul 2023 21:08:17 +0000 Subject: [PATCH] Setup class config file directory structure Co-authored-by: sigonasr2 --- Crawler/Crawler.cpp | 18 +++++++++++-- Crawler/Crawler.h | 19 +------------- Crawler/Player.h | 6 +++++ Crawler/Ranger.cpp | 32 ++++++++++++----------- Crawler/Thief.cpp | 32 ++++++++++++----------- Crawler/Trapper.cpp | 32 ++++++++++++----------- Crawler/Warrior.cpp | 32 ++++++++++++----------- Crawler/Witch.cpp | 32 ++++++++++++----------- Crawler/Wizard.cpp | 32 ++++++++++++----------- Crawler/assets/config/classes/Ranger.txt | 4 +++ Crawler/assets/config/classes/Thief.txt | 4 +++ Crawler/assets/config/classes/Trapper.txt | 4 +++ Crawler/assets/config/classes/Warrior.txt | 9 +++++++ Crawler/assets/config/classes/Witch.txt | 4 +++ Crawler/assets/config/classes/Wizard.txt | 4 +++ Crawler/assets/config/configuration.txt | 8 +++++- Crawler/config.h | 20 ++++++++++++++ 17 files changed, 181 insertions(+), 111 deletions(-) create mode 100644 Crawler/assets/config/classes/Ranger.txt create mode 100644 Crawler/assets/config/classes/Thief.txt create mode 100644 Crawler/assets/config/classes/Trapper.txt create mode 100644 Crawler/assets/config/classes/Warrior.txt create mode 100644 Crawler/assets/config/classes/Witch.txt create mode 100644 Crawler/assets/config/classes/Wizard.txt create mode 100644 Crawler/config.h diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 1da3efd2..aa2305f3 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -14,6 +14,7 @@ #include #include #include "Emitter.h" +#include "config.h" INCLUDE_EMITTER_LIST @@ -50,6 +51,13 @@ Crawler::Crawler() std::string MAP_CONFIG = CONFIG_PATH + "map_config"_S; utils::datafile::Read(DATA,MAP_CONFIG); + + for(std::string&cl:DATA.GetProperty("class_list").GetValues()){ + std::cout<UpdateIdleAnimation(DOWN); } -void Crawler::InitializeClassAbilities(){ +void Crawler::InitializeClasses(){ + Warrior::Initialize(); + Thief::Initialize(); + Ranger::Initialize(); + Trapper::Initialize(); + Wizard::Initialize(); + Witch::Initialize(); Warrior::InitializeClassAbilities(); Thief::InitializeClassAbilities(); Ranger::InitializeClassAbilities(); diff --git a/Crawler/Crawler.h b/Crawler/Crawler.h index 734d84c8..4de77a7a 100644 --- a/Crawler/Crawler.h +++ b/Crawler/Crawler.h @@ -51,7 +51,7 @@ private: std::vectorupperForegroundTileGroups; int bridgeLayerIndex=-1; float bridgeFadeFactor=0.f; - void InitializeClassAbilities(); + void InitializeClasses(); public: Crawler(); bool OnUserCreate() override; @@ -108,20 +108,3 @@ public: double GetDouble(std::string key); datafiledoubledata GetDoubleList(std::string key); }; - -//Read a string array from the config. -datafilestringdata operator ""_s(const char*key,std::size_t len); -//Read an int array from the config. -datafileintdata operator ""_i(const char*key,std::size_t len); -//Read a float array from the config. -datafilefloatdata operator ""_f(const char*key,std::size_t len); -//Read a double array from the config. -datafiledoubledata operator ""_d(const char*key,std::size_t len); -//Read a string key from the config. -std::string operator ""_S(const char*key,std::size_t len); -//Read an integer key from the config. -int operator ""_I(const char*key,std::size_t len); -//Read a float key from the config. -float operator ""_F(const char*key,std::size_t len); -//Read a double key from the config. -double operator ""_D(const char*key,std::size_t len); \ No newline at end of file diff --git a/Crawler/Player.h b/Crawler/Player.h index b468ccd5..83c52111 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -166,6 +166,7 @@ struct Warrior:Player{ static Class cl; static Ability rightClickAbility,ability1,ability2,ability3,ability4; static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w; + static void Initialize(); Warrior(); Warrior(Player*player); Class GetClass()override; @@ -194,6 +195,7 @@ struct Thief:Player{ static Class cl; static Ability rightClickAbility,ability1,ability2,ability3,ability4; static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w; + static void Initialize(); Thief(); Thief(Player*player); Class GetClass()override; @@ -222,6 +224,7 @@ struct Ranger:Player{ static Class cl; static Ability rightClickAbility,ability1,ability2,ability3,ability4; static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w; + static void Initialize(); Ranger(); Ranger(Player*player); Class GetClass()override; @@ -250,6 +253,7 @@ struct Trapper:Player{ static Class cl; static Ability rightClickAbility,ability1,ability2,ability3,ability4; static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w; + static void Initialize(); Trapper(); Trapper(Player*player); Class GetClass()override; @@ -278,6 +282,7 @@ struct Wizard:Player{ static Class cl; static Ability rightClickAbility,ability1,ability2,ability3,ability4; static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w; + static void Initialize(); Wizard(); Wizard(Player*player); Class GetClass()override; @@ -306,6 +311,7 @@ struct Witch:Player{ static Class cl; static Ability rightClickAbility,ability1,ability2,ability3,ability4; static AnimationState walk_n,walk_e,walk_s,walk_w,idle_n,idle_e,idle_s,idle_w; + static void Initialize(); Witch(); Witch(Player*player); Class GetClass()override; diff --git a/Crawler/Ranger.cpp b/Crawler/Ranger.cpp index ac33f1db..be60e746 100644 --- a/Crawler/Ranger.cpp +++ b/Crawler/Ranger.cpp @@ -11,21 +11,23 @@ INCLUDE_MONSTER_LIST INCLUDE_BULLET_LIST INCLUDE_game -std::string Ranger::name="Ranger"; -Class Ranger::cl=RANGER; -Ability Ranger::rightClickAbility=Ability("Retreat",7,0,VERY_DARK_BLUE,DARK_BLUE); -Ability Ranger::ability1=Ability("Rapid Fire",12,35); -Ability Ranger::ability2=Ability("Charged Shot",15,40,VERY_DARK_RED,DARK_RED,PrecastData(0.3)); -Ability Ranger::ability3=Ability("Multishot",25,50); -Ability Ranger::ability4=Ability("???",0,0); -AnimationState Ranger::idle_n=RANGER_IDLE_N; -AnimationState Ranger::idle_e=RANGER_IDLE_E; -AnimationState Ranger::idle_s=RANGER_IDLE_S; -AnimationState Ranger::idle_w=RANGER_IDLE_W; -AnimationState Ranger::walk_n=RANGER_WALK_N; -AnimationState Ranger::walk_e=RANGER_WALK_E; -AnimationState Ranger::walk_s=RANGER_WALK_S; -AnimationState Ranger::walk_w=RANGER_WALK_W; +void Ranger::Initialize(){ + Ranger::name="Ranger"; + Ranger::cl=RANGER; + Ranger::rightClickAbility=Ability("Retreat",7,0,VERY_DARK_BLUE,DARK_BLUE); + Ranger::ability1=Ability("Rapid Fire",12,35); + Ranger::ability2=Ability("Charged Shot",15,40,VERY_DARK_RED,DARK_RED,PrecastData(0.3)); + Ranger::ability3=Ability("Multishot",25,50); + Ranger::ability4=Ability("???",0,0); + Ranger::idle_n=RANGER_IDLE_N; + Ranger::idle_e=RANGER_IDLE_E; + Ranger::idle_s=RANGER_IDLE_S; + Ranger::idle_w=RANGER_IDLE_W; + Ranger::walk_n=RANGER_WALK_N; + Ranger::walk_e=RANGER_WALK_E; + Ranger::walk_s=RANGER_WALK_S; + Ranger::walk_w=RANGER_WALK_W; +} SETUP_CLASS(Ranger) diff --git a/Crawler/Thief.cpp b/Crawler/Thief.cpp index 74f77001..e26ddcf8 100644 --- a/Crawler/Thief.cpp +++ b/Crawler/Thief.cpp @@ -9,21 +9,23 @@ INCLUDE_MONSTER_LIST INCLUDE_BULLET_LIST INCLUDE_game -std::string Thief::name="Thief"; -Class Thief::cl=THIEF; -Ability Thief::rightClickAbility={"???",15,0,VERY_DARK_BLUE,DARK_BLUE}; -Ability Thief::ability1={"???",12,40}; -Ability Thief::ability2={"???",15,50}; -Ability Thief::ability3={"???",40,60}; -Ability Thief::ability4={"???",0,0}; -AnimationState Thief::idle_n=WARRIOR_IDLE_N; -AnimationState Thief::idle_e=WARRIOR_IDLE_E; -AnimationState Thief::idle_s=WARRIOR_IDLE_S; -AnimationState Thief::idle_w=WARRIOR_IDLE_W; -AnimationState Thief::walk_n=WARRIOR_WALK_N; -AnimationState Thief::walk_e=WARRIOR_WALK_E; -AnimationState Thief::walk_s=WARRIOR_WALK_S; -AnimationState Thief::walk_w=WARRIOR_WALK_W; +void Thief::Initialize(){ + Thief::name="Thief"; + Thief::cl=THIEF; + Thief::rightClickAbility={"???",15,0,VERY_DARK_BLUE,DARK_BLUE}; + Thief::ability1={"???",12,40}; + Thief::ability2={"???",15,50}; + Thief::ability3={"???",40,60}; + Thief::ability4={"???",0,0}; + Thief::idle_n=WARRIOR_IDLE_N; + Thief::idle_e=WARRIOR_IDLE_E; + Thief::idle_s=WARRIOR_IDLE_S; + Thief::idle_w=WARRIOR_IDLE_W; + Thief::walk_n=WARRIOR_WALK_N; + Thief::walk_e=WARRIOR_WALK_E; + Thief::walk_s=WARRIOR_WALK_S; + Thief::walk_w=WARRIOR_WALK_W; +} SETUP_CLASS(Thief) diff --git a/Crawler/Trapper.cpp b/Crawler/Trapper.cpp index b08f4aed..fb88e43a 100644 --- a/Crawler/Trapper.cpp +++ b/Crawler/Trapper.cpp @@ -9,21 +9,23 @@ INCLUDE_MONSTER_LIST INCLUDE_BULLET_LIST INCLUDE_game -std::string Trapper::name="Trapper"; -Class Trapper::cl=TRAPPER; -Ability Trapper::rightClickAbility={"???",15,0,VERY_DARK_BLUE,DARK_BLUE}; -Ability Trapper::ability1={"???",12,40}; -Ability Trapper::ability2={"???",15,50}; -Ability Trapper::ability3={"???",40,60}; -Ability Trapper::ability4={"???",0,0}; -AnimationState Trapper::idle_n=WARRIOR_IDLE_N; -AnimationState Trapper::idle_e=WARRIOR_IDLE_E; -AnimationState Trapper::idle_s=WARRIOR_IDLE_S; -AnimationState Trapper::idle_w=WARRIOR_IDLE_W; -AnimationState Trapper::walk_n=WARRIOR_WALK_N; -AnimationState Trapper::walk_e=WARRIOR_WALK_E; -AnimationState Trapper::walk_s=WARRIOR_WALK_S; -AnimationState Trapper::walk_w=WARRIOR_WALK_W; +void Trapper::Initialize(){ + Trapper::name="Trapper"; + Trapper::cl=TRAPPER; + Trapper::rightClickAbility={"???",15,0,VERY_DARK_BLUE,DARK_BLUE}; + Trapper::ability1={"???",12,40}; + Trapper::ability2={"???",15,50}; + Trapper::ability3={"???",40,60}; + Trapper::ability4={"???",0,0}; + Trapper::idle_n=WARRIOR_IDLE_N; + Trapper::idle_e=WARRIOR_IDLE_E; + Trapper::idle_s=WARRIOR_IDLE_S; + Trapper::idle_w=WARRIOR_IDLE_W; + Trapper::walk_n=WARRIOR_WALK_N; + Trapper::walk_e=WARRIOR_WALK_E; + Trapper::walk_s=WARRIOR_WALK_S; + Trapper::walk_w=WARRIOR_WALK_W; +} SETUP_CLASS(Trapper) diff --git a/Crawler/Warrior.cpp b/Crawler/Warrior.cpp index d421fa19..dacf723a 100644 --- a/Crawler/Warrior.cpp +++ b/Crawler/Warrior.cpp @@ -9,21 +9,23 @@ INCLUDE_MONSTER_LIST INCLUDE_BULLET_LIST INCLUDE_game -std::string Warrior::name="Warrior"; -Class Warrior::cl=WARRIOR; -Ability Warrior::rightClickAbility={"Block",15,0,VERY_DARK_BLUE,DARK_BLUE}; -Ability Warrior::ability1={"Battlecry",12,40}; -Ability Warrior::ability2={"Ground Slam",15,50}; -Ability Warrior::ability3={"Sonic Slash",40,60}; -Ability Warrior::ability4={"???",0,0}; -AnimationState Warrior::idle_n=WARRIOR_IDLE_N; -AnimationState Warrior::idle_e=WARRIOR_IDLE_E; -AnimationState Warrior::idle_s=WARRIOR_IDLE_S; -AnimationState Warrior::idle_w=WARRIOR_IDLE_W; -AnimationState Warrior::walk_n=WARRIOR_WALK_N; -AnimationState Warrior::walk_e=WARRIOR_WALK_E; -AnimationState Warrior::walk_s=WARRIOR_WALK_S; -AnimationState Warrior::walk_w=WARRIOR_WALK_W; +void Warrior::Initialize(){ + Warrior::name="Warrior"; + Warrior::cl=WARRIOR; + Warrior::rightClickAbility={"Block",15,0,VERY_DARK_BLUE,DARK_BLUE}; + Warrior::ability1={"Battlecry",12,40}; + Warrior::ability2={"Ground Slam",15,50}; + Warrior::ability3={"Sonic Slash",40,60}; + Warrior::ability4={"???",0,0}; + Warrior::idle_n=WARRIOR_IDLE_N; + Warrior::idle_e=WARRIOR_IDLE_E; + Warrior::idle_s=WARRIOR_IDLE_S; + Warrior::idle_w=WARRIOR_IDLE_W; + Warrior::walk_n=WARRIOR_WALK_N; + Warrior::walk_e=WARRIOR_WALK_E; + Warrior::walk_s=WARRIOR_WALK_S; + Warrior::walk_w=WARRIOR_WALK_W; +} SETUP_CLASS(Warrior) diff --git a/Crawler/Witch.cpp b/Crawler/Witch.cpp index 813aa601..fa48ccfd 100644 --- a/Crawler/Witch.cpp +++ b/Crawler/Witch.cpp @@ -9,21 +9,23 @@ INCLUDE_MONSTER_LIST INCLUDE_BULLET_LIST INCLUDE_game -std::string Witch::name="Witch"; -Class Witch::cl=WITCH; -Ability Witch::rightClickAbility={"???",15,0,VERY_DARK_BLUE,DARK_BLUE}; -Ability Witch::ability1={"???",12,40}; -Ability Witch::ability2={"???",15,50}; -Ability Witch::ability3={"???",40,60}; -Ability Witch::ability4={"???",0,0}; -AnimationState Witch::idle_n=WARRIOR_IDLE_N; -AnimationState Witch::idle_e=WARRIOR_IDLE_E; -AnimationState Witch::idle_s=WARRIOR_IDLE_S; -AnimationState Witch::idle_w=WARRIOR_IDLE_W; -AnimationState Witch::walk_n=WARRIOR_WALK_N; -AnimationState Witch::walk_e=WARRIOR_WALK_E; -AnimationState Witch::walk_s=WARRIOR_WALK_S; -AnimationState Witch::walk_w=WARRIOR_WALK_W; +void Witch::Initialize(){ + Witch::name="Witch"; + Witch::cl=WITCH; + Witch::rightClickAbility={"???",15,0,VERY_DARK_BLUE,DARK_BLUE}; + Witch::ability1={"???",12,40}; + Witch::ability2={"???",15,50}; + Witch::ability3={"???",40,60}; + Witch::ability4={"???",0,0}; + Witch::idle_n=WARRIOR_IDLE_N; + Witch::idle_e=WARRIOR_IDLE_E; + Witch::idle_s=WARRIOR_IDLE_S; + Witch::idle_w=WARRIOR_IDLE_W; + Witch::walk_n=WARRIOR_WALK_N; + Witch::walk_e=WARRIOR_WALK_E; + Witch::walk_s=WARRIOR_WALK_S; + Witch::walk_w=WARRIOR_WALK_W; +} SETUP_CLASS(Witch) diff --git a/Crawler/Wizard.cpp b/Crawler/Wizard.cpp index 2f9dfa67..fce2a79b 100644 --- a/Crawler/Wizard.cpp +++ b/Crawler/Wizard.cpp @@ -10,21 +10,23 @@ INCLUDE_MONSTER_LIST INCLUDE_BULLET_LIST INCLUDE_game -std::string Wizard::name="Wizard"; -Class Wizard::cl=WIZARD; -Ability Wizard::rightClickAbility={"Teleport",8,5,VERY_DARK_BLUE,DARK_BLUE}; -Ability Wizard::ability1={"Firebolt",6,30}; -Ability Wizard::ability2={"Lightning Bolt",6,25}; -Ability Wizard::ability3={"Meteor",40,75,VERY_DARK_RED,VERY_DARK_RED,PrecastData(1.5,9*24,4*24)}; -Ability Wizard::ability4={"???",0,0}; -AnimationState Wizard::idle_n=WIZARD_IDLE_N; -AnimationState Wizard::idle_e=WIZARD_IDLE_E; -AnimationState Wizard::idle_s=WIZARD_IDLE_S; -AnimationState Wizard::idle_w=WIZARD_IDLE_W; -AnimationState Wizard::walk_n=WIZARD_WALK_N; -AnimationState Wizard::walk_e=WIZARD_WALK_E; -AnimationState Wizard::walk_s=WIZARD_WALK_S; -AnimationState Wizard::walk_w=WIZARD_WALK_W; +void Wizard::Initialize(){ + Wizard::name="Wizard"; + Wizard::cl=WIZARD; + Wizard::rightClickAbility={"Teleport",8,5,VERY_DARK_BLUE,DARK_BLUE}; + Wizard::ability1={"Firebolt",6,30}; + Wizard::ability2={"Lightning Bolt",6,25}; + Wizard::ability3={"Meteor",40,75,VERY_DARK_RED,VERY_DARK_RED,PrecastData(1.5,9*24,4*24)}; + Wizard::ability4={"???",0,0}; + Wizard::idle_n=WIZARD_IDLE_N; + Wizard::idle_e=WIZARD_IDLE_E; + Wizard::idle_s=WIZARD_IDLE_S; + Wizard::idle_w=WIZARD_IDLE_W; + Wizard::walk_n=WIZARD_WALK_N; + Wizard::walk_e=WIZARD_WALK_E; + Wizard::walk_s=WIZARD_WALK_S; + Wizard::walk_w=WIZARD_WALK_W; +} SETUP_CLASS(Wizard) diff --git a/Crawler/assets/config/classes/Ranger.txt b/Crawler/assets/config/classes/Ranger.txt new file mode 100644 index 00000000..10465486 --- /dev/null +++ b/Crawler/assets/config/classes/Ranger.txt @@ -0,0 +1,4 @@ +Ranger +{ + +} \ No newline at end of file diff --git a/Crawler/assets/config/classes/Thief.txt b/Crawler/assets/config/classes/Thief.txt new file mode 100644 index 00000000..dc3932e7 --- /dev/null +++ b/Crawler/assets/config/classes/Thief.txt @@ -0,0 +1,4 @@ +Thief +{ + +} \ No newline at end of file diff --git a/Crawler/assets/config/classes/Trapper.txt b/Crawler/assets/config/classes/Trapper.txt new file mode 100644 index 00000000..f368fd1e --- /dev/null +++ b/Crawler/assets/config/classes/Trapper.txt @@ -0,0 +1,4 @@ +Trapper +{ + +} \ No newline at end of file diff --git a/Crawler/assets/config/classes/Warrior.txt b/Crawler/assets/config/classes/Warrior.txt new file mode 100644 index 00000000..e3df7539 --- /dev/null +++ b/Crawler/assets/config/classes/Warrior.txt @@ -0,0 +1,9 @@ +Warrior +{ + ClassName = Warrior + + Right Click Ability + { + testNumber = 1 + } +} \ No newline at end of file diff --git a/Crawler/assets/config/classes/Witch.txt b/Crawler/assets/config/classes/Witch.txt new file mode 100644 index 00000000..ad022340 --- /dev/null +++ b/Crawler/assets/config/classes/Witch.txt @@ -0,0 +1,4 @@ +Witch +{ + +} \ No newline at end of file diff --git a/Crawler/assets/config/classes/Wizard.txt b/Crawler/assets/config/classes/Wizard.txt new file mode 100644 index 00000000..e033f8ac --- /dev/null +++ b/Crawler/assets/config/classes/Wizard.txt @@ -0,0 +1,4 @@ +Wizard +{ + +} \ No newline at end of file diff --git a/Crawler/assets/config/configuration.txt b/Crawler/assets/config/configuration.txt index 8c27a6d7..deb90aed 100644 --- a/Crawler/assets/config/configuration.txt +++ b/Crawler/assets/config/configuration.txt @@ -7,4 +7,10 @@ WINDOW_SIZE = 360,240 gfx_config = gfx/gfx.txt # Map Files Loading Config -map_config = levels.txt \ No newline at end of file +map_config = levels.txt + +# Path to class configuration files +class_directory = classes/ + +# Class list to be loaded into the game. +class_list = Warrior, Thief, Ranger, Trapper, Wizard, Witch \ No newline at end of file diff --git a/Crawler/config.h b/Crawler/config.h new file mode 100644 index 00000000..19b16792 --- /dev/null +++ b/Crawler/config.h @@ -0,0 +1,20 @@ +#include "olcUTIL_DataFile.h" + +using namespace olc; + +//Read a string array from the config. +utils::datafilestringdata operator ""_s(const char*key,std::size_t len); +//Read an int array from the config. +utils::datafileintdata operator ""_i(const char*key,std::size_t len); +//Read a float array from the config. +utils::datafilefloatdata operator ""_f(const char*key,std::size_t len); +//Read a double array from the config. +utils::datafiledoubledata operator ""_d(const char*key,std::size_t len); +//Read a string key from the config. +std::string operator ""_S(const char*key,std::size_t len); +//Read an integer key from the config. +int operator ""_I(const char*key,std::size_t len); +//Read a float key from the config. +float operator ""_F(const char*key,std::size_t len); +//Read a double key from the config. +double operator ""_D(const char*key,std::size_t len); \ No newline at end of file