|
|
|
#include "olcPixelGameEngine.h"
|
|
|
|
#include "Monster.h"
|
|
|
|
#include "Animation.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "DEFINES.h"
|
|
|
|
#include "safemap.h"
|
|
|
|
|
|
|
|
INCLUDE_DATA
|
|
|
|
INCLUDE_STRATEGY_DATA
|
|
|
|
|
|
|
|
std::map<MonsterName,MonsterData>MONSTER_DATA;
|
|
|
|
|
|
|
|
MonsterData::MonsterData(){}
|
|
|
|
MonsterData::MonsterData(MonsterName type,int hp,int atk,std::vector<std::string>animations,std::string jumpAnimation,std::string shootAnimation,std::string deathAnimation
|
|
|
|
,float moveSpd,float size,MonsterStrategy strategy,int collisionDmg):
|
|
|
|
type(type),hp(hp),atk(atk),moveSpd(moveSpd),size(size),strategy(strategy),animations(animations),collisionDmg(collisionDmg)
|
|
|
|
,jumpAnimation(jumpAnimation),shootAnimation(shootAnimation),deathAnimation(deathAnimation){
|
|
|
|
}
|
|
|
|
void MonsterData::InitializeMonsterData(){
|
|
|
|
for(int i=0;i<MonsterName::END;i++){
|
|
|
|
std::string ID=DATA["Monsters"][std::to_string(i)]["DisplayName"].GetString(1);
|
|
|
|
std::vector<std::string>animations{
|
|
|
|
ID+"_JUMP",
|
|
|
|
ID+"_SPIT",
|
|
|
|
ID+"_DIE",
|
|
|
|
ID+"_IDLE",
|
|
|
|
};
|
|
|
|
|
|
|
|
//Add additional custom animations defined in the config.
|
|
|
|
int animationCounter=0;
|
|
|
|
while(DATA["Monsters"][std::to_string(i)].HasProperty("ANIMATION["+std::to_string(animationCounter)+"]")){
|
|
|
|
animations.push_back(DATA["Monsters"][std::to_string(i)]["ANIMATION["+std::to_string(animationCounter)+"]"].GetString());
|
|
|
|
animationCounter++;
|
|
|
|
}
|
|
|
|
|
|
|
|
MonsterData monster(
|
|
|
|
MonsterName(i),
|
|
|
|
DATA["Monsters"][std::to_string(i)]["Health"].GetInt(),
|
|
|
|
DATA["Monsters"][std::to_string(i)]["Attack"].GetInt(),
|
|
|
|
animations,
|
|
|
|
ID+"_JUMP",
|
|
|
|
ID+"_SPIT",
|
|
|
|
ID+"_DIE",
|
|
|
|
DATA["Monsters"][std::to_string(i)]["MoveSpd"].GetReal()/100,
|
|
|
|
DATA["Monsters"][std::to_string(i)]["Size"].GetReal()/100,
|
|
|
|
STRATEGY_DATA[DATA["Monsters"][std::to_string(i)]["Strategy"].GetString()],
|
|
|
|
DATA["Monsters"][std::to_string(i)]["CollisionDmg"].GetInt()
|
|
|
|
);
|
|
|
|
|
|
|
|
MONSTER_DATA[MonsterName(i)]=monster;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int MonsterData::GetHealth(){
|
|
|
|
return hp;
|
|
|
|
}
|
|
|
|
int MonsterData::GetAttack(){
|
|
|
|
return atk;
|
|
|
|
}
|
|
|
|
float MonsterData::GetMoveSpdMult(){
|
|
|
|
return moveSpd;
|
|
|
|
}
|
|
|
|
float MonsterData::GetSizeMult(){
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
int MonsterData::GetCollisionDmg(){
|
|
|
|
return collisionDmg;
|
|
|
|
}
|
|
|
|
MonsterName MonsterData::GetType(){
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
MonsterStrategy MonsterData::GetAIStrategy(){
|
|
|
|
return strategy;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string MonsterData::GetJumpAnimation(){
|
|
|
|
return jumpAnimation;
|
|
|
|
}
|
|
|
|
std::string MonsterData::GetShootAnimation(){
|
|
|
|
return shootAnimation;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string MonsterData::GetDeathAnimation()
|
|
|
|
{
|
|
|
|
return deathAnimation;
|
|
|
|
}
|