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
parent b289741897
commit ffa6da1a2f
7 changed files with 134 additions and 107 deletions

View File

@ -121,50 +121,50 @@ void GamingUI::ReadKeyInput()
this->key_Jump = false; this->key_Jump = false;
// shoot // shoot
if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseLeftBtn) ) //if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseLeftBtn) )
{ //{
if( !this->key_Shoot ) // if( !this->key_Shoot )
{ // {
Protocol_PlayerShot playerShot; // Protocol_PlayerShot playerShot;
playerShot.primaryPressed = true; // playerShot.primaryPressed = true;
playerShot.secondaryPressed = false; // playerShot.secondaryPressed = false;
playerShot.utilityPressed = false; // playerShot.utilityPressed = false;
this->sharedData->network->Send( playerShot ); // this->sharedData->network->Send( playerShot );
this->key_Shoot = true; // this->key_Shoot = true;
} // }
} //}
else //else
this->key_Shoot = false; // this->key_Shoot = false;
//
if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseRightBtn) ) //if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseRightBtn) )
{ //{
if( !this->key_Shoot ) // if( !this->key_Shoot )
{ // {
Protocol_PlayerShot playerShot; // Protocol_PlayerShot playerShot;
playerShot.primaryPressed = false; // playerShot.primaryPressed = false;
playerShot.secondaryPressed = true; // playerShot.secondaryPressed = true;
playerShot.utilityPressed = false; // playerShot.utilityPressed = false;
this->sharedData->network->Send( playerShot ); // this->sharedData->network->Send( playerShot );
this->key_Shoot = true; // this->key_Shoot = true;
} // }
} //}
else //else
this->key_Shoot = false; // this->key_Shoot = false;
//
if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseMiddleBtn) ) //if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseMiddleBtn) )
{ //{
if( !this->key_Shoot ) // if( !this->key_Shoot )
{ // {
Protocol_PlayerShot playerShot; // Protocol_PlayerShot playerShot;
playerShot.primaryPressed = false; // playerShot.primaryPressed = false;
playerShot.secondaryPressed = false; // playerShot.secondaryPressed = false;
playerShot.utilityPressed = true; // playerShot.utilityPressed = true;
this->sharedData->network->Send( playerShot ); // this->sharedData->network->Send( playerShot );
this->key_Shoot = true; // this->key_Shoot = true;
} // }
} //}
else //else
this->key_Shoot = false; // this->key_Shoot = false;
if( this->sharedData->keyboardDevice->IsKeyDown(::Input::Enum::SAKI_Escape) ) if( this->sharedData->keyboardDevice->IsKeyDown(::Input::Enum::SAKI_Escape) )
{ {
@ -177,31 +177,13 @@ void GamingUI::OnMousePress ( Input::Enum::SAMI key, Input::Mouse* sender )
switch ( key ) switch ( key )
{ {
case ::Input::Enum::SAMI_MouseLeftBtn: // shoot case ::Input::Enum::SAMI_MouseLeftBtn: // shoot
{ this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_PrimaryPress) );
Protocol_PlayerShot playerShot;
playerShot.primaryPressed = true;
playerShot.secondaryPressed = false;
playerShot.utilityPressed = false;
this->sharedData->network->Send( playerShot );
}
break; break;
case ::Input::Enum::SAMI_MouseRightBtn: case ::Input::Enum::SAMI_MouseRightBtn:
{ this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_SecondaryPress) );
Protocol_PlayerShot playerShot;
playerShot.primaryPressed = false;
playerShot.secondaryPressed = true;
playerShot.utilityPressed = false;
this->sharedData->network->Send( playerShot );
}
break; break;
case ::Input::Enum::SAMI_MouseMiddleBtn: case ::Input::Enum::SAMI_MouseMiddleBtn:
{ this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_UtilityPress) );
Protocol_PlayerShot playerShot;
playerShot.primaryPressed = false;
playerShot.secondaryPressed = false;
playerShot.utilityPressed = true;
this->sharedData->network->Send( playerShot );
}
break; break;
} }
} }
@ -209,14 +191,14 @@ void GamingUI::OnMouseRelease ( Input::Enum::SAMI key, Input::Mouse* sender )
{ {
switch ( key ) switch ( key )
{ {
case ::Input::Enum::SAMI_MouseLeftBtn: // shoot
this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_PrimaryRelease) );
break;
case ::Input::Enum::SAMI_MouseRightBtn: case ::Input::Enum::SAMI_MouseRightBtn:
{ this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_SecondaryRelease) );
Protocol_PlayerShot playerShot; break;
playerShot.primaryPressed = false; case ::Input::Enum::SAMI_MouseMiddleBtn:
playerShot.secondaryPressed = false; this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_UtilityRelease) );
playerShot.utilityPressed = false;
this->sharedData->network->Send( playerShot );
}
break; break;
} }
} }

View File

@ -54,7 +54,13 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
break; break;
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS: 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; currentEnergy -= 1.0f;
if(!this->hasObject) if(!this->hasObject)
@ -76,9 +82,9 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
{ {
if (this->hasObject) //Dummy check if (this->hasObject) //Dummy check
{ {
((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation(); //((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation();
this->hasObject = false; //this->hasObject = false;
this->heldObject = NULL; //this->heldObject = NULL;
} }
} }
break; 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::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; forcePushData args;
args.pushForce = -pullForce; args.pushForce = -pullForce;
args.p = this->owner; args.p = this->owner;
Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction); Oyster::Physics::API::Instance().ApplyEffect(&hitCone,&args,ForcePushAction);
if(hitCone) delete hitCone;
} }
void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt) void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt)
{ {
Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized()*2; //DEBUG:
Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,10); 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;
} }

View File

