|
|
|
@ -40,6 +40,7 @@ void Ranger::OnUpdate(float fElapsedTime){ |
|
|
|
|
if(retreatTimer<=0){ |
|
|
|
|
SetVelocity({}); |
|
|
|
|
SetZ(0); |
|
|
|
|
SetState(State::NORMAL); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(ghostRemoveTimer>0){ |
|
|
|
@ -53,27 +54,23 @@ void Ranger::OnUpdate(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(ghostFrameTimer>0){ |
|
|
|
|
ghostFrameTimer-=fElapsedTime; |
|
|
|
|
if(ghostFrameTimer<=0&&GetState()==State::RETREAT){ |
|
|
|
|
ghostPositions.push_back(GetPos()+vf2d{0,-GetZ()}); |
|
|
|
|
ghostFrameTimer=RETREAT_GHOST_FRAME_DELAY; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
attack_cooldown_timer=ARROW_ATTACK_COOLDOWN; |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
SetAnimationBasedOnTargetingDirection(angleToCursor); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -86,9 +83,12 @@ void Ranger::InitializeClassAbilities(){ |
|
|
|
|
p->SetVelocity(mouseDir.vector().norm()*velocity); |
|
|
|
|
p->retreatTimer=p->RETREAT_TIME; |
|
|
|
|
p->iframe_time=p->RETREAT_TIME; |
|
|
|
|
p->ghostPositions.push_back(p->GetPos()); |
|
|
|
|
p->ghostPositions.push_back(p->GetPos()+vf2d{0,-p->GetZ()}); |
|
|
|
|
p->ghostFrameTimer=p->RETREAT_GHOST_FRAME_DELAY; |
|
|
|
|
p->ghostRemoveTimer=p->RETREAT_GHOST_FRAMES*p->RETREAT_GHOST_FRAME_DELAY; |
|
|
|
|
float angleToCursor=atan2(game->GetWorldMousePos().y-p->GetPos().y,game->GetWorldMousePos().x-p->GetPos().x); |
|
|
|
|
p->SetAnimationBasedOnTargetingDirection(angleToCursor); |
|
|
|
|
p->SetState(State::RETREAT); |
|
|
|
|
return true; |
|
|
|
|
}; |
|
|
|
|
#pragma endregion |
|
|
|
|