Death animation now tied to monster data.

pull/28/head
sigonasr2 2 years ago
parent 03854e6bd8
commit 42c5043163
  1. 18
      Crawler/Monster.cpp
  2. 5
      Crawler/Monster.h
  3. 26
      Crawler/MonsterData.cpp
  4. 2
      Crawler/Version.h

@ -276,23 +276,7 @@ bool Monster::SetPosition(vf2d pos){
return SetX(pos.x)|SetY(pos.y);
}
AnimationState Monster::GetDeathAnimationName(){
switch(type){
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;
}
}
return MONSTER_DATA[type].GetDeathAnimation();
}
bool Monster::Hurt(int damage){
if(hp<=0) return false;

@ -34,11 +34,11 @@ struct MonsterData{
int collisionDmg;
AnimationState jumpAnimation=AnimationState::WARRIOR_IDLE_S;
AnimationState shootAnimation=AnimationState::WARRIOR_IDLE_S;
AnimationState deathAnimation=AnimationState::WARRIOR_IDLE_S;
public:
MonsterData();
//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
,AnimationState jumpAnimation=AnimationState::WARRIOR_IDLE_S,AnimationState shootAnimation=AnimationState::WARRIOR_IDLE_S);
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);
int GetHealth();
int GetAttack();
float GetMoveSpdMult();
@ -48,6 +48,7 @@ struct MonsterData{
int GetCollisionDmg();
AnimationState GetJumpAnimation();
AnimationState GetShootAnimation();
AnimationState GetDeathAnimation();
std::vector<AnimationState>GetAnimations(){
return animations;
}

@ -4,18 +4,23 @@
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_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)},
{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)},
{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_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}},AnimationState::GREEN_SLIME_JUMP,AnimationState::GREEN_SLIME_SPIT,AnimationState::GREEN_SLIME_DIE
,1.1f,0.8f,MonsterStrategy::RUN_TOWARDS,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}},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(MonsterName type,int hp,int atk,std::vector<AnimationState>animations,float moveSpd,float size,MonsterStrategy strategy,int collisionDmg
,AnimationState jumpAnimation,AnimationState shootAnimation):
MonsterData::MonsterData(MonsterName type,int hp,int atk,std::vector<AnimationState>animations,AnimationState jumpAnimation,AnimationState shootAnimation,AnimationState 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){
,jumpAnimation(jumpAnimation),shootAnimation(shootAnimation),deathAnimation(deathAnimation){
}
int MonsterData::GetHealth(){
return hp;
@ -44,4 +49,9 @@ AnimationState MonsterData::GetJumpAnimation(){
}
AnimationState MonsterData::GetShootAnimation(){
return shootAnimation;
}
}
AnimationState MonsterData::GetDeathAnimation()
{
return deathAnimation;
}

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

Loading…
Cancel
Save