-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkill.cpp
More file actions
80 lines (69 loc) · 1.73 KB
/
Copy pathSkill.cpp
File metadata and controls
80 lines (69 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "Skill.h"
#include <iostream>
Skill::Skill(int id, Player *p_aliado, Player *p_inimigo, Ball *ball, Sound gemidao) {
this->id = id;
this->p_aliado = p_aliado;
this->p_inimigo = p_inimigo;
this->ball = ball;
this->isActive = false;
this->gemidao = gemidao;
if(id == 1) {
this->skill_time = 180;
this->cd = 15*60;
this->timeremaining = 0;
}
else if(id == 2) {
this->skill_time = 0;
this->cd = 15*60;
this->timeremaining = 0;
}
else if(id ==3) {
this->skill_time = 180;
this->cd = 15*60;
this->timeremaining = 0;
}
else if(id == 69) {
this->skill_time = 0;
this->cd = 15*60;
this->timeremaining = 0;
}
}
void Skill::increaseSpeed() {
p_aliado->recSpeed = MAX_REC_SPEED;
}
void Skill::changeDirection() {
ball->vx = (ball->vx) * -1;
}
void Skill::changeEnemyControl() {
p_inimigo->isControlInverted = true;
}
void Skill::playGemidao() {
PlaySound(gemidao);
}
void Skill::updateSkill() {
if(this->isActive) {
switch (this->id) {
case 1:
increaseSpeed();
break;
case 2:
changeDirection();
break;
case 3:
changeEnemyControl();
break;
case 69:
playGemidao();
break;
default:
break;
}
}
else {
p_aliado->recSpeed = DEFAULT_REC_SPEED;
p_inimigo->isControlInverted = false;
}
this->timeremaining--;
if(this->cd - this->timeremaining >= this->skill_time) this->isActive = false;
if(timeremaining <=0) timeremaining = 0;
}