gamesession testing
This commit is contained in:
parent
92b3525587
commit
0ea08fbd54
|
@ -4,6 +4,10 @@
|
|||
#include <PostBox\PostBox.h>
|
||||
#include "ClientObject.h"
|
||||
|
||||
#include "DynamicObject.h"
|
||||
#include "CollisionManager.h"
|
||||
#include "GameLogicStates.h"
|
||||
|
||||
|
||||
#define ERIK
|
||||
|
||||
|
@ -83,6 +87,8 @@ namespace DanBias
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////private:
|
||||
void GameSession::Init()
|
||||
{
|
||||
|
@ -125,13 +131,20 @@ namespace DanBias
|
|||
|
||||
|
||||
#pragma region TESTING
|
||||
|
||||
using namespace GameLogic;
|
||||
|
||||
void ConvertToMovement(ClientObject* reciever, CustomNetProtocol& inputToConvert);
|
||||
|
||||
//VARIABLES GOES HERE
|
||||
int i = 0;
|
||||
GameLogic::Player erik;
|
||||
DynamicObject* objectBox;
|
||||
|
||||
void GameSession::EricLogicInitFunc()
|
||||
{
|
||||
CollisionManager::BoxCollision(0,0);
|
||||
|
||||
objectBox = new DynamicObject(CollisionManager::BoxCollision, OBJECT_TYPE::OBJECT_TYPE_BOX);
|
||||
}
|
||||
void GameSession::EricLogicFrameFunc()
|
||||
{
|
||||
|
@ -139,7 +152,25 @@ namespace DanBias
|
|||
}
|
||||
void GameSession::EricsLogicTestingProtocalRecieved(ClientObject* reciever, CustomNetProtocol& protocol)
|
||||
{
|
||||
switch (protocol[protocol_ID_INDEX].value.netShort)
|
||||
{
|
||||
case protocol_Gamplay_PlayerNavigation:
|
||||
ConvertToMovement(reciever, protocol);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ConvertToMovement(ClientObject* reciever,CustomNetProtocol& inputToConvert)
|
||||
{
|
||||
if (inputToConvert[1].value.netBool == true)
|
||||
{
|
||||
reciever->Logic_Object()->Move(PLAYER_MOVEMENT::PLAYER_MOVEMENT_FORWARD);
|
||||
}
|
||||
if (inputToConvert[2].value.netBool == true)
|
||||
{
|
||||
reciever->Logic_Object()->Move(PLAYER_MOVEMENT::PLAYER_MOVEMENT_BACKWARD);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
|
|
@ -6,26 +6,22 @@
|
|||
|
||||
using namespace Oyster;
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
|
||||
namespace CollisionManager
|
||||
{
|
||||
using namespace GameLogic;
|
||||
|
||||
void PlayerVBox(Player &player, DynamicObject &box);
|
||||
|
||||
|
||||
Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj)
|
||||
Physics::ICustomBody::SubscriptMessage CollisionManager::PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj)
|
||||
{
|
||||
Player *player = ((Player*)(rigidBodyPlayer->gameObjectRef));
|
||||
Object *realObj = (Object*)obj->gameObjectRef;
|
||||
|
||||
switch (realObj->GetType())
|
||||
switch (realObj->GetType().value)
|
||||
{
|
||||
case OBJECT_TYPE_BOX:
|
||||
case OBJECT_TYPE::OBJECT_TYPE_BOX:
|
||||
PlayerVBox(*player,(*(DynamicObject*) realObj));
|
||||
break;
|
||||
case OBJECT_TYPE_PLAYER:
|
||||
case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -38,22 +34,24 @@ namespace GameLogic
|
|||
player.DamageLife(20);
|
||||
}
|
||||
|
||||
Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj)
|
||||
Physics::ICustomBody::SubscriptMessage CollisionManager::BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj)
|
||||
{
|
||||
if(rigidBodyBox == 0)
|
||||
{
|
||||
return Physics::ICustomBody::SubscriptMessage::SubscriptMessage_none;
|
||||
}
|
||||
DynamicObject *box = (DynamicObject*)rigidBodyBox->gameObjectRef;
|
||||
Object *realObj = (Object*)obj->gameObjectRef;
|
||||
|
||||
switch (realObj->GetType())
|
||||
switch (realObj->GetType().value)
|
||||
{
|
||||
case OBJECT_TYPE_BOX:
|
||||
case OBJECT_TYPE::OBJECT_TYPE_BOX:
|
||||
|
||||
break;
|
||||
case OBJECT_TYPE_PLAYER:
|
||||
case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
|
||||
//PlayerVBox(*(Player*)realObj,*box);
|
||||
break;
|
||||
}
|
||||
|
||||
return Physics::ICustomBody::SubscriptMessage_none;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,12 +7,13 @@
|
|||
namespace GameLogic
|
||||
{
|
||||
|
||||
namespace CollisionManager
|
||||
class CollisionManager
|
||||
{
|
||||
public:
|
||||
//these are the main collision functions
|
||||
//typedef SubscriptMessage (*EventAction_Collision)( const ICustomBody *proto, const ICustomBody *deuter );
|
||||
Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj);
|
||||
Oyster::Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj);
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj);
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj);
|
||||
|
||||
//these are the specific collision case functions
|
||||
//void PlayerVBox(Player &player, DynamicObject &box);
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
#ifndef DYNAMICOBJECT_H
|
||||
#define DYNAMICOBJECT_H
|
||||
#include "Object.h"
|
||||
#include "GameLogicDef.h"
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
|
||||
|
||||
class DynamicObject : public Object
|
||||
class DANBIAS_GAMELOGIC_DLL DynamicObject : public Object
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -174,6 +174,7 @@
|
|||
<ClInclude Include="CollisionManager.h" />
|
||||
<ClInclude Include="DynamicObject.h" />
|
||||
<ClInclude Include="GameLogicDef.h" />
|
||||
<ClInclude Include="GameLogicStates.h" />
|
||||
<ClInclude Include="GameMode.h" />
|
||||
<ClInclude Include="IAttatchment.h" />
|
||||
<ClInclude Include="Level.h" />
|
||||
|
|
|
@ -1,23 +1,63 @@
|
|||
#ifndef GAMELOGICSTATES_H
|
||||
#define GAMELOGICSTATES_H
|
||||
|
||||
#include "GameLogicDef.h"
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
enum PLAYER_STATE
|
||||
class DANBIAS_GAMELOGIC_DLL PLAYER_STATE
|
||||
{
|
||||
PLAYER_STATE_JUMPING = 0,
|
||||
PLAYER_STATE_WALKING = 1,
|
||||
PLAYER_STATE_IDLE = 2,
|
||||
public:
|
||||
PLAYER_STATE()
|
||||
{
|
||||
|
||||
}
|
||||
PLAYER_STATE(int value)
|
||||
{
|
||||
this->value = value;
|
||||
}
|
||||
|
||||
static const int PLAYER_STATE_JUMPING = 0;
|
||||
static const int PLAYER_STATE_WALKING = 1;
|
||||
static const int PLAYER_STATE_IDLE = 2;
|
||||
int value;
|
||||
|
||||
};
|
||||
class DANBIAS_GAMELOGIC_DLL PLAYER_MOVEMENT
|
||||
{
|
||||
public:
|
||||
PLAYER_MOVEMENT()
|
||||
{
|
||||
|
||||
}
|
||||
PLAYER_MOVEMENT(int value)
|
||||
{
|
||||
this->value = value;
|
||||
}
|
||||
static const int PLAYER_MOVEMENT_FORWARD = 0;
|
||||
static const int PLAYER_MOVEMENT_BACKWARD = 1;
|
||||
static const int PLAYER_MOVEMENT_LEFT = 2;
|
||||
static const int PLAYER_MOVEMENT_RIGHT = 4;
|
||||
static const int PLAYER_MOVEMENT_JUMP = 8;
|
||||
int value;
|
||||
};
|
||||
|
||||
enum PLAYER_MOVEMENT
|
||||
class DANBIAS_GAMELOGIC_DLL OBJECT_TYPE
|
||||
{
|
||||
PLAYER_MOVEMENT_FORWARD = 0,
|
||||
PLAYER_MOVEMENT_BACKWARD = 1,
|
||||
PLAYER_MOVEMENT_LEFT = 2,
|
||||
PLAYER_MOVEMENT_RIGHT = 4,
|
||||
PLAYER_MOVEMENT_JUMP = 8,
|
||||
public:
|
||||
OBJECT_TYPE()
|
||||
{
|
||||
|
||||
}
|
||||
OBJECT_TYPE(int value)
|
||||
{
|
||||
this->value = value;
|
||||
}
|
||||
static const int OBJECT_TYPE_PLAYER = 0;
|
||||
static const int OBJECT_TYPE_BOX = 1;
|
||||
static const int OBJECT_TYPE_UNKNOWN = 2;
|
||||
|
||||
public: int value;
|
||||
};
|
||||
|
||||
enum WEAPON_FIRE
|
||||
|
@ -37,12 +77,7 @@ namespace GameLogic
|
|||
WEAPON_STATE_RELOADING = 2,
|
||||
};
|
||||
|
||||
enum OBJECT_TYPE
|
||||
{
|
||||
OBJECT_TYPE_PLAYER = 0,
|
||||
OBJECT_TYPE_BOX = 1,
|
||||
OBJECT_TYPE_UNKNOWN = 2,
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -20,7 +20,7 @@ Object::Object()
|
|||
rigidBody->gameObjectRef = this;
|
||||
|
||||
this->objectID = GID();
|
||||
this->type = OBJECT_TYPE_UNKNOWN;
|
||||
this->type = OBJECT_TYPE::OBJECT_TYPE_UNKNOWN;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ struct Player::PrivateData
|
|||
|
||||
life = 100;
|
||||
teamID = -1;
|
||||
playerState = PLAYER_STATE_IDLE;
|
||||
playerState.value = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||
|
||||
lookDir = Oyster::Math::Float3(1,0,0);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ struct Player::PrivateData
|
|||
}myData;
|
||||
|
||||
Player::Player()
|
||||
:Object(CollisionManager::PlayerCollision, OBJECT_TYPE_PLAYER)
|
||||
:Object(CollisionManager::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER)
|
||||
{
|
||||
myData = new PrivateData();
|
||||
}
|
||||
|
@ -51,23 +51,23 @@ void Player::Move(const PLAYER_MOVEMENT &movement)
|
|||
{
|
||||
Oyster::Math::Float3 currentVelocity = rigidBody->GetRigidLinearVelocity();
|
||||
|
||||
switch(movement)
|
||||
switch(movement.value)
|
||||
{
|
||||
case PLAYER_MOVEMENT_FORWARD:
|
||||
case PLAYER_MOVEMENT::PLAYER_MOVEMENT_FORWARD:
|
||||
API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),myData->lookDir * 100);
|
||||
break;
|
||||
|
||||
case PLAYER_MOVEMENT_BACKWARD:
|
||||
case PLAYER_MOVEMENT::PLAYER_MOVEMENT_BACKWARD:
|
||||
API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-myData->lookDir * 100);
|
||||
break;
|
||||
|
||||
case PLAYER_MOVEMENT_LEFT:
|
||||
case PLAYER_MOVEMENT::PLAYER_MOVEMENT_LEFT:
|
||||
break;
|
||||
|
||||
case PLAYER_MOVEMENT_RIGHT:
|
||||
case PLAYER_MOVEMENT::PLAYER_MOVEMENT_RIGHT:
|
||||
break;
|
||||
|
||||
case PLAYER_MOVEMENT_JUMP:
|
||||
case PLAYER_MOVEMENT::PLAYER_MOVEMENT_JUMP:
|
||||
Jump();
|
||||
break;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint)
|
|||
{
|
||||
API::Instance().SetCenter(rigidBody,spawnPoint);
|
||||
myData->life = 100;
|
||||
myData->playerState = PLAYER_STATE_IDLE;
|
||||
myData->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||
myData->lookDir = Oyster::Math::Float3(1,0,0);
|
||||
}
|
||||
|
||||
|
@ -93,20 +93,21 @@ void Player::Jump()
|
|||
|
||||
bool Player::IsWalking()
|
||||
{
|
||||
return (myData->playerState == PLAYER_STATE_WALKING);
|
||||
return (myData->playerState.value == PLAYER_STATE::PLAYER_STATE_WALKING);
|
||||
}
|
||||
bool Player::IsJumping()
|
||||
{
|
||||
return (myData->playerState == PLAYER_STATE_JUMPING);
|
||||
return (myData->playerState.value == PLAYER_STATE::PLAYER_STATE_JUMPING);
|
||||
}
|
||||
bool Player::IsIdle()
|
||||
{
|
||||
return (myData->playerState == PLAYER_STATE_IDLE);
|
||||
return (myData->playerState.value == PLAYER_STATE::PLAYER_STATE_IDLE);
|
||||
}
|
||||
|
||||
Oyster::Math::Float3 Player::GetPos()
|
||||
{
|
||||
return rigidBody->GetCenter();
|
||||
return Oyster::Math::Float3(0,0,0);
|
||||
}
|
||||
|
||||
Oyster::Math::Float3 Player::GetLookDir()
|
||||
|
|
|
@ -7,11 +7,13 @@
|
|||
|
||||
/* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */
|
||||
|
||||
#define protocol_Gamplay_PlayerNavigation 0
|
||||
#define protocol_Gamplay_PlayerMouseMovement 1
|
||||
#define protocol_Gamplay_PlayerPosition 2
|
||||
#define protocol_Gamplay_CreateObject 3
|
||||
#define protocol_Gamplay_ObjectPosition 4
|
||||
#define protocol_ID_INDEX 0
|
||||
|
||||
#define protocol_Gamplay_PlayerNavigation 300
|
||||
#define protocol_Gamplay_PlayerMouseMovement 301
|
||||
#define protocol_Gamplay_PlayerPosition 302
|
||||
#define protocol_Gamplay_CreateObject 303
|
||||
#define protocol_Gamplay_ObjectPosition 304
|
||||
|
||||
|
||||
#define protocol_Lobby_Msg 100
|
||||
|
|
Loading…
Reference in New Issue