Gamelogic - Merged with existing stuff
This commit is contained in:
commit
be39365a27
|
@ -5,9 +5,7 @@
|
|||
#include "GameClientState/GameClientState.h"
|
||||
#include "GameClientState\GameState.h"
|
||||
#include "GameClientState\LobbyState.h"
|
||||
#include "PlayerProtocols.h"
|
||||
#include "ControlProtocols.h"
|
||||
#include "GameProtocols.h"
|
||||
#include <GameProtocols.h>
|
||||
#include "NetworkClient.h"
|
||||
|
||||
#include "../WindowManager/WindowShell.h"
|
||||
|
@ -279,6 +277,7 @@ namespace DanBias
|
|||
delete m_data->recieverObj->gameClientState;
|
||||
m_data->recieverObj->nwClient->Disconnect();
|
||||
delete m_data->recieverObj->nwClient;
|
||||
delete m_data->timer;
|
||||
delete m_data->recieverObj;
|
||||
delete m_data->inputObj;
|
||||
delete m_data;
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace DanBias
|
|||
|
||||
struct ModelInitData
|
||||
{
|
||||
int id;
|
||||
std::wstring modelPath;
|
||||
Oyster::Math::Float4x4 world;
|
||||
bool visible;
|
||||
|
@ -24,5 +25,6 @@ public:
|
|||
|
||||
virtual void Render() = 0;
|
||||
virtual void Release() = 0;
|
||||
virtual int GetId() = 0;
|
||||
};};};
|
||||
#endif
|
||||
|
|
|
@ -5,6 +5,7 @@ struct C_DynamicObj::myData
|
|||
{
|
||||
myData(){}
|
||||
Oyster::Graphics::Model::Model *model;
|
||||
int ID;
|
||||
// light
|
||||
// sound
|
||||
// effect
|
||||
|
@ -40,3 +41,7 @@ void C_DynamicObj::Release()
|
|||
Oyster::Graphics::API::DeleteModel(privData->model);
|
||||
delete privData;
|
||||
}
|
||||
int C_DynamicObj::GetId()
|
||||
{
|
||||
return privData->ID;
|
||||
}
|
|
@ -18,5 +18,6 @@ public:
|
|||
|
||||
void Render();
|
||||
void Release();
|
||||
int GetId();
|
||||
};};};
|
||||
#endif
|
||||
|
|
|
@ -8,6 +8,7 @@ struct C_Player::myData
|
|||
Oyster::Math3D::Float4x4 view;
|
||||
Oyster::Math3D::Float4x4 proj;
|
||||
Oyster::Graphics::Model::Model *model;
|
||||
int ID;
|
||||
}privData;
|
||||
|
||||
C_Player::C_Player(void)
|
||||
|
@ -44,3 +45,7 @@ void C_Player::Release()
|
|||
Oyster::Graphics::API::DeleteModel(privData->model);
|
||||
delete privData;
|
||||
}
|
||||
int C_Player::GetId()
|
||||
{
|
||||
return privData->ID;
|
||||
}
|
|
@ -19,6 +19,7 @@ public:
|
|||
|
||||
void Render();
|
||||
void Release();
|
||||
int GetId();
|
||||
|
||||
};};};
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,7 @@ struct C_StaticObj::myData
|
|||
{
|
||||
myData(){}
|
||||
Oyster::Graphics::Model::Model *model;
|
||||
int ID;
|
||||
// light
|
||||
// sound
|
||||
// effect
|
||||
|
@ -43,3 +44,7 @@ void C_StaticObj::Release()
|
|||
Oyster::Graphics::API::DeleteModel(privData->model);
|
||||
delete privData;
|
||||
}
|
||||
int C_StaticObj::GetId()
|
||||
{
|
||||
return privData->ID;
|
||||
}
|
|
@ -18,5 +18,6 @@ public:
|
|||
|
||||
void Render();
|
||||
void Release();
|
||||
int GetId();
|
||||
};};};
|
||||
#endif
|
|
@ -5,9 +5,8 @@ using namespace DanBias::Client;
|
|||
struct C_UIobject::myData
|
||||
{
|
||||
myData(){}
|
||||
Oyster::Math3D::Float4x4 view;
|
||||
Oyster::Math3D::Float4x4 proj;
|
||||
Oyster::Graphics::Model::Model *model;
|
||||
int ID;
|
||||
}privData;
|
||||
|
||||
C_UIobject::C_UIobject(void)
|
||||
|
@ -41,3 +40,7 @@ void C_UIobject::Release()
|
|||
Oyster::Graphics::API::DeleteModel(privData->model);
|
||||
delete privData;
|
||||
}
|
||||
int C_UIobject::GetId()
|
||||
{
|
||||
return privData->ID;
|
||||
}
|
|
@ -18,5 +18,6 @@ namespace DanBias
|
|||
|
||||
void Render();
|
||||
void Release();
|
||||
int GetId();
|
||||
};};};
|
||||
#endif
|
|
@ -2,9 +2,7 @@
|
|||
#include "DllInterfaces/GFXAPI.h"
|
||||
#include "C_obj/C_Player.h"
|
||||
#include "C_obj/C_DynamicObj.h"
|
||||
#include "PlayerProtocols.h"
|
||||
#include "ControlProtocols.h"
|
||||
#include "GameProtocols.h"
|
||||
#include <GameProtocols.h>
|
||||
#include "NetworkClient.h"
|
||||
|
||||
|
||||
|
@ -15,7 +13,7 @@ struct GameState::myData
|
|||
myData(){}
|
||||
Oyster::Math3D::Float4x4 view;
|
||||
Oyster::Math3D::Float4x4 proj;
|
||||
C_Object* object[3];
|
||||
std::vector<C_Object*> object;
|
||||
int modelCount;
|
||||
Oyster::Network::NetworkClient* nwClient;
|
||||
gameStateState state;
|
||||
|
@ -59,15 +57,17 @@ bool GameState::LoadModels(std::wstring mapFile)
|
|||
modelData.visible = true;
|
||||
modelData.modelPath = L"..\\Content\\worldDummy";
|
||||
// load models
|
||||
privData->object[0] = new C_Player();
|
||||
privData->object[0]->Init(modelData);
|
||||
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));
|
||||
modelData.world = modelData.world * translate;
|
||||
modelData.modelPath = L"..\\Content\\worldDummy";
|
||||
|
||||
privData->object[1] = new C_DynamicObj();
|
||||
privData->object[1]->Init(modelData);
|
||||
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)
|
||||
|
@ -174,7 +174,7 @@ bool GameState::Render()
|
|||
}
|
||||
bool GameState::Release()
|
||||
{
|
||||
for (int i = 0; i < privData->modelCount; i++)
|
||||
for (int i = 0; i < privData->object.size(); i++)
|
||||
{
|
||||
privData->object[i]->Release();
|
||||
delete privData->object[i];
|
||||
|
@ -209,7 +209,11 @@ void GameState::Protocol( ObjPos* pos )
|
|||
{
|
||||
world[i] = pos->worldPos[i];
|
||||
}
|
||||
privData->object[pos->object_ID]->setPos(world);
|
||||
for (int i = 0; i < privData->object.size(); i++)
|
||||
{
|
||||
if(privData->object[i]->GetId() == pos->object_ID)
|
||||
privData->object[i]->setPos(world);
|
||||
}
|
||||
}
|
||||
|
||||
void GameState::Protocol( NewObj* pos )
|
||||
|
@ -224,45 +228,29 @@ void GameState::Protocol( NewObj* pos )
|
|||
|
||||
modelData.world = world;
|
||||
modelData.visible = true;
|
||||
modelData.id = pos->object_ID;
|
||||
//not sure if this is good parsing rom char* to wstring
|
||||
const char* path = pos->path;
|
||||
modelData.modelPath = std::wstring(path, path + strlen(path));
|
||||
// load models
|
||||
privData->object[pos->object_ID] = new C_Player();
|
||||
privData->object[pos->object_ID]->Init(modelData);
|
||||
}
|
||||
C_Object* player = new C_Player();
|
||||
player->Init(modelData);
|
||||
|
||||
privData->object.push_back(player);
|
||||
|
||||
void GameState::Protocol( KeyInput* pos )
|
||||
{
|
||||
bool key = false;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
key = pos->key[i];
|
||||
}
|
||||
}
|
||||
|
||||
void DanBias::Client::GameState::Protocol( RemoveObj* obj )
|
||||
{
|
||||
privData->object[obj->object_ID]->Release( );
|
||||
}
|
||||
|
||||
void GameState::PlayerPosProtocol(PlayerPos* pos)
|
||||
{
|
||||
Oyster::Math::Float4x4 world, translate;
|
||||
|
||||
world = Oyster::Math::Float4x4::identity;
|
||||
translate = Oyster::Math::Float4x4::identity;
|
||||
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(pos->playerPos[0],pos->playerPos[1],pos->playerPos[2] ));
|
||||
world = translate;
|
||||
privData->object[0]->setPos( world );
|
||||
}
|
||||
void GameState::ObjectPosProtocol(ObjPos* pos)
|
||||
{
|
||||
Oyster::Math::Float4x4 world;
|
||||
for(int i = 0; i<16; i++)
|
||||
for (int i = 0; i < privData->object.size(); i++)
|
||||
{
|
||||
world[i] = pos->worldPos[i];
|
||||
if(privData->object[i]->GetId() == obj->object_ID)
|
||||
{
|
||||
privData->object.at(i)->Release();
|
||||
privData->object.erase(privData->object.begin() + i );
|
||||
}
|
||||
}
|
||||
privData->object[1]->setPos(world);
|
||||
//privData->object[obj->object_ID]->Release( );
|
||||
}
|
||||
|
||||
//void GameState::Protocol(LightPos pos);
|
|
@ -34,11 +34,8 @@ public:
|
|||
void Protocol(ProtocolStruct* pos)override;
|
||||
void Protocol(PlayerPos* pos);
|
||||
void Protocol(ObjPos* pos);
|
||||
void Protocol(KeyInput* pos);
|
||||
void Protocol( NewObj* pos );
|
||||
void Protocol(RemoveObj* obj);
|
||||
void PlayerPosProtocol(PlayerPos* pos);
|
||||
void ObjectPosProtocol(ObjPos* pos);
|
||||
//void Protocol(LightPos pos);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -110,8 +110,8 @@
|
|||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
|
@ -126,8 +126,8 @@
|
|||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
|
@ -146,8 +146,8 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
|
@ -166,8 +166,8 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -18,7 +18,8 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
|
|||
DanBias::DanBiasGameDesc gameDesc;
|
||||
gameDesc.port = 15151;
|
||||
//gameDesc.IP = "193.11.184.196";
|
||||
gameDesc.IP = "127.0.0.1";
|
||||
gameDesc.IP = "193.11.186.101";
|
||||
//gameDesc.IP = "127.0.0.1";
|
||||
gameDesc.hinst = hinst;
|
||||
gameDesc.nCmdShow = cmdShow;
|
||||
|
||||
|
|
|
@ -107,8 +107,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>DANBIAS_SERVER_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Game\GameLogic\</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -124,8 +123,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>DANBIAS_SERVER_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Game\GameLogic\</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -143,8 +141,7 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>DANBIAS_SERVER_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Game\GameLogic\</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -164,8 +161,7 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>DANBIAS_SERVER_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Game\GameLogic\</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
|
|
@ -93,6 +93,7 @@ namespace DanBias
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifndef ERIK
|
||||
////private:
|
||||
bool GameSession::Init(GameSessionDescription& desc)
|
||||
{
|
||||
|
@ -106,6 +107,7 @@ namespace DanBias
|
|||
this->clients.Push(desc.clients[i]);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
void GameSession::Frame()
|
||||
|
@ -166,5 +168,96 @@ namespace DanBias
|
|||
|
||||
}
|
||||
}
|
||||
#else
|
||||
#include "DynamicObject.h"
|
||||
//#include "CollisionManager.h"
|
||||
//#include "GameLogicStates.h"
|
||||
//#include <GameProtocols.h>
|
||||
|
||||
/*
|
||||
using namespace GameLogic;
|
||||
//VARIABLES GOES HERE
|
||||
DynamicObject* objectBox;
|
||||
|
||||
bool GameSession::Init(GameSessionDescription& desc)
|
||||
{
|
||||
if(desc.clients.Size() == 0) return false;
|
||||
this->box = new PostBox<NetEvent>();
|
||||
this->owner = desc.owner;
|
||||
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
||||
{
|
||||
desc.clients[i]->SetPostbox(this->box);
|
||||
this->clients.Push(desc.clients[i]);
|
||||
}
|
||||
|
||||
CollisionManager::BoxCollision(0,0);
|
||||
|
||||
objectBox = new DynamicObject(CollisionManager::BoxCollision, OBJECT_TYPE::OBJECT_TYPE_BOX);
|
||||
|
||||
Protocol_CreateObject objectCreation;
|
||||
objectCreation.object_ID = objectBox->GetID();
|
||||
objectCreation.path = "crate";
|
||||
Oyster::Math::Float4x4 worldMat = objectBox->GetRigidBody()->GetOrientation();
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
objectCreation.worldMatrix[i] = worldMat[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i < clients.Size(); i++)
|
||||
{
|
||||
clients[i]->NetClient_Object()->Send(objectCreation);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
void GameSession::Frame()
|
||||
{
|
||||
}
|
||||
void GameSession::ParseEvents()
|
||||
{
|
||||
if(this->box && !this->box->IsEmpty())
|
||||
{
|
||||
NetEvent &e = this->box->Fetch();
|
||||
|
||||
if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return;
|
||||
|
||||
ParseProtocol(e.protocol, *e.reciever);
|
||||
}
|
||||
}
|
||||
void GameSession::ParseProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::ClientObject& c)
|
||||
{
|
||||
switch (p[0].value.netShort)
|
||||
{
|
||||
case protocol_Gamplay_PlayerNavigation:
|
||||
{
|
||||
if(p[1].value.netBool) //bool bForward;
|
||||
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
|
||||
if(p[2].value.netBool) //bool bBackward;
|
||||
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
|
||||
if(p[5].value.netBool) //bool bStrafeRight;
|
||||
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
||||
if(p[6].value.netBool) //bool bStrafeLeft;
|
||||
c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
||||
}
|
||||
break;
|
||||
case protocol_Gamplay_PlayerMouseMovement:
|
||||
|
||||
break;
|
||||
case protocol_Gamplay_PlayerPosition:
|
||||
|
||||
break;
|
||||
case protocol_Gamplay_CreateObject:
|
||||
|
||||
break;
|
||||
case protocol_Gamplay_ObjectPosition:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
}//End namespace DanBias
|
||||
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
//////////////////////////////////////////////////
|
||||
#ifndef DYNAMICOBJECT_H
|
||||
#define DYNAMICOBJECT_H
|
||||
#include "Object.h"
|
||||
#include "GameLogicDef.h"
|
||||
#include "Object.h"
|
||||
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue