diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp
index 0edbce01..0554a480 100644
--- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp
+++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp
@@ -23,7 +23,8 @@ namespace DanBias
{
Oyster::Network::NetworkClient* nwClient;
Client::GameClientState* gameClientState;
-
+
+
void NetworkCallback(Oyster::Network::CustomNetProtocol& p) override
{
int pType = p[0].value.netInt;
diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp
index f47fc9fe..3df74e40 100644
--- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp
+++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp
@@ -26,6 +26,7 @@ void C_DynamicObj::Init(ModelInitData modelInit)
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
+ privData->ID = modelInit.id;
}
void C_DynamicObj::setPos(Oyster::Math::Float4x4 world)
{
diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp
index 86acaf4b..4cd6fbd3 100644
--- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp
+++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp
@@ -28,7 +28,7 @@ void C_Player::Init(ModelInitData modelInit)
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
-
+ privData->ID = modelInit.id;
}
void C_Player::setPos(Oyster::Math::Float4x4 world)
diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp
index c5f2e119..177b032b 100644
--- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp
+++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp
@@ -28,6 +28,7 @@ void C_StaticObj::Init(ModelInitData modelInit)
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
+ privData->ID = modelInit.id;
}
void C_StaticObj::setPos(Oyster::Math::Float4x4 world)
diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp
index 226d8ca7..fa5dff04 100644
--- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp
+++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp
@@ -24,6 +24,7 @@ void C_UIobject::Init(ModelInitData modelInit)
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->WorldMatrix = modelInit.world;
privData->model->Visible = modelInit.visible;
+ privData->ID = modelInit.id;
}
void C_UIobject::setPos(Oyster::Math::Float4x4 world)
diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp
index bf156d3e..cc4bbe53 100644
--- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp
+++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp
@@ -40,6 +40,12 @@ bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
}
GameState::gameStateState GameState::LoadGame()
{
+ Oyster::Graphics::Definitions::Pointlight plight;
+ plight.Pos = Oyster::Math::Float3(0,3,0);
+ plight.Color = Oyster::Math::Float3(0,1,0);
+ plight.Radius = 5;
+ plight.Bright = 2;
+ Oyster::Graphics::API::AddLight(plight);
LoadModels(L"map");
InitCamera(Oyster::Math::Float3(0,0,5.4f));
return gameStateState_playing;
@@ -56,18 +62,22 @@ bool GameState::LoadModels(std::wstring mapFile)
modelData.world = Oyster::Math3D::Float4x4::identity;
modelData.visible = true;
modelData.modelPath = L"..\\Content\\worldDummy";
+ modelData.id = 0;
// load models
C_Object* obj = new C_Player();
privData->object.push_back(obj);
privData->object[privData->object.size() -1 ]->Init(modelData);
- Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2));
+ Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,2,2));
modelData.world = modelData.world * translate;
modelData.modelPath = L"..\\Content\\worldDummy";
+ modelData.id ++;
obj = new C_DynamicObj();
privData->object.push_back(obj);
privData->object[privData->object.size() -1 ]->Init(modelData);
+
+
return true;
}
bool GameState::InitCamera(Oyster::Math::Float3 startPos)
@@ -209,6 +219,7 @@ void GameState::Protocol( ObjPos* pos )
{
world[i] = pos->worldPos[i];
}
+
for (int i = 0; i < privData->object.size(); i++)
{
if(privData->object[i]->GetId() == pos->object_ID)
diff --git a/Code/Game/DanBiasServer/GameSession/GameSession.cpp b/Code/Game/DanBiasServer/GameSession/GameSession.cpp
index 706a575c..745e1369 100644
--- a/Code/Game/DanBiasServer/GameSession/GameSession.cpp
+++ b/Code/Game/DanBiasServer/GameSession/GameSession.cpp
@@ -157,17 +157,25 @@ namespace DanBias
{
case protocol_Gameplay_PlayerNavigation:
{
+
+ Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
if(p[1].value.netBool) //bool bForward;
- c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
+ world.v[3].x = 2;
+ //c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
if(p[2].value.netBool) //bool bBackward;
- c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
+ world.v[3].x = -2;
+ //c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
if(p[5].value.netBool) //bool bStrafeRight;
- c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
+ world.v[3].y = 2;
+ //c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
if(p[6].value.netBool) //bool bStrafeLeft;
- c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
-
- //Protocol_ObjectPosition op(c->GetPlayer()->GetOrientation(), c->GetPlayer()->GetID());
- //Send(op.GetProtocol());
+ world.v[3].y = -2;
+ //c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
+
+ Protocol_ObjectPosition res(world, 0);
+ Send(res.GetProtocol());
+
+
}
break;
case protocol_Gameplay_PlayerMouseMovement:
diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp
new file mode 100644
index 00000000..806ac6d2
--- /dev/null
+++ b/Code/Game/GameLogic/Game.cpp
@@ -0,0 +1,71 @@
+#include "Game.h"
+#include "Player.h"
+#include "Level.h"
+
+using namespace GameLogic;
+
+struct Game::PrivateData
+{
+ PrivateData()
+ {
+
+ }
+
+ ~PrivateData()
+ {
+
+ }
+
+ Player **players;
+ Level *level;
+
+}myData;
+
+
+Game::Game(void)
+{
+ myData = new PrivateData();
+}
+
+Game::~Game(void)
+{
+ if(myData)
+ {
+ delete myData;
+ }
+}
+
+void Game::MovePlayer(int playerID, const PLAYER_MOVEMENT &movement)
+{
+
+}
+
+void Game::PlayerUseWeapon(int playerID, const WEAPON_FIRE &Usage)
+{
+
+}
+
+void Game::GetPlayerPos(int playerID)
+{
+
+}
+
+void Game::GetAllPlayerPos()
+{
+
+}
+
+Game::PlayerData Game::CreatePlayer()
+{
+
+}
+
+void Game::CreateTeam()
+{
+
+}
+
+void Game::NewFrame()
+{
+
+}
\ No newline at end of file
diff --git a/Code/Game/GameLogic/Game.h b/Code/Game/GameLogic/Game.h
new file mode 100644
index 00000000..a70dc842
--- /dev/null
+++ b/Code/Game/GameLogic/Game.h
@@ -0,0 +1,88 @@
+#ifndef GAME_H
+#define GAME_H
+
+#include "GameLogicStates.h"
+namespace GameLogic
+{
+ class Game
+ {
+
+ public:
+ struct PlayerData
+ {
+ int playerID;
+ int teamID;
+
+ PlayerData()
+ {
+ playerID = 0;
+ teamID = 0;
+ }
+
+ PlayerData(int playerID,int teamID)
+ {
+ this->playerID = playerID;
+ this->teamID = teamID;
+
+ }
+
+ ~PlayerData()
+ {
+
+ }
+ };
+
+ public:
+ Game(void);
+ ~Game(void);
+
+ /********************************************************
+ * Moves the chosen player based on input
+ * @param playerID: ID of the player you want to recieve the message
+ * @param movement: enum value on what kind of action is to be taken
+ ********************************************************/
+ void MovePlayer(int playerID, const PLAYER_MOVEMENT &movement);
+
+ /********************************************************
+ * Uses the chosen players weapon based on input
+ * @param playerID: ID of the player you want to recieve the message
+ * @param Usage: enum value on what kind of action is to be taken
+ ********************************************************/
+ void PlayerUseWeapon(int playerID, const WEAPON_FIRE &Usage);
+
+ /********************************************************
+ * Gets a specific players position
+ * @param playerID: ID of the player whos position you want
+ ********************************************************/
+ void GetPlayerPos(int playerID);
+
+ /********************************************************
+ * Gets the position of all players currently in the game
+ ********************************************************/
+ void GetAllPlayerPos();
+
+ /********************************************************
+ * Creates a player and returns PlayerData containing ID of the player
+ ********************************************************/
+ PlayerData CreatePlayer();
+
+ /********************************************************
+ * Creates a team
+ ********************************************************/
+ void CreateTeam();
+
+ /********************************************************
+ * Runs a update of the gamelogic and physics
+ ********************************************************/
+ void NewFrame();
+
+
+ private:
+ struct PrivateData;
+ PrivateData *myData;
+
+ };
+}
+
+
+#endif
diff --git a/Code/Game/GameLogic/GameLogic.vcxproj b/Code/Game/GameLogic/GameLogic.vcxproj
index 500f8bbc..c67ef3d9 100644
--- a/Code/Game/GameLogic/GameLogic.vcxproj
+++ b/Code/Game/GameLogic/GameLogic.vcxproj
@@ -173,6 +173,7 @@
+
@@ -190,6 +191,7 @@
+
diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp
index f0d1b935..9f4416aa 100644
--- a/Code/Game/GameLogic/Level.cpp
+++ b/Code/Game/GameLogic/Level.cpp
@@ -10,7 +10,7 @@ using namespace GameLogic;
struct Level::PrivateData
{
- PrivateData()
+ PrivateData()
{
}
diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp
index 9e516907..49ff7780 100644
--- a/Code/Game/GameLogic/Object.cpp
+++ b/Code/Game/GameLogic/Object.cpp
@@ -23,6 +23,8 @@ Object::Object()
this->objectID = GID();
this->type = OBJECT_TYPE::OBJECT_TYPE_UNKNOWN;
+
+ rigidBody->GetState(state);
}
Object::Object(void* collisionFunc, OBJECT_TYPE type)
@@ -40,13 +42,14 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type)
this->objectID = GID();
this->type = type;
+
+ rigidBody->GetState(state);
}
Object::~Object(void)
{
-
}
OBJECT_TYPE Object::GetType()
diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h
index a73dc154..6d6437f1 100644
--- a/Code/Game/GameLogic/Object.h
+++ b/Code/Game/GameLogic/Object.h
@@ -9,14 +9,8 @@
#include "GameLogicStates.h"
#include "GameLogicDef.h"
+#include
-namespace Oyster
-{
- namespace Physics
- {
- class ICustomBody;
- }
-}
namespace GameLogic
{
class DANBIAS_GAMELOGIC_DLL Object
@@ -36,6 +30,8 @@ namespace GameLogic
int objectID;
protected:
Oyster::Physics::ICustomBody *rigidBody;
+ Oyster::Physics::ICustomBody::State state;
+
};
}
diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp
index ecf60dd3..a3702a53 100644
--- a/Code/Game/GameLogic/Player.cpp
+++ b/Code/Game/GameLogic/Player.cpp
@@ -16,7 +16,7 @@ struct Player::PrivateData
teamID = -1;
playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
- lookDir = Oyster::Math::Float3(1,0,0);
+ lookDir = Oyster::Math::Float4(1,0,0,0);
}
~PrivateData()
@@ -31,7 +31,7 @@ struct Player::PrivateData
int teamID;
Weapon *weapon;
PLAYER_STATE playerState;
- Oyster::Math::Float3 lookDir;
+ Oyster::Math::Float4 lookDir;
}myData;
@@ -49,8 +49,6 @@ Player::~Player(void)
void Player::Move(const PLAYER_MOVEMENT &movement)
{
- //Oyster::Math::Float3 currentVelocity = rigidBody->GetRigidLinearVelocity();
-
switch(movement)
{
case PLAYER_MOVEMENT::PLAYER_MOVEMENT_FORWARD:
@@ -77,41 +75,41 @@ void Player::Move(const PLAYER_MOVEMENT &movement)
void Player::MoveForward()
{
- //API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),myData->lookDir * 100);
+ state.ApplyLinearImpulse(myData->lookDir * 100);
}
void Player::MoveBackwards()
{
- //API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-myData->lookDir * 100);
+ state.ApplyLinearImpulse(-myData->lookDir * 100);
}
void Player::MoveRight()
{
//Do cross product with forward vector and negative gravity vector
- //Oyster::Math::Float3 r = (-rigidBody->GetGravityNormal()).Cross(myData->lookDir);
- //API::Instance().ApplyForceAt(rigidBody, rigidBody->GetCenter(), r * 100);
+ Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)myData->lookDir);
+ state.ApplyLinearImpulse(r * 100);
}
void Player::MoveLeft()
{
//Do cross product with forward vector and negative gravity vector
- //Oyster::Math::Float3 r = -(-rigidBody->GetGravityNormal()).Cross(myData->lookDir);
- //API::Instance().ApplyForceAt(rigidBody, rigidBody->GetCenter(), r * 100);
+ Oyster::Math::Float4 r = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)myData->lookDir);
+ state.ApplyLinearImpulse(-r * 100);
}
-void Player::UseWeapon(const WEAPON_FIRE &fireInput)
+void Player::UseWeapon(const WEAPON_FIRE &Usage)
{
- myData->weapon->Use(fireInput);
+ myData->weapon->Use(Usage);
}
void Player::Respawn(Oyster::Math::Float3 spawnPoint)
{
- //API::Instance().SetCenter(rigidBody,spawnPoint);
+
myData->life = 100;
myData->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
- myData->lookDir = Oyster::Math::Float3(1,0,0);
+ myData->lookDir = Oyster::Math::Float4(1,0,0);
}
void Player::Jump()
{
- //API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-Oyster::Math::Float3(0,1,0) * 100);
+
}
bool Player::IsWalking()
@@ -129,8 +127,7 @@ bool Player::IsIdle()
Oyster::Math::Float3 Player::GetPos()
{
- //return rigidBody->GetCenter();
- return Oyster::Math::Float3(0,0,0);
+ return (Oyster::Math::Float3)state.GetCenterPosition();
}
Oyster::Math::Float3 Player::GetLookDir()
diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h
index 2cc703ac..e9ad03da 100644
--- a/Code/Game/GameLogic/Player.h
+++ b/Code/Game/GameLogic/Player.h
@@ -33,7 +33,7 @@ namespace GameLogic
* Uses the weapon based on input
* @param fireInput: enum value on what kind of action is to be taken
********************************************************/
- void UseWeapon(const WEAPON_FIRE &fireInput);
+ void UseWeapon(const WEAPON_FIRE &Usage);
/********************************************************
* Respawns the player, this resets several stats and settings on the player
diff --git a/Code/Game/GameLogic/Weapon.h b/Code/Game/GameLogic/Weapon.h
index cdd1a3b7..719a853c 100644
--- a/Code/Game/GameLogic/Weapon.h
+++ b/Code/Game/GameLogic/Weapon.h
@@ -34,8 +34,6 @@ namespace GameLogic
bool IsValidSocket(int socketID);
int GetCurrentSocketID();
-
-
private:
struct PrivateData;