This commit is contained in:
Erik Persson 2014-01-31 14:14:20 +01:00
parent 16a342da49
commit b753387649
30 changed files with 1737 additions and 11 deletions

171
.merge_file_a01532 Normal file
View File

@ -0,0 +1,171 @@
#include "LoginState.h"
#include "DllInterfaces/GFXAPI.h"
#include "OysterMath.h"
#include "C_obj/C_Player.h"
#include "C_obj/C_StaticObj.h"
#include "C_obj/C_DynamicObj.h"
#include <GameServerAPI.h>
using namespace DanBias::Client;
struct LoginState::myData
{
myData(){}
Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj;
C_Object* object[2];
int modelCount;
// UI object
// game client*
}privData;
LoginState::LoginState(void)
{
}
LoginState::~LoginState(void)
{
}
bool LoginState::Init(Oyster::Network::NetworkClient* nwClient)
{
privData = new myData();
this->nwClient = nwClient;
// load models
LoadModels(L"UImodels.txt");
InitCamera(Oyster::Math::Float3(0,0,5.4f));
return true;
}
bool LoginState::LoadModels(std::wstring file)
{
Oyster::Graphics::Definitions::Pointlight plight;
plight.Pos = Oyster::Math::Float3(-2,3,0);
plight.Color = Oyster::Math::Float3(0,1,0);
plight.Radius = 10;
plight.Bright = 1;
Oyster::Graphics::API::AddLight(plight);
// open file
// read file
// init models
privData->modelCount = 2;
ModelInitData modelData;
modelData.world = Oyster::Math3D::Float4x4::identity;
modelData.visible = true;
modelData.modelPath = L"..\\Content\\Models\\box_2.dan";
// load models
privData->object[0] = new C_StaticObj();
privData->object[0]->Init(modelData);
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2));
modelData.world = modelData.world * translate;
privData->object[1] = new C_DynamicObj();
privData->object[1]->Init(modelData);
return true;
}
bool LoginState::InitCamera(Oyster::Math::Float3 startPos)
{
privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
//privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
Oyster::Graphics::API::SetProjection(privData->proj);
privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
return true;
}
GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* KeyInput)
{
// picking
// mouse events
// different menus
// play sounds
// update animation
// send data to server
// check data from server
// create game
if( KeyInput->IsKeyPressed(DIK_C))
{
DanBias::GameServerAPI::ServerInitDesc desc;
DanBias::GameServerAPI::ServerInitiate(desc);
DanBias::GameServerAPI::ServerStart();
// my ip
nwClient->Connect(15151, "127.0.0.1");
if (!nwClient->IsConnected())
{
// failed to connect
return ClientState_Same;
}
return ClientState_LobbyCreated;
}
// join game
if( KeyInput->IsKeyPressed(DIK_J))
{
// game ip
nwClient->Connect(15151, "193.11.184.109");
if (!nwClient->IsConnected())
{
// failed to connect
return ClientState_Same;
}
return ClientState_Lobby;
}
return ClientState_Same;
}
bool LoginState::Render()
{
Oyster::Graphics::API::SetView(privData->view);
Oyster::Graphics::API::SetProjection( privData->proj);
Oyster::Graphics::API::NewFrame();
// render objects
for (int i = 0; i < privData->modelCount; i++)
{
privData->object[i]->Render();
}
// render effects
// render lights
Oyster::Graphics::API::EndFrame();
return true;
}
bool LoginState::Release()
{
for (int i = 0; i < privData->modelCount; i++)
{
privData->object[i]->Release();
delete privData->object[i];
privData->object[i] = NULL;
}
delete privData;
privData = NULL;
return true;
}
void LoginState::Protocol(ProtocolStruct* protocol)
{
if((PlayerName*)protocol)
PlayerJoinProtocol((PlayerName*)protocol);
}
void LoginState::PlayerJoinProtocol(PlayerName* name)
{
}

93
.merge_file_a04876 Normal file
View File

