Death animation now tied to monster data.

sigonasr2 2 years ago
parent f819eabbf9
commit 90626bf628
  1. 18
      Crawler/Monster.cpp
  2. 5
      Crawler/Monster.h
  3. 24
      Crawler/MonsterData.cpp
  4. 2
      Crawler/Version.h

@ -276,23 +276,7 @@ bool Monster::SetPosition(vf2d pos){
return SetX(pos.x)|SetY(pos.y); return SetX(pos.x)|SetY(pos.y);
} }
AnimationState Monster::GetDeathAnimationName(){ AnimationState Monster::GetDeathAnimationName(){
switch(type){ return MONSTER_DATA[type].GetDeathAnimation();
case SLIME_GREEN:{
return AnimationState::GREEN_SLIME_DIE;
}
case SLIME_BLUE:{
return AnimationState::BLUE_SLIME_DIE;
}
case SLIME_RED:{
return AnimationState::RED_SLIME_DIE;
}
case SLIME_YELLOW:{
return AnimationState::YELLOW_SLIME_DIE;
}
default:{
return AnimationState::WARRIOR_IDLE_S;
}
}
} }
bool Monster::Hurt(int damage){ bool Monster::Hurt(int damage){
if(hp<=0) return false; if(hp<=0) return false;

@ -34,11 +34,11 @@ struct MonsterData{
int collisionDmg; int collisionDmg;
AnimationState jumpAnimation=AnimationState::WARRIOR_IDLE_S; AnimationState jumpAnimation=AnimationState::WARRIOR_IDLE_S;
AnimationState shootAnimation=AnimationState::WARRIOR_IDLE_S; AnimationState shootAnimation=AnimationState::WARRIOR_IDLE_S;
AnimationState deathAnimation=AnimationState::WARRIOR_IDLE_S;
public: public:
MonsterData(); MonsterData();
//When specifying animations, the first one will become the default animation. The last becomes the death animation. //When specifying animations, the first one will become the default animation. The last becomes the death animation.
MonsterData(MonsterName type,int hp,int atk,std::vector<AnimationState>animations,float moveSpd=1.0f,float size=1.0f,MonsterStrategy strategy=RUN_TOWARDS,int collisionDmg=0 MonsterData(MonsterName type,int hp,int atk,std::vector<AnimationState>animations,AnimationState jumpAnimation,AnimationState shootAnimation,AnimationState deathAnimation,float moveSpd=1.0f,float size=1.0f,MonsterStrategy strategy=RUN_TOWARDS,int collisionDmg=0);
,AnimationState jumpAnimation=AnimationState::WARRIOR_IDLE_S,AnimationState shootAnimation=AnimationState::WARRIOR_IDLE_S);
int GetHealth(); int GetHealth();
int GetAttack(); int GetAttack();
float GetMoveSpdMult(); float GetMoveSpdMult();
@ -48,6 +48,7 @@ struct MonsterData{
int GetCollisionDmg(); int GetCollisionDmg();
AnimationState GetJumpAnimation(); AnimationState GetJumpAnimation();
AnimationState GetShootAnimation(); AnimationState GetShootAnimation();
AnimationState GetDeathAnimation();
std::vector<AnimationState>GetAnimations(){ std::vector<AnimationState>GetAnimations(){
return animations; return animations;
} }

@ -4,18 +4,23 @@
std::map<MonsterName,MonsterData>MONSTER_DATA={ std::map<MonsterName,MonsterData>MONSTER_DATA={
{SLIME_GREEN,MonsterData(MonsterName::SLIME_GREEN,10,5,{{AnimationState::GREEN_SLIME_IDLE,AnimationState::GREEN_SLIME_JUMP,AnimationState::GREEN_SLIME_ROLL,AnimationState::GREEN_SLIME_DIE,AnimationState::GREEN_SLIME_SPIT}},1.1f,0.8f,MonsterStrategy::RUN_TOWARDS,5,AnimationState::GREEN_SLIME_JUMP,AnimationState::GREEN_SLIME_SPIT)}, {SLIME_GREEN,MonsterData(MonsterName::SLIME_GREEN,10,5,
{SLIME_BLUE,MonsterData(MonsterName::SLIME_BLUE,30,10,{{AnimationState::BLUE_SLIME_IDLE,AnimationState::BLUE_SLIME_JUMP,AnimationState::BLUE_SLIME_ROLL,AnimationState::BLUE_SLIME_DIE,AnimationState::BLUE_SLIME_SPIT}},0.8f,1.0f,MonsterStrategy::SHOOT_AFAR,0,AnimationState::BLUE_SLIME_JUMP,AnimationState::BLUE_SLIME_SPIT)}, {{AnimationState::GREEN_SLIME_IDLE,AnimationState::GREEN_SLIME_JUMP,AnimationState::GREEN_SLIME_ROLL,AnimationState::GREEN_SLIME_DIE,AnimationState::GREEN_SLIME_SPIT}},AnimationState::GREEN_SLIME_JUMP,AnimationState::GREEN_SLIME_SPIT,AnimationState::GREEN_SLIME_DIE
{SLIME_RED,MonsterData(MonsterName::SLIME_RED,25,10,{{AnimationState::RED_SLIME_IDLE,AnimationState::RED_SLIME_JUMP,AnimationState::RED_SLIME_ROLL,AnimationState::RED_SLIME_DIE,AnimationState::RED_SLIME_SPIT}},0.95f,1.2f,MonsterStrategy::RUN_TOWARDS,10,AnimationState::RED_SLIME_JUMP,AnimationState::RED_SLIME_SPIT)}, ,1.1f,0.8f,MonsterStrategy::RUN_TOWARDS,5)},
{SLIME_YELLOW,MonsterData(MonsterName::SLIME_YELLOW,175,10,{{AnimationState::YELLOW_SLIME_IDLE,AnimationState::YELLOW_SLIME_JUMP,AnimationState::YELLOW_SLIME_ROLL,AnimationState::YELLOW_SLIME_DIE,AnimationState::YELLOW_SLIME_SPIT}},0.4f,1.6f,MonsterStrategy::RUN_TOWARDS,15,AnimationState::YELLOW_SLIME_JUMP,AnimationState::YELLOW_SLIME_SPIT)}, {SLIME_BLUE,MonsterData(MonsterName::SLIME_BLUE,30,10,{{AnimationState::BLUE_SLIME_IDLE,AnimationState::BLUE_SLIME_JUMP,AnimationState::BLUE_SLIME_ROLL,AnimationState::BLUE_SLIME_DIE,AnimationState::BLUE_SLIME_SPIT}},AnimationState::BLUE_SLIME_JUMP,AnimationState::BLUE_SLIME_SPIT,AnimationState::BLUE_SLIME_DIE
,0.8f,1.0f,MonsterStrategy::SHOOT_AFAR,0)},
{SLIME_RED,MonsterData(MonsterName::SLIME_RED,25,10,{{AnimationState::RED_SLIME_IDLE,AnimationState::RED_SLIME_JUMP,AnimationState::RED_SLIME_ROLL,AnimationState::RED_SLIME_DIE,AnimationState::RED_SLIME_SPIT}},AnimationState::RED_SLIME_JUMP,AnimationState::RED_SLIME_SPIT,AnimationState::RED_SLIME_DIE
,0.95f,1.2f,MonsterStrategy::RUN_TOWARDS,10)},
{SLIME_YELLOW,MonsterData(MonsterName::SLIME_YELLOW,175,10,{{AnimationState::YELLOW_SLIME_IDLE,AnimationState::YELLOW_SLIME_JUMP,AnimationState::YELLOW_SLIME_ROLL,AnimationState::YELLOW_SLIME_DIE,AnimationState::YELLOW_SLIME_SPIT}},AnimationState::YELLOW_SLIME_JUMP,AnimationState::YELLOW_SLIME_SPIT,AnimationState::YELLOW_SLIME_DIE
,0.4f,1.6f,MonsterStrategy::RUN_TOWARDS,15)},
}; };
MonsterData::MonsterData(){} MonsterData::MonsterData(){}
MonsterData::MonsterData(MonsterName type,int hp,int atk,std::vector<AnimationState>animations,float moveSpd,float size,MonsterStrategy strategy,int collisionDmg MonsterData::MonsterData(MonsterName type,int hp,int atk,std::vector<AnimationState>animations,AnimationState jumpAnimation,AnimationState shootAnimation,AnimationState deathAnimation
,AnimationState jumpAnimation,AnimationState shootAnimation): ,float moveSpd,float size,MonsterStrategy strategy,int collisionDmg):
type(type),hp(hp),atk(atk),moveSpd(moveSpd),size(size),strategy(strategy),animations(animations),collisionDmg(collisionDmg) type(type),hp(hp),atk(atk),moveSpd(moveSpd),size(size),strategy(strategy),animations(animations),collisionDmg(collisionDmg)
,jumpAnimation(jumpAnimation),shootAnimation(shootAnimation){ ,jumpAnimation(jumpAnimation),shootAnimation(shootAnimation),deathAnimation(deathAnimation){
} }
int MonsterData::GetHealth(){ int MonsterData::GetHealth(){
return hp; return hp;
@ -45,3 +50,8 @@ AnimationState MonsterData::GetJumpAnimation(){
AnimationState MonsterData::GetShootAnimation(){ AnimationState MonsterData::GetShootAnimation(){
return shootAnimation; return shootAnimation;
} }
AnimationState MonsterData::GetDeathAnimation()
{
return deathAnimation;
}

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 369 #define VERSION_BUILD 370
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

Loading…
Cancel
Save