GL - weapon energy, force etc inside weapon

This commit is contained in:
Erik Persson 2014-02-25 13:56:35 +01:00 committed by Dander7BD
parent 4d967b995d
commit f2b63b7ad4
2 changed files with 54 additions and 10 deletions

View File

@ -11,10 +11,18 @@ AttatchmentMassDriver::AttatchmentMassDriver(void)
this->owner = 0; this->owner = 0;
this->heldObject = NULL; this->heldObject = NULL;
this->hasObject = false; this->hasObject = false;
this->currentEnergy = StandardMaxEnergy;
this->maxEnergy = StandardMaxEnergy;
this->rechargeRate = StandardrechargeRate;
this->force = Standardforce;
} }
AttatchmentMassDriver::AttatchmentMassDriver(Player &owner) AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
{ {
this->currentEnergy = StandardMaxEnergy;
this->maxEnergy = StandardMaxEnergy;
this->rechargeRate = StandardrechargeRate;
this->force = Standardforce;
this->owner = &owner; this->owner = &owner;
this->heldObject = NULL; this->heldObject = NULL;
@ -36,15 +44,27 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
switch (usage) switch (usage)
{ {
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS: case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
ForcePush(usage,dt); if(currentEnergy >= 90.0f)
{
currentEnergy -= 90.0f;
ForcePush(usage,dt);
}
break; break;
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS: case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
ForcePull(usage,dt); if(currentEnergy >= 1.0f)
{
currentEnergy -= 1.0f;
ForcePull(usage,dt);
}
break; break;
case WEAPON_FIRE::WEAPON_USE_UTILLITY_PRESS: case WEAPON_FIRE::WEAPON_USE_UTILLITY_PRESS:
ForceZip(usage,dt); if(currentEnergy >= 90.0f)
{
currentEnergy -= 90.0f;
ForceZip(usage,dt);
}
break; break;
} }
@ -64,7 +84,14 @@ void AttatchmentMassDriver::Update(float dt)
heldObject->SetPosition(pos); heldObject->SetPosition(pos);
heldObject->SetLinearVelocity(Oyster::Math::Float3::null); heldObject->SetLinearVelocity(Oyster::Math::Float3::null);
currentEnergy += rechargeRate * 0.5f; //rechargeRate is halfed if you are holding an object
} }
else
{
currentEnergy += rechargeRate;
}
} }
/******************************************************** /********************************************************
@ -78,7 +105,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
if(hasObject) if(hasObject)
{ {
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (800); pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (this->force);
heldObject->ApplyImpulse((Oyster::Math::Float3)pushForce); heldObject->ApplyImpulse((Oyster::Math::Float3)pushForce);
((DynamicObject*)(heldObject->GetCustomTag()))->RemoveManipulation(); ((DynamicObject*)(heldObject->GetCustomTag()))->RemoveManipulation();
hasObject = false; hasObject = false;
@ -91,12 +118,10 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
Oyster::Math::Float lenght = 10; Oyster::Math::Float lenght = 10;
Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos; Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos;
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (400); pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (this->force * 0.6f);
Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius); Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius);
forcePushData args; forcePushData args;
args.pushForce = pushForce; args.pushForce = pushForce;
args.p = this->owner; args.p = this->owner;
@ -111,7 +136,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
********************************************************/ ********************************************************/
void AttatchmentMassDriver::ForceZip(const WEAPON_FIRE &usage, float dt) void AttatchmentMassDriver::ForceZip(const WEAPON_FIRE &usage, float dt)
{ {
Oyster::Math::Float3 force = Oyster::Math::Float4(this->owner->GetLookDir()) * (1000); Oyster::Math::Float3 force = Oyster::Math::Float4(this->owner->GetLookDir()) * (this->force);
this->owner->GetRigidBody()->ApplyImpulse(force); this->owner->GetRigidBody()->ApplyImpulse(force);
} }
@ -132,11 +157,11 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
Oyster::Math::Float lenght = 10; Oyster::Math::Float lenght = 10;
Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos; Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos;
Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (100); 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 = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius);
forcePushData args; forcePushData args;
args.pushForce = -pushForce; 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);

View File

@ -4,8 +4,14 @@
#ifndef ATTATCHMENTMASSDRIVER_H #ifndef ATTATCHMENTMASSDRIVER_H
#define ATTATCHMENTMASSDRIVER_H #define ATTATCHMENTMASSDRIVER_H
#include "IAttatchment.h" #include "IAttatchment.h"
namespace GameLogic namespace GameLogic
{ {
const Oyster::Math::Float StandardMaxEnergy = 100.0f;
const Oyster::Math::Float StandardrechargeRate = 0.5f;
const Oyster::Math::Float Standardforce = 1000.0f;
class AttatchmentMassDriver : public IAttatchment class AttatchmentMassDriver : public IAttatchment
{ {
@ -53,6 +59,19 @@ namespace GameLogic
Oyster::Physics::ICustomBody *heldObject; Oyster::Physics::ICustomBody *heldObject;
bool hasObject; bool hasObject;
Oyster::Math::Float force;
Oyster::Math::Float maxEnergy;
Oyster::Math::Float currentEnergy;
Oyster::Math::Float rechargeRate;
struct Aim
{
};
}; };
} }
#endif #endif