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

This commit is contained in:
Linda Andersson 2014-02-27 14:58:30 +01:00
commit d145853d34
6 changed files with 152 additions and 23 deletions

View File

@ -0,0 +1,71 @@
#include "AttatchmentGun.h"
#include "PhysicsAPI.h"
#include "GameLogicStates.h"
#include "Game.h"
using namespace GameLogic;
AttatchmentGun::AttatchmentGun(void)
{
this->owner = 0;
this->damage = 0.0f;
}
AttatchmentGun::AttatchmentGun(Player &owner)
{
this->owner = &owner;
this->damage = standardDamage;
}
AttatchmentGun::~AttatchmentGun(void)
{
}
/********************************************************
* Uses the attatchment and will from here switch case the different WEAPON_FIRE's that are to be used
********************************************************/
void AttatchmentGun::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, float dt)
{
//switch case to determin what functionallity to use in the attatchment
switch (usage)
{
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
//skjut här
break;
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
break;
case WEAPON_USE_SECONDARY_RELEASE:
break;
case WEAPON_FIRE::WEAPON_USE_UTILLITY_PRESS:
break;
}
}
void AttatchmentGun::Update(float dt)
{
}
void AttatchmentGun::ShootBullet(const WEAPON_FIRE &usage, float dt)
{
Oyster::Collision3D::Ray *hitRay;
Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos;
Oyster::Math::Float3 look = owner->GetLookDir().GetNormalized();
Oyster::Math::Float hitDamage = this->damage;
firedBullet bullet;
bullet.hitDamage = hitDamage;
hitRay = new Oyster::Collision3D::Ray(pos,look);
}

View File

@ -0,0 +1,33 @@
//////////////////////////////////////////////////
//Created by Erik of the GameLogic team
//////////////////////////////////////////////////
#ifndef ATTATCHMENTGUN_H
#define ATTATCHMENTGUN_H
#include "IAttatchment.h"
namespace GameLogic
{
const Oyster::Math::Float standardDamage = 10;
class AttatchmentGun : public IAttatchment
{
public:
AttatchmentGun(void);
AttatchmentGun(Player &owner);
~AttatchmentGun(void);
void UseAttatchment(const WEAPON_FIRE &usage, float dt);
void Update(float dt);
private:
Oyster::Math::Float damage;
private:
void ShootBullet(const WEAPON_FIRE &usage, float dt);
};
}
#endif

View File

