Move class-specific animation update functions into their own class update functions.

pull/28/head
sigonasr2 1 year ago
parent 0dfb58a777
commit bcd8569804
  1. 38
      Crawler/Class.cpp
  2. 41
      Crawler/Crawler.cpp
  3. 2
      Crawler/Version.h

@ -60,6 +60,28 @@ Warrior::Warrior(std::string name,Class cl,Ability rightClickAbility,Ability abi
{}
void Warrior::Update(float fElapsedTime){
ACCESS_PLAYER
if(p.GetState()==State::SWING_SWORD){
switch(p.GetFacingDirection()){
case UP:{
p.UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_N);
}break;
case DOWN:{
p.UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_S);
}break;
case LEFT:{
p.UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_W);
}break;
case RIGHT:{
p.UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_E);
}break;
}
p.SetSwordSwingTimer(p.GetSwordSwingTimer()-fElapsedTime);
if(p.GetSwordSwingTimer()<=0){
p.SetSwordSwingTimer(0);
p.SetState(State::NORMAL);
}
}
}
bool Warrior::AutoAttack(){
@ -277,6 +299,22 @@ void Wizard::Update(float fElapsedTime){
CLASS_DATA[cl]->walk_s=AnimationState::WIZARD_WALK_S;
CLASS_DATA[cl]->walk_w=AnimationState::WIZARD_WALK_W;
}
if(p.GetState()==State::CASTING){
switch(p.GetFacingDirection()){
case UP:{
p.UpdateAnimation(AnimationState::WIZARD_CAST_N);
}break;
case DOWN:{
p.UpdateAnimation(AnimationState::WIZARD_CAST_S);
}break;
case LEFT:{
p.UpdateAnimation(AnimationState::WIZARD_CAST_W);
}break;
case RIGHT:{
p.UpdateAnimation(AnimationState::WIZARD_CAST_E);
}break;
}
}
}
bool Wizard::AutoAttack(){

@ -286,47 +286,6 @@ void Crawler::HandleUserInput(float fElapsedTime){
}
}
if(player.GetState()==State::SWING_SWORD){
setIdleAnimation=false;
switch(player.GetFacingDirection()){
case UP:{
player.UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_N);
}break;
case DOWN:{
player.UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_S);
}break;
case LEFT:{
player.UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_W);
}break;
case RIGHT:{
player.UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_E);
}break;
}
player.SetSwordSwingTimer(player.GetSwordSwingTimer()-fElapsedTime);
if(player.GetSwordSwingTimer()<=0){
player.SetSwordSwingTimer(0);
player.SetState(State::NORMAL);
}
}
if(player.GetState()==State::CASTING){
setIdleAnimation=false;
switch(player.GetFacingDirection()){
case UP:{
player.UpdateAnimation(AnimationState::WIZARD_CAST_N);
}break;
case DOWN:{
player.UpdateAnimation(AnimationState::WIZARD_CAST_S);
}break;
case LEFT:{
player.UpdateAnimation(AnimationState::WIZARD_CAST_W);
}break;
case RIGHT:{
player.UpdateAnimation(AnimationState::WIZARD_CAST_E);
}break;
}
}
if(player.GetState()!=State::NORMAL){
setIdleAnimation=false;
}

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

Loading…
Cancel
Save