GameLogic - Pre-merge with physics

This commit is contained in:
Dennis Andersen 2013-12-19 15:35:49 +01:00
parent d68fd63b25
commit 694d5576d7
7 changed files with 33 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -57,14 +57,14 @@ bool GameState::LoadModels(std::wstring mapFile)
modelData.world = Oyster::Math3D::Float4x4::identity;
modelData.visible = true;
modelData.modelPath = L"worldDummy";
modelData.modelPath = L"..\\Content\\worldDummy";
// load models
privData->object[0] = new C_Player();
privData->object[0]->Init(modelData);
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2));
modelData.world = modelData.world * translate;
modelData.modelPath = L"crate";
modelData.modelPath = L"..\\Content\\worldDummy";
privData->object[1] = new C_DynamicObj();
privData->object[1]->Init(modelData);

View File

@ -22,13 +22,20 @@ void ClientObject::SetPostbox(Oyster::IPostBox<NetworkSession::NetEvent>* box)
}
GameLogic::Player* ClientObject::Logic_Object()
{
return &this->logicPlayer;
return this->logicPlayer;
}
Oyster::Network::NetworkClient* ClientObject::NetClient_Object()
{
return this->client;
}
void ClientObject::CreatePlayer()
{
if(this->logicPlayer) return;
this->logicPlayer = new GameLogic::Player();
}
void ClientObject::ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& protocol)
{
//this->client->Send(&protocol);

View File

@ -22,12 +22,15 @@ namespace DanBias
GameLogic::Player* Logic_Object();
Oyster::Network::NetworkClient* NetClient_Object();
public:
void CreatePlayer();
private:
/** This method is NOT threadsafe. */
virtual void ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& protocol) override;
private:
GameLogic::Player logicPlayer;
Utility::DynamicMemory::SmartPointer<GameLogic::Player> logicPlayer;
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client;
Oyster::IPostBox<DanBias::NetworkSession::NetEvent>* box;
};

View File

@ -13,6 +13,7 @@ using namespace Utility::DynamicMemory;
using namespace Oyster::Network;
using namespace Oyster;
using namespace Oyster::Thread;
using namespace GameLogic;
namespace DanBias
{
@ -61,13 +62,13 @@ namespace DanBias
{
return SmartPointer<ClientObject>();
}
void GameSession::Send(::CustomNetProtocol& protocol)
void GameSession::Send(CustomNetProtocol& protocol)
{
NetworkSession::Send(protocol);
}
void GameSession::Send(CustomNetProtocol& protocol, int ID)
{
NetworkSession::Send(protocol, ID);
}
void GameSession::SetPostbox(IPostBox<NetworkSession::NetEvent> *box)
{
@ -104,6 +105,7 @@ namespace DanBias
for (unsigned int i = 0; i < desc.clients.Size(); i++)
{
desc.clients[i]->SetPostbox(this->box);
desc.clients[i]->CreatePlayer();
this->clients.Push(desc.clients[i]);
}
@ -111,6 +113,7 @@ namespace DanBias
}
void GameSession::Frame()
{
}
void GameSession::ParseEvents()
{
@ -137,6 +140,13 @@ namespace DanBias
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
if(p[6].value.netBool) //bool bStrafeLeft;
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
Oyster::Math::Float4x4 p;
c.Logic_Object()->GetRigidBody()->GetOrientation(p);
Protocol_ObjectPosition op(p);
op.object_ID = c.Logic_Object()->GetID();
this->Send(*op.GetProtocol());
}
break;
case protocol_Gamplay_PlayerMouseMovement:

View File

@ -51,7 +51,7 @@ void Player::Move(const PLAYER_MOVEMENT &movement)
{
Oyster::Math::Float3 currentVelocity = rigidBody->GetRigidLinearVelocity();
switch(movement.value)
switch(movement)
{
case PLAYER_MOVEMENT::PLAYER_MOVEMENT_FORWARD:
API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),myData->lookDir * 100);

View File

@ -102,9 +102,12 @@ namespace GameLogic
this->protocol[17].type = Oyster::Network::NetAttributeType_Float;
}
Protocol_ObjectPosition(float m[16])
{
memcpy(&worldMatrix[0], &m[0], sizeof(float)*16);
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = object_ID;
this->protocol[2].value = worldMatrix[1];
this->protocol[3].value = worldMatrix[2];