@ -45,7 +45,7 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
//switch case to determin what functionallity to use in the attatchment //switch case to determin what functionallity to use in the attatchment
switch (usage) switch (usage)
{ {
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS: case WEAPON_USE_PRIMARY_PRESS:
//if(currentEnergy >= 9.0f) //if(currentEnergy >= 9.0f)
{ {
currentEnergy -= 9.0f; currentEnergy -= 9.0f;
@ -55,14 +55,14 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
} }
break; break;
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS: case WEAPON_USE_SECONDARY_PRESS:
if(this->hasObject) if(this->hasObject)
{ {
((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation(); goto CASE_WEAPON_INTERRUPT;
this->hasObject = false;
this->heldObject = NULL;
} }
else if( currentEnergy >= 1.0f ) else if( currentEnergy >= 1.0f )
{
if(this->hasObject)
{ {
currentEnergy -= 1.0f; currentEnergy -= 1.0f;
if(!this->hasObject) if(!this->hasObject)
@ -72,6 +72,7 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
((Game*)&Game::Instance())->onActionEventFnc(this->owner, WeaponAction::WeaponAction_SecondaryShoot); ((Game*)&Game::Instance())->onActionEventFnc(this->owner, WeaponAction::WeaponAction_SecondaryShoot);
} }
} }
}
else //Energy drained, release object else //Energy drained, release object
{ {
((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation(); ((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation();
@ -80,6 +81,13 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
} }
break; break;
case WEAPON_INTERRUPT:
CASE_WEAPON_INTERRUPT:
((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation();
this->hasObject = false;
this->heldObject = NULL;
break;
case WEAPON_USE_SECONDARY_RELEASE: case WEAPON_USE_SECONDARY_RELEASE:
{ {
if (this->hasObject) //Dummy check if (this->hasObject) //Dummy check
@ -91,7 +99,7 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
} }
break; break;
case WEAPON_FIRE::WEAPON_USE_UTILLITY_PRESS: case WEAPON_USE_UTILLITY_PRESS:
if(currentEnergy >= 90.0f) if(currentEnergy >= 90.0f)
{ {
currentEnergy -= 90.0f; currentEnergy -= 90.0f;
@ -101,7 +109,6 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
} }
break; break;
} }
} }
void AttatchmentMassDriver::Update(float dt) void AttatchmentMassDriver::Update(float dt)

View File

@ -242,6 +242,18 @@ using namespace GameLogic;
return; return;
} }
Player *player = realObjA->getManipulatingPlayer();
if( player != nullptr )
{
player->UseWeapon( WEAPON_INTERRUPT );
}
player = realObjB->getManipulatingPlayer();
if( player != nullptr )
{
player->UseWeapon( WEAPON_INTERRUPT );
}
//check which obj is the one that is already affected, if both are then use the special case of changing ownership. //check which obj is the one that is already affected, if both are then use the special case of changing ownership.
if(realObjA->getAffectingPlayer() == NULL && realObjB->getAffectingPlayer() == NULL) //None of the objects have a player affecting them if(realObjA->getAffectingPlayer() == NULL && realObjB->getAffectingPlayer() == NULL) //None of the objects have a player affecting them
{ {
@ -350,7 +362,6 @@ using namespace GameLogic;
weapon->heldObject = obj; //weapon now holds the object weapon->heldObject = obj; //weapon now holds the object
weapon->hasObject = true; weapon->hasObject = true;
dynamicObj->SetManipulatingPlayer(*weapon->owner); //TODO: add if this is to be a struggle of who has the most power in its weapon, the player that is already manipulating the object or you. if you then you take the object from the other player, if not then you do not take the object dynamicObj->SetManipulatingPlayer(*weapon->owner); //TODO: add if this is to be a struggle of who has the most power in its weapon, the player that is already manipulating the object or you. if you then you take the object from the other player, if not then you do not take the object
break; break;
} }

View File

@ -159,6 +159,7 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="AttatchmentGun.h" />
<ClInclude Include="AttatchmentMassDriver.h" /> <ClInclude Include="AttatchmentMassDriver.h" />
<ClInclude Include="AttatchmentSocket.h" /> <ClInclude Include="AttatchmentSocket.h" />
<ClInclude Include="CollisionManager.h" /> <ClInclude Include="CollisionManager.h" />
@ -185,6 +186,7 @@
<ClInclude Include="Weapon.h" /> <ClInclude Include="Weapon.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="AttatchmentGun.cpp" />
<ClCompile Include="AttatchmentMassDriver.cpp" /> <ClCompile Include="AttatchmentMassDriver.cpp" />
<ClCompile Include="AttatchmentSocket.cpp" /> <ClCompile Include="AttatchmentSocket.cpp" />
<ClCompile Include="CollisionManager.cpp" /> <ClCompile Include="CollisionManager.cpp" />

View File

@ -32,6 +32,7 @@ namespace GameLogic
WEAPON_USE_SECONDARY_RELEASE = 4, WEAPON_USE_SECONDARY_RELEASE = 4,
WEAPON_USE_UTILLITY_PRESS = 8, WEAPON_USE_UTILLITY_PRESS = 8,
WEAPON_USE_UTILLITY_RELEASE = 16, WEAPON_USE_UTILLITY_RELEASE = 16,
WEAPON_INTERRUPT = 32
}; };
enum WEAPON_STATE enum WEAPON_STATE
@ -46,6 +47,10 @@ namespace GameLogic
Oyster::Math::Float3 pushForce; Oyster::Math::Float3 pushForce;
Player *p; Player *p;
}; };
struct firedBullet
{
Oyster::Math::Float hitDamage;
};