From 97e0b1298aaaf4c1a6c06864d5e7e69c09c08996 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Tue, 10 Dec 2013 09:57:05 +0100 Subject: [PATCH 1/2] added functionallity to player and weapon, started on the weapon design. --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 38 +++++++++ Code/Game/GameLogic/AttatchmentMassDriver.h | 25 ++++++ Code/Game/GameLogic/AttatchmentSocket.cpp | 34 ++++++++ Code/Game/GameLogic/AttatchmentSocket.h | 20 +++++ Code/Game/GameLogic/GameLogic.vcxproj | 11 ++- Code/Game/GameLogic/GameLogicStates.h | 41 ++++++++++ Code/Game/GameLogic/IAttatchment.cpp | 29 +++++++ Code/Game/GameLogic/IAttatchment.h | 25 ++++++ Code/Game/GameLogic/Player.cpp | 81 ++++++++++++++++++- Code/Game/GameLogic/Player.h | 19 +++-- Code/Game/GameLogic/Weapon.cpp | 43 +++++++++- Code/Game/GameLogic/Weapon.h | 13 ++- 12 files changed, 363 insertions(+), 16 deletions(-) create mode 100644 Code/Game/GameLogic/AttatchmentMassDriver.cpp create mode 100644 Code/Game/GameLogic/AttatchmentMassDriver.h create mode 100644 Code/Game/GameLogic/AttatchmentSocket.cpp create mode 100644 Code/Game/GameLogic/AttatchmentSocket.h create mode 100644 Code/Game/GameLogic/GameLogicStates.h create mode 100644 Code/Game/GameLogic/IAttatchment.cpp create mode 100644 Code/Game/GameLogic/IAttatchment.h diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp new file mode 100644 index 00000000..fcee6afb --- /dev/null +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -0,0 +1,38 @@ +#include "AttatchmentMassDriver.h" + +using namespace GameLogic; + +struct AttatchmentMassDriver::PrivateData +{ + PrivateData() + { + + } + + ~PrivateData() + { + + } + +}myData; + + +AttatchmentMassDriver::AttatchmentMassDriver(void) +{ +} + + +AttatchmentMassDriver::~AttatchmentMassDriver(void) +{ +} + + +void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &fireInput) +{ + +} + +void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &fireInput) +{ + +} diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.h b/Code/Game/GameLogic/AttatchmentMassDriver.h new file mode 100644 index 00000000..bc95c327 --- /dev/null +++ b/Code/Game/GameLogic/AttatchmentMassDriver.h @@ -0,0 +1,25 @@ +#ifndef ATTATCHMENTMASSDRIVER_H +#define ATTATCHMENTMASSDRIVER_H +#include "IAttatchment.h" +namespace GameLogic +{ + + class AttatchmentMassDriver : public IAttatchment + { + public: + AttatchmentMassDriver(void); + ~AttatchmentMassDriver(void); + + + void UseAttatchment(const WEAPON_FIRE &fireInput); + + private: + void ForcePush(const WEAPON_FIRE &fireInput); + + private: + struct PrivateData; + PrivateData *myData; + }; +} +#endif + diff --git a/Code/Game/GameLogic/AttatchmentSocket.cpp b/Code/Game/GameLogic/AttatchmentSocket.cpp new file mode 100644 index 00000000..86e0850b --- /dev/null +++ b/Code/Game/GameLogic/AttatchmentSocket.cpp @@ -0,0 +1,34 @@ +#include "AttatchmentSocket.h" +#include "IAttatchment.h" +using namespace GameLogic; + +struct AttatchmentSocket::PrivateData +{ + PrivateData() + { + + } + + ~PrivateData() + { + + } + + IAttatchment *Attatchment; + + +}myData; + +AttatchmentSocket::AttatchmentSocket(void) +{ +} + + +AttatchmentSocket::~AttatchmentSocket(void) +{ +} + +IAttatchment* AttatchmentSocket::GetAttatchment() +{ + return myData->Attatchment; +} diff --git a/Code/Game/GameLogic/AttatchmentSocket.h b/Code/Game/GameLogic/AttatchmentSocket.h new file mode 100644 index 00000000..1067e339 --- /dev/null +++ b/Code/Game/GameLogic/AttatchmentSocket.h @@ -0,0 +1,20 @@ +#ifndef ATTATCHMENTSOCKET_H +#define ATTATCHMENTSOCKET_H +#include "IAttatchment.h" +namespace GameLogic +{ + + class AttatchmentSocket + { + public: + AttatchmentSocket(void); + ~AttatchmentSocket(void); + + IAttatchment* GetAttatchment(); + + private: + struct PrivateData; + PrivateData *myData; + }; +} +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/GameLogic.vcxproj b/Code/Game/GameLogic/GameLogic.vcxproj index 8afb5bb4..33fd6c92 100644 --- a/Code/Game/GameLogic/GameLogic.vcxproj +++ b/Code/Game/GameLogic/GameLogic.vcxproj @@ -166,12 +166,14 @@ + + - - + + @@ -180,12 +182,13 @@ + + - - + diff --git a/Code/Game/GameLogic/GameLogicStates.h b/Code/Game/GameLogic/GameLogicStates.h new file mode 100644 index 00000000..3c2b9997 --- /dev/null +++ b/Code/Game/GameLogic/GameLogicStates.h @@ -0,0 +1,41 @@ +#ifndef GAMELOGICSTATES_H +#define GAMELOGICSTATES_H + + +namespace GameLogic +{ + enum PLAYER_STATE + { + PLAYER_STATE_JUMPING = 0, + PLAYER_STATE_WALKING = 1, + PLAYER_STATE_IDLE = 2, + }; + + enum PLAYER_MOVEMENT + { + PLAYER_MOVEMENT_FORWARD = 0, + PLAYER_MOVEMENT_BACKWARD = 1, + PLAYER_MOVEMENT_LEFT = 2, + PLAYER_MOVEMENT_RIGHT = 4, + PLAYER_MOVEMENT_JUMP = 8, + }; + + enum WEAPON_FIRE + { + WEAPON_USE_PRIMARY_PRESS = 0, + WEAPON_USE_PRIMARY_RELEASE = 1, + WEAPON_USE_SECONDARY_PRESS = 2, + WEAPON_USE_SECONDARY_RELEASE = 4, + WEAPON_USE_UTILLITY_PRESS = 8, + WEAPON_USE_UTILLITY_RELEASE = 16, + }; + + enum WEAPON_STATE + { + WEAPON_STATE_FIREING = 0, + WEAPON_STATE_IDLE = 1, + WEAPON_STATE_RELOADING = 2, + }; +} + +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/IAttatchment.cpp b/Code/Game/GameLogic/IAttatchment.cpp new file mode 100644 index 00000000..c1e2a997 --- /dev/null +++ b/Code/Game/GameLogic/IAttatchment.cpp @@ -0,0 +1,29 @@ +#include "IAttatchment.h" +#include "AttatchmentSocket.h" + +using namespace GameLogic; + +struct IAttatchment::PrivateData +{ + PrivateData() + { + + } + + ~PrivateData() + { + + } + + + +}myData; + +IAttatchment::IAttatchment(void) +{ +} + + +IAttatchment::~IAttatchment(void) +{ +} diff --git a/Code/Game/GameLogic/IAttatchment.h b/Code/Game/GameLogic/IAttatchment.h new file mode 100644 index 00000000..c134026f --- /dev/null +++ b/Code/Game/GameLogic/IAttatchment.h @@ -0,0 +1,25 @@ +#ifndef IATTATCHMENT_H +#define IATTATCHMENT_H +#include "GameLogicStates.h" + +namespace GameLogic +{ + + + class IAttatchment + { + + public: + + IAttatchment(void); + ~IAttatchment(void); + + virtual void UseAttatchment(const WEAPON_FIRE &fireInput) = 0; + + private: + struct PrivateData; + PrivateData *myData; + + }; +} +#endif diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 6c514634..01046143 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -11,7 +11,14 @@ struct Player::PrivateData PrivateData() { weapon = new Weapon(); + + life = 100; + playerState = PLAYER_STATE_IDLE; + + rigidBody->SetSubscription(CollisionManager::PlayerCollision); + } + ~PrivateData() { if (weapon) @@ -19,9 +26,12 @@ struct Player::PrivateData delete weapon; } } - + int life; Weapon *weapon; + PLAYER_STATE playerState; + + ICustomBody *rigidBody; }myData; @@ -35,16 +45,81 @@ Player::~Player(void) delete myData; } +/******************************************************** +* Updates the player(is this function needed?) +********************************************************/ + void Player::Update() { } -void Player::Move() +/******************************************************** +* Moves the player based on client input +* Uses the physics to move the player by adding a force in the chosen direction +* Uses the Jump() function if the player is to jump, this is becuase jumping requires additional logic compared to normal movement +********************************************************/ +void Player::Move(const PLAYER_MOVEMENT &movement) +{ + switch(movement) + { + case PLAYER_MOVEMENT_FORWARD: + break; + + case PLAYER_MOVEMENT_BACKWARD: + break; + + case PLAYER_MOVEMENT_LEFT: + break; + + case PLAYER_MOVEMENT_RIGHT: + break; + + case PLAYER_MOVEMENT_JUMP: + Jump(); + break; + } +} +/******************************************************** +* Uses the players weapon based on user input +********************************************************/ +void Player::Shoot(const WEAPON_FIRE &fireInput) +{ + myData->weapon->UseWeapon(fireInput); +} + +/******************************************************** +* Jumps if the player is currently not in a state of jumping +* Applies a force upwards(current upwards) +********************************************************/ +void Player::Jump() { } -void Player::Shoot() + +bool Player::IsWalking() +{ + return (myData->playerState == PLAYER_STATE_WALKING); +} +bool Player::IsJumping() +{ + return (myData->playerState == PLAYER_STATE_JUMPING); +} +bool Player::IsIdle() +{ + return (myData->playerState == PLAYER_STATE_IDLE); +} + +//Oyster::Math::Float3 Player::GetPos() +//{ +// return myData->rigidBody->GetCenter(); +//} + +/******************************************************** +* Respawns the player on a new chosen position +* This resets a set of variables such as life, ammo etcetc +********************************************************/ +void Player::Respawn() { } diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index 439bbcd9..d4ce0a8d 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -3,6 +3,7 @@ ////////////////////////////////////////////////// #ifndef PLAYER_H #define PLAYER_H +#include "GameLogicStates.h" namespace GameLogic { @@ -13,14 +14,18 @@ namespace GameLogic Player(void); ~Player(void); - /******************************************************** - * Update the position of the rigid body - * This will be done with physics later - ********************************************************/ void Update(); - void Move(); - void Shoot(); - + void Move(const PLAYER_MOVEMENT &movement); + void Shoot(const WEAPON_FIRE &fireInput); + void Jump(); + + bool IsWalking(); + bool IsJumping(); + bool IsIdle(); + + //Oyster::Math::Float3 GetPos(); + void Respawn(); + private: struct PrivateData; PrivateData *myData; diff --git a/Code/Game/GameLogic/Weapon.cpp b/Code/Game/GameLogic/Weapon.cpp index c335ae7b..b7a47998 100644 --- a/Code/Game/GameLogic/Weapon.cpp +++ b/Code/Game/GameLogic/Weapon.cpp @@ -1,4 +1,6 @@ #include "Weapon.h" +#include "AttatchmentSocket.h" +#include "AttatchmentMassDriver.h" using namespace GameLogic; @@ -6,7 +8,8 @@ struct Weapon::PrivateData { PrivateData() { - + weaponState = WEAPON_STATE_IDLE; + SelectedAttatchment = new AttatchmentMassDriver(); } ~PrivateData() @@ -14,6 +17,13 @@ struct Weapon::PrivateData } + WEAPON_STATE weaponState; + + AttatchmentSocket **attatchmentSockets; + int nrOfAttatchmentSockets; + + IAttatchment *SelectedAttatchment; + }myData; Weapon::Weapon() @@ -26,3 +36,34 @@ Weapon::~Weapon(void) { delete myData; } + +/******************************************************** +* Uses the weapon based on the input given and the current state of the weapon +********************************************************/ +void Weapon::UseWeapon(const WEAPON_FIRE &fireInput) +{ + myData->SelectedAttatchment->UseAttatchment(fireInput); +} + +/******************************************************** +* Specific weapon usage implementation +********************************************************/ + +/******************************************************** +* Get functions for states +********************************************************/ +bool Weapon::IsFireing() +{ + return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_FIREING); +} + +bool Weapon::IsIdle() +{ + return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_IDLE); +} + +bool Weapon::IsReloading() +{ + return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_RELOADING); +} + diff --git a/Code/Game/GameLogic/Weapon.h b/Code/Game/GameLogic/Weapon.h index 527b0b73..74a408e9 100644 --- a/Code/Game/GameLogic/Weapon.h +++ b/Code/Game/GameLogic/Weapon.h @@ -3,6 +3,7 @@ ////////////////////////////////////////////////// #ifndef WEAPON_H #define WEAPON_H +#include "GameLogicStates.h" namespace GameLogic { @@ -11,10 +12,20 @@ namespace GameLogic { public: + + Weapon(void); ~Weapon(void); - private: + void UseWeapon(const WEAPON_FIRE &fireInput); + + + bool IsFireing(); + bool IsIdle(); + bool IsReloading(); + + + private: struct PrivateData; PrivateData *myData; }; From 4b9f2671bf0d5d6fae430913e8ab2b6bd8ac3498 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Tue, 10 Dec 2013 11:17:25 +0100 Subject: [PATCH 2/2] updated weapon --- Code/Game/DanBiasGame/DanBiasGame.vcxproj | 9 +++----- .../DanBiasLauncher/DanBiasLauncher.vcxproj | 7 ++----- Code/Game/DanBiasLauncher/Launcher.cpp | 4 ++-- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 21 ++++++++++++------- Code/Game/GameLogic/GameLogic.vcxproj | 1 - Code/Game/GameLogic/Player.cpp | 10 ++++----- Code/Game/GameLogic/Player.h | 3 ++- Code/Game/GameLogic/Weapon.cpp | 4 ++-- 8 files changed, 30 insertions(+), 29 deletions(-) diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj index 0b9d07d3..255f03bf 100644 --- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj +++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj @@ -71,7 +71,7 @@ $(SolutionDir)..\Bin\DLL\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D - C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL; + $(LibraryPath)$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL; $(SolutionDir)..\External\Include\;$(IncludePath) @@ -106,12 +106,12 @@ Disabled DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(SolutionDir)GameLogic;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + $(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) Windows true - OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;%(AdditionalDependencies) + OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies) OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs) @@ -181,9 +181,6 @@ {0ec83e64-230e-48ef-b08c-6ac9651b4f82} - - {b1195bb9-b3a5-47f0-906c-8dea384d1520} - diff --git a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj index 5a4ebeb6..0e97666f 100644 --- a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj +++ b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj @@ -110,8 +110,8 @@ Windows true - GameLogic_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs) - Input_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies) + DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + Input_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies) @@ -195,9 +195,6 @@ {52380daa-0f4a-4d97-8e57-98df39319caf} - - {b1195bb9-b3a5-47f0-906c-8dea384d1520} - diff --git a/Code/Game/DanBiasLauncher/Launcher.cpp b/Code/Game/DanBiasLauncher/Launcher.cpp index 28b89485..0440d973 100644 --- a/Code/Game/DanBiasLauncher/Launcher.cpp +++ b/Code/Game/DanBiasLauncher/Launcher.cpp @@ -4,8 +4,8 @@ #define NOMINMAX #include -#define DANBIAS_SERVER -//#define DANBIAS_CLIENT +//#define DANBIAS_SERVER +#define DANBIAS_CLIENT #if defined(DANBIAS_SERVER) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index fcee6afb..18324149 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -26,13 +26,20 @@ AttatchmentMassDriver::~AttatchmentMassDriver(void) { } - -void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &fireInput) -{ - -} - +/******************************************************** +* Uses the attatchment and will from here switch case the different WEAPON_FIRE's that are to be used +********************************************************/ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &fireInput) { - + ForcePush(fireInput); } + +/******************************************************** +* This is a specific functionallity of the weapon +********************************************************/ +void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &fireInput) +{ + +} + + diff --git a/Code/Game/GameLogic/GameLogic.vcxproj b/Code/Game/GameLogic/GameLogic.vcxproj index 33fd6c92..8f77f0d6 100644 --- a/Code/Game/GameLogic/GameLogic.vcxproj +++ b/Code/Game/GameLogic/GameLogic.vcxproj @@ -194,7 +194,6 @@ - diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 01046143..9bc9d752 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -32,7 +32,7 @@ struct Player::PrivateData PLAYER_STATE playerState; ICustomBody *rigidBody; - + }myData; Player::Player() @@ -110,10 +110,10 @@ bool Player::IsIdle() return (myData->playerState == PLAYER_STATE_IDLE); } -//Oyster::Math::Float3 Player::GetPos() -//{ -// return myData->rigidBody->GetCenter(); -//} +Oyster::Math::Float3 Player::GetPos() +{ + return myData->rigidBody->GetCenter(); +} /******************************************************** * Respawns the player on a new chosen position diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index d4ce0a8d..20fc8de6 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -4,6 +4,7 @@ #ifndef PLAYER_H #define PLAYER_H #include "GameLogicStates.h" +#include "OysterMath.h" namespace GameLogic { @@ -23,7 +24,7 @@ namespace GameLogic bool IsJumping(); bool IsIdle(); - //Oyster::Math::Float3 GetPos(); + Oyster::Math::Float3 GetPos(); void Respawn(); private: diff --git a/Code/Game/GameLogic/Weapon.cpp b/Code/Game/GameLogic/Weapon.cpp index b7a47998..2a575039 100644 --- a/Code/Game/GameLogic/Weapon.cpp +++ b/Code/Game/GameLogic/Weapon.cpp @@ -14,7 +14,7 @@ struct Weapon::PrivateData ~PrivateData() { - + delete SelectedAttatchment; } WEAPON_STATE weaponState; @@ -38,7 +38,7 @@ Weapon::~Weapon(void) } /******************************************************** -* Uses the weapon based on the input given and the current state of the weapon +* Uses the weapon based on the input given and the current chosen attatchment ********************************************************/ void Weapon::UseWeapon(const WEAPON_FIRE &fireInput) {