Player movement and weapon working
This commit is contained in:
commit
4c54be1e62
|
@ -713,7 +713,7 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
|||
if( this->privData->myId == decoded.objectID )
|
||||
{
|
||||
// show my energy
|
||||
float energy = decoded.energy;
|
||||
int energy = (int)decoded.energy;
|
||||
((GamingUI*)this->gameUI)->SetEnergyText(std::to_wstring(energy));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,22 +62,13 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
|
|||
}
|
||||
else if( currentEnergy >= 1.0f )
|
||||
{
|
||||
if(this->hasObject)
|
||||
{
|
||||
currentEnergy -= 1.0f;
|
||||
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;
|
||||
|
||||
currentEnergy -= 1.0f;
|
||||
|
||||
ForcePull(usage,dt);
|
||||
// add CD
|
||||
((Game*)&Game::Instance())->onActionEventFnc(this->owner, WeaponAction::WeaponAction_SecondaryShoot);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -142,7 +133,11 @@ void AttatchmentMassDriver::Update(float dt)
|
|||
}
|
||||
}
|
||||
|
||||
if(currentEnergy > maxEnergy) currentEnergy = maxEnergy;
|
||||
if(currentEnergy > maxEnergy)
|
||||
{
|
||||
currentEnergy = maxEnergy;
|
||||
energyChange = 6;
|
||||
}
|
||||
|
||||
if(energyChange > 5)
|
||||
{
|
||||
|
|
|
@ -75,7 +75,7 @@ void Player::initPlayerData()
|
|||
|
||||
void Player::BeginFrame()
|
||||
{
|
||||
if( !(this->playerState & (PLAYER_STATE_DEAD || PLAYER_STATE_DIED)) )
|
||||
if( this->playerState != PLAYER_STATE_DEAD && this->playerState != PLAYER_STATE_DIED)
|
||||
{
|
||||
static const Float maxSpeed = 30;
|
||||
weapon->Update(0.002f);
|
||||
|
|
|
@ -41,7 +41,7 @@ Weapon::Weapon(int MaxNrOfSockets,Player *owner)
|
|||
IAttatchment *gun = new AttatchmentGun(*owner);
|
||||
attatchmentSockets[1]->SetAttatchment(gun);
|
||||
this->currentNrOfAttatchments = 2;
|
||||
SelectAttatchment(1);
|
||||
|
||||
//give the weapon a normal gun on socket 1
|
||||
}
|
||||
|
||||
|
|
|
@ -376,11 +376,6 @@ void API_Impl::ReleaseFromLimbo( const ICustomBody* objRef )
|
|||
|
||||
void API_Impl::ApplyEffect(Oyster::Collision3D::ICollideable* collideable, void* args, EventAction_ApplyEffect effect)
|
||||
{
|
||||
btRigidBody* body;
|
||||
btCollisionShape* shape;
|
||||
btMotionState* state;
|
||||
btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(0, NULL, NULL);
|
||||
|
||||
Sphere* sphere;
|
||||
Box* box;
|
||||
Cone* cone;
|
||||
|
@ -388,59 +383,61 @@ void API_Impl::ApplyEffect(Oyster::Collision3D::ICollideable* collideable, void*
|
|||
switch(collideable->type)
|
||||
{
|
||||
case ICollideable::Type::Type_sphere:
|
||||
{
|
||||
sphere = dynamic_cast<Sphere*>(collideable);
|
||||
// Add collision shape
|
||||
shape = new btSphereShape(sphere->radius);
|
||||
btSphereShape btSphere(sphere->radius);
|
||||
|
||||
// Add motion state
|
||||
state = new btDefaultMotionState(btTransform(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f),btVector3(sphere->center.x, sphere->center.y, sphere->center.z)));
|
||||
btDefaultMotionState state = btDefaultMotionState(btTransform(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f),btVector3(sphere->center.x, sphere->center.y, sphere->center.z)));
|
||||
|
||||
// Add rigid body
|
||||
rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo(0, state, shape);
|
||||
body = new btRigidBody(rigidBodyCI);
|
||||
|
||||
btRigidBody::btRigidBodyConstructionInfo rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo(0, &state, &btSphere);
|
||||
btRigidBody body = btRigidBody(rigidBodyCI);
|
||||
|
||||
ContactSensorCallback callback(body, effect, args);
|
||||
this->dynamicsWorld->contactTest(&body, callback);
|
||||
}
|
||||
break;
|
||||
|
||||
case ICollideable::Type::Type_box:
|
||||
{
|
||||
box = dynamic_cast<Box*>(collideable);
|
||||
// Add collision shape
|
||||
shape = new btBoxShape(btVector3(box->boundingOffset.x, box->boundingOffset.y, box->boundingOffset.z));
|
||||
btBoxShape btBox = btBoxShape(btVector3(box->boundingOffset.x, box->boundingOffset.y, box->boundingOffset.z));
|
||||
|
||||
// Add motion state
|
||||
state = new btDefaultMotionState(btTransform(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f),btVector3(box->center.x, box->center.y, box->center.z)));
|
||||
btDefaultMotionState state = btDefaultMotionState(btTransform(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f),btVector3(box->center.x, box->center.y, box->center.z)));
|
||||
|
||||
// Add rigid body
|
||||
rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo(0, state, shape);
|
||||
body = new btRigidBody(rigidBodyCI);
|
||||
btRigidBody::btRigidBodyConstructionInfo rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo(0, &state, &btBox);
|
||||
btRigidBody body = btRigidBody(rigidBodyCI);
|
||||
|
||||
ContactSensorCallback callback(body, effect, args);
|
||||
this->dynamicsWorld->contactTest(&body, callback);
|
||||
}
|
||||
break;
|
||||
|
||||
case ICollideable::Type::Type_cone:
|
||||
{
|
||||
cone = dynamic_cast<Cone*>(collideable);
|
||||
// Add collision shape
|
||||
shape = new btConeShapeZ(cone->radius, cone->length);
|
||||
btConeShapeZ coneShape = btConeShapeZ(cone->radius, cone->length);
|
||||
|
||||
// Add motion state
|
||||
state = new btDefaultMotionState(btTransform(btQuaternion(cone->quaternion.x, cone->quaternion.y, cone->quaternion.z, cone->quaternion.w),btVector3(cone->center.x, cone->center.y, cone->center.z)));
|
||||
btDefaultMotionState state = btDefaultMotionState(btTransform(btQuaternion(cone->quaternion.x, cone->quaternion.y, cone->quaternion.z, cone->quaternion.w)*btQuaternion(0, 1, 0, 0),btVector3(cone->center.x, cone->center.y, cone->center.z)));
|
||||
|
||||
// Add rigid body
|
||||
rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo (0, state, shape);
|
||||
body = new btRigidBody(rigidBodyCI);
|
||||
btRigidBody::btRigidBodyConstructionInfo rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo (0, &state, &coneShape);
|
||||
btRigidBody body = btRigidBody(rigidBodyCI);
|
||||
|
||||
ContactSensorCallback callback(body, effect, args);
|
||||
this->dynamicsWorld->contactTest(&body, callback);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
ContactSensorCallback callback(*body, effect, args);
|
||||
|
||||
this->dynamicsWorld->contactTest(body, callback);
|
||||
|
||||
delete state;
|
||||
state = NULL;
|
||||
delete shape;
|
||||
shape = NULL;
|
||||
delete body;
|
||||
body = NULL;
|
||||
}
|
||||
|
||||
namespace Oyster
|
||||
|
|
Loading…
Reference in New Issue