diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index bda3ad13..1f971c7c 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -282,6 +282,8 @@ void GameState::readKeyInput(InputClass* KeyInput) playerLookDir.lookDirZ = look.z; privData->nwClient->Send(playerLookDir); } + + // shoot if(KeyInput->IsKeyPressed(DIK_Z)) { if(!key_Shoot) @@ -295,6 +297,20 @@ void GameState::readKeyInput(InputClass* KeyInput) else key_Shoot = false; + // jump + if(KeyInput->IsKeyPressed(DIK_X)) + { + if(!key_Jump) + { + GameLogic::Protocol_PlayerJump playerJump; + playerJump.hasJumped = true; + privData->nwClient->Send(playerJump); + key_Jump = true; + } + } + else + key_Jump = false; + // send event data // if(KeyInput->IsKeyPressed(DIK_L)) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.h b/Code/Game/DanBiasGame/GameClientState/GameState.h index 30884043..f8f1b67b 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameState.h @@ -23,6 +23,7 @@ private: bool key_strafeRight; bool key_strafeLeft; bool key_Shoot; + bool key_Jump; Camera* camera; struct myData; diff --git a/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp b/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp index 1ffd5e98..b9ad4d35 100644 --- a/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp +++ b/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp @@ -67,7 +67,13 @@ namespace DanBias break; case protocol_Gameplay_PlayerShot: - c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS); + if (p[1].value.netBool) + c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS); + break; + case protocol_Gameplay_PlayerJump: + if (p[1].value.netBool) + c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_JUMP); + break; case protocol_Gameplay_ObjectDamage: break; diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index ffb009cf..412ff08c 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -148,6 +148,31 @@ namespace GameLogic Oyster::Network::CustomNetProtocol protocol; }; + struct Protocol_PlayerJump :public Oyster::Network::CustomProtocolObject + { + bool hasJumped; + + Protocol_PlayerJump() + { + this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerJump; + this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short; + + this->protocol[1].type = Oyster::Network::NetAttributeType_Bool; + } + const Protocol_PlayerJump& operator=(Oyster::Network::CustomNetProtocol& val) + { + hasJumped = val[1].value.netBool; + return *this; + } + Oyster::Network::CustomNetProtocol* GetProtocol() override + { + this->protocol[1].value = hasJumped; + return &protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; } #endif // !GAMELOGIC_PLAYER_PROTOCOLS_H diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h index bb0414f8..180f6541 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -50,12 +50,13 @@ #define protocol_Gameplay_PlayerLookDir 301 #define protocol_Gameplay_PlayerChangeWeapon 302 #define protocol_Gameplay_PlayerShot 303 -#define protocol_Gameplay_ObjectPickup 304 -#define protocol_Gameplay_ObjectDamage 305 -#define protocol_Gameplay_ObjectPosition 306 -#define protocol_Gameplay_ObjectEnabled 307 -#define protocol_Gameplay_ObjectDisabled 308 -#define protocol_Gameplay_ObjectCreate 309 +#define protocol_Gameplay_PlayerJump 304 +#define protocol_Gameplay_ObjectPickup 305 +#define protocol_Gameplay_ObjectDamage 306 +#define protocol_Gameplay_ObjectPosition 307 +#define protocol_Gameplay_ObjectEnabled 308 +#define protocol_Gameplay_ObjectDisabled 309 +#define protocol_Gameplay_ObjectCreate 310 #define protocol_GameplayMAX 399