GameLogic - Fixed drop on secondary, Modified how keys are sent

This commit is contained in:
Dennis Andersen 2014-02-27 08:19:50 +01:00 committed by Dander7BD
parent 50acc12951
commit 22bc079ed7
6 changed files with 135 additions and 106 deletions

View File

@ -119,50 +119,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) )
{
@ -175,31 +175,13 @@ 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 );
}
this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_PrimaryPress) );
break;
case ::Input::Enum::SAMI_MouseRightBtn:
{
Protocol_PlayerShot playerShot;
playerShot.primaryPressed = false;
playerShot.secondaryPressed = true;
playerShot.utilityPressed = false;
this->sharedData->network->Send( playerShot );
}
this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_SecondaryPress) );
break;
case ::Input::Enum::SAMI_MouseMiddleBtn:
{
Protocol_PlayerShot playerShot;
playerShot.primaryPressed = false;
playerShot.secondaryPressed = false;
playerShot.utilityPressed = true;
this->sharedData->network->Send( playerShot );
}
this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_UtilityPress) );
break;
}
}
@ -207,14 +189,14 @@ 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:
{
Protocol_PlayerShot playerShot;
playerShot.primaryPressed = false;
playerShot.secondaryPressed = false;
playerShot.utilityPressed = false;
this->sharedData->network->Send( playerShot );
}
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;
}
}

View File

@ -54,7 +54,13 @@ 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;
if(!this->hasObject)
@ -76,9 +82,9 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
{
if (this->hasObject) //Dummy check
{
((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation();
this->hasObject = false;
this->heldObject = NULL;
//((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation();
//this->hasObject = false;
//this->heldObject = NULL;
}
}
break;
@ -185,22 +191,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)
{
//DEBUG:
MessageBeep(MB_ICONINFORMATION);
Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized() * 2;
Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,10);
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;
}

View File

@ -326,6 +326,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 +340,6 @@ using namespace GameLogic;
//check so that it is an object that you can pickup
DynamicObject *dynamicObj = dynamic_cast<DynamicObject*>(realObj);
if(!dynamicObj) return;
if(dynamicObj->getManipulatingPlayer() != NULL)

View File

@ -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;
}

View File

@ -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 )
{

View File

@ -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 );