GameLogic - Merged with gamelogic
This commit is contained in:
commit
ca715dbe05
|
@ -154,6 +154,11 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
|
|||
//this->privData->camera.UpdateOrientation();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
// some error loading model
|
||||
}
|
||||
}
|
||||
|
||||
GameClientState::ClientState GameState::Update( float deltaTime )
|
||||
|
@ -743,11 +748,20 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
|||
{
|
||||
//Remove the disconnected player
|
||||
Protocol_ObjectDisconnectPlayer decoded(data);
|
||||
auto object = this->privData->dynamicObjects->find( decoded.objectID );
|
||||
if( object != this->privData->dynamicObjects->end() )
|
||||
C_Player *player;
|
||||
player = (this->privData->players)[decoded.objectID];
|
||||
|
||||
if( player )
|
||||
{
|
||||
object->second = nullptr;
|
||||
this->privData->dynamicObjects->erase( 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;
|
||||
|
|
|
@ -170,6 +170,10 @@ void GamingUI::ReadKeyInput()
|
|||
{
|
||||
this->nextState = GameStateUI::UIState_shut_down;
|
||||
}
|
||||
if( this->sharedData->keyboardDevice->IsKeyDown(::Input::Enum::SAKI_M) )
|
||||
{
|
||||
this->nextState = GameStateUI::UIState_main_menu;
|
||||
}
|
||||
}
|
||||
|
||||
void GamingUI::OnMousePress ( Input::Enum::SAMI key, Input::Mouse* sender )
|
||||
|
|
|
@ -368,6 +368,9 @@ void Level::AddPlayerToTeam(Player *player, int teamID)
|
|||
}
|
||||
void Level::AddPlayerToGame(Player *player)
|
||||
{
|
||||
int i = rand() % spawnPoints.Size();
|
||||
Float3 spawnPoint = spawnPoints[i];
|
||||
player->ResetPlayer(spawnPoint);
|
||||
for(int i = 0; i < (int)this->playerObjects.Size(); i++)
|
||||
{
|
||||
if (!this->playerObjects[i])
|
||||
|
@ -408,6 +411,8 @@ void Level::Update(float deltaTime)
|
|||
|
||||
|
||||
for(int i = 0; i < (int)this->playerObjects.Size(); i++)
|
||||
{
|
||||
if(this->playerObjects[i])
|
||||
{
|
||||
if(this->playerObjects[i]->getAffectingPlayer() != NULL)
|
||||
{
|
||||
|
@ -433,6 +438,7 @@ void Level::Update(float deltaTime)
|
|||
((Game*)&Game::Instance())->onDeadFnc(this->playerObjects[i], killer, DEATH_TIMER); // add killer ID
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < dynamicObjects.Size(); i++)
|
||||
{
|
||||
|
|
|
@ -15,6 +15,8 @@ Player::Player()
|
|||
Player::initPlayerData();
|
||||
this->weapon = NULL;
|
||||
this->teamID = -1;
|
||||
this->playerScore.killScore = 0;
|
||||
this->playerScore.deathScore = 0;
|
||||
}
|
||||
|
||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, int teamID)
|
||||
|
@ -23,6 +25,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)
|
|||
this->weapon = new Weapon(2,this);
|
||||
Player::initPlayerData();
|
||||
this->teamID = teamID;
|
||||
this->playerScore.killScore = 0;
|
||||
this->playerScore.deathScore = 0;
|
||||
}
|
||||
|
||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, int teamID)
|
||||
|
@ -31,6 +35,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustom
|
|||
this->weapon = new Weapon(2,this);
|
||||
Player::initPlayerData();
|
||||
this->teamID = teamID;
|
||||
this->playerScore.killScore = 0;
|
||||
this->playerScore.deathScore = 0;
|
||||
}
|
||||
|
||||
Player::~Player(void)
|
||||
|
@ -45,8 +51,6 @@ void Player::initPlayerData()
|
|||
{
|
||||
this->playerStats.hp = MAX_HP;
|
||||
this->playerStats.movementSpeed = BASIC_SPEED;
|
||||
this->playerScore.killScore = 0;
|
||||
this->playerScore.deathScore = 0;
|
||||
this->playerState = PLAYER_STATE_IDLE;
|
||||
this->lookDir = Oyster::Math::Float3(0,0,-1);
|
||||
|
||||
|
@ -308,7 +312,13 @@ void Player::Inactivate()
|
|||
{
|
||||
//this->
|
||||
}
|
||||
|
||||
void Player::ResetPlayer( Oyster::Math::Float3 spawnPos)
|
||||
{
|
||||
Player::initPlayerData();
|
||||
this->rigidBody->SetPosition(spawnPos);
|
||||
this->playerScore.killScore = 0;
|
||||
this->playerScore.deathScore = 0;
|
||||
}
|
||||
Oyster::Math::Float3 Player::GetPosition() const
|
||||
{
|
||||
return (Oyster::Math::Float3) this->rigidBody->GetState().centerPos;
|
||||
|
|
|
@ -82,6 +82,7 @@ namespace GameLogic
|
|||
bool IsIdle();
|
||||
|
||||
void Inactivate();
|
||||
void ResetPlayer( Oyster::Math::Float3 spawnPos);
|
||||
|
||||
Oyster::Math::Float3 GetPosition() const;
|
||||
Oyster::Math::Float3 GetLookDir() const;
|
||||
|
|
|
@ -25,6 +25,10 @@ GameClient::GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::Net
|
|||
}
|
||||
GameClient::~GameClient()
|
||||
{
|
||||
if(this->player)
|
||||
{
|
||||
this->player->Inactivate();
|
||||
}
|
||||
this->isReady = false;
|
||||
this->character = L"char_orca.dan";
|
||||
this->alias = L"Unknown";
|
||||
|
|
Loading…
Reference in New Issue