Include pragma regions for specific class abilities and move Ranger stuff (that is actually player-implemented over)
This commit is contained in:
parent
b2b94eaf06
commit
19c2c198e6
@ -90,7 +90,7 @@ bool Crawler::OnUserCreate(){
|
||||
LoadLevel(CAMPAIGN_1_1);
|
||||
InitializeClassAbilities();
|
||||
ChangePlayerClass(WARRIOR);
|
||||
//Warrior::ability4=Wizard::ability3; //Class ability swapping demonstration.
|
||||
Warrior::ability4=Ranger::ability1; //Class ability swapping demonstration.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -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(){
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
#include "Buff.h"
|
||||
#include "Pathfinding.h"
|
||||
|
||||
|
||||
struct CastInfo{
|
||||
std::string name;
|
||||
float castTimer;
|
||||
@ -164,6 +163,7 @@ struct Warrior:Player{
|
||||
Warrior(Player*player);
|
||||
Class GetClass()override;
|
||||
bool AutoAttack()override;
|
||||
//Include only WARRIOR-specific implementations!
|
||||
void OnUpdate(float fElapsedTime)override;
|
||||
static void InitializeClassAbilities();
|
||||
std::string GetClassName()override;
|
||||
@ -191,6 +191,7 @@ struct Thief:Player{
|
||||
Thief(Player*player);
|
||||
Class GetClass()override;
|
||||
bool AutoAttack()override;
|
||||
//Include only THIEF-specific implementations!
|
||||
void OnUpdate(float fElapsedTime)override;
|
||||
static void InitializeClassAbilities();
|
||||
std::string GetClassName()override;
|
||||
@ -218,6 +219,7 @@ struct Ranger:Player{
|
||||
Ranger(Player*player);
|
||||
Class GetClass()override;
|
||||
bool AutoAttack()override;
|
||||
//Include only RANGER-specific implementations!
|
||||
void OnUpdate(float fElapsedTime)override;
|
||||
static void InitializeClassAbilities();
|
||||
std::string GetClassName()override;
|
||||
@ -245,6 +247,7 @@ struct Trapper:Player{
|
||||
Trapper(Player*player);
|
||||
Class GetClass()override;
|
||||
bool AutoAttack()override;
|
||||
//Include only TRAPPER-specific implementations!
|
||||
void OnUpdate(float fElapsedTime)override;
|
||||
static void InitializeClassAbilities();
|
||||
std::string GetClassName()override;
|
||||
@ -272,6 +275,7 @@ struct Wizard:Player{
|
||||
Wizard(Player*player);
|
||||
Class GetClass()override;
|
||||
bool AutoAttack()override;
|
||||
//Include only WIZARD-specific implementations!
|
||||
void OnUpdate(float fElapsedTime)override;
|
||||
static void InitializeClassAbilities();
|
||||
std::string GetClassName()override;
|
||||
@ -299,6 +303,7 @@ struct Witch:Player{
|
||||
Witch(Player*player);
|
||||
Class GetClass()override;
|
||||
bool AutoAttack()override;
|
||||
//Include only WITCHs-specific implementations!
|
||||
void OnUpdate(float fElapsedTime)override;
|
||||
static void InitializeClassAbilities();
|
||||
std::string GetClassName()override;
|
||||
|
||||
@ -29,38 +29,7 @@ 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);
|
||||
}
|
||||
}
|
||||
if(retreatTimer>0){
|
||||
SetZ(6*sin(PI/RETREAT_TIME*retreatTimer));
|
||||
retreatTimer-=fElapsedTime;
|
||||
if(retreatTimer<=0){
|
||||
SetVelocity({});
|
||||
SetZ(0);
|
||||
SetState(State::NORMAL);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool Ranger::AutoAttack(){
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 832
|
||||
#define VERSION_BUILD 833
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user