diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index 28880eef..1833b436 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -752,6 +752,7 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState player = (this->privData->players)[decoded.objectID]; if( player ) +<<<<<<< HEAD { if( this->privData->myId == decoded.objectID ) { @@ -820,6 +821,76 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState } if( object ) { +======= + { + if( this->privData->myId == decoded.objectID ) + { + // dont delete my player + } + if( player ) + { + player->SetVisible(false); + (this->privData->players)[decoded.objectID].Release(); + } + } + } + return GameClientState::event_processed; + case protocol_Gameplay_ObjectAction: + { + Protocol_ObjectAction decoded(data); + + C_Player *player; + player = (this->privData->players)[decoded.objectID]; + + if( player ) + { + if( this->privData->myId == decoded.objectID ) + { + // my player animation + //} + //else + //{ + // HACK for now animate my char + switch (decoded.animationID) + { + case GameLogic::PlayerAction::PlayerAction_Walk: + player->playAnimation(L"run_forwards", true); + break; + case GameLogic::PlayerAction::PlayerAction_Jump: + player->playAnimation(L"movement", true); + break; + case GameLogic::PlayerAction::PlayerAction_Idle: + player->playAnimation(L"idle", true); + break; + + case GameLogic::WeaponAction::WeaponAction_PrimaryShoot: + break; + case GameLogic::WeaponAction::WeaponAction_SecondaryShoot: + break; + case GameLogic::WeaponAction::WeaponAction_Reload: + break; + + + default: + break; + } + } + } + } + return GameClientState::event_processed; + case protocol_Gameplay_ObjectCollision: + { + Protocol_ObjectCollision decoded(data); + C_Object *object; + object = (this->privData->players)[decoded.objectID]; + if( !object) + { + // if it is not a player + object = (*this->privData->dynamicObjects)[decoded.objectID]; + } + if( object ) + { +>>>>>>> origin/New-inputsystem switch (decoded.collisionID) { case GameLogic::CollisionEvent::CollisionEvent_BasicCollision: diff --git a/Code/Game/GameClient/GameClientState/GamingUI.cpp b/Code/Game/GameClient/GameClientState/GamingUI.cpp index f6b9aa32..74f50c22 100644 --- a/Code/Game/GameClient/GameClientState/GamingUI.cpp +++ b/Code/Game/GameClient/GameClientState/GamingUI.cpp @@ -218,5 +218,8 @@ void GamingUI::OnMouseMoveVelocity ( Input::Struct::SAIPointInt2D coordinate, In } } } +<<<<<<< HEAD +======= +>>>>>>> origin/New-inputsystem diff --git a/Code/Game/GameLogic/GameAPI.h b/Code/Game/GameLogic/GameAPI.h index 80b255bd..503b40ba 100644 --- a/Code/Game/GameLogic/GameAPI.h +++ b/Code/Game/GameLogic/GameAPI.h @@ -30,7 +30,11 @@ namespace GameLogic typedef void(*ObjectEnabledFunction)(IObjectData* object); // Callback method that recieves and object typedef void(*ObjectHpFunction)(IObjectData* object, float hp); // Callback method that sends obj HP typedef void(*ObjectRespawnedFunction)(IObjectData* object, Oyster::Math::Float3 spawnPos ); // Callback method that sends spawnPos +<<<<<<< HEAD typedef void(*ObjectDeadFunction)(IObjectData* victim, IObjectData* killer, float seconds); // Callback method that sends killer and death timer +======= + typedef void(*ObjectDeadFunction)(IObjectData* object, IObjectData* killer, float seconds); // Callback method that sends death timer +>>>>>>> origin/New-inputsystem typedef void(*PickupEventFunction)(IObjectData* player, int pickupEffectID ); // Callback method that sends killer and death timer typedef void(*AnimationEventFunction)(IObjectData* player, int actionID ); // Callback method that sends killer and death timer typedef void(*CollisionEventFunction)(IObjectData*object, int collisionID); diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 34c46461..a6fc12f7 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -54,13 +54,18 @@ void Player::initPlayerData() this->playerStats.hp = MAX_HP; this->playerStats.movementSpeed = BASIC_SPEED; this->playerState = PLAYER_STATE_IDLE; +<<<<<<< HEAD this->lookDir = Float3( 0.0f, 0.0f, -1.0f ); +======= + this->lookDir = Oyster::Math::Float3(0,0,-1); +>>>>>>> origin/New-inputsystem this->key_forward = 0; this->key_backward = 0; this->key_strafeRight = 0; this->key_strafeLeft = 0; this->key_jump = 0; +<<<<<<< HEAD this->RecentlyAffected = 0; this->deathTimer = 0; @@ -70,11 +75,20 @@ void Player::initPlayerData() state.staticFrictionCoeff = 0.0f; state.dynamicFrictionCoeff = 0.0f; this->rigidBody->SetState( state ); +======= + this->deathTimer = 0; + + this->rotationUp = 0; +>>>>>>> origin/New-inputsystem } void Player::BeginFrame() { +<<<<<<< HEAD if( this->playerState != PLAYER_STATE_DEAD && this->playerState != PLAYER_STATE_DIED ) +======= + if( this->playerState != PLAYER_STATE_DEAD && PLAYER_STATE_DIED) +>>>>>>> origin/New-inputsystem { static const Float maxSpeed = 30.0f; @@ -83,7 +97,10 @@ void Player::BeginFrame() // Rotate player accordingly this->rigidBody->AddRotationAroundY(this->rotationUp); this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized()); +<<<<<<< HEAD this->rotationUp = 0; +======= +>>>>>>> origin/New-inputsystem // Direction data Oyster::Math::Float4x4 orientation; @@ -102,10 +119,15 @@ void Player::BeginFrame() Float3 upVelocity = linearVelocity * Float3(fabs(upDir.x), fabs(upDir.y), fabs(upDir.z) ); // Walking data +<<<<<<< HEAD Float3 walkDirection = Float3( 0.0f ); Float &walkSpeed = this->playerStats.movementSpeed; Float frameTime = gameInstance->GetFrameTime(); +======= + Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0); + Oyster::Math::Float walkSpeed = this->playerStats.movementSpeed*0.2f; +>>>>>>> origin/New-inputsystem // Check for input if(key_forward > 0.001) @@ -130,7 +152,11 @@ void Player::BeginFrame() } // Dampen velocity if certain keys are not pressed +<<<<<<< HEAD if( key_jump <= 0.001 && IsWalking() ) +======= + if(key_jump <= 0.001 && IsWalking()) +>>>>>>> origin/New-inputsystem { if(key_forward <= 0.001 && key_backward <= 0.001) { @@ -142,7 +168,21 @@ void Player::BeginFrame() } } +<<<<<<< HEAD if( walkDirection == Float3::null ) +======= + if(walkDirection == Oyster::Math::Float3::null) + { + 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; + } + } + // Walk if walkdirection is something + if(walkDirection != Oyster::Math::Float3::null) +>>>>>>> origin/New-inputsystem { if(this->playerState != PLAYER_STATE::PLAYER_STATE_JUMPING) { @@ -180,7 +220,10 @@ void Player::BeginFrame() rightVelocity += walkDirection*Oyster::Math::Float3(fabs(rightDir.x), fabs(rightDir.y), fabs(rightDir.z)) * walkSpeed*0.2f; } } +<<<<<<< HEAD +======= +>>>>>>> origin/New-inputsystem if(this->playerState != PLAYER_STATE::PLAYER_STATE_JUMPING) { if(this->playerState != PLAYER_STATE::PLAYER_STATE_WALKING) @@ -199,8 +242,13 @@ void Player::BeginFrame() //Jump if(key_jump > 0.001) { +<<<<<<< HEAD this->key_jump -= this->gameInstance->GetFrameTime(); if(IsWalking()) +======= + this->key_jump -= this->gameInstance->GetFrameTime(); + if(IsWalking()) +>>>>>>> origin/New-inputsystem { Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.GetNormalized(); this->rigidBody->ApplyImpulse(up*this->rigidBody->GetState().mass * 20); @@ -221,9 +269,13 @@ void Player::BeginFrame() } } +<<<<<<< HEAD void Player::EndFrame() { } +======= +void Player::EndFrame() { /* do nothing .. for now */ } +>>>>>>> origin/New-inputsystem void Player::Move(const PLAYER_MOVEMENT &movement) { @@ -292,7 +344,7 @@ void Player::SetLookDir(const Oyster::Math3D::Float3& lookDir) } void Player::TurnLeft(Oyster::Math3D::Float deltaRadians) { - this->rotationUp += deltaRadians; + this->rotationUp = deltaRadians; } void Player::Jump() @@ -347,6 +399,7 @@ PLAYER_STATE Player::GetState() const void Player::DamageLife(int damage) { +<<<<<<< HEAD if(damage != 0) { this->playerStats.hp -= damage; @@ -362,7 +415,33 @@ void Player::DamageLife(int damage) this->playerStats.hp = 0; this->playerState = PLAYER_STATE_DIED; } +======= + this->playerStats.hp -= damage; + // send hp to client + this->gameInstance->onDamageTakenFnc( this, this->playerStats.hp); + + if(this->playerStats.hp <= 0) + { + this->playerStats.hp = 0; + this->playerState = PLAYER_STATE_DIED; } + +} + +bool Player::deathTimerTick(float dt) +{ + this->deathTimer -= dt; + if( this->deathTimer <= 0) + { + return true; +>>>>>>> origin/New-inputsystem + } + return false; +} +void Player::setDeathTimer(float deathTimer) +{ + this->deathTimer = deathTimer; + this->playerState = PLAYER_STATE_DEAD; } bool Player::deathTimerTick(float dt) diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index e6e755c6..0b96166f 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -10,7 +10,11 @@ #include "DynamicArray.h" const float MAX_HP = 100.0f; +<<<<<<< HEAD const float BASIC_SPEED = 30.0f;// * 0.2f; +======= +const float BASIC_SPEED = 30.0f; +>>>>>>> origin/New-inputsystem namespace GameLogic { diff --git a/Code/Game/GameServer/GameSession.h b/Code/Game/GameServer/GameSession.h index d449ff2d..583e92b3 100644 --- a/Code/Game/GameServer/GameSession.h +++ b/Code/Game/GameServer/GameSession.h @@ -102,7 +102,11 @@ namespace DanBias static void ObjectEnabled ( GameLogic::IObjectData* movedObject ); static void ObjectDamaged ( GameLogic::IObjectData* movedObject, float hp ); static void ObjectRespawned ( GameLogic::IObjectData* movedObject, Oyster::Math::Float3 spawnPos ); +<<<<<<< HEAD static void ObjectDead ( GameLogic::IObjectData* victim, GameLogic::IObjectData* killer, float seconds ); +======= + static void ObjectDead ( GameLogic::IObjectData* movedObject, GameLogic::IObjectData* killer, float seconds ); +>>>>>>> origin/New-inputsystem static void PickupEvent ( GameLogic::IObjectData* movedObject, int pickupEffectID ); static void ActionEvent ( GameLogic::IObjectData* movedObject , int actionID ); static void CollisionEvent ( GameLogic::IObjectData* Object , int collisionID ); diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index 18e2b224..7ac4f157 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -162,7 +162,11 @@ using namespace DanBias; { GameSession::gameSession->Send(Protocol_ObjectRespawn(movedObject->GetID(), spawnPos).GetProtocol()); } +<<<<<<< HEAD void GameSession::ObjectDead( GameLogic::IObjectData* victim, GameLogic::IObjectData* killer, float seconds ) +======= + void GameSession::ObjectDead( GameLogic::IObjectData* movedObject, GameLogic::IObjectData* killer, float seconds ) +>>>>>>> origin/New-inputsystem { GameSession::gameSession->Send(Protocol_ObjectDie(victim->GetID(), killer->GetID(), seconds).GetProtocol()); } @@ -181,6 +185,21 @@ using namespace DanBias; // send action protocol GameSession::gameSession->Send(Protocol_ObjectCollision(movedObject->GetID(), collisionID).GetProtocol()); } + void GameSession::PickupEvent( GameLogic::IObjectData* movedObject, int pickupEffectID ) + { + // send pickup protocol + GameSession::gameSession->Send(Protocol_ObjectPickup(movedObject->GetID(), pickupEffectID).GetProtocol()); + } + void GameSession::ActionEvent( GameLogic::IObjectData* movedObject , int actionID ) + { + // send action protocol + GameSession::gameSession->Send(Protocol_ObjectAction(movedObject->GetID(), actionID).GetProtocol()); + } + void GameSession::CollisionEvent( GameLogic::IObjectData* movedObject , int collisionID ) + { + // send action protocol + GameSession::gameSession->Send(Protocol_ObjectCollision(movedObject->GetID(), collisionID).GetProtocol()); + } //*****************************************************// //****************** Protocol methods *****************// //******************************************************************************************************************// diff --git a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp index 7a8665a1..4587d36d 100644 --- a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp +++ b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp @@ -239,6 +239,7 @@ void SimpleRigidBody::SetUp(::Oyster::Math::Float3 up) btQuaternion newRotation; btTransform trans; trans = this->rigidBody->getWorldTransform(); +<<<<<<< HEAD btVector3 v1 = trans.getBasis().getColumn(1); btVector3 v2(up.x, up.y, up.z); @@ -247,17 +248,35 @@ void SimpleRigidBody::SetUp(::Oyster::Math::Float3 up) btVector3 a = v1.cross(v2); if (v1.dot(v2) < -0.999999) +======= + + btVector3 v1 = trans.getBasis().getColumn(1); + btVector3 v2(up.x, up.y, up.z); + + btQuaternion q; + btVector3 a = v1.cross(v2); + + if (v1.dot(v2) < -0.999999) +>>>>>>> origin/New-inputsystem { btVector3 xCrossPre = btVector3(1, 0 ,0).cross(v1); if(xCrossPre.length() < 0.000001) xCrossPre = btVector3(0, 1 ,0).cross(v1); xCrossPre.normalize(); q.setRotation(xCrossPre, 3.1415); +<<<<<<< HEAD } else if (v1.dot(v2) > 0.999999) { q = btQuaternion(0, 0, 0, 1); } +======= + } + else if (v1.dot(v2) > 0.999999) + { + q = btQuaternion(0, 0, 0, 1); + } +>>>>>>> origin/New-inputsystem else { q.setX(a.x()); diff --git a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.h b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.h index 3e478524..b8157be6 100644 --- a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.h +++ b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.h @@ -29,7 +29,11 @@ namespace Oyster void SetRotation(Math::Quaternion quaternion); void SetRotation(Math::Float3 eulerAngles); void SetRotation(::Oyster::Math::Float4x4 rotation); +<<<<<<< HEAD void AddRotationAroundY(::Oyster::Math::Float angle); +======= + void AddRotationAroundY(Math::Float angle); +>>>>>>> origin/New-inputsystem void SetAngularFactor(Math::Float factor); void SetMass(Math::Float mass);