diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index f133a394..73f3ade6 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -267,8 +267,6 @@ void GameState::readKeyInput(InputClass* KeyInput) //send delta mouse movement if (KeyInput->IsMousePressed()) { - - camera->Yaw(KeyInput->GetYaw()); camera->Pitch(KeyInput->GetPitch()); camera->UpdateViewMatrix(); diff --git a/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp b/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp index ddf41582..08bb39c9 100644 --- a/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp +++ b/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp @@ -24,24 +24,39 @@ using namespace GameLogic; namespace DanBias { + //TEST SHIT + GameAPI *game = &GameAPI::Instance(); + DynamicArray players; + + //TEST SHIT + bool GameSession::DoWork( ) { if(this->isRunning) { - if(GetAsyncKeyState(VK_UP)) - { - Protocol_General_Status p(Protocol_General_Status::States_ready); - Send(p.GetProtocol()); - Sleep(100); - } - if(GetAsyncKeyState(VK_DOWN)) - { - Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity; - Protocol_ObjectCreate p(world, 2, "../Content/crate"); - Send(p.GetProtocol()); - Sleep(100); - } - + //TEST SHIT + //player creation and testing + //players.Resize(10); + + //for(int i = 0; i < 10; i++) + //{ + // players[i] = game->CreatePlayer();WWW + // players[i]->Move(GameLogic::PLAYER_MOVEMENT::PLAYER_MOVEMENT_BACKWARD); + // players[i]->Move(GameLogic::PLAYER_MOVEMENT::PLAYER_MOVEMENT_FORWARD); + // players[i]->Move(GameLogic::PLAYER_MOVEMENT::PLAYER_MOVEMENT_JUMP); + // players[i]->Move(GameLogic::PLAYER_MOVEMENT::PLAYER_MOVEMENT_LEFT); + // players[i]->Move(GameLogic::PLAYER_MOVEMENT::PLAYER_MOVEMENT_RIGHT); + + // //using weapon testing + // players[i]->UseWeapon(GameLogic::WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS); + // players[i]->UseWeapon(GameLogic::WEAPON_FIRE::WEAPON_USE_PRIMARY_RELEASE); + // players[i]->UseWeapon(GameLogic::WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS); + // players[i]->UseWeapon(GameLogic::WEAPON_FIRE::WEAPON_USE_SECONDARY_RELEASE); + // players[i]->UseWeapon(GameLogic::WEAPON_FIRE::WEAPON_USE_UTILLITY_PRESS); + //} + + + //TEST SHIT double dt = this->timer.getElapsedSeconds(); gameInstance.SetFrameTimeLength((float)dt); diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index 692e4ef4..d110eb37 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -45,7 +45,7 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, ********************************************************/ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt) { - Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * 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)); diff --git a/Code/Game/GameLogic/AttatchmentSocket.cpp b/Code/Game/GameLogic/AttatchmentSocket.cpp index a3d9097c..4a663bef 100644 --- a/Code/Game/GameLogic/AttatchmentSocket.cpp +++ b/Code/Game/GameLogic/AttatchmentSocket.cpp @@ -5,25 +5,10 @@ using namespace GameLogic; using namespace Utility::DynamicMemory; -struct AttatchmentSocket::PrivateData -{ - PrivateData() - { - - } - - ~PrivateData() - { - - } - - SmartPointer attatchment; - - -}myData; AttatchmentSocket::AttatchmentSocket(void) { + this->attatchment = 0; } @@ -34,17 +19,17 @@ AttatchmentSocket::~AttatchmentSocket(void) IAttatchment* AttatchmentSocket::GetAttatchment() { - return myData->attatchment; + return this->attatchment; } void AttatchmentSocket::SetAttatchment(IAttatchment *attatchment) { - myData->attatchment = attatchment; + this->attatchment = attatchment; } void AttatchmentSocket::RemoveAttatchment() { - myData->attatchment = 0; + this->attatchment = 0; } diff --git a/Code/Game/GameLogic/AttatchmentSocket.h b/Code/Game/GameLogic/AttatchmentSocket.h index 2257dd7a..8c5745c5 100644 --- a/Code/Game/GameLogic/AttatchmentSocket.h +++ b/Code/Game/GameLogic/AttatchmentSocket.h @@ -19,8 +19,7 @@ namespace GameLogic void RemoveAttatchment(); private: - struct PrivateData; - PrivateData *myData; + IAttatchment *attatchment; }; } #endif \ No newline at end of file diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index f01dac1c..41908167 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -4,6 +4,7 @@ #include "Player.h" #include "Level.h" #include "AttatchmentMassDriver.h" +#include "Game.h" using namespace Oyster; @@ -15,8 +16,9 @@ using namespace GameLogic; //Physics::ICustomBody::SubscriptMessage void Player::PlayerCollision(Oyster::Physics::ICustomBody *rigidBodyPlayer, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) { - Player *player = ((Player*)(rigidBodyPlayer->GetCustomTag())); - Object *realObj = (Object*)obj->GetCustomTag(); + + Player *player = ((Game::PlayerData*)(rigidBodyPlayer->GetCustomTag()))->player; + Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed? switch (realObj->GetType()) { @@ -63,13 +65,13 @@ using namespace GameLogic; } //Oyster::Physics::ICustomBody::SubscriptMessage - void Level::LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) + void Level::LevelCollision(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) { - Oyster::Math::Float4 pushForce = Oyster::Math::Float4(owner->GetLookDir()) * (500); + Oyster::Math::Float4 pushForce = Oyster::Math::Float4(1,0,0,0) * (500); ((Object*)obj->GetCustomTag())->ApplyLinearImpulse(pushForce); } diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index 8e4b7707..fd0d9b89 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -6,6 +6,7 @@ using namespace GameLogic; Game::PlayerData::PlayerData() { Oyster::Physics::API::SimpleBodyDescription sbDesc; + //set some stats that are appropriate to a player //create rigidbody Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release(); @@ -60,5 +61,5 @@ OBJECT_TYPE Game::PlayerData::GetObjectType() const } void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir) { - this->player->Rotate(lookDir); + //this->player->Rotate(lookDir); } \ No newline at end of file diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index ab25b059..0e99d160 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -38,6 +38,20 @@ void Level::InitiateLevel(float radius) levelObj = new StaticObject(rigidBody, LevelCollision, OBJECT_TYPE::OBJECT_TYPE_WORLD); + + API::SphericalBodyDescription sbDesc_TestBox; + sbDesc.centerPosition = Oyster::Math::Float4(3,15,0,0); + sbDesc.ignoreGravity = true; + sbDesc.radius = 8; //radius; + sbDesc.mass = 10e12f; + //sbDesc.mass = 0; //10^16 + + + + ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release(); + + DynamicObject *testBox = new DynamicObject(rigidBody_TestBox,LevelCollision,OBJECT_TYPE::OBJECT_TYPE_BOX); + /*API::Gravity gravityWell; gravityWell.gravityType = API::Gravity::GravityType_Well; diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h index ce299b78..6aa54002 100644 --- a/Code/Game/GameLogic/Level.h +++ b/Code/Game/GameLogic/Level.h @@ -57,7 +57,7 @@ namespace GameLogic * @param rigidBodyLevel: physics object of the level * @param obj: physics object for the object that collided with the level ********************************************************/ - static void LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss); + static void LevelCollision(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss); private: TeamManager teamManager; diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 46695ddf..e156f262 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -62,6 +62,12 @@ Object::Object(ICustomBody *rigidBody ,void* collisionFunc, OBJECT_TYPE type) Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) { + Oyster::Physics::API::Instance().AddObject(rigidBody); + rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc)); + + this->rigidBody = rigidBody; + this->type = type; + this->objectID = GID(); } diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index f2f2f02b..c57340f7 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -18,17 +18,30 @@ Player::Player() lookDir = Oyster::Math::Float4(0,0,-1,0); setState.SetCenterPosition(Oyster::Math::Float4(0,15,0,1)); setState.SetReach(Oyster::Math::Float4(2,3.5,2,0)); - //setState.SetRotation(Oyster::Math::Float4(0,0,0,0).Normalize()); } -Player::Player(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) - :DynamicObject(rigidBody, collisionFunc, type) -{ +Player::Player(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) + :DynamicObject(rigidBody, collisionFunc, type) +{ + weapon = new Weapon(2,this); + + this->life = 100; + this->teamID = -1; + this->playerState = PLAYER_STATE_IDLE; + lookDir = Oyster::Math::Float4(0,0,-1,0); + + setState.SetCenterPosition(Oyster::Math::Float4(0,15,0,1)); + setState.SetReach(Oyster::Math::Float4(2,3.5,2,0)); } + Player::~Player(void) { - delete weapon; - weapon = NULL; + if(weapon) + { + delete weapon; + weapon = NULL; + } + } @@ -69,7 +82,6 @@ void Player::MoveBackwards() void Player::MoveRight() { //Do cross product with forward vector and negative gravity vector - // temp up vector Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 ); //Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir); setState.ApplyLinearImpulse(r * 20 * this->gameInstance->GetFrameTime()); @@ -78,7 +90,6 @@ void Player::MoveRight() void Player::MoveLeft() { //Do cross product with forward vector and negative gravity vector - // temp up vector Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 ); //Oyster::Math::Float4 r1 = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir); //Still get zero setState.ApplyLinearImpulse(-r * 20 * this->gameInstance->GetFrameTime()); @@ -99,16 +110,16 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint) void Player::Rotate(const Oyster::Math3D::Float3 lookDir) { - this->lookDir = lookDir; - + Oyster::Math::Float4 up(0,1,0,0);//-setState.GetGravityNormal(); Oyster::Math::Float4 pos = setState.GetCenterPosition(); Oyster::Math::Float4x4 world = Oyster::Math3D::OrientationMatrix_LookAtDirection(lookDir, up.xyz, pos.xyz); // cant set rotation //setState.SetOrientation(world); //this->lookDir = lookDir - up.xyz; - + //this->lookDir = lookDir; + //this->setState.AddRotation(Oyster::Math::Float4(x, y)); //this->setState.SetRotation(); } diff --git a/Code/Game/GameLogic/StaticObject.h b/Code/Game/GameLogic/StaticObject.h index 13d7f73e..5306d43b 100644 --- a/Code/Game/GameLogic/StaticObject.h +++ b/Code/Game/GameLogic/StaticObject.h @@ -17,7 +17,7 @@ namespace GameLogic public: StaticObject(); StaticObject(void* collisionFunc, OBJECT_TYPE type); - StaticObject(Oyster::Physics::ICustomBody *rigidBody,void* collisionFunc, OBJECT_TYPE type); + //StaticObject(Oyster::Physics::ICustomBody *rigidBody,void* collisionFunc, OBJECT_TYPE type); StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); StaticObject(OBJECT_TYPE type); ~StaticObject(void); diff --git a/Code/Game/GameLogic/Weapon.cpp b/Code/Game/GameLogic/Weapon.cpp index 994ccac5..a4c87e9e 100644 --- a/Code/Game/GameLogic/Weapon.cpp +++ b/Code/Game/GameLogic/Weapon.cpp @@ -1,5 +1,6 @@ #include "Weapon.h" #include "AttatchmentMassDriver.h" +#include "Player.h" using namespace GameLogic; @@ -15,9 +16,21 @@ Weapon::Weapon() attatchmentSockets = 0; } -Weapon::Weapon(int MaxNrOfSockets) +Weapon::Weapon(int MaxNrOfSockets,Player *owner) { attatchmentSockets.Resize(MaxNrOfSockets); + attatchmentSockets[0] = new AttatchmentSocket(); + + weaponState = WEAPON_STATE_IDLE; + currentNrOfAttatchments = 0; + selectedAttatchment = 0; + + //give the weapon a massdriver on socket 0 + IAttatchment *mD = new AttatchmentMassDriver(*owner); + attatchmentSockets[0]->SetAttatchment(mD); + this->currentNrOfAttatchments = 1; + SelectAttatchment(0); + //give the weapon a massdriver on socket 0 } diff --git a/Code/Game/GameLogic/Weapon.h b/Code/Game/GameLogic/Weapon.h index 0d3c09d8..5138b2ac 100644 --- a/Code/Game/GameLogic/Weapon.h +++ b/Code/Game/GameLogic/Weapon.h @@ -16,7 +16,7 @@ namespace GameLogic { public: Weapon(void); - Weapon(int nrOfAttatchmentSockets); + Weapon(int nrOfAttatchmentSockets, Player *owner); ~Weapon(void); void Use(const WEAPON_FIRE &usage, float dt);