@ -0,0 +1,93 @@
#include "Level.h"
#include "CollisionManager.h"
using namespace GameLogic;
using namespace Utility::DynamicMemory;
using namespace Oyster::Physics;
Level::Level(void)
{
}
Level::~Level(void)
{
}
void Level::InitiateLevel(std::string levelPath)
{
}
void Level::InitiateLevel(float radius)
{
// add level sphere
API::SphericalBodyDescription sbDesc;
sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
sbDesc.ignoreGravity = true;
sbDesc.radius = 300;
sbDesc.mass = 10e12f;
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
ICustomBody::State state;
rigidBody->GetState(state);
state.SetRestitutionCoeff(0.01);
rigidBody->SetState(state);
levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD);
rigidBody->SetCustomTag(levelObj);
// add box
API::SimpleBodyDescription sbDesc_TestBox;
sbDesc_TestBox.centerPosition = Oyster::Math::Float4(4,320,0,0);
sbDesc_TestBox.ignoreGravity = false;
sbDesc_TestBox.mass = 10;
sbDesc_TestBox.size = Oyster::Math::Float4(0.5f,0.5f,0.5f,0);
ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release();
rigidBody_TestBox->SetSubscription(Level::PhysicsOnMoveLevel);
testBox = new DynamicObject(rigidBody_TestBox, OBJECT_TYPE::OBJECT_TYPE_BOX);
rigidBody_TestBox->SetCustomTag(testBox);
rigidBody_TestBox->GetState(state);
state.ApplyLinearImpulse(Oyster::Math::Float3(0,20,0));
rigidBody_TestBox->SetState(state);
// add gravitation
API::Gravity gravityWell;
gravityWell.gravityType = API::Gravity::GravityType_Well;
gravityWell.well.mass = 1e15f;
gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
API::Instance().AddGravity(gravityWell);
}
void Level::AddPlayerToTeam(Player *player, int teamID)
{
this->teamManager.AddPlayerToTeam(player,teamID);
}
void Level::CreateTeam(int teamSize)
{
this->teamManager.CreateTeam(teamSize);
}
void Level::RespawnPlayer(Player *player)
{
this->teamManager.RespawnPlayerRandom(player);
}
Object* Level::GetObj( int ID) const
{
if( ID == 0 )
return (Object*)levelObj;
else
return (Object*)testBox;
}
void Level::PhysicsOnMoveLevel(const ICustomBody *object)
{
// function call from physics update when object was moved
Object* temp = (Object*)object->GetCustomTag();
}

66
.merge_file_a05028 Normal file
View File

@ -0,0 +1,66 @@
#include "Game.h"
#include "Player.h"
using namespace GameLogic;
Game::PlayerData::PlayerData()
{
//set some stats that are appropriate to a player
Oyster::Physics::API::SimpleBodyDescription sbDesc;
sbDesc.centerPosition = Oyster::Math::Float3(10,350,0);
sbDesc.size = Oyster::Math::Float3(4,7,4);
sbDesc.mass = 70;
//create rigid body
Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release();
//create player with this rigid body
this->player = new Player(rigidBody,Object::DefaultCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER);
this->player->GetRigidBody()->SetCustomTag(this);
}
Game::PlayerData::PlayerData(int playerID,int teamID)
{
this->player = new Player();
}
Game::PlayerData::~PlayerData()
{
delete this->player;
}
void Game::PlayerData::Move(const PLAYER_MOVEMENT &movement)
{
this->player->Move(movement);
}
void Game::PlayerData::UseWeapon(const WEAPON_FIRE &usage)
{
this->player->UseWeapon(usage);
}
Oyster::Math::Float3 Game::PlayerData::GetPosition()
{
return this->player->GetPosition();
}
Oyster::Math::Float4x4 Game::PlayerData::GetOrientation()
{
return this->player->GetOrientation();
}
PLAYER_STATE Game::PlayerData::GetState() const
{
return this->player->GetState();
}
int Game::PlayerData::GetID() const
{
return this->player->GetID();
}
int Game::PlayerData::GetTeamID() const
{
return this->player->GetTeamID();
}
OBJECT_TYPE Game::PlayerData::GetObjectType() const
{
return this->player->GetObjectType();
}
void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir)
{
this->player->Rotate(lookDir);
}

171
.merge_file_a06880 Normal file
View File

@ -0,0 +1,171 @@
#include "LoginState.h"
#include "DllInterfaces/GFXAPI.h"
#include "OysterMath.h"
#include "C_obj/C_Player.h"
#include "C_obj/C_StaticObj.h"
#include "C_obj/C_DynamicObj.h"
#include <GameServerAPI.h>
using namespace DanBias::Client;
struct LoginState::myData
{
myData(){}
Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj;
C_Object* object[2];
int modelCount;
// UI object
// game client*
}privData;
LoginState::LoginState(void)
{
}
LoginState::~LoginState(void)
{
}
bool LoginState::Init(Oyster::Network::NetworkClient* nwClient)
{
privData = new myData();
this->nwClient = nwClient;
// load models
LoadModels(L"UImodels.txt");
InitCamera(Oyster::Math::Float3(0,0,5.4f));
return true;
}
bool LoginState::LoadModels(std::wstring file)
{
Oyster::Graphics::Definitions::Pointlight plight;
plight.Pos = Oyster::Math::Float3(-2,3,0);
plight.Color = Oyster::Math::Float3(0,1,0);
plight.Radius = 10;
plight.Bright = 1;
Oyster::Graphics::API::AddLight(plight);
// open file
// read file
// init models
privData->modelCount = 2;
ModelInitData modelData;
modelData.world = Oyster::Math3D::Float4x4::identity;
modelData.visible = true;
modelData.modelPath = L"..\\Content\\Models\\box_2.dan";
// load models
privData->object[0] = new C_StaticObj();
privData->object[0]->Init(modelData);
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2));
modelData.world = modelData.world * translate;
privData->object[1] = new C_DynamicObj();
privData->object[1]->Init(modelData);
return true;
}
bool LoginState::InitCamera(Oyster::Math::Float3 startPos)
{
privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
//privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
Oyster::Graphics::API::SetProjection(privData->proj);
privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
return true;
}
GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* KeyInput)
{
// picking
// mouse events
// different menus
// play sounds
// update animation
// send data to server
// check data from server
// create game
if( KeyInput->IsKeyPressed(DIK_C))
{
DanBias::GameServerAPI::ServerInitDesc desc;
DanBias::GameServerAPI::ServerInitiate(desc);
DanBias::GameServerAPI::ServerStart();
// my ip
nwClient->Connect(15151, "127.0.0.1");
if (!nwClient->IsConnected())
{
// failed to connect
return ClientState_Same;
}
return ClientState_LobbyCreated;
}
// join game
if( KeyInput->IsKeyPressed(DIK_J))
{
// game ip
nwClient->Connect(15151, "194.47.150.56");
if (!nwClient->IsConnected())
{
// failed to connect
return ClientState_Same;
}
return ClientState_Lobby;
}
return ClientState_Same;
}
bool LoginState::Render()
{
Oyster::Graphics::API::SetView(privData->view);
Oyster::Graphics::API::SetProjection( privData->proj);
Oyster::Graphics::API::NewFrame();
// render objects
for (int i = 0; i < privData->modelCount; i++)
{
privData->object[i]->Render();
}
// render effects
// render lights
Oyster::Graphics::API::EndFrame();
return true;
}
bool LoginState::Release()
{
for (int i = 0; i < privData->modelCount; i++)
{
privData->object[i]->Release();
delete privData->object[i];
privData->object[i] = NULL;
}
delete privData;
privData = NULL;
return true;
}
void LoginState::Protocol(ProtocolStruct* protocol)
{
if((PlayerName*)protocol)
PlayerJoinProtocol((PlayerName*)protocol);
}
void LoginState::PlayerJoinProtocol(PlayerName* name)
{
}

