GameLogic - Pre-merge with physics
This commit is contained in:
parent
d68fd63b25
commit
694d5576d7
Binary file not shown.
Before Width: | Height: | Size: 4.4 KiB |
|
@ -57,14 +57,14 @@ bool GameState::LoadModels(std::wstring mapFile)
|
||||||
|
|
||||||
modelData.world = Oyster::Math3D::Float4x4::identity;
|
modelData.world = Oyster::Math3D::Float4x4::identity;
|
||||||
modelData.visible = true;
|
modelData.visible = true;
|
||||||
modelData.modelPath = L"worldDummy";
|
modelData.modelPath = L"..\\Content\\worldDummy";
|
||||||
// load models
|
// load models
|
||||||
privData->object[0] = new C_Player();
|
privData->object[0] = new C_Player();
|
||||||
privData->object[0]->Init(modelData);
|
privData->object[0]->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.world = modelData.world * translate;
|
||||||
modelData.modelPath = L"crate";
|
modelData.modelPath = L"..\\Content\\worldDummy";
|
||||||
|
|
||||||
privData->object[1] = new C_DynamicObj();
|
privData->object[1] = new C_DynamicObj();
|
||||||
privData->object[1]->Init(modelData);
|
privData->object[1]->Init(modelData);
|
||||||
|
|
|
@ -22,13 +22,20 @@ void ClientObject::SetPostbox(Oyster::IPostBox<NetworkSession::NetEvent>* box)
|
||||||
}
|
}
|
||||||
GameLogic::Player* ClientObject::Logic_Object()
|
GameLogic::Player* ClientObject::Logic_Object()
|
||||||
{
|
{
|
||||||
return &this->logicPlayer;
|
return this->logicPlayer;
|
||||||
}
|
}
|
||||||
Oyster::Network::NetworkClient* ClientObject::NetClient_Object()
|
Oyster::Network::NetworkClient* ClientObject::NetClient_Object()
|
||||||
{
|
{
|
||||||
return this->client;
|
return this->client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientObject::CreatePlayer()
|
||||||
|
{
|
||||||
|
if(this->logicPlayer) return;
|
||||||
|
|
||||||
|
this->logicPlayer = new GameLogic::Player();
|
||||||
|
}
|
||||||
|
|
||||||
void ClientObject::ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& protocol)
|
void ClientObject::ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& protocol)
|
||||||
{
|
{
|
||||||
//this->client->Send(&protocol);
|
//this->client->Send(&protocol);
|
||||||
|
|
|
@ -22,12 +22,15 @@ namespace DanBias
|
||||||
GameLogic::Player* Logic_Object();
|
GameLogic::Player* Logic_Object();
|
||||||
Oyster::Network::NetworkClient* NetClient_Object();
|
Oyster::Network::NetworkClient* NetClient_Object();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void CreatePlayer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** This method is NOT threadsafe. */
|
/** This method is NOT threadsafe. */
|
||||||
virtual void ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& protocol) override;
|
virtual void ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& protocol) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GameLogic::Player logicPlayer;
|
Utility::DynamicMemory::SmartPointer<GameLogic::Player> logicPlayer;
|
||||||
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client;
|
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client;
|
||||||
Oyster::IPostBox<DanBias::NetworkSession::NetEvent>* box;
|
Oyster::IPostBox<DanBias::NetworkSession::NetEvent>* box;
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,6 +13,7 @@ using namespace Utility::DynamicMemory;
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
using namespace Oyster;
|
using namespace Oyster;
|
||||||
using namespace Oyster::Thread;
|
using namespace Oyster::Thread;
|
||||||
|
using namespace GameLogic;
|
||||||
|
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
{
|
{
|
||||||
|
@ -61,13 +62,13 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
return SmartPointer<ClientObject>();
|
return SmartPointer<ClientObject>();
|
||||||
}
|
}
|
||||||
void GameSession::Send(::CustomNetProtocol& protocol)
|
void GameSession::Send(CustomNetProtocol& protocol)
|
||||||
{
|
{
|
||||||
|
NetworkSession::Send(protocol);
|
||||||
}
|
}
|
||||||
void GameSession::Send(CustomNetProtocol& protocol, int ID)
|
void GameSession::Send(CustomNetProtocol& protocol, int ID)
|
||||||
{
|
{
|
||||||
|
NetworkSession::Send(protocol, ID);
|
||||||
}
|
}
|
||||||
void GameSession::SetPostbox(IPostBox<NetworkSession::NetEvent> *box)
|
void GameSession::SetPostbox(IPostBox<NetworkSession::NetEvent> *box)
|
||||||
{
|
{
|
||||||
|
@ -104,6 +105,7 @@ namespace DanBias
|
||||||
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
||||||
{
|
{
|
||||||
desc.clients[i]->SetPostbox(this->box);
|
desc.clients[i]->SetPostbox(this->box);
|
||||||
|
desc.clients[i]->CreatePlayer();
|
||||||
this->clients.Push(desc.clients[i]);
|
this->clients.Push(desc.clients[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +113,7 @@ namespace DanBias
|
||||||
}
|
}
|
||||||
void GameSession::Frame()
|
void GameSession::Frame()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
void GameSession::ParseEvents()
|
void GameSession::ParseEvents()
|
||||||
{
|
{
|
||||||
|
@ -137,6 +140,13 @@ namespace DanBias
|
||||||
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
||||||
if(p[6].value.netBool) //bool bStrafeLeft;
|
if(p[6].value.netBool) //bool bStrafeLeft;
|
||||||
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
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;
|
break;
|
||||||
case protocol_Gamplay_PlayerMouseMovement:
|
case protocol_Gamplay_PlayerMouseMovement:
|
||||||
|
|
|
@ -51,7 +51,7 @@ void Player::Move(const PLAYER_MOVEMENT &movement)
|
||||||
{
|
{
|
||||||
Oyster::Math::Float3 currentVelocity = rigidBody->GetRigidLinearVelocity();
|
Oyster::Math::Float3 currentVelocity = rigidBody->GetRigidLinearVelocity();
|
||||||
|
|
||||||
switch(movement.value)
|
switch(movement)
|
||||||
{
|
{
|
||||||
case PLAYER_MOVEMENT::PLAYER_MOVEMENT_FORWARD:
|
case PLAYER_MOVEMENT::PLAYER_MOVEMENT_FORWARD:
|
||||||
API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),myData->lookDir * 100);
|
API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),myData->lookDir * 100);
|
||||||
|
|
|
@ -102,9 +102,12 @@ namespace GameLogic
|
||||||
this->protocol[17].type = Oyster::Network::NetAttributeType_Float;
|
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
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||||
{
|
{
|
||||||
|
|
||||||
this->protocol[1].value = object_ID;
|
this->protocol[1].value = object_ID;
|
||||||
this->protocol[2].value = worldMatrix[1];
|
this->protocol[2].value = worldMatrix[1];
|
||||||
this->protocol[3].value = worldMatrix[2];
|
this->protocol[3].value = worldMatrix[2];
|
||||||
|
|
Loading…
Reference in New Issue