Dash component now has the dash-maxCoolDownVariable in it.
This commit is contained in:
@@ -26,7 +26,7 @@ public:
|
|||||||
virtual bool OnCommand(const Events::InputCommand& e) override;
|
virtual bool OnCommand(const Events::InputCommand& e) override;
|
||||||
virtual void Reset();
|
virtual void Reset();
|
||||||
|
|
||||||
void AssaultDashCheck(double dt, bool isJumping);
|
void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer);
|
||||||
virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; }
|
virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; }
|
||||||
virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; }
|
virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; }
|
||||||
|
|
||||||
@@ -38,10 +38,11 @@ protected:
|
|||||||
bool m_Jumping = false;
|
bool m_Jumping = false;
|
||||||
bool m_DoubleJumping = false;
|
bool m_DoubleJumping = false;
|
||||||
bool m_Crouching = false;
|
bool m_Crouching = false;
|
||||||
//assault dash membervariables
|
//assault dash membervariables - needed to calculate the doubletap- and dashlogic
|
||||||
double m_AssaultDashDoubleTapDeltaTime = 0.0;
|
double m_AssaultDashDoubleTapDeltaTime = 0.0;
|
||||||
double m_AssaultDashCoolDownTimer = 0.0;
|
double m_AssaultDashCoolDownTimer = 0.0;
|
||||||
double m_AssaultDashCoolDownMaxTimer = 2.0;
|
//i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable),
|
||||||
|
//and its very unlikely that someone wants to change that value
|
||||||
const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f;
|
const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f;
|
||||||
std::string m_AssaultDashTapDirection = "";
|
std::string m_AssaultDashTapDirection = "";
|
||||||
bool m_AssaultDashDoubleTapped = false;
|
bool m_AssaultDashDoubleTapped = false;
|
||||||
@@ -178,11 +179,11 @@ bool FirstPersonInputController<EventContext>::OnLockMouse(const Events::LockMou
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename EventContext>
|
template <typename EventContext>
|
||||||
void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool isJumping) {
|
void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer) {
|
||||||
m_AssaultDashDoubleTapDeltaTime += dt;
|
m_AssaultDashDoubleTapDeltaTime += dt;
|
||||||
m_AssaultDashCoolDownTimer -= dt;
|
m_AssaultDashCoolDownTimer -= dt;
|
||||||
//cooldown = m_AssaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work)
|
//cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work)
|
||||||
if (m_AssaultDashCoolDownTimer > (m_AssaultDashCoolDownMaxTimer - 0.25f)) {
|
if (m_AssaultDashCoolDownTimer > (assaultDashCoolDownMaxTimer - 0.25f)) {
|
||||||
m_PlayerIsDashing = true;
|
m_PlayerIsDashing = true;
|
||||||
} else {
|
} else {
|
||||||
m_PlayerIsDashing = false;
|
m_PlayerIsDashing = false;
|
||||||
@@ -192,7 +193,7 @@ void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool
|
|||||||
if (m_ShiftDashing && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) {
|
if (m_ShiftDashing && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) {
|
||||||
//player is dashing with shift
|
//player is dashing with shift
|
||||||
//the wanted-direction is set in playermovement already so we dont need to check what direction we want to dash in!
|
//the wanted-direction is set in playermovement already so we dont need to check what direction we want to dash in!
|
||||||
m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer;
|
m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
|
||||||
m_AssaultDashDoubleTapped = true;
|
m_AssaultDashDoubleTapped = true;
|
||||||
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
||||||
//moving to the side has priority
|
//moving to the side has priority
|
||||||
@@ -223,7 +224,7 @@ void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool
|
|||||||
//ok, we have a valid tap, lets do it
|
//ok, we have a valid tap, lets do it
|
||||||
m_AssaultDashDoubleTapped = true;
|
m_AssaultDashDoubleTapped = true;
|
||||||
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
||||||
m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer;
|
m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
<Dash xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Dash.xsd">
|
<Dash xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Dash.xsd">
|
||||||
<Something>true</Something>
|
<CoolDownMaxTimer>2.0</CoolDownMaxTimer>
|
||||||
</Dash>
|
</Dash>
|
||||||
@@ -9,8 +9,8 @@
|
|||||||
</xs:annotation>
|
</xs:annotation>
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
<xs:element name="Something" type="t:bool" minOccurs="0">
|
<xs:element name="CoolDownMaxTimer" type="t:double" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Yada</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>This is the cooldown on dash</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
|
|||||||
@@ -41,10 +41,9 @@ void PlayerMovementSystem::Update(double dt)
|
|||||||
|
|
||||||
if (player.HasComponent("Physics")) {
|
if (player.HasComponent("Physics")) {
|
||||||
ComponentWrapper cPhysics = player["Physics"];
|
ComponentWrapper cPhysics = player["Physics"];
|
||||||
//Assault Dash Check -
|
//Assault Dash Check
|
||||||
//TODO: check if playerclass is assault!
|
|
||||||
if (player.HasComponent("Dash")) {
|
if (player.HasComponent("Dash")) {
|
||||||
controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f);
|
controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["Dash"]["CoolDownMaxTimer"]);
|
||||||
}
|
}
|
||||||
glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori));
|
glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori));
|
||||||
//this makes sure you can only dash in the 4 directions: forw,backw,left,right
|
//this makes sure you can only dash in the 4 directions: forw,backw,left,right
|
||||||
|
|||||||
Reference in New Issue
Block a user