98
.merge_file_a07272 Normal file
View File

@ -0,0 +1,98 @@
#include "Level.h"
#include "CollisionManager.h"
using namespace GameLogic;
using namespace Utility::DynamicMemory;
using namespace Oyster::Physics;
Level::Level(void)
{
}
Level::~Level(void)
{
}
void Level::InitiateLevel(std::string levelPath)
{
}
void Level::InitiateLevel(float radius)
{
// add level sphere
API::SphericalBodyDescription sbDesc;
sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
sbDesc.ignoreGravity = true;
sbDesc.radius = 300;
sbDesc.mass = 10e12f;
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
ICustomBody::State state;
rigidBody->GetState(state);
state.SetRestitutionCoeff(0.01);
rigidBody->SetState(state);
levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD);
rigidBody->SetCustomTag(levelObj);
// add box
API::SimpleBodyDescription sbDesc_TestBox;
sbDesc_TestBox.centerPosition = Oyster::Math::Float4(0,320,0,0);
sbDesc_TestBox.ignoreGravity = false;
<<<<<<< .merge_file_a07272
sbDesc_TestBox.mass = 10;
sbDesc_TestBox.size = Oyster::Math::Float4(4,4,4,0);
=======
sbDesc_TestBox.mass = 50;
sbDesc_TestBox.size = Oyster::Math::Float4(1,1,1,0);
>>>>>>> .merge_file_a07992
ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release();
rigidBody_TestBox->SetSubscription(Level::PhysicsOnMoveLevel);
testBox = new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX);
rigidBody_TestBox->SetCustomTag(testBox);
rigidBody_TestBox->GetState(state);
state.ApplyLinearImpulse(Oyster::Math::Float3(0,0,0));
rigidBody_TestBox->SetState(state);
// add gravitation
API::Gravity gravityWell;
gravityWell.gravityType = API::Gravity::GravityType_Well;
gravityWell.well.mass = 1e15f;
gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
API::Instance().AddGravity(gravityWell);
}
void Level::AddPlayerToTeam(Player *player, int teamID)
{
this->teamManager.AddPlayerToTeam(player,teamID);
}
void Level::CreateTeam(int teamSize)
{
this->teamManager.CreateTeam(teamSize);
}
void Level::RespawnPlayer(Player *player)
{
this->teamManager.RespawnPlayerRandom(player);
}
Object* Level::GetObj( int ID) const
{
if( ID == 0 )
return (Object*)levelObj;
else
return (Object*)testBox;
}
void Level::PhysicsOnMoveLevel(const ICustomBody *object)
{
// function call from physics update when object was moved
Object* temp = (Object*)object->GetCustomTag();
}

81
.merge_file_a07484 Normal file
View File

