Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic

This commit is contained in:
Linda Andersson 2014-02-25 14:35:39 +01:00
commit 2996627c56
2 changed files with 54 additions and 10 deletions

View File

@ -11,10 +11,18 @@ AttatchmentMassDriver::AttatchmentMassDriver(void)
this->owner = 0;
this->heldObject = NULL;
this->hasObject = false;
this->currentEnergy = StandardMaxEnergy;
this->maxEnergy = StandardMaxEnergy;
this->rechargeRate = StandardrechargeRate;
this->force = Standardforce;
}
AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
{
this->currentEnergy = StandardMaxEnergy;
this->maxEnergy = StandardMaxEnergy;
this->rechargeRate = StandardrechargeRate;
this->force = Standardforce;
this->owner = &owner;
this->heldObject = NULL;
@ -36,15 +44,27 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
switch (usage)
{
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
ForcePush(usage,dt);
if(currentEnergy >= 90.0f)
{
currentEnergy -= 90.0f;
ForcePush(usage,dt);
}
break;
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
ForcePull(usage,dt);
if(currentEnergy >= 1.0f)
{
currentEnergy -= 1.0f;
ForcePull(usage,dt);
}
break;
case WEAPON_FIRE::WEAPON_USE_UTILLITY_PRESS:
ForceZip(usage,dt);
if(currentEnergy >= 90.0f)
{
currentEnergy -= 90.0f;
ForceZip(usage,dt);
}
break;
}
@ -64,7 +84,14 @@ 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
}
else
{
currentEnergy += rechargeRate;
}
}
/********************************************************
@ -78,7 +105,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
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);
((DynamicObject*)(heldObject->GetCustomTag()))->RemoveManipulation();
hasObject = false;
@ -91,12 +118,10 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
Oyster::Math::Float lenght = 10;
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);
forcePushData args;
args.pushForce = pushForce;
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)
{
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);
}
@ -132,11 +157,11 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
Oyster::Math::Float lenght = 10;
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);
forcePushData args;
args.pushForce = -pushForce;
args.pushForce = -pullForce;
args.p = this->owner;
Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction);

View File

@ -4,8 +4,14 @@
#ifndef ATTATCHMENTMASSDRIVER_H
#define ATTATCHMENTMASSDRIVER_H
#include "IAttatchment.h"
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
{
@ -53,6 +59,19 @@ namespace GameLogic
Oyster::Physics::ICustomBody *heldObject;
bool hasObject;
Oyster::Math::Float force;
Oyster::Math::Float maxEnergy;
Oyster::Math::Float currentEnergy;
Oyster::Math::Float rechargeRate;
struct Aim
{
};
};
}
#endif