diff --git a/Code/Game/GameClient/DanBiasGame_Impl.cpp b/Code/Game/GameClient/DanBiasGame_Impl.cpp index acc97efb..85ea810a 100644 --- a/Code/Game/GameClient/DanBiasGame_Impl.cpp +++ b/Code/Game/GameClient/DanBiasGame_Impl.cpp @@ -78,7 +78,7 @@ namespace DanBias //if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC(L"Window", cPOINT(1600, 900), cPOINT()))) WindowShell::WINDOW_INIT_DESC winDesc; - winDesc.windowSize.x = 1080; + winDesc.windowSize.x = 1280; winDesc.windowSize.y = 720; winDesc.windowProcCallback = WindowCallBack; @@ -153,7 +153,7 @@ namespace DanBias Oyster::Graphics::API::Option p; p.modelPath = L"..\\Content\\Models\\"; p.texturePath = L"..\\Content\\Textures\\"; - p.Resolution = Oyster::Math::Float2( 1080.0f, 720.0f ); + p.Resolution = Oyster::Math::Float2( 1280.0f, 720.0f ); //! @todo fix proper amb value p.AmbientValue = 1.3f; diff --git a/Code/Game/GameClient/GameClientState/GamingUI.cpp b/Code/Game/GameClient/GameClientState/GamingUI.cpp index 22ee7cc7..f6b9aa32 100644 --- a/Code/Game/GameClient/GameClientState/GamingUI.cpp +++ b/Code/Game/GameClient/GameClientState/GamingUI.cpp @@ -121,50 +121,50 @@ void GamingUI::ReadKeyInput() this->key_Jump = false; // shoot - if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseLeftBtn) ) - { - if( !this->key_Shoot ) - { - Protocol_PlayerShot playerShot; - playerShot.primaryPressed = true; - playerShot.secondaryPressed = false; - playerShot.utilityPressed = false; - this->sharedData->network->Send( playerShot ); - this->key_Shoot = true; - } - } - else - this->key_Shoot = false; - - if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseRightBtn) ) - { - if( !this->key_Shoot ) - { - Protocol_PlayerShot playerShot; - playerShot.primaryPressed = false; - playerShot.secondaryPressed = true; - playerShot.utilityPressed = false; - this->sharedData->network->Send( playerShot ); - this->key_Shoot = true; - } - } - else - this->key_Shoot = false; - - if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseMiddleBtn) ) - { - if( !this->key_Shoot ) - { - Protocol_PlayerShot playerShot; - playerShot.primaryPressed = false; - playerShot.secondaryPressed = false; - playerShot.utilityPressed = true; - this->sharedData->network->Send( playerShot ); - this->key_Shoot = true; - } - } - else - this->key_Shoot = false; + //if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseLeftBtn) ) + //{ + // if( !this->key_Shoot ) + // { + // Protocol_PlayerShot playerShot; + // playerShot.primaryPressed = true; + // playerShot.secondaryPressed = false; + // playerShot.utilityPressed = false; + // this->sharedData->network->Send( playerShot ); + // this->key_Shoot = true; + // } + //} + //else + // this->key_Shoot = false; + // + //if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseRightBtn) ) + //{ + // if( !this->key_Shoot ) + // { + // Protocol_PlayerShot playerShot; + // playerShot.primaryPressed = false; + // playerShot.secondaryPressed = true; + // playerShot.utilityPressed = false; + // this->sharedData->network->Send( playerShot ); + // this->key_Shoot = true; + // } + //} + //else + // this->key_Shoot = false; + // + //if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseMiddleBtn) ) + //{ + // if( !this->key_Shoot ) + // { + // Protocol_PlayerShot playerShot; + // playerShot.primaryPressed = false; + // playerShot.secondaryPressed = false; + // playerShot.utilityPressed = true; + // this->sharedData->network->Send( playerShot ); + // this->key_Shoot = true; + // } + //} + //else + // this->key_Shoot = false; if( this->sharedData->keyboardDevice->IsKeyDown(::Input::Enum::SAKI_Escape) ) { @@ -176,7 +176,36 @@ void GamingUI::ReadKeyInput() } } - +void GamingUI::OnMousePress ( Input::Enum::SAMI key, Input::Mouse* sender ) +{ + switch ( key ) + { + case ::Input::Enum::SAMI_MouseLeftBtn: // shoot + this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_PrimaryPress) ); + break; + case ::Input::Enum::SAMI_MouseRightBtn: + this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_SecondaryPress) ); + break; + case ::Input::Enum::SAMI_MouseMiddleBtn: + this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_UtilityPress) ); + break; + } +} +void GamingUI::OnMouseRelease ( Input::Enum::SAMI key, Input::Mouse* sender ) +{ + switch ( key ) + { + case ::Input::Enum::SAMI_MouseLeftBtn: // shoot + this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_PrimaryRelease) ); + break; + case ::Input::Enum::SAMI_MouseRightBtn: + this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_SecondaryRelease) ); + break; + case ::Input::Enum::SAMI_MouseMiddleBtn: + this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_UtilityRelease) ); + break; + } +} void GamingUI::OnMouseMoveVelocity ( Input::Struct::SAIPointInt2D coordinate, Input::Mouse* sender ) { //send delta mouse movement diff --git a/Code/Game/GameClient/GameClientState/GamingUI.h b/Code/Game/GameClient/GameClientState/GamingUI.h index c4e34441..d21ae0bd 100644 --- a/Code/Game/GameClient/GameClientState/GamingUI.h +++ b/Code/Game/GameClient/GameClientState/GamingUI.h @@ -28,9 +28,9 @@ namespace DanBias { namespace Client private: /* Overidden mouse methods */ void OnMouse ( const Input::Struct::MouseEventData& eventData ) override { } - void OnMousePress ( Input::Enum::SAMI key, Input::Mouse* sender ) override { } + void OnMousePress ( Input::Enum::SAMI key, Input::Mouse* sender ) override; void OnMouseDown ( Input::Enum::SAMI key, Input::Mouse* sender ) override { } - void OnMouseRelease ( Input::Enum::SAMI key, Input::Mouse* sender ) override { } + void OnMouseRelease ( Input::Enum::SAMI key, Input::Mouse* sender ) override; void OnMouseMovePixelPos ( Input::Struct::SAIPointInt2D coordinate, Input::Mouse* sender ) override { } void OnMouseMoveVelocity ( Input::Struct::SAIPointInt2D coordinate, Input::Mouse* sender ) override; void OnMouseScroll ( int delta, Input::Mouse* sender ) override { } diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index 13ef8fef..401c40f8 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -44,9 +44,9 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, switch (usage) { case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS: - if(currentEnergy >= 90.0f) + if(currentEnergy >= 9.0f) { - currentEnergy -= 90.0f; + currentEnergy -= 9.0f; ForcePush(usage,dt); // add CD ((Game*)&Game::Instance())->onActionEventFnc(this->owner, WeaponAction::WeaponAction_PrimaryShoot); @@ -54,13 +54,39 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, break; case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS: - if(currentEnergy >= 1.0f) + if(this->hasObject) + { + ((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation(); + this->hasObject = false; + this->heldObject = NULL; + } + else if( currentEnergy >= 1.0f ) { currentEnergy -= 1.0f; - ForcePull(usage,dt); - // add CD - ((Game*)&Game::Instance())->onActionEventFnc(this->owner, WeaponAction::WeaponAction_SecondaryShoot); + if(!this->hasObject) + { + ForcePull(usage,dt); + // add CD + ((Game*)&Game::Instance())->onActionEventFnc(this->owner, WeaponAction::WeaponAction_SecondaryShoot); + } } + else //Energy drained, release object + { + ((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation(); + this->hasObject = false; + this->heldObject = NULL; + } + break; + + case WEAPON_USE_SECONDARY_RELEASE: + { + if (this->hasObject) //Dummy check + { + //((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation(); + //this->hasObject = false; + //this->heldObject = NULL; + } + } break; case WEAPON_FIRE::WEAPON_USE_UTILLITY_PRESS: @@ -79,6 +105,7 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, void AttatchmentMassDriver::Update(float dt) { + //update position of heldObject if there is an object being held if(hasObject) { @@ -90,12 +117,26 @@ void AttatchmentMassDriver::Update(float dt) heldObject->SetPosition(pos); heldObject->SetLinearVelocity(Oyster::Math::Float3::null); - currentEnergy += rechargeRate * 0.5f; //rechargeRate is halfed if you are holding an object + if(currentEnergy < maxEnergy) + { + currentEnergy += rechargeRate * 0.5f; //rechargeRate is halfed if you are holding an object + } + } else { - currentEnergy += rechargeRate; + if(currentEnergy < maxEnergy) + { + currentEnergy += rechargeRate; + + if(currentEnergy == maxEnergy) + { + int trap = 0; + } + } } + + if(currentEnergy > maxEnergy) currentEnergy = maxEnergy; } @@ -112,11 +153,11 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float if(hasObject) { pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (this->force); - heldObject->ApplyImpulse((Oyster::Math::Float3)pushForce); - ((DynamicObject*)(heldObject->GetCustomTag()))->RemoveManipulation(); - hasObject = false; - heldObject = NULL; - return; + this->heldObject->ApplyImpulse((Oyster::Math::Float3)pushForce); + ((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation(); + this->hasObject = false; + this->heldObject = NULL; + return ; } Oyster::Math::Float radius = 4; @@ -165,22 +206,27 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt) Oyster::Math::Float4 pullForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (this->force * 0.2); - Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius); + Oyster::Collision3D::Cone hitCone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius); forcePushData args; args.pushForce = -pullForce; args.p = this->owner; - Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction); - - if(hitCone) delete hitCone; + Oyster::Physics::API::Instance().ApplyEffect(&hitCone,&args,ForcePushAction); } void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt) { - Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized()*2; - Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,10); + //DEBUG: + MessageBeep(MB_ICONINFORMATION); + Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized() * 2; - Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp); + //Do ray test first! + //Oyster::Collision3D::Ray r(pos, owner->GetLookDir()); + //Oyster::Physics::API::Instance().ApplyEffect(&r, this, AttemptPickUp); - if(hitSphere) delete hitSphere; + if(this->hasObject) return; + + Oyster::Collision3D::Sphere hitSphere = Oyster::Collision3D::Sphere(pos , 1); + Oyster::Physics::API::Instance().ApplyEffect(&hitSphere,this,AttemptPickUp); + return; } diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index c355fd04..928ddaac 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -167,9 +167,6 @@ using namespace GameLogic; { Player *hitPlayer = (Player*)realObj; hitPlayer->DamageLife(ExplosionSource->extraDamageOnCollision); - //hitPlayer->GetRigidBody()->ApplyImpulse(force); - - //hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision()); realObj->GetRigidBody()->ApplyImpulse(force * 5); //do shredding damage } @@ -192,11 +189,11 @@ using namespace GameLogic; Oyster::Math::Float angularFactor = deltaPos.GetNormalized().Dot( (objPrevVel - playerPrevVel).GetNormalized()); Oyster::Math::Float impactPower = deltaSpeed * angularFactor; - Oyster::Math::Float damageFactor = 0.01f; + Oyster::Math::Float damageFactor = 0.1f; - int damageDone = 0; - int forceThreashHold = 30; //FIX: balance this + Oyster::Math::Float damageDone = 0.0f; + Oyster::Math::Float forceThreashHold = 30.0f; //FIX: balance this if(impactPower > forceThreashHold) //should only take damage if the force is high enough { @@ -326,6 +323,7 @@ using namespace GameLogic; void AttatchmentMassDriver::AttemptPickUp(Oyster::Physics::ICustomBody *obj, void* args) { if(obj->GetState().mass == 0) return; + if(!args) return; AttatchmentMassDriver *weapon = ((AttatchmentMassDriver*)args); @@ -339,7 +337,6 @@ using namespace GameLogic; //check so that it is an object that you can pickup DynamicObject *dynamicObj = dynamic_cast(realObj); - if(!dynamicObj) return; if(dynamicObj->getManipulatingPlayer() != NULL) diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 324d49da..ae409d47 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -68,8 +68,8 @@ Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody) break; case ObjectSpecialType_RedExplosiveBox: { - Oyster::Math::Float dmg = 120; - Oyster::Math::Float force = 500; + Oyster::Math::Float dmg = 50; + Oyster::Math::Float force = 800; Oyster::Math::Float radie = 3; gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objIDCounter, dmg, force, radie); } @@ -90,8 +90,7 @@ Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody) break; case ObjectSpecialType_CrystalFormation: { - int dmg = 50; - //gameObj = new Crystal(rigidBody); + int dmg = 30; gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objIDCounter); } break; @@ -102,7 +101,7 @@ Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody) break; case ObjectSpecialType_JumpPad: { - float power = 500; //((JumpPadAttributes*)obj)->power; + float power = ((JumpPadAttributes*)obj)->power; Oyster::Math::Float3 dir = ((JumpPadAttributes*)obj)->direction; Oyster::Math::Float3 pushForce = dir * power; gameObj = new JumpPad(rigidBody, (ObjectSpecialType)obj->specialTypeID, objIDCounter , pushForce); diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index 66d1b38f..168a825c 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -157,37 +157,59 @@ namespace GameLogic struct Protocol_PlayerShot :public Oyster::Network::CustomProtocolObject { - bool primaryPressed; - bool secondaryPressed; - bool utilityPressed; + enum ShootValue + { + ShootValue_PrimaryPress, + ShootValue_PrimaryRelease, + ShootValue_SecondaryPress, + ShootValue_SecondaryRelease, + ShootValue_UtilityPress, + ShootValue_UtilityRelease, + } value; + //bool primaryPressed; + //bool secondaryPressed; + //bool utilityPressed; Protocol_PlayerShot() { this->protocol[0].value = protocol_Gameplay_PlayerShot; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; - this->protocol[1].type = Oyster::Network::NetAttributeType_Bool; - this->protocol[2].type = Oyster::Network::NetAttributeType_Bool; - this->protocol[3].type = Oyster::Network::NetAttributeType_Bool; + this->protocol[1].type = Oyster::Network::NetAttributeType_Char; + + //this->protocol[1].type = Oyster::Network::NetAttributeType_Bool; + //this->protocol[2].type = Oyster::Network::NetAttributeType_Bool; + //this->protocol[3].type = Oyster::Network::NetAttributeType_Bool; + } + Protocol_PlayerShot(ShootValue val) + { + this->protocol[0].value = protocol_Gameplay_PlayerShot; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + + this->protocol[1].type = Oyster::Network::NetAttributeType_Char; + this->value = val; } Protocol_PlayerShot(Oyster::Network::CustomNetProtocol& p) { - primaryPressed = p[1].value.netBool; - secondaryPressed = p[2].value.netBool; - utilityPressed = p[3].value.netBool; + value = (ShootValue)p[1].value.netChar; + //primaryPressed = p[1].value.netBool; + //secondaryPressed = p[2].value.netBool; + //utilityPressed = p[3].value.netBool; } const Protocol_PlayerShot& operator=(Oyster::Network::CustomNetProtocol& val) { - primaryPressed = val[1].value.netBool; - secondaryPressed = val[2].value.netBool; - utilityPressed = val[3].value.netBool; + value = (ShootValue)val[1].value.netChar; + //primaryPressed = val[1].value.netBool; + //secondaryPressed = val[2].value.netBool; + //utilityPressed = val[3].value.netBool; return *this; } Oyster::Network::CustomNetProtocol GetProtocol() override { - this->protocol[1].value = primaryPressed; - this->protocol[2].value = secondaryPressed; - this->protocol[3].value = utilityPressed; + this->protocol[1].value = value; + //this->protocol[1].value = primaryPressed; + //this->protocol[2].value = secondaryPressed; + //this->protocol[3].value = utilityPressed; return protocol; } diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index 4583978c..77381395 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -257,9 +257,21 @@ using namespace DanBias; } void GameSession::Gameplay_PlayerShot ( Protocol_PlayerShot& p, DanBias::GameClient* c ) { - if(p.secondaryPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_SECONDARY_PRESS); - if(p.primaryPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS); - if(p.utilityPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_UTILLITY_PRESS); + switch (p.value) + { + case Protocol_PlayerShot::ShootValue_PrimaryPress: c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS); + break; + case Protocol_PlayerShot::ShootValue_PrimaryRelease: c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_RELEASE); + break; + case Protocol_PlayerShot::ShootValue_SecondaryPress: c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_SECONDARY_PRESS); + break; + case Protocol_PlayerShot::ShootValue_SecondaryRelease: c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_SECONDARY_RELEASE); + break; + case Protocol_PlayerShot::ShootValue_UtilityPress: c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_UTILLITY_PRESS); + break; + case Protocol_PlayerShot::ShootValue_UtilityRelease: c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_UTILLITY_RELEASE); + break; + } } void GameSession::Gameplay_ObjectPickup ( Protocol_ObjectPickup& p, DanBias::GameClient* c ) { diff --git a/Code/Misc/Input/Source/Win32/Win32Mouse.cpp b/Code/Misc/Input/Source/Win32/Win32Mouse.cpp index 4faeed64..79cb49a4 100644 --- a/Code/Misc/Input/Source/Win32/Win32Mouse.cpp +++ b/Code/Misc/Input/Source/Win32/Win32Mouse.cpp @@ -200,12 +200,12 @@ void Win32Mouse::ProccessMouseData (RAWMOUSE mouse) if(btn == SAMI_Unknown) return; - this->buttons[btn].isDown = !isUp; this->buttons[btn].makeCode = makeCode; //The btn is released. if(isUp) { + this->buttons[btn].isDown = false; InternalOnBtnRelease(btn); GetNormalizedPosition( mouseEventData.normalizedPos ); @@ -222,6 +222,7 @@ void Win32Mouse::ProccessMouseData (RAWMOUSE mouse) //The btn is down since last frame if(this->buttons[btn].isDown) { + this->buttons[btn].isDown = true; InternalOnBtnDown(btn); GetNormalizedPosition( mouseEventData.normalizedPos ); @@ -234,6 +235,7 @@ void Win32Mouse::ProccessMouseData (RAWMOUSE mouse) } else { + this->buttons[btn].isDown = true; InternalOnBtnPress(btn); GetNormalizedPosition( mouseEventData.normalizedPos );