|
|
|
@ -75,53 +75,54 @@ bool Wizard::AutoAttack(){ |
|
|
|
|
void Wizard::InitializeClassAbilities(){ |
|
|
|
|
#pragma region Wizard Right-click Ability (Teleport) |
|
|
|
|
Wizard::rightClickAbility.action= |
|
|
|
|
[&](vf2d pos={}){ |
|
|
|
|
float pointMouseDirection=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x); |
|
|
|
|
[](Player*p,vf2d pos={}){ |
|
|
|
|
if(p->GetState()==State::CASTING)return false; |
|
|
|
|
float pointMouseDirection=atan2(game->GetWorldMousePos().y-p->GetPos().y,game->GetWorldMousePos().x-p->GetPos().x); |
|
|
|
|
vf2d pointTowardsMouse={cos(pointMouseDirection),sin(pointMouseDirection)}; |
|
|
|
|
float dist=std::clamp(geom2d::line<float>{GetPos(),game->GetWorldMousePos()}.length(),0.f,6.5f*24); |
|
|
|
|
float dist=std::clamp(geom2d::line<float>{p->GetPos(),game->GetWorldMousePos()}.length(),0.f,6.5f*24); |
|
|
|
|
if(dist<12)return false; |
|
|
|
|
vf2d teleportPoint=GetPos()+pointTowardsMouse*dist; |
|
|
|
|
while(dist>0&&game->HasTileCollision(game->GetCurrentLevel(),teleportPoint)&&CanPathfindTo(GetPos(),teleportPoint)){ |
|
|
|
|
vf2d teleportPoint=p->GetPos()+pointTowardsMouse*dist; |
|
|
|
|
while(dist>0&&game->HasTileCollision(game->GetCurrentLevel(),teleportPoint)&&p->CanPathfindTo(p->GetPos(),teleportPoint)){ |
|
|
|
|
dist-=24; |
|
|
|
|
teleportPoint=GetPos()+pointTowardsMouse*dist; |
|
|
|
|
teleportPoint=p->GetPos()+pointTowardsMouse*dist; |
|
|
|
|
} |
|
|
|
|
if(dist>0&&CanPathfindTo(GetPos(),teleportPoint)){ |
|
|
|
|
SetState(State::TELEPORT); |
|
|
|
|
teleportAnimationTimer=0.35; |
|
|
|
|
teleportTarget=teleportPoint; |
|
|
|
|
teleportStartPosition=GetPos(); |
|
|
|
|
iframe_time=0.35; |
|
|
|
|
if(dist>0&&p->CanPathfindTo(p->GetPos(),teleportPoint)){ |
|
|
|
|
p->SetState(State::TELEPORT); |
|
|
|
|
p->teleportAnimationTimer=0.35; |
|
|
|
|
p->teleportTarget=teleportPoint; |
|
|
|
|
p->teleportStartPosition=p->GetPos(); |
|
|
|
|
p->iframe_time=0.35; |
|
|
|
|
for(int i=0;i<16;i++){ |
|
|
|
|
game->AddEffect(std::make_unique<Effect>(GetPos()+vf2d{(rand()%160-80)/10.f,(rand()%160-80)/10.f},float(rand()%300)/1000,AnimationState::DOT_PARTICLE,upperLevel,0.3,0.2,vf2d{float(rand()%1000-500)/100,float(rand()%1000-500)/100},BLACK)); |
|
|
|
|
game->AddEffect(std::make_unique<Effect>(p->GetPos()+vf2d{(rand()%160-80)/10.f,(rand()%160-80)/10.f},float(rand()%300)/1000,AnimationState::DOT_PARTICLE,p->upperLevel,0.3,0.2,vf2d{float(rand()%1000-500)/100,float(rand()%1000-500)/100},BLACK)); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
notificationDisplay={"Cannot Teleport to that location!",0.5}; |
|
|
|
|
p->notificationDisplay={"Cannot Teleport to that location!",0.5}; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
#pragma endregion |
|
|
|
|
#pragma region Wizard Ability 1 (Fire Bolt) |
|
|
|
|
Wizard::ability1.action= |
|
|
|
|
[&](vf2d pos={}){ |
|
|
|
|
float angleToCursor=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x); |
|
|
|
|
BULLET_LIST.push_back(std::make_unique<FireBolt>(FireBolt(GetPos(),{cos(angleToCursor)*275,sin(angleToCursor)*275},12,GetAttack(),upperLevel,true,{240,120,60}))); |
|
|
|
|
[](Player*p,vf2d pos={}){ |
|
|
|
|
float angleToCursor=atan2(game->GetWorldMousePos().y-p->GetPos().y,game->GetWorldMousePos().x-p->GetPos().x); |
|
|
|
|
BULLET_LIST.push_back(std::make_unique<FireBolt>(FireBolt(p->GetPos(),{cos(angleToCursor)*275,sin(angleToCursor)*275},12,p->GetAttack(),p->upperLevel,true,{240,120,60}))); |
|
|
|
|
return true; |
|
|
|
|
}; |
|
|
|
|
#pragma endregion |
|
|
|
|
#pragma region Wizard Ability 2 (Lightning Bolt) |
|
|
|
|
Wizard::ability2.action= |
|
|
|
|
[&](vf2d pos={}){ |
|
|
|
|
float angleToCursor=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x); |
|
|
|
|
BULLET_LIST.push_back(std::make_unique<LightningBolt>(LightningBolt(GetPos(),{cos(angleToCursor)*230,sin(angleToCursor)*230},12,GetAttack()*4,upperLevel,true,WHITE))); |
|
|
|
|
[](Player*p,vf2d pos={}){ |
|
|
|
|
float angleToCursor=atan2(game->GetWorldMousePos().y-p->GetPos().y,game->GetWorldMousePos().x-p->GetPos().x); |
|
|
|
|
BULLET_LIST.push_back(std::make_unique<LightningBolt>(LightningBolt(p->GetPos(),{cos(angleToCursor)*230,sin(angleToCursor)*230},12,p->GetAttack()*4,p->upperLevel,true,WHITE))); |
|
|
|
|
return true; |
|
|
|
|
}; |
|
|
|
|
#pragma endregion |
|
|
|
|
#pragma region Wizard Ability 3 (Meteor) |
|
|
|
|
Wizard::ability3.action= |
|
|
|
|
[&](vf2d pos={}){ |
|
|
|
|
CastSpell(Wizard::ability3); |
|
|
|
|
game->AddEffect(std::make_unique<Meteor>(pos,3,AnimationState::METEOR,OnUpperLevel(),vf2d{1,1},2)); |
|
|
|
|
[](Player*p,vf2d pos={}){ |
|
|
|
|
p->CastSpell(Wizard::ability3); |
|
|
|
|
game->AddEffect(std::make_unique<Meteor>(pos,3,AnimationState::METEOR,p->OnUpperLevel(),vf2d{1,1},2)); |
|
|
|
|
return true; |
|
|
|
|
}; |
|
|
|
|
#pragma endregion |
|
|
|
|