Include pragma regions for specific class abilities and move Ranger stuff (that is actually player-implemented over)
This commit is contained in:
+58
-21
@@ -360,29 +360,66 @@ void Player::Update(float fElapsedTime){
|
||||
CheckAbilityKeyReleasedAndCastSpell(ability4,game->GetKey(Crawler::KEY_ABILITY4))
|
||||
}
|
||||
|
||||
switch(GetState()){
|
||||
case SWING_SWORD:{
|
||||
switch(GetFacingDirection()){
|
||||
case UP:{
|
||||
UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_N);
|
||||
}break;
|
||||
case DOWN:{
|
||||
UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_S);
|
||||
}break;
|
||||
case LEFT:{
|
||||
UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_W);
|
||||
}break;
|
||||
case RIGHT:{
|
||||
UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_E);
|
||||
}break;
|
||||
#pragma region Warrior
|
||||
switch(GetState()){
|
||||
case SWING_SWORD:{
|
||||
switch(GetFacingDirection()){
|
||||
case UP:{
|
||||
UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_N);
|
||||
}break;
|
||||
case DOWN:{
|
||||
UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_S);
|
||||
}break;
|
||||
case LEFT:{
|
||||
UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_W);
|
||||
}break;
|
||||
case RIGHT:{
|
||||
UpdateAnimation(AnimationState::WARRIOR_SWINGSWORD_E);
|
||||
}break;
|
||||
}
|
||||
SetSwordSwingTimer(GetSwordSwingTimer()-fElapsedTime);
|
||||
if(GetSwordSwingTimer()<=0){
|
||||
SetSwordSwingTimer(0);
|
||||
SetState(State::NORMAL);
|
||||
}
|
||||
}break;
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Ranger
|
||||
if(GetState()==SHOOT_ARROW){
|
||||
if(attack_cooldown_timer<=ARROW_ATTACK_COOLDOWN-0.3){
|
||||
SetState(NORMAL);
|
||||
}
|
||||
SetSwordSwingTimer(GetSwordSwingTimer()-fElapsedTime);
|
||||
if(GetSwordSwingTimer()<=0){
|
||||
SetSwordSwingTimer(0);
|
||||
SetState(State::NORMAL);
|
||||
}
|
||||
if(retreatTimer>0){
|
||||
SetZ(6*sin(PI/RETREAT_TIME*retreatTimer));
|
||||
retreatTimer-=fElapsedTime;
|
||||
if(retreatTimer<=0){
|
||||
SetVelocity({});
|
||||
SetZ(0);
|
||||
SetState(State::NORMAL);
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
if(ghostRemoveTimer>0){
|
||||
ghostRemoveTimer-=fElapsedTime;
|
||||
if(ghostRemoveTimer<=0){
|
||||
if(ghostPositions.size()>0){
|
||||
ghostPositions.erase(ghostPositions.begin());
|
||||
if(ghostPositions.size()>0){
|
||||
ghostRemoveTimer=RETREAT_GHOST_FRAME_DELAY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(ghostFrameTimer>0){
|
||||
ghostFrameTimer-=fElapsedTime;
|
||||
if(ghostFrameTimer<=0&&GetState()==State::RETREAT){
|
||||
ghostPositions.push_back(GetPos()+vf2d{0,-GetZ()});
|
||||
ghostFrameTimer=RETREAT_GHOST_FRAME_DELAY;
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
}
|
||||
|
||||
float Player::GetSwordSwingTimer(){
|
||||
|
||||
Reference in New Issue
Block a user