Play action animation
This commit is contained in:
parent
9a449253c2
commit
d91fa3073f
|
@ -123,7 +123,10 @@ void C_Object::SetGlowTint(Oyster::Math::Float3 tint)
|
||||||
model->GlowTint = tint;
|
model->GlowTint = tint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void C_Object::SetVisible(bool visible)
|
||||||
|
{
|
||||||
|
model->Visible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
// RB DEBUG
|
// RB DEBUG
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace DanBias
|
||||||
|
|
||||||
void SetTint(Oyster::Math::Float3);
|
void SetTint(Oyster::Math::Float3);
|
||||||
void SetGlowTint(Oyster::Math::Float3);
|
void SetGlowTint(Oyster::Math::Float3);
|
||||||
|
void SetVisible(bool visible);
|
||||||
|
|
||||||
// RB DEBUG
|
// RB DEBUG
|
||||||
void updateRBWorld();
|
void updateRBWorld();
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "GamingUI.h"
|
#include "GamingUI.h"
|
||||||
#include "RespawnUI.h"
|
#include "RespawnUI.h"
|
||||||
#include "StatsUI.h"
|
#include "StatsUI.h"
|
||||||
|
#include <ObjectDefines.h>
|
||||||
|
|
||||||
using namespace ::DanBias::Client;
|
using namespace ::DanBias::Client;
|
||||||
using namespace ::Oyster;
|
using namespace ::Oyster;
|
||||||
|
@ -135,7 +136,7 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
|
||||||
p->InitRB( RBData );
|
p->InitRB( RBData );
|
||||||
// !RB DEBUG
|
// !RB DEBUG
|
||||||
// start with runing animation
|
// start with runing animation
|
||||||
p->playAnimation( L"run_forwards", true );
|
p->playAnimation( L"idle", true );
|
||||||
|
|
||||||
(this->privData->players)[id] = p;
|
(this->privData->players)[id] = p;
|
||||||
|
|
||||||
|
@ -425,18 +426,62 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
|
|
||||||
switch(ID)
|
switch(ID)
|
||||||
{
|
{
|
||||||
case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectPickup:
|
||||||
|
{
|
||||||
|
Protocol_ObjectPickup decoded(data);
|
||||||
|
decoded.object_ID;
|
||||||
|
C_Object *object;
|
||||||
|
object = (this->privData->players)[decoded.object_ID];
|
||||||
|
if( !object)
|
||||||
|
{
|
||||||
|
// if it is not a player
|
||||||
|
object = (*this->privData->dynamicObjects)[decoded.object_ID];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( object )
|
||||||
|
{
|
||||||
|
if( this->privData->myId == decoded.object_ID )
|
||||||
|
{
|
||||||
|
// I picked up the pickUp!
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decoded.pickup_ID == GameLogic::PickupType::PickupType_Health)
|
||||||
|
{
|
||||||
|
// object->PickupHealth();
|
||||||
|
}
|
||||||
|
else if (decoded.pickup_ID == GameLogic::PickupType::PickupType_SpeedBoost)
|
||||||
|
{
|
||||||
|
// object->PickupSpeed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
decoded.pickup_ID;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectDamage:
|
case protocol_Gameplay_ObjectDamage:
|
||||||
{
|
{
|
||||||
Protocol_ObjectDamage decoded(data);
|
Protocol_ObjectDamage decoded(data);
|
||||||
|
C_Object *object;
|
||||||
|
object = (this->privData->players)[decoded.object_ID];
|
||||||
|
if( !object)
|
||||||
|
{
|
||||||
|
// if it is not a player
|
||||||
|
object = (*this->privData->dynamicObjects)[decoded.object_ID];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( object )
|
||||||
|
{
|
||||||
if( this->privData->myId == decoded.object_ID )
|
if( this->privData->myId == decoded.object_ID )
|
||||||
{
|
{
|
||||||
if(currGameUI == gameUI)
|
if(currGameUI == gameUI)
|
||||||
{
|
{
|
||||||
|
// set my HP
|
||||||
((GamingUI*)currGameUI)->SetHPtext(std::to_wstring(decoded.healthLost));
|
((GamingUI*)currGameUI)->SetHPtext(std::to_wstring(decoded.healthLost));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return GameClientState::event_processed;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectHealthStatus:
|
case protocol_Gameplay_ObjectHealthStatus:
|
||||||
{
|
{
|
||||||
|
@ -446,39 +491,73 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
{
|
{
|
||||||
Protocol_ObjectPosition decoded(data);
|
Protocol_ObjectPosition decoded(data);
|
||||||
|
|
||||||
// if is this player. Remember to change camera
|
C_Object *object;
|
||||||
if( this->privData->myId == decoded.object_ID )
|
object = (this->privData->players)[decoded.object_ID];
|
||||||
this->privData->camera.SetPosition( decoded.position );
|
if( !object)
|
||||||
|
{
|
||||||
|
// if it is not a player
|
||||||
|
object = (*this->privData->dynamicObjects)[decoded.object_ID];
|
||||||
|
}
|
||||||
|
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setPos( decoded.position );
|
if( object )
|
||||||
|
{
|
||||||
|
if( this->privData->myId == decoded.object_ID )
|
||||||
|
{
|
||||||
|
this->privData->camera.SetPosition( decoded.position );
|
||||||
|
}
|
||||||
|
|
||||||
|
object->setPos( decoded.position );
|
||||||
// RB DEBUG
|
// RB DEBUG
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBPos ( decoded.position );
|
object->setRBPos ( decoded.position );
|
||||||
// !RB DEBUG
|
// !RB DEBUG
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return GameClientState::event_processed;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectScale:
|
case protocol_Gameplay_ObjectScale:
|
||||||
{
|
{
|
||||||
Protocol_ObjectScale decoded(data);
|
Protocol_ObjectScale decoded(data);
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setScale( decoded.scale );
|
C_Object *object;
|
||||||
|
object = (this->privData->players)[decoded.object_ID];
|
||||||
|
if( !object)
|
||||||
|
{
|
||||||
|
// if it is not a player
|
||||||
|
object = (*this->privData->dynamicObjects)[decoded.object_ID];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( object )
|
||||||
|
{
|
||||||
|
object->setScale( decoded.scale );
|
||||||
// RB DEBUG
|
// RB DEBUG
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBScale ( decoded.scale );
|
object->setRBScale ( decoded.scale );
|
||||||
// !RB DEBUG
|
// !RB DEBUG
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return GameClientState::event_processed;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectRotation:
|
case protocol_Gameplay_ObjectRotation:
|
||||||
{
|
{
|
||||||
Protocol_ObjectRotation decoded(data);
|
Protocol_ObjectRotation decoded(data);
|
||||||
Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
|
Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
|
||||||
|
C_Object *object;
|
||||||
|
object = (this->privData->players)[decoded.object_ID];
|
||||||
|
if( !object)
|
||||||
|
{
|
||||||
|
// if it is not a player
|
||||||
|
object = (*this->privData->dynamicObjects)[decoded.object_ID];
|
||||||
|
}
|
||||||
|
|
||||||
// if is this player. Remember to change camera
|
if( object )
|
||||||
|
{
|
||||||
if( this->privData->myId == decoded.object_ID )
|
if( this->privData->myId == decoded.object_ID )
|
||||||
|
{
|
||||||
this->privData->camera.SetRotation( rotation );
|
this->privData->camera.SetRotation( rotation );
|
||||||
|
}
|
||||||
|
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRot( rotation );
|
object->setRot( rotation );
|
||||||
// RB DEBUG
|
// RB DEBUG
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBRot ( rotation );
|
object->setRBRot( rotation );
|
||||||
// !RB DEBUG
|
// !RB DEBUG
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return GameClientState::event_processed;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectPositionRotation:
|
case protocol_Gameplay_ObjectPositionRotation:
|
||||||
{
|
{
|
||||||
|
@ -511,17 +590,46 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GameClientState::event_processed;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectEnabled: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectEnabled:
|
||||||
|
{
|
||||||
|
Protocol_ObjectEnable 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 )
|
||||||
|
{
|
||||||
|
object->SetVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectDisabled:
|
case protocol_Gameplay_ObjectDisabled:
|
||||||
{
|
{
|
||||||
Protocol_ObjectDisable decoded(data);
|
Protocol_ObjectDisable 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];
|
||||||
|
}
|
||||||
|
|
||||||
auto object = this->privData->dynamicObjects->find( decoded.objectID );
|
if( object )
|
||||||
|
{
|
||||||
|
object->SetVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*auto object = this->privData->dynamicObjects->find( decoded.objectID );
|
||||||
if( object != this->privData->dynamicObjects->end() )
|
if( object != this->privData->dynamicObjects->end() )
|
||||||
{
|
{
|
||||||
object->second = nullptr;
|
object->second = nullptr;
|
||||||
this->privData->dynamicObjects->erase( object );
|
this->privData->dynamicObjects->erase( object );
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
return GameClientState::event_processed;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectCreate:
|
case protocol_Gameplay_ObjectCreate:
|
||||||
|
@ -616,6 +724,40 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GameClientState::event_processed;
|
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;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GameClientState::event_processed;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,6 @@ namespace GameLogic
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<Player>> playerObjects;
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<Player>> playerObjects;
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<Player>> deadPlayerObjects;
|
|
||||||
TeamManager teamManager;
|
TeamManager teamManager;
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<StaticObject>> staticObjects;
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<StaticObject>> staticObjects;
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<DynamicObject>> dynamicObjects;
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<DynamicObject>> dynamicObjects;
|
||||||
|
|
|
@ -135,6 +135,15 @@ void Player::BeginFrame()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(walkDirection == Oyster::Math::Float3::null)
|
||||||
|
{
|
||||||
|
if(this->playerState != PLAYER_STATE::PLAYER_STATE_JUMPING)
|
||||||
|
{
|
||||||
|
if(this->playerState != PLAYER_STATE::PLAYER_STATE_IDLE)
|
||||||
|
this->gameInstance->onPlayerActionEventFnc( this, PlayerAction::PlayerAction_Idle);
|
||||||
|
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Walk if walkdirection is something
|
// Walk if walkdirection is something
|
||||||
if(walkDirection != Oyster::Math::Float3::null)
|
if(walkDirection != Oyster::Math::Float3::null)
|
||||||
{
|
{
|
||||||
|
@ -164,6 +173,12 @@ void Player::BeginFrame()
|
||||||
rightVelocity += walkDirection*Oyster::Math::Float3(fabs(rightDir.x), fabs(rightDir.y), fabs(rightDir.z)) * walkSpeed*0.2f;
|
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)
|
||||||
|
{
|
||||||
|
if(this->playerState != PLAYER_STATE::PLAYER_STATE_WALKING)
|
||||||
|
this->gameInstance->onPlayerActionEventFnc( this, PlayerAction::PlayerAction_Walk);
|
||||||
|
this->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust velocities so no squaring occurs
|
// Adjust velocities so no squaring occurs
|
||||||
|
@ -181,9 +196,20 @@ void Player::BeginFrame()
|
||||||
{
|
{
|
||||||
Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.GetNormalized();
|
Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.GetNormalized();
|
||||||
this->rigidBody->ApplyImpulse(up*this->rigidBody->GetState().mass * 20);
|
this->rigidBody->ApplyImpulse(up*this->rigidBody->GetState().mass * 20);
|
||||||
|
|
||||||
|
if(this->playerState != PLAYER_STATE::PLAYER_STATE_JUMPING)
|
||||||
|
this->gameInstance->onPlayerActionEventFnc( this, PlayerAction::PlayerAction_Jump);
|
||||||
this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING;
|
this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(this->playerState == PLAYER_STATE::PLAYER_STATE_JUMPING)
|
||||||
|
{
|
||||||
|
this->gameInstance->onPlayerActionEventFnc( this, PlayerAction::PlayerAction_Idle);
|
||||||
|
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -941,29 +941,29 @@ namespace GameLogic
|
||||||
struct Protocol_ObjectAction :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectAction :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
short objectID;
|
short objectID;
|
||||||
float animationID;
|
int animationID;
|
||||||
|
|
||||||
Protocol_ObjectAction()
|
Protocol_ObjectAction()
|
||||||
{
|
{
|
||||||
this->protocol[0].value = protocol_Gameplay_ObjectAction;
|
this->protocol[0].value = protocol_Gameplay_ObjectAction;
|
||||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
|
||||||
objectID = 0;
|
objectID = -1;
|
||||||
animationID = -1;
|
animationID = -1;
|
||||||
}
|
}
|
||||||
Protocol_ObjectAction(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectAction(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
objectID = p[1].value.netShort;
|
objectID = p[1].value.netShort;
|
||||||
animationID = p[2].value.netFloat;
|
animationID = p[2].value.netInt;
|
||||||
}
|
}
|
||||||
Protocol_ObjectAction(float animID, int id)
|
Protocol_ObjectAction( int id, float animID)
|
||||||
{
|
{
|
||||||
this->protocol[0].value = protocol_Gameplay_ObjectAction;
|
this->protocol[0].value = protocol_Gameplay_ObjectAction;
|
||||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
|
||||||
objectID = id;
|
objectID = id;
|
||||||
animationID = animID;
|
animationID = animID;
|
||||||
|
|
Loading…
Reference in New Issue