@ -326,6 +326,7 @@ using namespace GameLogic;
void AttatchmentMassDriver::AttemptPickUp(Oyster::Physics::ICustomBody *obj, void* args) void AttatchmentMassDriver::AttemptPickUp(Oyster::Physics::ICustomBody *obj, void* args)
{ {
if(obj->GetState().mass == 0) return; if(obj->GetState().mass == 0) return;
if(!args) return;
AttatchmentMassDriver *weapon = ((AttatchmentMassDriver*)args); AttatchmentMassDriver *weapon = ((AttatchmentMassDriver*)args);
@ -339,7 +340,6 @@ using namespace GameLogic;
//check so that it is an object that you can pickup //check so that it is an object that you can pickup
DynamicObject *dynamicObj = dynamic_cast<DynamicObject*>(realObj); DynamicObject *dynamicObj = dynamic_cast<DynamicObject*>(realObj);
if(!dynamicObj) return; if(!dynamicObj) return;
if(dynamicObj->getManipulatingPlayer() != NULL) if(dynamicObj->getManipulatingPlayer() != NULL)

View File

@ -157,37 +157,59 @@ namespace GameLogic
struct Protocol_PlayerShot :public Oyster::Network::CustomProtocolObject struct Protocol_PlayerShot :public Oyster::Network::CustomProtocolObject
{ {
bool primaryPressed; enum ShootValue
bool secondaryPressed; {
bool utilityPressed; ShootValue_PrimaryPress,
ShootValue_PrimaryRelease,
ShootValue_SecondaryPress,
ShootValue_SecondaryRelease,
ShootValue_UtilityPress,
ShootValue_UtilityRelease,
} value;
//bool primaryPressed;
//bool secondaryPressed;
//bool utilityPressed;
Protocol_PlayerShot() Protocol_PlayerShot()
{ {
this->protocol[0].value = protocol_Gameplay_PlayerShot; this->protocol[0].value = protocol_Gameplay_PlayerShot;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool; this->protocol[1].type = Oyster::Network::NetAttributeType_Char;
this->protocol[2].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool; //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) Protocol_PlayerShot(Oyster::Network::CustomNetProtocol& p)
{ {
primaryPressed = p[1].value.netBool; value = (ShootValue)p[1].value.netChar;
secondaryPressed = p[2].value.netBool; //primaryPressed = p[1].value.netBool;
utilityPressed = p[3].value.netBool; //secondaryPressed = p[2].value.netBool;
//utilityPressed = p[3].value.netBool;
} }
const Protocol_PlayerShot& operator=(Oyster::Network::CustomNetProtocol& val) const Protocol_PlayerShot& operator=(Oyster::Network::CustomNetProtocol& val)
{ {
primaryPressed = val[1].value.netBool; value = (ShootValue)val[1].value.netChar;
secondaryPressed = val[2].value.netBool; //primaryPressed = val[1].value.netBool;
utilityPressed = val[3].value.netBool; //secondaryPressed = val[2].value.netBool;
//utilityPressed = val[3].value.netBool;
return *this; return *this;
} }
Oyster::Network::CustomNetProtocol GetProtocol() override Oyster::Network::CustomNetProtocol GetProtocol() override
{ {
this->protocol[1].value = primaryPressed; this->protocol[1].value = value;
this->protocol[2].value = secondaryPressed; //this->protocol[1].value = primaryPressed;
this->protocol[3].value = utilityPressed; //this->protocol[2].value = secondaryPressed;
//this->protocol[3].value = utilityPressed;
return protocol; return protocol;
} }

View File

@ -25,8 +25,6 @@ GameClient::GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::Net
} }
GameClient::~GameClient() GameClient::~GameClient()
{ {
delete this->player;
this->isReady = false; this->isReady = false;
this->character = L"char_orca.dan"; this->character = L"char_orca.dan";
this->alias = L"Unknown"; this->alias = L"Unknown";

View File

@ -257,9 +257,21 @@ using namespace DanBias;
} }
void GameSession::Gameplay_PlayerShot ( Protocol_PlayerShot& p, DanBias::GameClient* c ) void GameSession::Gameplay_PlayerShot ( Protocol_PlayerShot& p, DanBias::GameClient* c )
{ {
if(p.secondaryPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_SECONDARY_PRESS); switch (p.value)
if(p.primaryPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS); {
if(p.utilityPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_UTILLITY_PRESS); 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 ) 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; if(btn == SAMI_Unknown) return;
this->buttons[btn].isDown = !isUp;
this->buttons[btn].makeCode = makeCode; this->buttons[btn].makeCode = makeCode;
//The btn is released. //The btn is released.
if(isUp) if(isUp)
{ {
this->buttons[btn].isDown = false;
InternalOnBtnRelease(btn); InternalOnBtnRelease(btn);
GetNormalizedPosition( mouseEventData.normalizedPos ); GetNormalizedPosition( mouseEventData.normalizedPos );
@ -222,6 +222,7 @@ void Win32Mouse::ProccessMouseData (RAWMOUSE mouse)
//The btn is down since last frame //The btn is down since last frame
if(this->buttons[btn].isDown) if(this->buttons[btn].isDown)
{ {
this->buttons[btn].isDown = true;
InternalOnBtnDown(btn); InternalOnBtnDown(btn);
GetNormalizedPosition( mouseEventData.normalizedPos ); GetNormalizedPosition( mouseEventData.normalizedPos );
@ -234,6 +235,7 @@ void Win32Mouse::ProccessMouseData (RAWMOUSE mouse)
} }
else else
{ {
this->buttons[btn].isDown = true;
InternalOnBtnPress(btn); InternalOnBtnPress(btn);
GetNormalizedPosition( mouseEventData.normalizedPos ); GetNormalizedPosition( mouseEventData.normalizedPos );