Changed Dash name to DashAbility. Fixed dash bug where you could do two different keys to dash.

This commit is contained in:
verysecrethero
2016-02-04 11:41:21 +01:00
parent 03a16b46b5
commit 035c79564b
6 changed files with 16 additions and 9 deletions
@@ -45,6 +45,7 @@ protected:
//and its very unlikely that someone wants to change that value
const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f;
std::string m_AssaultDashTapDirection = "";
std::string m_CurrentDirectionVector = "";
bool m_AssaultDashDoubleTapped = false;
bool m_PlayerIsDashing = false;
bool m_ShiftDashing = false;
@@ -125,17 +126,21 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
}
if (e.Command == "Forward" || e.Command == "Right") {
if (e.Value != 0) {
m_CurrentDirectionVector = e.Command == "Right" ? (e.Value > 0 ? "Right" : "Left") : (e.Value > 0 ? "Forward" : "Backward");
}
//if value = 0 then you have just released this key
if (e.Value > 0 || e.Value < 0) {
if (e.Value != 0) {
m_MovementKeyDown = true;
//if you pressed the same key within m_AssaultDashDoubleTapSensitivityTimer then you have doubletapped it
if (m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer && m_AssaultDashTapDirection == e.Command) {
if (m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer && m_AssaultDashTapDirection == m_CurrentDirectionVector) {
m_ValidDoubleTap = true;
}
} else {
//== 0
m_MovementKeyDown = false;
//you have just released the key, store what key it was and reset the doubletap-sensitivity-timer
m_AssaultDashTapDirection = e.Command;
m_AssaultDashTapDirection = m_CurrentDirectionVector;
m_AssaultDashDoubleTapDeltaTime = 0.f;
}
}
+1 -1
View File
@@ -30,5 +30,5 @@
<xs:include schemaLocation="Components/Fill.xsd"/>
<xs:include schemaLocation="Components/Lifetime.xsd"/>
<xs:include schemaLocation="Components/HiddenForLocalPlayer.xsd"/>
<xs:include schemaLocation="Components/Dash.xsd"/>
<xs:include schemaLocation="Components/DashAbility.xsd"/>
</xs:schema>
@@ -1,4 +1,4 @@
<?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="DashAbility.xsd">
<CoolDownMaxTimer>2.0</CoolDownMaxTimer>
</Dash>
@@ -3,7 +3,7 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="Dash">
<xs:element name="DashAbility">
<xs:annotation>
<xs:documentation>A dash component for one of the classes</xs:documentation>
</xs:annotation>
+3 -1
View File
@@ -6,7 +6,9 @@
<Origin X="0" Y="0.772000015" Z="0"/>
<Size X="1" Y="1.60000002" Z="1"/>
</c:AABB>
<c:Dash/>
<c:DashAbility>
<CoolDownMaxTimer>2.0</CoolDownMaxTimer>
</c:DashAbility>
<c:Collidable/>
<c:Health/>
<c:Physics>
+2 -2
View File
@@ -42,8 +42,8 @@ void PlayerMovementSystem::Update(double dt)
if (player.HasComponent("Physics")) {
ComponentWrapper cPhysics = player["Physics"];
//Assault Dash Check
if (player.HasComponent("Dash")) {
controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["Dash"]["CoolDownMaxTimer"]);
if (player.HasComponent("DashAbility")) {
controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"]);
}
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