GL - merge with GL

This commit is contained in:
lindaandersson 2014-01-31 16:42:25 +01:00
commit 5b263caccd
14 changed files with 209 additions and 20 deletions

View File

@ -38,7 +38,7 @@ namespace DanBias
public: public:
WindowShell* window; WindowShell* window;
InputClass* inputObj; InputClass* inputObj;
Utility::WinTimer* timer; Utility::WinTimer timer;
GameRecieverObject* recieverObj; GameRecieverObject* recieverObj;
bool serverOwner; bool serverOwner;
@ -69,12 +69,11 @@ namespace DanBias
m_data->serverOwner = false; m_data->serverOwner = false;
// Start in lobby state // Start in lobby state
m_data->recieverObj->gameClientState = new Client::LoginState(); m_data->recieverObj->gameClientState = new Client::LoginState();
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj)) if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj))
return DanBiasClientReturn_Error; return DanBiasClientReturn_Error;
m_data->timer = new Utility::WinTimer(); //why dynamic memory? m_data->timer.reset();
m_data->timer->reset();
return DanBiasClientReturn_Sucess; return DanBiasClientReturn_Sucess;
} }
@ -83,8 +82,8 @@ namespace DanBias
// Main message loop // Main message loop
while(m_data->window->Frame()) while(m_data->window->Frame())
{ {
float dt = (float)m_data->timer->getElapsedSeconds(); float dt = (float)m_data->timer.getElapsedSeconds();
m_data->timer->reset(); m_data->timer.reset();
capFrame += dt; capFrame += dt;
if(capFrame > 0.03) if(capFrame > 0.03)
@ -131,8 +130,9 @@ namespace DanBias
HRESULT DanBiasGame::Update(float deltaTime) HRESULT DanBiasGame::Update(float deltaTime)
{ {
if(m_data->recieverObj->IsConnected())
m_data->recieverObj->Update();
m_data->recieverObj->Update();
m_data->inputObj->Update(); m_data->inputObj->Update();
if(m_data->serverOwner) if(m_data->serverOwner)
@ -198,7 +198,6 @@ namespace DanBias
delete m_data->recieverObj->gameClientState; delete m_data->recieverObj->gameClientState;
m_data->recieverObj->Disconnect(); m_data->recieverObj->Disconnect();
delete m_data->recieverObj; delete m_data->recieverObj;
delete m_data->timer;
delete m_data->inputObj; delete m_data->inputObj;
delete m_data; delete m_data;

View File

@ -2,6 +2,8 @@
#define DANBIAS_CLIENTRECIEVEROBJECT_H #define DANBIAS_CLIENTRECIEVEROBJECT_H
//WTF!? No headers included??? //WTF!? No headers included???
#include "../DanBiasGame/Include/DanBiasGame.h"
#include "../GameProtocols/GeneralProtocols.h"
namespace DanBias namespace DanBias
{ {
@ -140,8 +142,8 @@ namespace DanBias
break; break;
case protocol_Lobby_GameData: //this->LobbyGameData (Protocol_LobbyGameData (p), c); case protocol_Lobby_GameData: //this->LobbyGameData (Protocol_LobbyGameData (p), c);
{ {
GameLogic::Protocol_LobbyGameData temp(p); //GameLogic::Protocol_LobbyGameData temp(p);
printf("%s, %i.%i\n", temp.mapName.c_str(), temp.majorVersion, temp.minorVersion); //printf("%s, %i.%i\n", temp.mapName.c_str(), temp.majorVersion, temp.minorVersion);
} }
break; break;
case protocol_Lobby_ClientData: //this->LobbyMainData (Protocol_LobbyClientData (p), c); case protocol_Lobby_ClientData: //this->LobbyMainData (Protocol_LobbyClientData (p), c);

View File

@ -53,6 +53,7 @@ public:
{ {
ClientState_Login, ClientState_Login,
ClientState_Lobby, ClientState_Lobby,
ClientState_Lan,
ClientState_LobbyCreated, ClientState_LobbyCreated,
ClientState_Game, ClientState_Game,
ClientState_Same, ClientState_Same,

View File

@ -5,6 +5,10 @@
#include "C_obj/C_DynamicObj.h" #include "C_obj/C_DynamicObj.h"
#include "DllInterfaces/GFXAPI.h" #include "DllInterfaces/GFXAPI.h"
#include "LobbyState.h"
#include "GameState.h"
#include "../GameClientRecieverFunc.h"
#include <GameServerAPI.h> #include <GameServerAPI.h>
using namespace DanBias::Client; using namespace DanBias::Client;
@ -16,6 +20,10 @@ struct LanMenuState::myData
Oyster::Math3D::Float4x4 proj; Oyster::Math3D::Float4x4 proj;
C_Object* object[2]; C_Object* object[2];
int modelCount; int modelCount;
GameRecieverObject* recieverObj;
bool serverOwner;
// UI object // UI object
// game client* // game client*
}privData; }privData;
@ -83,6 +91,49 @@ bool LanMenuState::InitCamera(Oyster::Math::Float3 startPos)
} }
GameClientState::ClientState LanMenuState::Update(float deltaTime, InputClass* KeyInput) GameClientState::ClientState LanMenuState::Update(float deltaTime, InputClass* KeyInput)
{
/*ChangeState(KeyInput);
if(privData->recieverObj->IsConnected())
privData->recieverObj->Update();
KeyInput->Update();
if(privData->serverOwner)
{
DanBias::GameServerAPI::ServerUpdate();
}
DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same;
state = privData->recieverObj->gameClientState->Update(deltaTime, KeyInput);
if(state != Client::GameClientState::ClientState_Same)
{
privData->recieverObj->gameClientState->Release();
delete privData->recieverObj->gameClientState;
privData->recieverObj->gameClientState = NULL;
switch (state)
{
case Client::GameClientState::ClientState_LobbyCreated:
privData->serverOwner = true;
case Client::GameClientState::ClientState_Lobby:
privData->recieverObj->gameClientState = new Client::LobbyState();
break;
case Client::GameClientState::ClientState_Game:
privData->recieverObj->gameClientState = new Client::GameState();
break;
default:
//return E_FAIL;
break;
}
privData->recieverObj->gameClientState->Init(privData->recieverObj); // send game client
}*/
return ChangeState(KeyInput);
}
GameClientState::ClientState LanMenuState::ChangeState(InputClass* KeyInput)
{ {
// create game // create game
if( KeyInput->IsKeyPressed(DIK_C)) if( KeyInput->IsKeyPressed(DIK_C))

View File

@ -17,6 +17,8 @@ namespace DanBias
virtual bool Init(Oyster::Network::NetworkClient* nwClient); virtual bool Init(Oyster::Network::NetworkClient* nwClient);
virtual ClientState Update(float deltaTime, InputClass* KeyInput); virtual ClientState Update(float deltaTime, InputClass* KeyInput);
ClientState ChangeState(InputClass* KeyInput);
bool LoadModels(std::wstring file); bool LoadModels(std::wstring file);
bool InitCamera(Oyster::Math::Float3 startPos); bool InitCamera(Oyster::Math::Float3 startPos);

View File

@ -1,5 +1,6 @@
#include "AttatchmentMassDriver.h" #include "AttatchmentMassDriver.h"
#include "PhysicsAPI.h" #include "PhysicsAPI.h"
#include "GameLogicStates.h"
using namespace GameLogic; using namespace GameLogic;
@ -45,17 +46,16 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
********************************************************/ ********************************************************/
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt) void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt)
{ {
//Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
Oyster::Math::Float3 look = owner->GetLookDir(); Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
Oyster::Math::Float3 up = -owner->GetRigidBody()->GetGravityNormal(); Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
Oyster::Math::Float3 pos = owner->GetPosition();
Oyster::Math::Float4x4 aim = Oyster::Math3D::OrientationMatrix_LookAtDirection(owner->GetLookDir(), -owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20); Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20);
Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace)); Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace));
int arg = 0; forcePushData args;
args.pushForce = pushForce;
Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&arg,ForcePushAction); Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&args,ForcePushAction);
} }
/******************************************************** /********************************************************

View File

@ -84,14 +84,13 @@ using namespace GameLogic;
void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void *args) void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void *args)
{ {
Oyster::Math::Float3 pushForce = Oyster::Math::Float4(1,0,0) * (500);
Oyster::Physics::ICustomBody::State state; Oyster::Physics::ICustomBody::State state;
Object *realObj = (Object*)obj->GetCustomTag(); Object *realObj = (Object*)obj->GetCustomTag();
if(realObj->GetObjectType() == OBJECT_TYPE_PLAYER || realObj->GetObjectType() == OBJECT_TYPE_WORLD) if(realObj->GetObjectType() == OBJECT_TYPE_PLAYER || realObj->GetObjectType() == OBJECT_TYPE_WORLD)
return; return;
state = obj->GetState(); state = obj->GetState();
state.ApplyLinearImpulse(pushForce); state.ApplyLinearImpulse(((forcePushData*)(args))->pushForce);
obj->SetState(state); obj->SetState(state);
//((Object*)obj->GetCustomTag())->ApplyLinearImpulse(pushForce);
} }

View File

@ -1,5 +1,6 @@
#ifndef GAMELOGICSTATES_H #ifndef GAMELOGICSTATES_H
#define GAMELOGICSTATES_H #define GAMELOGICSTATES_H
#include "OysterMath.h"
namespace GameLogic namespace GameLogic
{ {
@ -46,6 +47,12 @@ namespace GameLogic
WEAPON_STATE_RELOADING = 2, WEAPON_STATE_RELOADING = 2,
}; };
struct forcePushData
{
Oyster::Math::Float3 pushForce;
};
}; };

View File

View File

View File

@ -0,0 +1,25 @@
#include "EventButtonCollection.h"
using namespace Oyster::Event;
EventButtonCollection::EventButtonCollection()
{
}
EventButtonCollection::~EventButtonCollection()
{
}
void EventButtonCollection::Update(InputClass* inputObject)
{
for(int i = 0; i < buttons.size(); i++)
{
buttons.at(i)->Update(inputObject);
}
}
EventButton* EventButtonCollection::AddButton(EventButton* button)
{
}

View File

@ -0,0 +1,31 @@
#ifndef EVENT_BUTTON_COLLECTION_H
#define EVENT_BUTTON_COLLECTION_H
#include "../../Input/L_inputClass.h"
#include "EventButton.h"
#include <vector>
namespace Oyster
{
namespace Event
{
class EventButtonCollection
{
public:
EventButtonCollection();
~EventButtonCollection();
void Update(InputClass* inputObject);
EventButton* AddButton(EventButton* button);
private:
std::vector<EventButton*> buttons;
};
}
}
#endif

View File

@ -0,0 +1,37 @@
#include "EventHandler.h"
using namespace Oyster::Event;
EventHandler EvtHandler;
EventHandler& EventHandler::Instance()
{
return EvtHandler;
}
EventHandler::EventHandler()
{
}
EventHandler::~EventHandler()
{
}
void EventHandler::Update(InputClass* inputObject)
{
for(int i = 0; i < collections.size(); i++)
{
collections.at(i)->Update(inputObject);
}
}
EventButtonCollection* EventHandler::CreateCollection()
{
}
EventButtonCollection* EventHandler::GetCollection(/*ID*/);
{
}

View File

@ -0,0 +1,35 @@
#ifndef EVENT_HANDLER_H
#define EVENT_HANDLER_H
#include "../../Input/L_inputClass.h"
#include "EventButtonCollection.h"
#include "EventButton.h"
#include <vector>
namespace Oyster
{
namespace Event
{
class EventHandler
{
EventHandler();
~EventHandler();
EventHandler& Instance();
void Update(InputClass* inputObject);
EventButtonCollection* CreateCollection();
EventButtonCollection* GetCollection(/*ID*/);
private:
std::vector<EventButtonCollection*> collections;
};
}
}
#endif