@ -0,0 +1,81 @@
#include "AttatchmentMassDriver.h"
#include "PhysicsAPI.h"
#include "GameLogicStates.h"
using namespace GameLogic;
AttatchmentMassDriver::AttatchmentMassDriver(void)
{
this->owner = 0;
}
AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
{
this->owner = &owner;
}
AttatchmentMassDriver::~AttatchmentMassDriver(void)
{
}
/********************************************************
* Uses the attatchment and will from here switch case the different WEAPON_FIRE's that are to be used
********************************************************/
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, float dt)
{
//switch case to determin what functionallity to use in the attatchment
switch (usage)
{
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
ForcePush(usage,dt);
break;
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
ForcePull(usage,dt);
break;
}
}
/********************************************************
* Pushes objects in a cone in front of the weapon when fired
********************************************************/
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt)
{
<<<<<<< .merge_file_a07484
Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
=======
//Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
Oyster::Math::Float3 look = owner->GetLookDir();
Oyster::Math::Float3 up = -owner->GetRigidBody()->GetGravityNormal();
Oyster::Math::Float3 pos = owner->GetPosition();
Oyster::Math::Float4x4 aim = Oyster::Math3D::OrientationMatrix_LookAtDirection(owner->GetLookDir(), -owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
>>>>>>> .merge_file_a11560
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));
forcePushData args;
args.pushForce = pushForce;
Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&args,ForcePushAction);
}
/********************************************************
* Pulls the player in the direction he is looking, used for fast movement(kinda like a jetpack)
********************************************************/
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
{
Oyster::Physics::Struct::CustomBodyState state = this->owner->GetRigidBody()->GetState();
//do something with state
state.ApplyLinearImpulse(Oyster::Math::Float3(this->owner->GetLookDir()) * (500 * dt));
this->owner->GetRigidBody()->SetState(state);
}

93
.merge_file_a07992 Normal file
View File

@ -0,0 +1,93 @@
#include "Level.h"
#include "CollisionManager.h"
using namespace GameLogic;
using namespace Utility::DynamicMemory;
using namespace Oyster::Physics;
Level::Level(void)
{
}
Level::~Level(void)
{
}
void Level::InitiateLevel(std::string levelPath)
{
}
void Level::InitiateLevel(float radius)
{
// add level sphere
API::SphericalBodyDescription sbDesc;
sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
sbDesc.ignoreGravity = true;
sbDesc.radius = 300;
sbDesc.mass = 10e12f;
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
ICustomBody::State state;
rigidBody->GetState(state);
state.SetRestitutionCoeff(0.01);
rigidBody->SetState(state);
levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD);
rigidBody->SetCustomTag(levelObj);
// add box
API::SimpleBodyDescription sbDesc_TestBox;
sbDesc_TestBox.centerPosition = Oyster::Math::Float4(0,320,0,0);
sbDesc_TestBox.ignoreGravity = false;
sbDesc_TestBox.mass = 50;
sbDesc_TestBox.size = Oyster::Math::Float4(1,1,1,0);
ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release();
rigidBody_TestBox->SetSubscription(Level::PhysicsOnMoveLevel);
testBox = new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX);
rigidBody_TestBox->SetCustomTag(testBox);
rigidBody_TestBox->GetState(state);
state.ApplyLinearImpulse(Oyster::Math::Float3(0,0,0));
rigidBody_TestBox->SetState(state);
// add gravitation
API::Gravity gravityWell;
gravityWell.gravityType = API::Gravity::GravityType_Well;
gravityWell.well.mass = 1e15f;
gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
API::Instance().AddGravity(gravityWell);
}
void Level::AddPlayerToTeam(Player *player, int teamID)
{
this->teamManager.AddPlayerToTeam(player,teamID);
}
void Level::CreateTeam(int teamSize)
{
this->teamManager.CreateTeam(teamSize);
}
void Level::RespawnPlayer(Player *player)
{
this->teamManager.RespawnPlayerRandom(player);
}
Object* Level::GetObj( int ID) const
{
if( ID == 0 )
return (Object*)levelObj;
else
return (Object*)testBox;
}
void Level::PhysicsOnMoveLevel(const ICustomBody *object)
{
// function call from physics update when object was moved
Object* temp = (Object*)object->GetCustomTag();
}

66
.merge_file_a08280 Normal file
View File

@ -0,0 +1,66 @@
#include "Game.h"
#include "Player.h"
using namespace GameLogic;
Game::PlayerData::PlayerData()
{
//set some stats that are appropriate to a player
Oyster::Physics::API::SimpleBodyDescription sbDesc;
sbDesc.centerPosition = Oyster::Math::Float3(0,320,0);
sbDesc.size = Oyster::Math::Float3(4,7,4);
sbDesc.mass = 10;
//create rigid body
Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release();
//create player with this rigid body
this->player = new Player(rigidBody,Object::DefaultCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER);
this->player->GetRigidBody()->SetCustomTag(this);
}
Game::PlayerData::PlayerData(int playerID,int teamID)
{
this->player = new Player();
}
Game::PlayerData::~PlayerData()
{
delete this->player;
}
void Game::PlayerData::Move(const PLAYER_MOVEMENT &movement)
{
this->player->Move(movement);
}
void Game::PlayerData::UseWeapon(const WEAPON_FIRE &usage)
{
this->player->UseWeapon(usage);
}
Oyster::Math::Float3 Game::PlayerData::GetPosition()
{
return this->player->GetPosition();
}
Oyster::Math::Float4x4 Game::PlayerData::GetOrientation()
{
return this->player->GetOrientation();
}
PLAYER_STATE Game::PlayerData::GetState() const
{
return this->player->GetState();
}
int Game::PlayerData::GetID() const
{
return this->player->GetID();
}
int Game::PlayerData::GetTeamID() const
{
return this->player->GetTeamID();
}
OBJECT_TYPE Game::PlayerData::GetObjectType() const
{
return this->player->GetObjectType();
}
void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir)
{
this->player->Rotate(lookDir);
}

