Merge pull request #157 from teamfisk/DashAbiltyEffect
Dash abilty effect
This commit is contained in:
@@ -27,7 +27,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, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer);
|
void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer, EntityID playerID);
|
||||||
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; }
|
||||||
|
|
||||||
@@ -41,6 +41,7 @@ protected:
|
|||||||
bool m_Crouching = false;
|
bool m_Crouching = false;
|
||||||
//assault dash membervariables - needed to calculate the doubletap- and dashlogic
|
//assault dash membervariables - needed to calculate the doubletap- and dashlogic
|
||||||
double m_AssaultDashDoubleTapDeltaTime = 0.0;
|
double m_AssaultDashDoubleTapDeltaTime = 0.0;
|
||||||
|
double m_DashEffectResetTimer = 0.0;
|
||||||
//i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable),
|
//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
|
//and its very unlikely that someone wants to change that value
|
||||||
const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f;
|
const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f;
|
||||||
@@ -51,7 +52,7 @@ protected:
|
|||||||
bool m_ShiftDashing = false;
|
bool m_ShiftDashing = false;
|
||||||
bool m_ValidDoubleTap = false;
|
bool m_ValidDoubleTap = false;
|
||||||
|
|
||||||
//specialabilitys
|
//specialabilities
|
||||||
bool m_MovementKeyDown = false;
|
bool m_MovementKeyDown = false;
|
||||||
bool m_SpecialAbilityKeyDown = false;
|
bool m_SpecialAbilityKeyDown = false;
|
||||||
int m_NumberOfMovementKeysDown = 0;
|
int m_NumberOfMovementKeysDown = 0;
|
||||||
@@ -190,12 +191,19 @@ bool FirstPersonInputController<EventContext>::OnLockMouse(const Events::LockMou
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename EventContext>
|
template <typename EventContext>
|
||||||
void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer) {
|
void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer, EntityID playerID) {
|
||||||
m_AssaultDashDoubleTapDeltaTime += dt;
|
m_AssaultDashDoubleTapDeltaTime += dt;
|
||||||
|
m_DashEffectResetTimer += dt;
|
||||||
assaultDashCoolDownTimer -= dt;
|
assaultDashCoolDownTimer -= dt;
|
||||||
//cooldown = 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 (assaultDashCoolDownTimer > (assaultDashCoolDownMaxTimer - 0.25f)) {
|
if (assaultDashCoolDownTimer > (assaultDashCoolDownMaxTimer - 0.25f)) {
|
||||||
m_PlayerIsDashing = true;
|
m_PlayerIsDashing = true;
|
||||||
|
if (m_DashEffectResetTimer > 0.05) {
|
||||||
|
Events::DashAbility e;
|
||||||
|
e.Player = playerID;
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
|
m_DashEffectResetTimer = 0.0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
m_PlayerIsDashing = false;
|
m_PlayerIsDashing = false;
|
||||||
}
|
}
|
||||||
@@ -207,6 +215,9 @@ void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool
|
|||||||
assaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
|
assaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
|
||||||
m_AssaultDashDoubleTapped = true;
|
m_AssaultDashDoubleTapped = true;
|
||||||
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
||||||
|
Events::DashAbility e;
|
||||||
|
e.Player = playerID;
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,6 +248,7 @@ void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool
|
|||||||
assaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
|
assaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
|
||||||
|
|
||||||
Events::DashAbility e;
|
Events::DashAbility e;
|
||||||
|
e.Player = playerID;
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "Core/EPlayerSpawned.h"
|
#include "Core/EPlayerSpawned.h"
|
||||||
#include "Core/EAmmoPickup.h"
|
#include "Core/EAmmoPickup.h"
|
||||||
#include "Network/ESearchForServers.h"
|
#include "Network/ESearchForServers.h"
|
||||||
|
#include "../Game/Events/EDashAbility.h"
|
||||||
|
|
||||||
struct ServerInfo
|
struct ServerInfo
|
||||||
{
|
{
|
||||||
@@ -107,6 +108,7 @@ private:
|
|||||||
void parsePlayerDamage(Packet& packet);
|
void parsePlayerDamage(Packet& packet);
|
||||||
void parseComponentDeletion(Packet& packet);
|
void parseComponentDeletion(Packet& packet);
|
||||||
void parseDoubleJump(Packet& packet);
|
void parseDoubleJump(Packet& packet);
|
||||||
|
void parseDashEffect(Packet& packet);
|
||||||
void parseAmmoPickup(Packet& packet);
|
void parseAmmoPickup(Packet& packet);
|
||||||
void InterpolateFields(Packet& packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
void InterpolateFields(Packet& packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
||||||
void parseSnapshot(Packet& packet);
|
void parseSnapshot(Packet& packet);
|
||||||
@@ -135,6 +137,9 @@ private:
|
|||||||
EventRelay< Client, Events::SearchForServers> m_ESearchForServers;
|
EventRelay< Client, Events::SearchForServers> m_ESearchForServers;
|
||||||
EventRelay<Client, Events::DoubleJump> m_EDoubleJump;
|
EventRelay<Client, Events::DoubleJump> m_EDoubleJump;
|
||||||
bool OnDoubleJump(Events::DoubleJump & e);
|
bool OnDoubleJump(Events::DoubleJump & e);
|
||||||
|
EventRelay<Client, Events::DashAbility> m_EDashAbility;
|
||||||
|
bool OnDashAbility(const Events::DashAbility& e);
|
||||||
|
|
||||||
bool OnSearchForServers(const Events::SearchForServers& e);
|
bool OnSearchForServers(const Events::SearchForServers& e);
|
||||||
UDPClient m_ServerlistRequest;
|
UDPClient m_ServerlistRequest;
|
||||||
std::vector<ServerInfo> m_Serverlist;
|
std::vector<ServerInfo> m_Serverlist;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ enum class MessageType
|
|||||||
ComponentDeleted,
|
ComponentDeleted,
|
||||||
PlayerTransform,
|
PlayerTransform,
|
||||||
OnDoubleJump,
|
OnDoubleJump,
|
||||||
|
OnDashEffect,
|
||||||
ServerlistRequest,
|
ServerlistRequest,
|
||||||
AmmoPickup,
|
AmmoPickup,
|
||||||
Invalid
|
Invalid
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ private:
|
|||||||
void parseClientPing();
|
void parseClientPing();
|
||||||
void parsePing();
|
void parsePing();
|
||||||
bool parseDoubleJump(Packet& packet);
|
bool parseDoubleJump(Packet& packet);
|
||||||
|
void parseDashEffect(Packet& packet);
|
||||||
void parseUDPConnect(Packet& packet);
|
void parseUDPConnect(Packet& packet);
|
||||||
void parseTCPConnect(Packet& packet);
|
void parseTCPConnect(Packet& packet);
|
||||||
void parseDisconnect();
|
void parseDisconnect();
|
||||||
|
|||||||
@@ -2,11 +2,15 @@
|
|||||||
#define Events_DashAbility_h__
|
#define Events_DashAbility_h__
|
||||||
|
|
||||||
#include "Core/Event.h"
|
#include "Core/Event.h"
|
||||||
|
#include "Core/EntityWrapper.h"
|
||||||
|
|
||||||
namespace Events
|
namespace Events
|
||||||
{
|
{
|
||||||
|
|
||||||
struct DashAbility : public Event { };
|
struct DashAbility : public Event
|
||||||
|
{
|
||||||
|
EntityID Player;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ private:
|
|||||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||||
EventRelay<PlayerMovementSystem, Events::DoubleJump> m_EDoubleJump;
|
EventRelay<PlayerMovementSystem, Events::DoubleJump> m_EDoubleJump;
|
||||||
bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e);
|
bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e);
|
||||||
|
EventRelay<PlayerMovementSystem, Events::DashAbility> m_EDashAbility;
|
||||||
|
bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e);
|
||||||
|
|
||||||
void updateMovementControllers(double dt);
|
void updateMovementControllers(double dt);
|
||||||
void updateVelocity(EntityWrapper player, double dt);
|
void updateVelocity(EntityWrapper player, double dt);
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity name="DashEffect" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Animation/>
|
||||||
|
<c:Lifetime>
|
||||||
|
<Lifetime>0.5</Lifetime>
|
||||||
|
</c:Lifetime>
|
||||||
|
<c:ExplosionEffect>
|
||||||
|
<Velocity X="0" Y="0" Z="0"/>
|
||||||
|
<TimeSinceDeath>0</TimeSinceDeath>
|
||||||
|
<ExplosionDuration>0.5</ExplosionDuration>
|
||||||
|
<EndColor A="0" B="0" G="0" R="0"/>
|
||||||
|
</c:ExplosionEffect>
|
||||||
|
<c:Model/>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
</Entity>
|
||||||
@@ -33,6 +33,7 @@ void Client::Connect(std::string address, int port)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Client::OnPlayerDamage);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Client::OnPlayerDamage);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Client::OnPlayerSpawned);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Client::OnPlayerSpawned);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &Client::OnDoubleJump);
|
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &Client::OnDoubleJump);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EDashAbility, &Client::OnDashAbility);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ESearchForServers, &Client::OnSearchForServers);
|
EVENT_SUBSCRIBE_MEMBER(m_ESearchForServers, &Client::OnSearchForServers);
|
||||||
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||||
m_Address = address;
|
m_Address = address;
|
||||||
@@ -143,6 +144,9 @@ void Client::parseMessageType(Packet& packet)
|
|||||||
case MessageType::OnDoubleJump:
|
case MessageType::OnDoubleJump:
|
||||||
parseDoubleJump(packet);
|
parseDoubleJump(packet);
|
||||||
break;
|
break;
|
||||||
|
case MessageType::OnDashEffect:
|
||||||
|
parseDashEffect(packet);
|
||||||
|
break;
|
||||||
case MessageType::AmmoPickup:
|
case MessageType::AmmoPickup:
|
||||||
parseAmmoPickup(packet);
|
parseAmmoPickup(packet);
|
||||||
break;
|
break;
|
||||||
@@ -262,7 +266,7 @@ void Client::parseEntityDeletion(Packet & packet)
|
|||||||
if (m_ServerIDToClientID.find(entityToDelete) != m_ServerIDToClientID.end()) {
|
if (m_ServerIDToClientID.find(entityToDelete) != m_ServerIDToClientID.end()) {
|
||||||
EntityID localEntity = m_ServerIDToClientID.at(entityToDelete);
|
EntityID localEntity = m_ServerIDToClientID.at(entityToDelete);
|
||||||
if (m_World->ValidEntity(localEntity)) {
|
if (m_World->ValidEntity(localEntity)) {
|
||||||
if (m_World->HasComponent(localEntity,"Player")) {
|
if (m_World->HasComponent(localEntity, "Player")) {
|
||||||
Events::PlayerDeath e;
|
Events::PlayerDeath e;
|
||||||
e.Player = EntityWrapper(m_World, localEntity);
|
e.Player = EntityWrapper(m_World, localEntity);
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
@@ -297,6 +301,20 @@ void Client::parseDoubleJump(Packet & packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Client::parseDashEffect(Packet& packet)
|
||||||
|
{
|
||||||
|
EntityID serverID = packet.ReadPrimitive<EntityID>();
|
||||||
|
if (!serverClientMapsHasEntity(serverID)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Events::DashAbility e;
|
||||||
|
e.Player = m_ServerIDToClientID.at(serverID);
|
||||||
|
if (e.Player != m_LocalPlayer.ID) {
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Client::parseAmmoPickup(Packet & packet)
|
void Client::parseAmmoPickup(Packet & packet)
|
||||||
{
|
{
|
||||||
Events::AmmoPickup e;
|
Events::AmmoPickup e;
|
||||||
@@ -518,6 +536,18 @@ bool Client::OnPlayerSpawned(const Events::PlayerSpawned& e)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Client::OnDashAbility(const Events::DashAbility& e)
|
||||||
|
{
|
||||||
|
if (!clientServerMapsHasEntity(e.Player) || e.Player != m_LocalPlayer.ID) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Packet packet(MessageType::OnDashEffect);
|
||||||
|
packet.WritePrimitive(m_ClientIDToServerID.at(e.Player));
|
||||||
|
m_Reliable.Send(packet);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Client::OnSearchForServers(const Events::SearchForServers& e)
|
bool Client::OnSearchForServers(const Events::SearchForServers& e)
|
||||||
{
|
{
|
||||||
m_SearchingForServers = true;
|
m_SearchingForServers = true;
|
||||||
|
|||||||
@@ -141,6 +141,9 @@ void Server::parseMessageType(Packet& packet)
|
|||||||
case MessageType::OnDoubleJump:
|
case MessageType::OnDoubleJump:
|
||||||
parseDoubleJump(packet);
|
parseDoubleJump(packet);
|
||||||
break;
|
break;
|
||||||
|
case MessageType::OnDashEffect:
|
||||||
|
parseDashEffect(packet);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -555,6 +558,11 @@ bool Server::parseDoubleJump(Packet & packet)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Server::parseDashEffect(Packet& packet)
|
||||||
|
{
|
||||||
|
reliableBroadcast(packet);
|
||||||
|
}
|
||||||
|
|
||||||
void Server::parseOnInputCommand(Packet& packet)
|
void Server::parseOnInputCommand(Packet& packet)
|
||||||
{
|
{
|
||||||
PlayerID player = -1;
|
PlayerID player = -1;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ PlayerMovementSystem::PlayerMovementSystem(SystemParams params)
|
|||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &PlayerMovementSystem::OnDoubleJump);
|
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &PlayerMovementSystem::OnDoubleJump);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EDashAbility, &PlayerMovementSystem::OnDashAbility);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerMovementSystem::~PlayerMovementSystem()
|
PlayerMovementSystem::~PlayerMovementSystem()
|
||||||
@@ -72,7 +73,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
|||||||
ComponentWrapper cPhysics = player["Physics"];
|
ComponentWrapper cPhysics = player["Physics"];
|
||||||
//Assault Dash Check
|
//Assault Dash Check
|
||||||
if (player.HasComponent("DashAbility")) {
|
if (player.HasComponent("DashAbility")) {
|
||||||
controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"], player["DashAbility"]["CoolDownTimer"]);
|
controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"], player["DashAbility"]["CoolDownTimer"], player.ID);
|
||||||
}
|
}
|
||||||
wishDirection = controller->Movement() * glm::inverse(glm::quat(ori));
|
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
|
||||||
@@ -333,3 +334,29 @@ void PlayerMovementSystem::spawnHexagon(EntityWrapper target)
|
|||||||
EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID);
|
EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID);
|
||||||
hexagonEW["Transform"]["Position"] = (glm::vec3)target["Transform"]["Position"];
|
hexagonEW["Transform"]["Position"] = (glm::vec3)target["Transform"]["Position"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e)
|
||||||
|
{
|
||||||
|
EntityWrapper player(m_World, e.Player);
|
||||||
|
if (!player.Valid() || !IsClient || player.ID == LocalPlayer.ID) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto dashEffectResource = ResourceManager::Load<EntityFile>("Schema/Entities/DashEffect.xml");
|
||||||
|
EntityFileParser parser(dashEffectResource);
|
||||||
|
EntityID dashEffectID = parser.MergeEntities(m_World);
|
||||||
|
EntityWrapper dashEffect(m_World, dashEffectID);
|
||||||
|
auto playerModel = player.FirstChildByName("PlayerModel");
|
||||||
|
auto playerEntityModel = playerModel["Model"];
|
||||||
|
auto playerEntityAnimation = playerModel["Animation"];
|
||||||
|
playerEntityModel.Copy(dashEffect["Model"]);
|
||||||
|
playerEntityAnimation.Copy(dashEffect["Animation"]);
|
||||||
|
dashEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"];
|
||||||
|
((glm::vec4&)dashEffect["ExplosionEffect"]["EndColor"]).w = 0.f;
|
||||||
|
dashEffect["Animation"]["Speed1"] = 0.0;
|
||||||
|
dashEffect["Animation"]["Speed2"] = 0.0;
|
||||||
|
dashEffect["Animation"]["Speed3"] = 0.0;
|
||||||
|
dashEffect["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"];
|
||||||
|
dashEffect["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user