From 97ea35e91e33084b4ad3a19ab4df26961cd7edf5 Mon Sep 17 00:00:00 2001 From: Linda Andersson Date: Thu, 27 Feb 2014 14:11:03 +0100 Subject: [PATCH 1/3] Fixing player animation updates --- Code/Game/GameLogic/Player.cpp | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 209287a8..9cd4635e 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -71,9 +71,6 @@ void Player::BeginFrame() { weapon->Update(0.002f); - - - Oyster::Math::Float maxSpeed = 30; // Rotate player accordingly @@ -137,15 +134,11 @@ void Player::BeginFrame() rightVelocity *= Oyster::Math::Float3(0.2f*fabs(rightDir.x), 0.2f*fabs(rightDir.y), 0.2f*fabs(rightDir.z)); } } - - if(walkDirection == Oyster::Math::Float3::null) + if(IsIdle()) { - if(this->playerState != PLAYER_STATE::PLAYER_STATE_JUMPING) - { - if(this->playerState != PLAYER_STATE::PLAYER_STATE_IDLE) - this->gameInstance->onActionEventFnc( this, PlayerAction::PlayerAction_Idle); - this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; - } + if(this->playerState != PLAYER_STATE::PLAYER_STATE_IDLE) + this->gameInstance->onActionEventFnc( this, PlayerAction::PlayerAction_Idle); + this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; } // Walk if walkdirection is something if(walkDirection != Oyster::Math::Float3::null) @@ -176,12 +169,13 @@ void Player::BeginFrame() rightVelocity += walkDirection*Oyster::Math::Float3(fabs(rightDir.x), fabs(rightDir.y), fabs(rightDir.z)) * walkSpeed*0.2f; } } - if(this->playerState != PLAYER_STATE::PLAYER_STATE_JUMPING) - { + // TODO not suer if we want to keep jump animation while jumping + //if(this->playerState != PLAYER_STATE::PLAYER_STATE_JUMPING) + //{ if(this->playerState != PLAYER_STATE::PLAYER_STATE_WALKING) this->gameInstance->onActionEventFnc( this, PlayerAction::PlayerAction_Walk); this->playerState = PLAYER_STATE::PLAYER_STATE_WALKING; - } + //} } // Adjust velocities so no squaring occurs @@ -205,14 +199,6 @@ void Player::BeginFrame() this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING; } } - else - { - if(this->playerState == PLAYER_STATE::PLAYER_STATE_JUMPING) - { - this->gameInstance->onActionEventFnc( this, PlayerAction::PlayerAction_Idle); - this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; - } - } } } @@ -305,7 +291,7 @@ bool Player::IsJumping() } bool Player::IsIdle() { - return (this->rigidBody->GetLambdaUp() == 1.0f && this->rigidBody->GetLinearVelocity().GetMagnitude() < 0.0001f); + return (this->rigidBody->GetLambdaUp() < 1.0f && this->rigidBody->GetLinearVelocity().GetMagnitude() < 0.1f); } void Player::Inactivate() From 2592e4d3e3d28e50858165028aa64d06a2d9f1d3 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Thu, 27 Feb 2014 14:36:15 +0100 Subject: [PATCH 2/3] Picked box should be dropped when impacted by any dynamic object --- Code/Game/GameLogic/CollisionManager.cpp | 13 ++++++++++++- Code/Game/GameLogic/GameLogicStates.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index fd5f372a..f8669591 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -242,6 +242,18 @@ using namespace GameLogic; 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. 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->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 - break; } diff --git a/Code/Game/GameLogic/GameLogicStates.h b/Code/Game/GameLogic/GameLogicStates.h index f006ad27..5f3952fd 100644 --- a/Code/Game/GameLogic/GameLogicStates.h +++ b/Code/Game/GameLogic/GameLogicStates.h @@ -32,6 +32,7 @@ namespace GameLogic WEAPON_USE_SECONDARY_RELEASE = 4, WEAPON_USE_UTILLITY_PRESS = 8, WEAPON_USE_UTILLITY_RELEASE = 16, + WEAPON_INTERRUPT = 32 }; enum WEAPON_STATE From 36761a83142f4a9d603e58b75d503bf97428dc25 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Thu, 27 Feb 2014 14:37:15 +0100 Subject: [PATCH 3/3] OnDynamicCollision drop box .. missed a file in commit --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index 6abe81b6..4e584a44 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -43,7 +43,7 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, //switch case to determin what functionallity to use in the attatchment switch (usage) { - case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS: + case WEAPON_USE_PRIMARY_PRESS: //if(currentEnergy >= 9.0f) { currentEnergy -= 9.0f; @@ -51,23 +51,24 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, // add CD ((Game*)&Game::Instance())->onActionEventFnc(this->owner, WeaponAction::WeaponAction_PrimaryShoot); } - break; + break; - case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS: + case WEAPON_USE_SECONDARY_PRESS: if(this->hasObject) { - ((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation(); - this->hasObject = false; - this->heldObject = NULL; + goto CASE_WEAPON_INTERRUPT; } else if( currentEnergy >= 1.0f ) { - currentEnergy -= 1.0f; - if(!this->hasObject) + if(this->hasObject) { - ForcePull(usage,dt); - // add CD - ((Game*)&Game::Instance())->onActionEventFnc(this->owner, WeaponAction::WeaponAction_SecondaryShoot); + 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 @@ -76,20 +77,27 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, this->hasObject = false; this->heldObject = NULL; } - 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: - { - if (this->hasObject) //Dummy check { - //((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation(); - //this->hasObject = false; - //this->heldObject = NULL; + if (this->hasObject) //Dummy check + { + //((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation(); + //this->hasObject = false; + //this->heldObject = NULL; + } } - } - break; + break; - case WEAPON_FIRE::WEAPON_USE_UTILLITY_PRESS: + case WEAPON_USE_UTILLITY_PRESS: if(currentEnergy >= 90.0f) { currentEnergy -= 90.0f; @@ -97,9 +105,8 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, // add CD ((Game*)&Game::Instance())->onActionEventFnc(this->owner, WeaponAction::WeaponAction_UtilityActivate); } - break; + break; } - } void AttatchmentMassDriver::Update(float dt)