96
.merge_file_a08532 Normal file
View File

@ -0,0 +1,96 @@
#include "PhysicsAPI.h"
#include "Object.h"
#include "DynamicObject.h"
#include "Player.h"
#include "Level.h"
#include "AttatchmentMassDriver.h"
#include "Game.h"
using namespace Oyster;
using namespace GameLogic;
void PlayerVBox(Player &player, DynamicObject &box, Oyster::Math::Float kineticEnergyLoss);
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss);
//Physics::ICustomBody::SubscriptMessage
void Player::PlayerCollision(Oyster::Physics::ICustomBody *rigidBodyPlayer, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{
Player *player = ((Game::PlayerData*)(rigidBodyPlayer->GetCustomTag()))->player;
Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed?
switch (realObj->GetObjectType())
{
case OBJECT_TYPE::OBJECT_TYPE_GENERIC:
PlayerVObject(*player,*realObj, kineticEnergyLoss);
//return Physics::ICustomBody::SubscriptMessage_none;
break;
case OBJECT_TYPE::OBJECT_TYPE_BOX:
PlayerVBox(*player,(*(DynamicObject*) realObj), kineticEnergyLoss);
//return Physics::ICustomBody::SubscriptMessage_none;
break;
case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
//return Physics::ICustomBody::SubscriptMessage_none;
break;
case OBJECT_TYPE::OBJECT_TYPE_WORLD:
int test = 5;
break;
}
//return Physics::ICustomBody::SubscriptMessage_none;
}
void PlayerVBox(Player &player, DynamicObject &box, Oyster::Math::Float kineticEnergyLoss)
{
//use kinetic energyloss of the collision in order too determin how much damage to take
//use as part of the damage algorithm
player.DamageLife(20);
}
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss)
{
//Collision between a player and a general static or dynamic object
//use kinetic energyloss of the collision in order too determin how much damage to take
//use as part of the damage algorithm
int damageDone = 0;
int forceThreashHold = 200;
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
{
damageDone = kineticEnergyLoss * 0.10f;
player.DamageLife(damageDone);
}
}
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj)
{
return Physics::ICustomBody::SubscriptMessage_none;
}
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{
return Physics::ICustomBody::SubscriptMessage_none;
}
//Oyster::Physics::ICustomBody::SubscriptMessage
Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj)
{
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
}
Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
}
void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void *args)
{
Oyster::Physics::ICustomBody::State state;
Object *realObj = (Object*)obj->GetCustomTag();
if(realObj->GetObjectType() == OBJECT_TYPE_PLAYER || realObj->GetObjectType() == OBJECT_TYPE_WORLD)
return;
state = obj->GetState();
state.ApplyLinearImpulse(((forcePushData*)(args))->pushForce);
obj->SetState(state);
}

166
.merge_file_a08608 Normal file
View File

@ -0,0 +1,166 @@
#include "LoginState.h"
#include "DllInterfaces/GFXAPI.h"
#include "OysterMath.h"
#include "C_obj/C_Player.h"
#include "C_obj/C_StaticObj.h"
#include "C_obj/C_DynamicObj.h"
#include <GameServerAPI.h>
using namespace DanBias::Client;
struct LoginState::myData
{
myData(){}
Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj;
C_Object* object[2];
int modelCount;
// UI object
// game client*
}privData;
LoginState::LoginState(void)
{
}
LoginState::~LoginState(void)
{
}
bool LoginState::Init(Oyster::Network::NetworkClient* nwClient)
{
privData = new myData();
this->nwClient = nwClient;
// load models
LoadModels(L"UImodels.txt");
InitCamera(Oyster::Math::Float3(0,0,5.4f));
return true;
}
bool LoginState::LoadModels(std::wstring file)
{
Oyster::Graphics::Definitions::Pointlight plight;
plight.Pos = Oyster::Math::Float3(-2,3,0);
plight.Color = Oyster::Math::Float3(0,1,0);
plight.Radius = 10;
plight.Bright = 1;
Oyster::Graphics::API::AddLight(plight);
// open file
// read file
// init models
privData->modelCount = 2;
ModelInitData modelData;
modelData.world = Oyster::Math3D::Float4x4::identity;
modelData.visible = true;
modelData.modelPath = L"..\\Content\\Models\\box_2.dan";
// load models
privData->object[0] = new C_StaticObj();
privData->object[0]->Init(modelData);
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2));
modelData.world = modelData.world * translate;
privData->object[1] = new C_DynamicObj();
privData->object[1]->Init(modelData);
return true;
}
bool LoginState::InitCamera(Oyster::Math::Float3 startPos)
{
privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
//privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
Oyster::Graphics::API::SetProjection(privData->proj);
privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
return true;
}
GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* KeyInput)
{
// picking
// mouse events
// different menus
// play sounds
// update animation
// send data to server
// check data from server
// create game
if( KeyInput->IsKeyPressed(DIK_C))
{
DanBias::GameServerAPI::ServerInitDesc desc;
DanBias::GameServerAPI::ServerInitiate(desc);
DanBias::GameServerAPI::ServerStart();
// my ip
nwClient->Connect(15151, "127.0.0.1");
if (!nwClient->IsConnected())
{
// failed to connect
return ClientState_Same;
}
return ClientState_LobbyCreated;
}
// join game
if( KeyInput->IsKeyPressed(DIK_J))
{
// game ip
nwClient->Connect(15151, "194.47.150.56");
if (!nwClient->IsConnected())
{
// failed to connect
return ClientState_Same;
}
return ClientState_Lobby;
}
return ClientState_Same;
}
bool LoginState::Render()
{
Oyster::Graphics::API::SetView(privData->view);
Oyster::Graphics::API::SetProjection( privData->proj);
Oyster::Graphics::API::NewFrame();
// render objects
for (int i = 0; i < privData->modelCount; i++)
{
privData->object[i]->Render();
}
// render effects
// render lights
Oyster::Graphics::API::EndFrame();
return true;
}
bool LoginState::Release()
{
for (int i = 0; i < privData->modelCount; i++)
{
privData->object[i]->Release();
delete privData->object[i];
privData->object[i] = NULL;
}
delete privData;
privData = NULL;
return true;
}
void LoginState::Protocol(ProtocolStruct* protocol)
{
if((PlayerName*)protocol)
PlayerJoinProtocol((PlayerName*)protocol);
}
void LoginState::PlayerJoinProtocol(PlayerName* name)
{
}

