Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic
This commit is contained in:
commit
039dcef6a2
|
@ -90,10 +90,13 @@ int C_Object::GetId() const
|
||||||
void C_Object::Render()
|
void C_Object::Render()
|
||||||
{
|
{
|
||||||
if( this->model )
|
if( this->model )
|
||||||
|
{
|
||||||
|
if(this->model->Visible)
|
||||||
{
|
{
|
||||||
Oyster::Graphics::API::RenderModel(model);
|
Oyster::Graphics::API::RenderModel(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
void C_Object::Release()
|
void C_Object::Release()
|
||||||
{
|
{
|
||||||
if( this->model )
|
if( this->model )
|
||||||
|
|
|
@ -142,8 +142,8 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
|
||||||
this->privData->camera.SetPosition( p->getPos() );
|
this->privData->camera.SetPosition( p->getPos() );
|
||||||
Float3 offset = Float3( 0.0f );
|
Float3 offset = Float3( 0.0f );
|
||||||
// DEBUG position of camera so we can see the player model
|
// DEBUG position of camera so we can see the player model
|
||||||
offset.y = p->getScale().y * 5.0f;
|
//offset.y = p->getScale().y * 5.0f;
|
||||||
offset.z = p->getScale().z * -5.0f;
|
//offset.z = p->getScale().z * -5.0f;
|
||||||
// !DEBUG
|
// !DEBUG
|
||||||
this->privData->camera.SetHeadOffset( offset );
|
this->privData->camera.SetHeadOffset( offset );
|
||||||
this->privData->camera.UpdateOrientation();
|
this->privData->camera.UpdateOrientation();
|
||||||
|
@ -187,7 +187,7 @@ bool GameState::Render()
|
||||||
{
|
{
|
||||||
if(playerObject->second)
|
if(playerObject->second)
|
||||||
{
|
{
|
||||||
//if( this->privData->myId != playerObject->second->GetId() )
|
if( this->privData->myId != playerObject->second->GetId() )
|
||||||
{
|
{
|
||||||
playerObject->second->Render();
|
playerObject->second->Render();
|
||||||
}
|
}
|
||||||
|
@ -596,6 +596,12 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
{
|
{
|
||||||
// if it is not a player
|
// if it is not a player
|
||||||
object = (*this->privData->dynamicObjects)[decoded.objectID];
|
object = (*this->privData->dynamicObjects)[decoded.objectID];
|
||||||
|
|
||||||
|
if(!object)
|
||||||
|
{
|
||||||
|
//If it is a static object
|
||||||
|
object = (*this->privData->staticObjects)[decoded.objectID];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( object )
|
if( object )
|
||||||
|
@ -613,6 +619,12 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
{
|
{
|
||||||
// if it is not a player
|
// if it is not a player
|
||||||
object = (*this->privData->dynamicObjects)[decoded.objectID];
|
object = (*this->privData->dynamicObjects)[decoded.objectID];
|
||||||
|
|
||||||
|
if(!object)
|
||||||
|
{
|
||||||
|
//If it is a static object
|
||||||
|
object = (*this->privData->staticObjects)[decoded.objectID];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( object )
|
if( object )
|
||||||
|
|
|
@ -44,7 +44,6 @@ using namespace GameLogic;
|
||||||
realObjB = realObjA;
|
realObjB = realObjA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch (realObjB->GetObjectType())
|
switch (realObjB->GetObjectType())
|
||||||
{
|
{
|
||||||
case ObjectSpecialType::ObjectSpecialType_Generic:
|
case ObjectSpecialType::ObjectSpecialType_Generic:
|
||||||
|
@ -375,9 +374,14 @@ using namespace GameLogic;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(b->GetObjectType() == ObjectSpecialType_Player)
|
if(b->GetObjectType() == ObjectSpecialType_Player)
|
||||||
|
{
|
||||||
|
//Only update if it is active. And if the player is alive
|
||||||
|
if(((Pickup*)a)->IsActive() && ((Player*)b)->GetState() != PLAYER_STATE_DEAD && ((Player*)b)->GetState() != PLAYER_STATE_DIED)
|
||||||
{
|
{
|
||||||
((Pickup*)a)->OnCollision((Player*)(b));
|
((Pickup*)a)->OnCollision((Player*)(b));
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
else if(a->GetObjectType() != ObjectSpecialType_Player)
|
else if(a->GetObjectType() != ObjectSpecialType_Player)
|
||||||
{
|
{
|
||||||
//One of the objects are not a player.
|
//One of the objects are not a player.
|
||||||
|
@ -385,5 +389,9 @@ using namespace GameLogic;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Only update if it is active. And if the player is alive
|
||||||
|
if(((Pickup*)b)->IsActive() && ((Player*)a)->GetState() != PLAYER_STATE_DEAD && ((Player*)a)->GetState() != PLAYER_STATE_DIED)
|
||||||
|
{
|
||||||
((Pickup*)b)->OnCollision((Player*)a);
|
((Pickup*)b)->OnCollision((Player*)a);
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -239,7 +239,11 @@ bool Level::InitiateLevel(std::wstring levelPath)
|
||||||
{
|
{
|
||||||
LevelMetaData* LevelObjData = ((LevelMetaData*)obj);
|
LevelMetaData* LevelObjData = ((LevelMetaData*)obj);
|
||||||
std::string levelName = LevelObjData->levelName;
|
std::string levelName = LevelObjData->levelName;
|
||||||
|
|
||||||
// LevelObjData->worldSize;
|
// LevelObjData->worldSize;
|
||||||
|
|
||||||
|
//LevelMetaData is not an object.
|
||||||
|
--this->objID;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectType::ObjectType_Static:
|
case ObjectType::ObjectType_Static:
|
||||||
|
|
|
@ -9,6 +9,7 @@ Pickup::Pickup(Oyster::Physics::ICustomBody *rigidBody, EventOnCollision collisi
|
||||||
this->active = true;
|
this->active = true;
|
||||||
this->spawnTime = spawnTime;
|
this->spawnTime = spawnTime;
|
||||||
timer.reset();
|
timer.reset();
|
||||||
|
this->GetRigidBody()->MoveToLimbo();
|
||||||
}
|
}
|
||||||
|
|
||||||
Pickup::~Pickup()
|
Pickup::~Pickup()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "PickupHealth.h"
|
#include "PickupHealth.h"
|
||||||
|
#include "../Game.h"
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
@ -14,5 +15,8 @@ PickupHealth::~PickupHealth()
|
||||||
void PickupHealth::OnCollision(Player *player)
|
void PickupHealth::OnCollision(Player *player)
|
||||||
{
|
{
|
||||||
timer.reset();
|
timer.reset();
|
||||||
|
((Game*)&Game::Instance())->onDisableFnc(this);
|
||||||
|
|
||||||
|
this->active = false;
|
||||||
player->DamageLife(-hpValue);
|
player->DamageLife(-hpValue);
|
||||||
}
|
}
|
|
@ -341,8 +341,14 @@ PLAYER_STATE Player::GetState() const
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::DamageLife(int damage)
|
void Player::DamageLife(int damage)
|
||||||
|
{
|
||||||
|
if(damage != 0)
|
||||||
{
|
{
|
||||||
this->playerStats.hp -= damage;
|
this->playerStats.hp -= damage;
|
||||||
|
|
||||||
|
if(this->playerStats.hp > 100)
|
||||||
|
this->playerStats.hp = 100;
|
||||||
|
|
||||||
// send hp to client
|
// send hp to client
|
||||||
this->gameInstance->onDamageTakenFnc( this, this->playerStats.hp);
|
this->gameInstance->onDamageTakenFnc( this, this->playerStats.hp);
|
||||||
|
|
||||||
|
@ -351,7 +357,7 @@ void Player::DamageLife(int damage)
|
||||||
this->playerStats.hp = 0;
|
this->playerStats.hp = 0;
|
||||||
this->playerState = PLAYER_STATE_DIED;
|
this->playerState = PLAYER_STATE_DIED;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::AddAffectedObject(DynamicObject &AffectedObject)
|
void Player::AddAffectedObject(DynamicObject &AffectedObject)
|
||||||
|
|
|
@ -152,7 +152,7 @@ using namespace DanBias;
|
||||||
}
|
}
|
||||||
void GameSession::ObjectEnabled( GameLogic::IObjectData* movedObject )
|
void GameSession::ObjectEnabled( GameLogic::IObjectData* movedObject )
|
||||||
{
|
{
|
||||||
GameSession::gameSession->Send(Protocol_ObjectDisable(movedObject->GetID()).GetProtocol());
|
GameSession::gameSession->Send(Protocol_ObjectEnable(movedObject->GetID()).GetProtocol());
|
||||||
}
|
}
|
||||||
void GameSession::ObjectDamaged( GameLogic::IObjectData* movedObject, float hp )
|
void GameSession::ObjectDamaged( GameLogic::IObjectData* movedObject, float hp )
|
||||||
{
|
{
|
||||||
|
|
|
@ -168,6 +168,14 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
||||||
ParseObject(&buffer[counter], &header->healthValue, 4);
|
ParseObject(&buffer[counter], &header->healthValue, 4);
|
||||||
counter += 4;
|
counter += 4;
|
||||||
|
|
||||||
|
// DEBUG
|
||||||
|
header->position[1] = 150;
|
||||||
|
header->spawnTime = 5;
|
||||||
|
header->boundingVolume.box.mass = 0;
|
||||||
|
header->typeID = ObjectType_Static;
|
||||||
|
header->healthValue = 50;
|
||||||
|
// !DEBUG
|
||||||
|
|
||||||
objects.push_back(header);
|
objects.push_back(header);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue