All underlying class differences now applied to code. Preparation for other class implementations. Implemented class swapping via mouse wheel.
This commit is contained in:
+88
-35
@@ -23,6 +23,7 @@ void Player::SetClass(Class cl){
|
||||
ability1=CLASS_DATA[cl].ability1;
|
||||
ability2=CLASS_DATA[cl].ability2;
|
||||
ability3=CLASS_DATA[cl].ability3;
|
||||
UpdateIdleAnimation(DOWN);
|
||||
}
|
||||
|
||||
void Player::SetX(float x){
|
||||
@@ -99,14 +100,14 @@ void Player::Update(float fElapsedTime){
|
||||
if(lastAnimationFlip==0){
|
||||
lastAnimationFlip=0.03;
|
||||
facingDirection=DOWN;
|
||||
animation.ChangeState(internal_animState,AnimationState::WALK_S);
|
||||
animation.ChangeState(internal_animState,AnimationState::WARRIOR_WALK_S);
|
||||
}
|
||||
}break;
|
||||
case DOWN:{
|
||||
if(lastAnimationFlip==0){
|
||||
lastAnimationFlip=0.03;
|
||||
facingDirection=UP;
|
||||
animation.ChangeState(internal_animState,AnimationState::WALK_N);
|
||||
animation.ChangeState(internal_animState,AnimationState::WARRIOR_WALK_N);
|
||||
}
|
||||
}break;
|
||||
}
|
||||
@@ -177,41 +178,71 @@ void Player::Update(float fElapsedTime){
|
||||
pos.y=newY;
|
||||
}
|
||||
if(attack_cooldown_timer==0&&game->GetMouse(0).bHeld){
|
||||
bool attack=false;
|
||||
Monster*closest=nullptr;
|
||||
float closest_dist=999999;
|
||||
for(Monster&m:MONSTER_LIST){
|
||||
if(m.IsAlive()
|
||||
&&geom2d::overlaps(geom2d::circle<float>(pos-vf2d{size*12,size*12},attack_range*size*12),geom2d::circle<float>(m.GetPos()-vf2d{m.GetSizeMult()*12,m.GetSizeMult()*12},m.GetSizeMult()*12))
|
||||
&&geom2d::line<float>(game->GetWorldMousePos(),m.GetPos()).length()<closest_dist){
|
||||
closest_dist=geom2d::line<float>(game->GetWorldMousePos(),m.GetPos()).length();
|
||||
closest=&m;
|
||||
}
|
||||
}
|
||||
if(closest!=nullptr&&closest->Hurt(atk)){
|
||||
attack_cooldown_timer=ATTACK_COOLDOWN;
|
||||
swordSwingTimer=0.2;
|
||||
SetState(State::SWING_SWORD);
|
||||
switch(facingDirection){
|
||||
case DOWN:{
|
||||
UpdateAnimation(AnimationState::SWINGSWORD_S);
|
||||
}break;
|
||||
case RIGHT:{
|
||||
UpdateAnimation(AnimationState::SWINGSWORD_E);
|
||||
}break;
|
||||
case LEFT:{
|
||||
UpdateAnimation(AnimationState::SWINGSWORD_W);
|
||||
}break;
|
||||
case UP:{
|
||||
UpdateAnimation(AnimationState::SWINGSWORD_N);
|
||||
}break;
|
||||
}
|
||||
switch (cl) {
|
||||
case WARRIOR: {
|
||||
bool attack=false;
|
||||
Monster*closest=nullptr;
|
||||
float closest_dist=999999;
|
||||
for(Monster&m:MONSTER_LIST){
|
||||
if(m.IsAlive()
|
||||
&&geom2d::overlaps(geom2d::circle<float>(pos-vf2d{size*12,size*12},attack_range*size*12),geom2d::circle<float>(m.GetPos()-vf2d{m.GetSizeMult()*12,m.GetSizeMult()*12},m.GetSizeMult()*12))
|
||||
&&geom2d::line<float>(game->GetWorldMousePos(),m.GetPos()).length()<closest_dist){
|
||||
closest_dist=geom2d::line<float>(game->GetWorldMousePos(),m.GetPos()).length();
|
||||
closest=&m;
|
||||
}
|
||||
}
|
||||
if(closest!=nullptr&&closest->Hurt(atk)){
|
||||
attack_cooldown_timer=ATTACK_COOLDOWN;
|
||||
swordSwingTimer=0.2;
|
||||
SetState(State::SWING_SWORD);
|
||||
switch(facingDirection){
|
||||
case DOWN:{
|
||||
UpdateAnimation(AnimationState::SWINGSWORD_S);
|
||||
}break;
|
||||
case RIGHT:{
|
||||
UpdateAnimation(AnimationState::SWINGSWORD_E);
|
||||
}break;
|
||||
case LEFT:{
|
||||
UpdateAnimation(AnimationState::SWINGSWORD_W);
|
||||
}break;
|
||||
case UP:{
|
||||
UpdateAnimation(AnimationState::SWINGSWORD_N);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case THIEF: {
|
||||
}break;
|
||||
case RANGER: {
|
||||
}break;
|
||||
case BARD: {
|
||||
}break;
|
||||
case WIZARD: {
|
||||
}break;
|
||||
case WITCH: {
|
||||
}break;
|
||||
}
|
||||
}
|
||||
if(rightClickAbility.cooldown==0&&GetState()==State::NORMAL&&game->GetMouse(1).bHeld){
|
||||
rightClickAbility.cooldown=rightClickAbility.COOLDOWN_TIME;
|
||||
SetState(State::BLOCK);
|
||||
moveSpd=0.7;
|
||||
if(rightClickAbility.cooldown==0&&game->GetMouse(1).bHeld){
|
||||
switch (cl) {
|
||||
case WARRIOR: {
|
||||
if(GetState()==State::NORMAL){
|
||||
rightClickAbility.cooldown=rightClickAbility.COOLDOWN_TIME;
|
||||
SetState(State::BLOCK);
|
||||
moveSpd=0.7;
|
||||
}
|
||||
}break;
|
||||
case THIEF: {
|
||||
}break;
|
||||
case RANGER: {
|
||||
}break;
|
||||
case BARD: {
|
||||
}break;
|
||||
case WIZARD: {
|
||||
}break;
|
||||
case WITCH: {
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,4 +322,26 @@ void Player::Spin(float duration,float spinSpd){
|
||||
spin_spd=spinSpd;
|
||||
spin_angle=0;
|
||||
ability2.cooldown=ability2.COOLDOWN_TIME;
|
||||
}
|
||||
|
||||
void Player::UpdateWalkingAnimation(Key direction){
|
||||
AnimationState anim;
|
||||
switch(direction){
|
||||
case UP:anim=CLASS_DATA[cl].walk_n;break;
|
||||
case RIGHT:anim=CLASS_DATA[cl].walk_e;break;
|
||||
case DOWN:anim=CLASS_DATA[cl].walk_s;break;
|
||||
case LEFT:anim=CLASS_DATA[cl].walk_w;break;
|
||||
}
|
||||
UpdateAnimation(anim);
|
||||
}
|
||||
|
||||
void Player::UpdateIdleAnimation(Key direction){
|
||||
AnimationState anim;
|
||||
switch(direction){
|
||||
case UP:anim=CLASS_DATA[cl].idle_n;break;
|
||||
case RIGHT:anim=CLASS_DATA[cl].idle_e;break;
|
||||
case DOWN:anim=CLASS_DATA[cl].idle_s;break;
|
||||
case LEFT:anim=CLASS_DATA[cl].idle_w;break;
|
||||
}
|
||||
UpdateAnimation(anim);
|
||||
}
|
||||
Reference in New Issue
Block a user