100
.merge_file_a09540 Normal file
View File

@ -0,0 +1,100 @@
#include "PhysicsAPI.h"
#include "Object.h"
#include "DynamicObject.h"
#include "Player.h"
#include "Level.h"
#include "AttatchmentMassDriver.h"
#include "Game.h"
using namespace Oyster;
using namespace GameLogic;
void PlayerVBox(Player &player, DynamicObject &box, Oyster::Math::Float kineticEnergyLoss);
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss);
//Physics::ICustomBody::SubscriptMessage
void Player::PlayerCollision(Oyster::Physics::ICustomBody *rigidBodyPlayer, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{
Player *player = ((Game::PlayerData*)(rigidBodyPlayer->GetCustomTag()))->player;
Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed?
return;
switch (realObj->GetObjectType())
{
case OBJECT_TYPE::OBJECT_TYPE_GENERIC:
PlayerVObject(*player,*realObj, kineticEnergyLoss);
//return Physics::ICustomBody::SubscriptMessage_none;
break;
case OBJECT_TYPE::OBJECT_TYPE_BOX:
PlayerVBox(*player,(*(DynamicObject*) realObj), kineticEnergyLoss);
//return Physics::ICustomBody::SubscriptMessage_none;
break;
case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
//return Physics::ICustomBody::SubscriptMessage_none;
break;
case OBJECT_TYPE::OBJECT_TYPE_WORLD:
int test = 5;
break;
}
//return Physics::ICustomBody::SubscriptMessage_none;
}
void PlayerVBox(Player &player, DynamicObject &box, Oyster::Math::Float kineticEnergyLoss)
{
//use kinetic energyloss of the collision in order too determin how much damage to take
//use as part of the damage algorithm
player.DamageLife(20);
}
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss)
{
//Collision between a player and a general static or dynamic object
//use kinetic energyloss of the collision in order too determin how much damage to take
//use as part of the damage algorithm
int damageDone = 0;
int forceThreashHold = 200;
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
{
damageDone = kineticEnergyLoss * 0.10f;
player.DamageLife(damageDone);
}
}
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj)
{
return Physics::ICustomBody::SubscriptMessage_none;
}
//Oyster::Physics::ICustomBody::SubscriptMessage
Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj)
{
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
}
Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
}
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;
Object *realObj = (Object*)obj->GetCustomTag();
if(realObj->GetObjectType() == OBJECT_TYPE_BOX)
{
state = obj->GetState();
state.SetOrientation(Oyster::Math::Float3(1,0.5,1),Oyster::Math::Float3(1,0.5,1));
obj->SetState(state);
}
if(realObj->GetObjectType() == OBJECT_TYPE_PLAYER || realObj->GetObjectType() == OBJECT_TYPE_WORLD)
return;
state = obj->GetState();
state.ApplyLinearImpulse(pushForce);
obj->SetState(state);
//((Object*)obj->GetCustomTag())->ApplyLinearImpulse(pushForce);
}

70
.merge_file_a11072 Normal file
View File

