From b753387649ba6eec14ca1d6514ce5ab0cd94274d Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Fri, 31 Jan 2014 14:14:20 +0100 Subject: [PATCH] asd --- .merge_file_a01532 | 171 ++++++++++++++++++ .merge_file_a04876 | 93 ++++++++++ .merge_file_a05028 | 66 +++++++ .merge_file_a06880 | 171 ++++++++++++++++++ .merge_file_a07272 | 98 ++++++++++ .merge_file_a07484 | 81 +++++++++ .merge_file_a07992 | 93 ++++++++++ .merge_file_a08280 | 66 +++++++ .merge_file_a08532 | 96 ++++++++++ .merge_file_a08608 | 166 +++++++++++++++++ .merge_file_a09540 | 100 ++++++++++ .merge_file_a11072 | 70 +++++++ .merge_file_a11132 | 70 +++++++ .merge_file_a11320 | 103 +++++++++++ .merge_file_a11560 | 74 ++++++++ Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 15 +- .../Game/DanBiasGame/GameClientRecieverFunc.h | 6 +- .../GameClientState/GameClientState.h | 1 + .../GameClientState/LanMenuState.cpp | 51 ++++++ .../GameClientState/LanMenuState.h | 2 + Code/Game/GameLogic/Object.h | 1 + .../Implementation/PhysicsAPI_Impl.cpp | 2 +- Code/Misc/EventHandler/EventButton.cpp | 0 Code/Misc/EventHandler/EventButton.h | 0 .../EventHandler/EventButtonCollection.cpp | 25 +++ .../Misc/EventHandler/EventButtonCollection.h | 31 ++++ Code/Misc/EventHandler/EventHandler.cpp | 37 ++++ Code/Misc/EventHandler/EventHandler.h | 35 ++++ Code/Misc/Misc.vcxproj | 6 + Code/Misc/Misc.vcxproj.filters | 18 ++ 30 files changed, 1737 insertions(+), 11 deletions(-) create mode 100644 .merge_file_a01532 create mode 100644 .merge_file_a04876 create mode 100644 .merge_file_a05028 create mode 100644 .merge_file_a06880 create mode 100644 .merge_file_a07272 create mode 100644 .merge_file_a07484 create mode 100644 .merge_file_a07992 create mode 100644 .merge_file_a08280 create mode 100644 .merge_file_a08532 create mode 100644 .merge_file_a08608 create mode 100644 .merge_file_a09540 create mode 100644 .merge_file_a11072 create mode 100644 .merge_file_a11132 create mode 100644 .merge_file_a11320 create mode 100644 .merge_file_a11560 create mode 100644 Code/Misc/EventHandler/EventButton.cpp create mode 100644 Code/Misc/EventHandler/EventButton.h create mode 100644 Code/Misc/EventHandler/EventButtonCollection.cpp create mode 100644 Code/Misc/EventHandler/EventButtonCollection.h create mode 100644 Code/Misc/EventHandler/EventHandler.cpp create mode 100644 Code/Misc/EventHandler/EventHandler.h diff --git a/.merge_file_a01532 b/.merge_file_a01532 new file mode 100644 index 00000000..0a50fbd0 --- /dev/null +++ b/.merge_file_a01532 @@ -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 + +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) +{ + +} \ No newline at end of file diff --git a/.merge_file_a04876 b/.merge_file_a04876 new file mode 100644 index 00000000..c0b0685b --- /dev/null +++ b/.merge_file_a04876 @@ -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(); +} diff --git a/.merge_file_a05028 b/.merge_file_a05028 new file mode 100644 index 00000000..93fcfba6 --- /dev/null +++ b/.merge_file_a05028 @@ -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); +} \ No newline at end of file diff --git a/.merge_file_a06880 b/.merge_file_a06880 new file mode 100644 index 00000000..a5188306 --- /dev/null +++ b/.merge_file_a06880 @@ -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 + +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) +{ + +} \ No newline at end of file diff --git a/.merge_file_a07272 b/.merge_file_a07272 new file mode 100644 index 00000000..93c41976 --- /dev/null +++ b/.merge_file_a07272 @@ -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(); +} diff --git a/.merge_file_a07484 b/.merge_file_a07484 new file mode 100644 index 00000000..f0a2a4d6 --- /dev/null +++ b/.merge_file_a07484 @@ -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); +} + + diff --git a/.merge_file_a07992 b/.merge_file_a07992 new file mode 100644 index 00000000..e09f9bb0 --- /dev/null +++ b/.merge_file_a07992 @@ -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(); +} diff --git a/.merge_file_a08280 b/.merge_file_a08280 new file mode 100644 index 00000000..18f57212 --- /dev/null +++ b/.merge_file_a08280 @@ -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); +} \ No newline at end of file diff --git a/.merge_file_a08532 b/.merge_file_a08532 new file mode 100644 index 00000000..019df6f4 --- /dev/null +++ b/.merge_file_a08532 @@ -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); + } \ No newline at end of file diff --git a/.merge_file_a08608 b/.merge_file_a08608 new file mode 100644 index 00000000..cd1e4663 --- /dev/null +++ b/.merge_file_a08608 @@ -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 + +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) +{ + +} \ No newline at end of file diff --git a/.merge_file_a09540 b/.merge_file_a09540 new file mode 100644 index 00000000..27aa6db6 --- /dev/null +++ b/.merge_file_a09540 @@ -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); + } \ No newline at end of file diff --git a/.merge_file_a11072 b/.merge_file_a11072 new file mode 100644 index 00000000..4f47006e --- /dev/null +++ b/.merge_file_a11072 @@ -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); +} \ No newline at end of file diff --git a/.merge_file_a11132 b/.merge_file_a11132 new file mode 100644 index 00000000..7554c879 --- /dev/null +++ b/.merge_file_a11132 @@ -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); +} + + diff --git a/.merge_file_a11320 b/.merge_file_a11320 new file mode 100644 index 00000000..196aed09 --- /dev/null +++ b/.merge_file_a11320 @@ -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); + } \ No newline at end of file diff --git a/.merge_file_a11560 b/.merge_file_a11560 new file mode 100644 index 00000000..94efbb71 --- /dev/null +++ b/.merge_file_a11560 @@ -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); +} + + diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 06f200bf..4a54297f 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -38,7 +38,7 @@ namespace DanBias public: WindowShell* window; InputClass* inputObj; - Utility::WinTimer* timer; + Utility::WinTimer timer; GameRecieverObject* recieverObj; bool serverOwner; @@ -69,12 +69,11 @@ namespace DanBias m_data->serverOwner = false; // 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)) 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->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; diff --git a/Code/Game/DanBiasGame/GameClientRecieverFunc.h b/Code/Game/DanBiasGame/GameClientRecieverFunc.h index 36b831a0..de8f63a6 100644 --- a/Code/Game/DanBiasGame/GameClientRecieverFunc.h +++ b/Code/Game/DanBiasGame/GameClientRecieverFunc.h @@ -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); diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.h b/Code/Game/DanBiasGame/GameClientState/GameClientState.h index a369233a..378eeefc 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameClientState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.h @@ -53,6 +53,7 @@ public: { ClientState_Login, ClientState_Lobby, + ClientState_Lan, ClientState_LobbyCreated, ClientState_Game, ClientState_Same, diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp index fdb02fa9..8df39bfa 100644 --- a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp @@ -5,6 +5,10 @@ #include "C_obj/C_DynamicObj.h" #include "DllInterfaces/GFXAPI.h" +#include "LobbyState.h" +#include "GameState.h" +#include "../GameClientRecieverFunc.h" + #include 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)) diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.h b/Code/Game/DanBiasGame/GameClientState/LanMenuState.h index 5182c80c..6b11fd20 100644 --- a/Code/Game/DanBiasGame/GameClientState/LanMenuState.h +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.h @@ -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); diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index 44b0ca48..d3a3690f 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -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; diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index 6f164810..5fa3a982 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -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 diff --git a/Code/Misc/EventHandler/EventButton.cpp b/Code/Misc/EventHandler/EventButton.cpp new file mode 100644 index 00000000..e69de29b diff --git a/Code/Misc/EventHandler/EventButton.h b/Code/Misc/EventHandler/EventButton.h new file mode 100644 index 00000000..e69de29b diff --git a/Code/Misc/EventHandler/EventButtonCollection.cpp b/Code/Misc/EventHandler/EventButtonCollection.cpp new file mode 100644 index 00000000..b3d37bfe --- /dev/null +++ b/Code/Misc/EventHandler/EventButtonCollection.cpp @@ -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) +{ + +} \ No newline at end of file diff --git a/Code/Misc/EventHandler/EventButtonCollection.h b/Code/Misc/EventHandler/EventButtonCollection.h new file mode 100644 index 00000000..31201f9c --- /dev/null +++ b/Code/Misc/EventHandler/EventButtonCollection.h @@ -0,0 +1,31 @@ +#ifndef EVENT_BUTTON_COLLECTION_H +#define EVENT_BUTTON_COLLECTION_H + +#include "../../Input/L_inputClass.h" + +#include "EventButton.h" + +#include + +namespace Oyster +{ + namespace Event + { + class EventButtonCollection + { + public: + EventButtonCollection(); + ~EventButtonCollection(); + + void Update(InputClass* inputObject); + + EventButton* AddButton(EventButton* button); + + private: + std::vector buttons; + + }; + } +} + +#endif \ No newline at end of file diff --git a/Code/Misc/EventHandler/EventHandler.cpp b/Code/Misc/EventHandler/EventHandler.cpp new file mode 100644 index 00000000..8f6705df --- /dev/null +++ b/Code/Misc/EventHandler/EventHandler.cpp @@ -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*/); +{ + +} \ No newline at end of file diff --git a/Code/Misc/EventHandler/EventHandler.h b/Code/Misc/EventHandler/EventHandler.h new file mode 100644 index 00000000..c3ecc0a2 --- /dev/null +++ b/Code/Misc/EventHandler/EventHandler.h @@ -0,0 +1,35 @@ +#ifndef EVENT_HANDLER_H +#define EVENT_HANDLER_H + +#include "../../Input/L_inputClass.h" + +#include "EventButtonCollection.h" +#include "EventButton.h" + +#include + +namespace Oyster +{ + namespace Event + { + class EventHandler + { + EventHandler(); + ~EventHandler(); + + EventHandler& Instance(); + + void Update(InputClass* inputObject); + + EventButtonCollection* CreateCollection(); + EventButtonCollection* GetCollection(/*ID*/); + + + private: + std::vector collections; + + }; + } +} + +#endif \ No newline at end of file diff --git a/Code/Misc/Misc.vcxproj b/Code/Misc/Misc.vcxproj index 6c3db1ec..52b7c96c 100644 --- a/Code/Misc/Misc.vcxproj +++ b/Code/Misc/Misc.vcxproj @@ -146,6 +146,9 @@ + + + @@ -162,8 +165,11 @@ + + + diff --git a/Code/Misc/Misc.vcxproj.filters b/Code/Misc/Misc.vcxproj.filters index 8413642a..d4874b4c 100644 --- a/Code/Misc/Misc.vcxproj.filters +++ b/Code/Misc/Misc.vcxproj.filters @@ -51,6 +51,15 @@ Source Files + + Source Files + + + Source Files + + + Source Files + @@ -116,5 +125,14 @@ Header Files + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file