GL - merge stuff
This commit is contained in:
parent
7d7d475499
commit
977920b360
|
@ -255,16 +255,18 @@ using namespace GameLogic;
|
|||
{
|
||||
//realobjA is the affectedObject, transfer this to realobjB
|
||||
realObjB->SetAffectedBy(*realObjA->getAffectingPlayer());
|
||||
return;
|
||||
|
||||
}
|
||||
if(realObjB->getAffectingPlayer() != NULL && realObjA->getAffectingPlayer() == NULL)
|
||||
{
|
||||
//realobjB is the affectedObject, transfer this to realobjA
|
||||
realObjA->SetAffectedBy(*realObjB->getAffectingPlayer());
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(realObjA->getAffectingPlayer() != NULL && realObjB->getAffectingPlayer() != NULL)
|
||||
if(realObjA->getAffectingPlayer() != NULL && realObjB->getAffectingPlayer() != NULL && ( realObjA->getAffectingPlayer()->GetID() != realObjB->getAffectingPlayer()->GetID()))
|
||||
{
|
||||
//Both objects have a player affecting them, now use the special case
|
||||
if(realObjA->GetRigidBody()->GetState().previousVelocity.GetMagnitude() > realObjB->GetRigidBody()->GetState().previousVelocity.GetMagnitude() )
|
||||
|
|
|
@ -90,11 +90,6 @@ void DynamicObject::Activate()
|
|||
void DynamicObject::SetAffectedBy(Player &player)
|
||||
{
|
||||
this->affectedBy = &player;
|
||||
if(this->type != ObjectSpecialType::ObjectSpecialType_Player) //should not add itself to its own list if its a player
|
||||
{
|
||||
player.AddAffectedObject(*this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Player* DynamicObject::getAffectingPlayer()
|
||||
|
|
|
@ -369,10 +369,15 @@ void Level::RespawnPlayer(Player *player)
|
|||
void Level::Update(float deltaTime)
|
||||
{
|
||||
// update lvl-things
|
||||
|
||||
|
||||
for(int i = 0; i < (int)this->playerObjects.Size(); i++)
|
||||
{
|
||||
if(this->playerObjects[i])
|
||||
if(this->playerObjects[i]->getAffectingPlayer() != NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (this->playerObjects[i]->GetState() == PLAYER_STATE::PLAYER_STATE_DEAD)
|
||||
{
|
||||
// true when timer reaches 0
|
||||
|
@ -383,9 +388,40 @@ void Level::Update(float deltaTime)
|
|||
{
|
||||
this->playerObjects[i]->setDeathTimer(DEATH_TIMER);
|
||||
// HACK to avoid crasch. affected by tag is NULL
|
||||
//((Game*)&Game::Instance())->onDeadFnc(this->playerObjects[i], this->playerObjects[i], DEATH_TIMER); // add killer ID
|
||||
Player* killer = this->playerObjects[i]->getAffectingPlayer();
|
||||
((Game*)&Game::Instance())->onDeadFnc(this->playerObjects[i], this->playerObjects[i], DEATH_TIMER); // add killer ID
|
||||
//((Game*)&Game::Instance())->onDeadFnc(this->playerObjects[i], this->playerObjects[i]->getAffectingPlayer(), DEATH_TIMER); // add killer ID
|
||||
if(!killer) //if there is no killer then you commited suicide
|
||||
{
|
||||
killer = this->playerObjects[i];
|
||||
}
|
||||
((Game*)&Game::Instance())->onDeadFnc(this->playerObjects[i], killer, DEATH_TIMER); // add killer ID
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < dynamicObjects.Size(); i++)
|
||||
{
|
||||
if(dynamicObjects[i]->getAffectingPlayer() != NULL)
|
||||
{
|
||||
Oyster::Math::Float vel = dynamicObjects[i]->GetRigidBody()->GetLinearVelocity().GetMagnitude();
|
||||
|
||||
if(vel <= 0.1f) // is bearly moving
|
||||
{
|
||||
//set the tag AffectedBy to NULL
|
||||
dynamicObjects[i]->RemoveAffectedBy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < playerObjects.Size(); i++)
|
||||
{
|
||||
if(playerObjects[i]->getAffectingPlayer() != NULL)
|
||||
{
|
||||
Oyster::Math::Float vel = playerObjects[i]->GetRigidBody()->GetLinearVelocity().GetMagnitude();
|
||||
|
||||
if(vel <= 0.1f) // is bearly moving
|
||||
{
|
||||
//set the tag AffectedBy to NULL
|
||||
playerObjects[i]->RemoveAffectedBy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@ using namespace GameLogic;
|
|||
using namespace Oyster::Physics;
|
||||
const float MOVE_FORCE = 30;
|
||||
const float KEY_TIMER = 0.03f;
|
||||
const float AFFECTED_TIMER = 1.0f;
|
||||
Player::Player()
|
||||
:DynamicObject()
|
||||
{
|
||||
Player::initPlayerData();
|
||||
AffectedObjects.Reserve(15);
|
||||
this->weapon = NULL;
|
||||
this->teamID = -1;
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)
|
|||
{
|
||||
this->weapon = new Weapon(2,this);
|
||||
Player::initPlayerData();
|
||||
AffectedObjects.Reserve(15);
|
||||
this->teamID = teamID;
|
||||
}
|
||||
|
||||
|
@ -31,7 +30,6 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustom
|
|||
{
|
||||
this->weapon = new Weapon(2,this);
|
||||
Player::initPlayerData();
|
||||
AffectedObjects.Reserve(15);
|
||||
this->teamID = teamID;
|
||||
}
|
||||
|
||||
|
@ -57,7 +55,7 @@ void Player::initPlayerData()
|
|||
this->key_strafeRight = 0;
|
||||
this->key_strafeLeft = 0;
|
||||
this->key_jump = 0;
|
||||
this->invincibleCooldown = 0;
|
||||
this->RecentlyAffected = 0;
|
||||
this->deathTimer = 0;
|
||||
|
||||
this->rotationUp = 0;
|
||||
|
@ -69,6 +67,9 @@ void Player::BeginFrame()
|
|||
{
|
||||
weapon->Update(0.002f);
|
||||
|
||||
|
||||
|
||||
|
||||
Oyster::Math::Float maxSpeed = 30;
|
||||
|
||||
// Rotate player accordingly
|
||||
|
@ -217,16 +218,6 @@ void Player::BeginFrame()
|
|||
|
||||
void Player::EndFrame()
|
||||
{
|
||||
//check if there are any objects that can be removed from the AffectedObjects list
|
||||
for(int i = 0; i < this->AffectedObjects.Size(); i++)
|
||||
{
|
||||
if(this->AffectedObjects[i] && (this->AffectedObjects[i]->GetRigidBody()->GetState().previousVelocity).GetMagnitude() <= 0.1f)
|
||||
{
|
||||
this->AffectedObjects[i]->RemoveAffectedBy();
|
||||
this->AffectedObjects.Remove(i);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Player::Move(const PLAYER_MOVEMENT &movement)
|
||||
|
@ -363,20 +354,6 @@ void Player::DamageLife(int damage)
|
|||
}
|
||||
}
|
||||
|
||||
void Player::AddAffectedObject(DynamicObject &AffectedObject)
|
||||
{
|
||||
//check if object already exists in the list, if so then do not add
|
||||
for(int i = 0; i < AffectedObjects.Size(); i++)
|
||||
{
|
||||
if(AffectedObjects[i]->GetID() == AffectedObject.GetID())
|
||||
{
|
||||
//object already exists, exit function
|
||||
return;
|
||||
}
|
||||
}
|
||||
//else you add the object to the stack
|
||||
AffectedObjects.Push(&AffectedObject);
|
||||
}
|
||||
bool Player::deathTimerTick(float dt)
|
||||
{
|
||||
this->deathTimer -= dt;
|
||||
|
|
|
@ -68,8 +68,6 @@ namespace GameLogic
|
|||
|
||||
void TurnLeft(Oyster::Math3D::Float deltaRadians);
|
||||
|
||||
void AddAffectedObject(DynamicObject &AffectedObject);
|
||||
|
||||
/********************************************************
|
||||
* Collision function for player, this is to be sent to physics through the subscribe function with the rigidbody
|
||||
* Will be called when the physics detect a collision
|
||||
|
@ -90,6 +88,7 @@ namespace GameLogic
|
|||
Oyster::Math::Float4x4 GetOrientation() const;
|
||||
int GetTeamID() const;
|
||||
PLAYER_STATE GetState() const;
|
||||
Oyster::Math::Float GetRecentlyAffected();
|
||||
|
||||
void DamageLife(int damage);
|
||||
void setDeathTimer(float deathTimer);
|
||||
|
@ -99,14 +98,11 @@ namespace GameLogic
|
|||
void EndFrame();
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||
|
||||
|
||||
private:
|
||||
void Jump();
|
||||
void initPlayerData();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
int teamID;
|
||||
Weapon *weapon;
|
||||
PLAYER_STATE playerState;
|
||||
|
@ -123,7 +119,7 @@ namespace GameLogic
|
|||
float deathTimer;
|
||||
|
||||
bool hasTakenDamage;
|
||||
float invincibleCooldown;
|
||||
Oyster::Math::Float RecentlyAffected;
|
||||
PlayerStats playerStats;
|
||||
PlayerScore playerScore;
|
||||
|
||||
|
|
Loading…
Reference in New Issue