@ -0,0 +1,70 @@
#include "Game.h"
#include "Player.h"
using namespace GameLogic;
Game::PlayerData::PlayerData()
{
//set some stats that are appropriate to a player
Oyster::Physics::API::SimpleBodyDescription sbDesc;
sbDesc.centerPosition = Oyster::Math::Float3(10,350,0);
sbDesc.size = Oyster::Math::Float3(4,7,4);
<<<<<<< .merge_file_a11072
sbDesc.mass = 90;
=======
sbDesc.mass = 70;
>>>>>>> .merge_file_a05028
//create rigid body
Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release();
//create player with this rigid body
this->player = new Player(rigidBody,Object::DefaultCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER);
this->player->GetRigidBody()->SetCustomTag(this);
}
Game::PlayerData::PlayerData(int playerID,int teamID)
{
this->player = new Player();
}
Game::PlayerData::~PlayerData()
{
delete this->player;
}
void Game::PlayerData::Move(const PLAYER_MOVEMENT &movement)
{
this->player->Move(movement);
}
void Game::PlayerData::UseWeapon(const WEAPON_FIRE &usage)
{
this->player->UseWeapon(usage);
}
Oyster::Math::Float3 Game::PlayerData::GetPosition()
{
return this->player->GetPosition();
}
Oyster::Math::Float4x4 Game::PlayerData::GetOrientation()
{
return this->player->GetOrientation();
}
PLAYER_STATE Game::PlayerData::GetState() const
{
return this->player->GetState();
}
int Game::PlayerData::GetID() const
{
return this->player->GetID();
}
int Game::PlayerData::GetTeamID() const
{
return this->player->GetTeamID();
}
OBJECT_TYPE Game::PlayerData::GetObjectType() const
{
return this->player->GetObjectType();
}
void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir)
{
this->player->Rotate(lookDir);
}

70
.merge_file_a11132 Normal file
View File

@ -0,0 +1,70 @@
#include "AttatchmentMassDriver.h"
#include "PhysicsAPI.h"
using namespace GameLogic;
AttatchmentMassDriver::AttatchmentMassDriver(void)
{
this->owner = 0;
}
AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
{
this->owner = &owner;
}
AttatchmentMassDriver::~AttatchmentMassDriver(void)
{
}
/********************************************************
* Uses the attatchment and will from here switch case the different WEAPON_FIRE's that are to be used
********************************************************/
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, float dt)
{
//switch case to determin what functionallity to use in the attatchment
switch (usage)
{
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
ForcePush(usage,dt);
break;
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
ForcePull(usage,dt);
break;
}
}
/********************************************************
* Pushes objects in a cone in front of the weapon when fired
********************************************************/
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt)
{
//Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
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));
int arg = 0;
Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&arg,ForcePushAction);
}
/********************************************************
* Pulls the player in the direction he is looking, used for fast movement(kinda like a jetpack)
********************************************************/
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
{
Oyster::Physics::Struct::CustomBodyState state = this->owner->GetRigidBody()->GetState();
//do something with state
state.ApplyLinearImpulse(Oyster::Math::Float3(this->owner->GetLookDir()) * (500 * dt));
this->owner->GetRigidBody()->SetState(state);
}

103
.merge_file_a11320 Normal file
View File

@ -0,0 +1,103 @@
#include "PhysicsAPI.h"
#include "Object.h"
#include "DynamicObject.h"
#include "Player.h"
#include "Level.h"
#include "AttatchmentMassDriver.h"
#include "Game.h"
using namespace Oyster;
using namespace GameLogic;
void PlayerVBox(Player &player, DynamicObject &box, Oyster::Math::Float kineticEnergyLoss);
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss);
//Physics::ICustomBody::SubscriptMessage
void Player::PlayerCollision(Oyster::Physics::ICustomBody *rigidBodyPlayer, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{
Player *player = ((Game::PlayerData*)(rigidBodyPlayer->GetCustomTag()))->player;
Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed?
switch (realObj->GetObjectType())
{
case OBJECT_TYPE::OBJECT_TYPE_GENERIC:
PlayerVObject(*player,*realObj, kineticEnergyLoss);
//return Physics::ICustomBody::SubscriptMessage_none;
break;
case OBJECT_TYPE::OBJECT_TYPE_BOX:
PlayerVBox(*player,(*(DynamicObject*) realObj), kineticEnergyLoss);
//return Physics::ICustomBody::SubscriptMessage_none;
break;
case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
//return Physics::ICustomBody::SubscriptMessage_none;
break;
case OBJECT_TYPE::OBJECT_TYPE_WORLD:
int test = 5;
break;
}
//return Physics::ICustomBody::SubscriptMessage_none;
}
void PlayerVBox(Player &player, DynamicObject &box, Oyster::Math::Float kineticEnergyLoss)
{
//use kinetic energyloss of the collision in order too determin how much damage to take
//use as part of the damage algorithm
player.DamageLife(20);
}
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss)
{
//Collision between a player and a general static or dynamic object
//use kinetic energyloss of the collision in order too determin how much damage to take
//use as part of the damage algorithm
int damageDone = 0;
int forceThreashHold = 200;
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
{
damageDone = kineticEnergyLoss * 0.10f;
player.DamageLife(damageDone);
}
}
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj)
{
return Physics::ICustomBody::SubscriptMessage_none;
}
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{
return Physics::ICustomBody::SubscriptMessage_none;
}
//Oyster::Physics::ICustomBody::SubscriptMessage
Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj)
{
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
}
Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
}
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;
Object *realObj = (Object*)obj->GetCustomTag();
if(realObj->GetObjectType() == OBJECT_TYPE_BOX)
{
state = obj->GetState();
state.SetOrientation(Oyster::Math::Float3(1,0.5,1),Oyster::Math::Float3(1,0.5,1));
obj->SetState(state);
}
if(realObj->GetObjectType() == OBJECT_TYPE_PLAYER || realObj->GetObjectType() == OBJECT_TYPE_WORLD)
return;
state = obj->GetState();
state.ApplyLinearImpulse(pushForce);
obj->SetState(state);
//((Object*)obj->GetCustomTag())->ApplyLinearImpulse(pushForce);
}

