GameServer - Merge with gamelogic
This commit is contained in:
commit
2b5a5b2fbd
|
@ -24,6 +24,7 @@ namespace DanBias
|
|||
Oyster::Network::NetworkClient* nwClient;
|
||||
Client::GameClientState* gameClientState;
|
||||
|
||||
|
||||
void NetworkCallback(Oyster::Network::CustomNetProtocol& p) override
|
||||
{
|
||||
int pType = p[0].value.netInt;
|
||||
|
|
|
@ -26,6 +26,7 @@ void C_DynamicObj::Init(ModelInitData modelInit)
|
|||
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
|
||||
privData->model->WorldMatrix = modelInit.world;
|
||||
privData->model->Visible = modelInit.visible;
|
||||
privData->ID = modelInit.id;
|
||||
}
|
||||
void C_DynamicObj::setPos(Oyster::Math::Float4x4 world)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ void C_Player::Init(ModelInitData modelInit)
|
|||
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
|
||||
privData->model->WorldMatrix = modelInit.world;
|
||||
privData->model->Visible = modelInit.visible;
|
||||
|
||||
privData->ID = modelInit.id;
|
||||
|
||||
}
|
||||
void C_Player::setPos(Oyster::Math::Float4x4 world)
|
||||
|
|
|
@ -28,6 +28,7 @@ void C_StaticObj::Init(ModelInitData modelInit)
|
|||
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
|
||||
privData->model->WorldMatrix = modelInit.world;
|
||||
privData->model->Visible = modelInit.visible;
|
||||
privData->ID = modelInit.id;
|
||||
|
||||
}
|
||||
void C_StaticObj::setPos(Oyster::Math::Float4x4 world)
|
||||
|
|
|
@ -24,6 +24,7 @@ void C_UIobject::Init(ModelInitData modelInit)
|
|||
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
|
||||
privData->model->WorldMatrix = modelInit.world;
|
||||
privData->model->Visible = modelInit.visible;
|
||||
privData->ID = modelInit.id;
|
||||
|
||||
}
|
||||
void C_UIobject::setPos(Oyster::Math::Float4x4 world)
|
||||
|
|
|
@ -40,6 +40,12 @@ bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
|
|||
}
|
||||
GameState::gameStateState GameState::LoadGame()
|
||||
{
|
||||
Oyster::Graphics::Definitions::Pointlight plight;
|
||||
plight.Pos = Oyster::Math::Float3(0,3,0);
|
||||
plight.Color = Oyster::Math::Float3(0,1,0);
|
||||
plight.Radius = 5;
|
||||
plight.Bright = 2;
|
||||
Oyster::Graphics::API::AddLight(plight);
|
||||
LoadModels(L"map");
|
||||
InitCamera(Oyster::Math::Float3(0,0,5.4f));
|
||||
return gameStateState_playing;
|
||||
|
@ -56,18 +62,22 @@ bool GameState::LoadModels(std::wstring mapFile)
|
|||
modelData.world = Oyster::Math3D::Float4x4::identity;
|
||||
modelData.visible = true;
|
||||
modelData.modelPath = L"..\\Content\\worldDummy";
|
||||
modelData.id = 0;
|
||||
// load models
|
||||
C_Object* obj = new C_Player();
|
||||
privData->object.push_back(obj);
|
||||
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||
|
||||
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2));
|
||||
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,2,2));
|
||||
modelData.world = modelData.world * translate;
|
||||
modelData.modelPath = L"..\\Content\\worldDummy";
|
||||
modelData.id ++;
|
||||
|
||||
obj = new C_DynamicObj();
|
||||
privData->object.push_back(obj);
|
||||
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
bool GameState::InitCamera(Oyster::Math::Float3 startPos)
|
||||
|
@ -209,6 +219,7 @@ void GameState::Protocol( ObjPos* pos )
|
|||
{
|
||||
world[i] = pos->worldPos[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i < privData->object.size(); i++)
|
||||
{
|
||||
if(privData->object[i]->GetId() == pos->object_ID)
|
||||
|
|
|
@ -157,17 +157,25 @@ namespace DanBias
|
|||
{
|
||||
case protocol_Gameplay_PlayerNavigation:
|
||||
{
|
||||
if(p[1].value.netBool) //bool bForward;
|
||||
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
|
||||
if(p[2].value.netBool) //bool bBackward;
|
||||
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
|
||||
if(p[5].value.netBool) //bool bStrafeRight;
|
||||
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
||||
if(p[6].value.netBool) //bool bStrafeLeft;
|
||||
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
||||
|
||||
//Protocol_ObjectPosition op(c->GetPlayer()->GetOrientation(), c->GetPlayer()->GetID());
|
||||
//Send(op.GetProtocol());
|
||||
Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
|
||||
if(p[1].value.netBool) //bool bForward;
|
||||
world.v[3].x = 2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
|
||||
if(p[2].value.netBool) //bool bBackward;
|
||||
world.v[3].x = -2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
|
||||
if(p[5].value.netBool) //bool bStrafeRight;
|
||||
world.v[3].y = 2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
||||
if(p[6].value.netBool) //bool bStrafeLeft;
|
||||
world.v[3].y = -2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
||||
|
||||
Protocol_ObjectPosition res(world, 0);
|
||||
Send(res.GetProtocol());
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case protocol_Gameplay_PlayerMouseMovement:
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
#include "Game.h"
|
||||
#include "Player.h"
|
||||
#include "Level.h"
|
||||
|
||||
using namespace GameLogic;
|
||||
|
||||
struct Game::PrivateData
|
||||
{
|
||||
PrivateData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~PrivateData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Player **players;
|
||||
Level *level;
|
||||
|
||||
}myData;
|
||||
|
||||
|
||||
Game::Game(void)
|
||||
{
|
||||
myData = new PrivateData();
|
||||
}
|
||||
|
||||
Game::~Game(void)
|
||||
{
|
||||
if(myData)
|
||||
{
|
||||
delete myData;
|
||||
}
|
||||
}
|
||||
|
||||
void Game::MovePlayer(int playerID, const PLAYER_MOVEMENT &movement)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Game::PlayerUseWeapon(int playerID, const WEAPON_FIRE &Usage)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Game::GetPlayerPos(int playerID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Game::GetAllPlayerPos()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Game::PlayerData Game::CreatePlayer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Game::CreateTeam()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Game::NewFrame()
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
#ifndef GAME_H
|
||||
#define GAME_H
|
||||
|
||||
#include "GameLogicStates.h"
|
||||
namespace GameLogic
|
||||
{
|
||||
class Game
|
||||
{
|
||||
|
||||
public:
|
||||
struct PlayerData
|
||||
{
|
||||
int playerID;
|
||||
int teamID;
|
||||
|
||||
PlayerData()
|
||||
{
|
||||
playerID = 0;
|
||||
teamID = 0;
|
||||
}
|
||||
|
||||
PlayerData(int playerID,int teamID)
|
||||
{
|
||||
this->playerID = playerID;
|
||||
this->teamID = teamID;
|
||||
|
||||
}
|
||||
|
||||
~PlayerData()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
Game(void);
|
||||
~Game(void);
|
||||
|
||||
/********************************************************
|
||||
* Moves the chosen player based on input
|
||||
* @param playerID: ID of the player you want to recieve the message
|
||||
* @param movement: enum value on what kind of action is to be taken
|
||||
********************************************************/
|
||||
void MovePlayer(int playerID, const PLAYER_MOVEMENT &movement);
|
||||
|
||||
/********************************************************
|
||||
* Uses the chosen players weapon based on input
|
||||
* @param playerID: ID of the player you want to recieve the message
|
||||
* @param Usage: enum value on what kind of action is to be taken
|
||||
********************************************************/
|
||||
void PlayerUseWeapon(int playerID, const WEAPON_FIRE &Usage);
|
||||
|
||||
/********************************************************
|
||||
* Gets a specific players position
|
||||
* @param playerID: ID of the player whos position you want
|
||||
********************************************************/
|
||||
void GetPlayerPos(int playerID);
|
||||
|
||||
/********************************************************
|
||||
* Gets the position of all players currently in the game
|
||||
********************************************************/
|
||||
void GetAllPlayerPos();
|
||||
|
||||
/********************************************************
|
||||
* Creates a player and returns PlayerData containing ID of the player
|
||||
********************************************************/
|
||||
PlayerData CreatePlayer();
|
||||
|
||||
/********************************************************
|
||||
* Creates a team
|
||||
********************************************************/
|
||||
void CreateTeam();
|
||||
|
||||
/********************************************************
|
||||
* Runs a update of the gamelogic and physics
|
||||
********************************************************/
|
||||
void NewFrame();
|
||||
|
||||
|
||||
private:
|
||||
struct PrivateData;
|
||||
PrivateData *myData;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -173,6 +173,7 @@
|
|||
<ClInclude Include="AttatchmentSocket.h" />
|
||||
<ClInclude Include="CollisionManager.h" />
|
||||
<ClInclude Include="DynamicObject.h" />
|
||||
<ClInclude Include="Game.h" />
|
||||
<ClInclude Include="GameLogicDef.h" />
|
||||
<ClInclude Include="GameLogicStates.h" />
|
||||
<ClInclude Include="GameMode.h" />
|
||||
|
@ -190,6 +191,7 @@
|
|||
<ClCompile Include="AttatchmentSocket.cpp" />
|
||||
<ClCompile Include="CollisionManager.cpp" />
|
||||
<ClCompile Include="DynamicObject.cpp" />
|
||||
<ClCompile Include="Game.cpp" />
|
||||
<ClCompile Include="GameMode.cpp" />
|
||||
<ClCompile Include="IAttatchment.cpp" />
|
||||
<ClCompile Include="Level.cpp" />
|
||||
|
|
|
@ -23,6 +23,8 @@ Object::Object()
|
|||
this->objectID = GID();
|
||||
|
||||
this->type = OBJECT_TYPE::OBJECT_TYPE_UNKNOWN;
|
||||
|
||||
rigidBody->GetState(state);
|
||||
}
|
||||
|
||||
Object::Object(void* collisionFunc, OBJECT_TYPE type)
|
||||
|
@ -40,13 +42,14 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type)
|
|||
this->objectID = GID();
|
||||
|
||||
this->type = type;
|
||||
|
||||
rigidBody->GetState(state);
|
||||
}
|
||||
|
||||
|
||||
Object::~Object(void)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
OBJECT_TYPE Object::GetType()
|
||||
|
|
|
@ -9,14 +9,8 @@
|
|||
|
||||
#include "GameLogicStates.h"
|
||||
#include "GameLogicDef.h"
|
||||
#include <PhysicsAPI.h>
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Physics
|
||||
{
|
||||
class ICustomBody;
|
||||
}
|
||||
}
|
||||
namespace GameLogic
|
||||
{
|
||||
class DANBIAS_GAMELOGIC_DLL Object
|
||||
|
@ -36,6 +30,8 @@ namespace GameLogic
|
|||
int objectID;
|
||||
protected:
|
||||
Oyster::Physics::ICustomBody *rigidBody;
|
||||
Oyster::Physics::ICustomBody::State state;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ struct Player::PrivateData
|
|||
teamID = -1;
|
||||
playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||
|
||||
lookDir = Oyster::Math::Float3(1,0,0);
|
||||
lookDir = Oyster::Math::Float4(1,0,0,0);
|
||||
}
|
||||
|
||||
~PrivateData()
|
||||
|
@ -31,7 +31,7 @@ struct Player::PrivateData
|
|||
int teamID;
|
||||
Weapon *weapon;
|
||||
PLAYER_STATE playerState;
|
||||
Oyster::Math::Float3 lookDir;
|
||||
Oyster::Math::Float4 lookDir;
|
||||
|
||||
}myData;
|
||||
|
||||
|
@ -49,8 +49,6 @@ Player::~Player(void)
|
|||
|
||||
void Player::Move(const PLAYER_MOVEMENT &movement)
|
||||
{
|
||||
//Oyster::Math::Float3 currentVelocity = rigidBody->GetRigidLinearVelocity();
|
||||
|
||||
switch(movement)
|
||||
{
|
||||
case PLAYER_MOVEMENT::PLAYER_MOVEMENT_FORWARD:
|
||||
|
@ -77,41 +75,41 @@ void Player::Move(const PLAYER_MOVEMENT &movement)
|
|||
|
||||
void Player::MoveForward()
|
||||
{
|
||||
//API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),myData->lookDir * 100);
|
||||
state.ApplyLinearImpulse(myData->lookDir * 100);
|
||||
}
|
||||
void Player::MoveBackwards()
|
||||
{
|
||||
//API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-myData->lookDir * 100);
|
||||
state.ApplyLinearImpulse(-myData->lookDir * 100);
|
||||
}
|
||||
void Player::MoveRight()
|
||||
{
|
||||
//Do cross product with forward vector and negative gravity vector
|
||||
//Oyster::Math::Float3 r = (-rigidBody->GetGravityNormal()).Cross(myData->lookDir);
|
||||
//API::Instance().ApplyForceAt(rigidBody, rigidBody->GetCenter(), r * 100);
|
||||
Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)myData->lookDir);
|
||||
state.ApplyLinearImpulse(r * 100);
|
||||
}
|
||||
void Player::MoveLeft()
|
||||
{
|
||||
//Do cross product with forward vector and negative gravity vector
|
||||
//Oyster::Math::Float3 r = -(-rigidBody->GetGravityNormal()).Cross(myData->lookDir);
|
||||
//API::Instance().ApplyForceAt(rigidBody, rigidBody->GetCenter(), r * 100);
|
||||
Oyster::Math::Float4 r = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)myData->lookDir);
|
||||
state.ApplyLinearImpulse(-r * 100);
|
||||
}
|
||||
|
||||
void Player::UseWeapon(const WEAPON_FIRE &fireInput)
|
||||
void Player::UseWeapon(const WEAPON_FIRE &Usage)
|
||||
{
|
||||
myData->weapon->Use(fireInput);
|
||||
myData->weapon->Use(Usage);
|
||||
}
|
||||
|
||||
void Player::Respawn(Oyster::Math::Float3 spawnPoint)
|
||||
{
|
||||
//API::Instance().SetCenter(rigidBody,spawnPoint);
|
||||
|
||||
myData->life = 100;
|
||||
myData->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||
myData->lookDir = Oyster::Math::Float3(1,0,0);
|
||||
myData->lookDir = Oyster::Math::Float4(1,0,0);
|
||||
}
|
||||
|
||||
void Player::Jump()
|
||||
{
|
||||
//API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-Oyster::Math::Float3(0,1,0) * 100);
|
||||
|
||||
}
|
||||
|
||||
bool Player::IsWalking()
|
||||
|
@ -129,8 +127,7 @@ bool Player::IsIdle()
|
|||
|
||||
Oyster::Math::Float3 Player::GetPos()
|
||||
{
|
||||
//return rigidBody->GetCenter();
|
||||
return Oyster::Math::Float3(0,0,0);
|
||||
return (Oyster::Math::Float3)state.GetCenterPosition();
|
||||
}
|
||||
|
||||
Oyster::Math::Float3 Player::GetLookDir()
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace GameLogic
|
|||
* Uses the weapon based on input
|
||||
* @param fireInput: enum value on what kind of action is to be taken
|
||||
********************************************************/
|
||||
void UseWeapon(const WEAPON_FIRE &fireInput);
|
||||
void UseWeapon(const WEAPON_FIRE &Usage);
|
||||
|
||||
/********************************************************
|
||||
* Respawns the player, this resets several stats and settings on the player
|
||||
|
|
|
@ -35,8 +35,6 @@ namespace GameLogic
|
|||
|
||||
int GetCurrentSocketID();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
struct PrivateData;
|
||||
PrivateData *myData;
|
||||
|
|
Loading…
Reference in New Issue