Implemented Ranger auto attack plus animations.
This commit is contained in:
+25
-1
@@ -4,6 +4,7 @@
|
||||
#include "Player.h"
|
||||
#include "Effect.h"
|
||||
#include "Crawler.h"
|
||||
#include "BulletTypes.h"
|
||||
|
||||
INCLUDE_MONSTER_LIST
|
||||
INCLUDE_BULLET_LIST
|
||||
@@ -28,12 +29,35 @@ AnimationState Ranger::walk_w=RANGER_WALK_W;
|
||||
SETUP_CLASS(Ranger)
|
||||
|
||||
void Ranger::OnUpdate(float fElapsedTime){
|
||||
|
||||
if(GetState()==SHOOT_ARROW){
|
||||
if(attack_cooldown_timer<=ARROW_ATTACK_COOLDOWN-0.3){
|
||||
SetState(NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Ranger::AutoAttack(){
|
||||
attack_cooldown_timer=ARROW_ATTACK_COOLDOWN;
|
||||
geom2d::line pointTowardsCursor(GetPos(),game->GetWorldMousePos());
|
||||
vf2d extendedLine=pointTowardsCursor.upoint(1.1);
|
||||
float angleToCursor=atan2(extendedLine.y-GetPos().y,extendedLine.x-GetPos().x);
|
||||
BULLET_LIST.push_back(std::make_unique<Arrow>(Arrow(GetPos(),extendedLine,vf2d{cos(angleToCursor)*250,float(sin(angleToCursor)*250-PI/8*250)}+movementVelocity,12,GetAttack(),OnUpperLevel(),true)));
|
||||
SetState(State::SHOOT_ARROW);
|
||||
if(angleToCursor<=PI/4&&angleToCursor>-PI/4){
|
||||
UpdateAnimation(AnimationState::RANGER_SHOOT_E);
|
||||
} else
|
||||
if(angleToCursor>=3*PI/4||angleToCursor<-3*PI/4){
|
||||
UpdateAnimation(AnimationState::RANGER_SHOOT_W);
|
||||
} else
|
||||
if(angleToCursor<=3*PI/4&&angleToCursor>PI/4){
|
||||
UpdateAnimation(AnimationState::RANGER_SHOOT_S);
|
||||
} else
|
||||
if(angleToCursor>=-3*PI/4&&angleToCursor<-PI/4){
|
||||
UpdateAnimation(AnimationState::RANGER_SHOOT_N);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Ranger::InitializeClassAbilities(){
|
||||
#pragma region Ranger Right-click Ability (???)
|
||||
Ranger::rightClickAbility.action=
|
||||
|
||||
Reference in New Issue
Block a user