74
.merge_file_a11560 Normal file
View File

@ -0,0 +1,74 @@
#include "AttatchmentMassDriver.h"
#include "PhysicsAPI.h"
using namespace GameLogic;
AttatchmentMassDriver::AttatchmentMassDriver(void)
{
this->owner = 0;
}
AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
{
this->owner = &owner;
}
AttatchmentMassDriver::~AttatchmentMassDriver(void)
{
}
/********************************************************
* Uses the attatchment and will from here switch case the different WEAPON_FIRE's that are to be used
********************************************************/
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, float dt)
{
//switch case to determin what functionallity to use in the attatchment
switch (usage)
{
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
ForcePush(usage,dt);
break;
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
ForcePull(usage,dt);
break;
}
}
/********************************************************
* Pushes objects in a cone in front of the weapon when fired
********************************************************/
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::Float3 up = -owner->GetRigidBody()->GetGravityNormal();
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::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace));
int arg = 0;
Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&arg,ForcePushAction);
}
/********************************************************
* Pulls the player in the direction he is looking, used for fast movement(kinda like a jetpack)
********************************************************/
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
{
Oyster::Physics::Struct::CustomBodyState state = this->owner->GetRigidBody()->GetState();
//do something with state
state.ApplyLinearImpulse(Oyster::Math::Float3(this->owner->GetLookDir()) * (500 * dt));
this->owner->GetRigidBody()->SetState(state);
}

View File

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

View File

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

View File

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

View File

@ -5,6 +5,10 @@
#include "C_obj/C_DynamicObj.h"
#include "DllInterfaces/GFXAPI.h"
#include "LobbyState.h"
#include "GameState.h"
#include "../GameClientRecieverFunc.h"
#include <GameServerAPI.h>
using namespace DanBias::Client;
@ -16,6 +20,10 @@ struct LanMenuState::myData
Oyster::Math3D::Float4x4 proj;
C_Object* object[2];
int modelCount;
GameRecieverObject* recieverObj;
bool serverOwner;
// UI object
// game client*
}privData;
@ -83,6 +91,49 @@ bool LanMenuState::InitCamera(Oyster::Math::Float3 startPos)
}
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
if( KeyInput->IsKeyPressed(DIK_C))

View File

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

View File

@ -42,6 +42,7 @@ namespace GameLogic
void setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss));
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj);
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
private:
OBJECT_TYPE type;
int objectID;

View File

@ -26,7 +26,7 @@ namespace
ICustomBody::State protoState; proto->GetState( protoState );
ICustomBody::State deuterState; deuter->GetState( deuterState );
Float4 protoG = protoState.GetLinearMomentum( worldPointOfContact.xyz ),
Float4 protoG = protoState.GetLinearMomentum(worldPointOfContact.xyz ),
deuterG = deuterState.GetLinearMomentum( worldPointOfContact.xyz );
// calc from perspective of deuter

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

View File

@ -146,6 +146,9 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="EventHandler\EventButton.cpp" />
<ClCompile Include="EventHandler\EventButtonCollection.cpp" />
<ClCompile Include="EventHandler\EventHandler.cpp" />
<ClCompile Include="Packing\Packing.cpp" />
<ClCompile Include="Resource\Loaders\ByteLoader.cpp" />
<ClCompile Include="Resource\Loaders\CustomLoader.cpp" />
@ -162,8 +165,11 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="DynamicArray.h" />
<ClInclude Include="EventHandler\EventButton.h" />
<ClInclude Include="EventHandler\EventButtonCollection.h" />
<ClInclude Include="GID.h" />
<ClInclude Include="IQueue.h" />
<ClInclude Include="EventHandler\EventHandler.h" />
<ClInclude Include="OysterCallback.h" />
<ClInclude Include="Packing\Packing.h" />
<ClInclude Include="PostBox\IPostBox.h" />

View File

@ -51,6 +51,15 @@
<ClCompile Include="Packing\Packing.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="EventHandler\EventHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="EventHandler\EventButton.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="EventHandler\EventButtonCollection.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Utilities.h">
@ -116,5 +125,14 @@
<ClInclude Include="Packing\Packing.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="EventHandler\EventHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="EventHandler\EventButton.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="EventHandler\EventButtonCollection.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>