diff --git a/Code/Game/GameClient/GameClientState/GamingUI.cpp b/Code/Game/GameClient/GameClientState/GamingUI.cpp index 19fad94c..97748ee5 100644 --- a/Code/Game/GameClient/GameClientState/GamingUI.cpp +++ b/Code/Game/GameClient/GameClientState/GamingUI.cpp @@ -148,7 +148,7 @@ void GamingUI::ReadKeyInput() this->key_Shoot = true; } } - else + else this->key_Shoot = false; if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseMiddleBtn) ) @@ -172,7 +172,54 @@ void GamingUI::ReadKeyInput() } } - +void GamingUI::OnMousePress ( Input::Enum::SAMI key, Input::Mouse* sender ) +{ + switch ( key ) + { + case ::Input::Enum::SAMI_MouseLeftBtn: // shoot + { + Protocol_PlayerShot playerShot; + playerShot.primaryPressed = true; + playerShot.secondaryPressed = false; + playerShot.utilityPressed = false; + this->sharedData->network->Send( playerShot ); + } + break; + case ::Input::Enum::SAMI_MouseRightBtn: + { + Protocol_PlayerShot playerShot; + playerShot.primaryPressed = false; + playerShot.secondaryPressed = true; + playerShot.utilityPressed = false; + this->sharedData->network->Send( playerShot ); + } + break; + case ::Input::Enum::SAMI_MouseMiddleBtn: + { + Protocol_PlayerShot playerShot; + playerShot.primaryPressed = false; + playerShot.secondaryPressed = false; + playerShot.utilityPressed = true; + this->sharedData->network->Send( playerShot ); + } + break; + } +} +void GamingUI::OnMouseRelease ( Input::Enum::SAMI key, Input::Mouse* sender ) +{ + switch ( key ) + { + case ::Input::Enum::SAMI_MouseRightBtn: + { + Protocol_PlayerShot playerShot; + playerShot.primaryPressed = false; + playerShot.secondaryPressed = false; + playerShot.utilityPressed = false; + this->sharedData->network->Send( playerShot ); + } + 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..dd20e8f3 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,33 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, break; case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS: - if(currentEnergy >= 1.0f) + 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: @@ -112,11 +132,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;