Danbias/Code/Game/GameLogic/Game.h

122 lines
4.6 KiB
C
Raw Permalink Normal View History

/////////////////////////////////////////////////////////////////////
// Created by [Erik Persson] [2013]
/////////////////////////////////////////////////////////////////////
#ifndef GAME_H
#define GAME_H
2014-01-20 15:47:52 +01:00
//Includes windows so we need to undef minmax
#define NOMINMAX
#include <vld.h>
#include "GameAPI.h"
#include "Player.h"
#include "Level.h"
#include <DynamicArray.h>
#include <GID.h>
#include <PhysicsAPI.h>
#include <WinTimer.h>
namespace GameLogic
{
2014-01-20 15:47:52 +01:00
class Game :public GameAPI
{
public:
2014-01-20 15:47:52 +01:00
class PlayerData :public IPlayerData
{
2014-01-20 15:47:52 +01:00
public:
PlayerData();
PlayerData(int playerID,int teamID);
~PlayerData();
2014-01-20 15:47:52 +01:00
void Move(const PLAYER_MOVEMENT &movement) override;
void UseWeapon(const WEAPON_FIRE &usage) override;
int GetTeamID() const override;
PLAYER_STATE GetState() const override;
Oyster::Math::Float3 GetPosition() override;
Oyster::Math::Quaternion GetRotation() override;
Oyster::Math::Float3 GetScale() override;
Oyster::Math::Float4x4 GetOrientation() override;
int GetID() const override;
int GetKills() const override;
int GetDeaths() const override;
void SetLookDir(const Oyster::Math3D::Float3& lookDir) override;
void TurnLeft(Oyster::Math3D::Float deltaLeftRadians ) override;
ObjectSpecialType GetObjectType() const override;
void Inactivate() override;
void Release() override;
Player* GetPlayer();
2014-01-20 15:47:52 +01:00
Player *player;
};
2014-01-20 15:47:52 +01:00
class LevelData :public ILevelData
{
2014-01-20 15:47:52 +01:00
public:
LevelData();
~LevelData();
2014-01-20 15:47:52 +01:00
Oyster::Math::Float3 GetPosition() override;
Oyster::Math::Quaternion GetRotation() override;
Oyster::Math::Float3 GetScale() override;
2014-01-20 15:47:52 +01:00
Oyster::Math::Float4x4 GetOrientation() override;
int GetID() const override;
2014-02-18 11:44:02 +01:00
ObjectSpecialType GetObjectType() const override;
int getNrOfDynamicObj()const override;
2014-01-30 09:40:58 +01:00
IObjectData* GetObjectAt(int ID) const override;
2014-02-18 11:44:02 +01:00
void GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const override;
void Update(float deltaTime);
void AddPlayerToGame(IPlayerData *player);
2014-01-20 15:47:52 +01:00
Level *level;
};
public:
2014-01-20 15:47:52 +01:00
Game();
~Game();
void GetAllPlayerPositions() const override;
PlayerData* CreatePlayer() override;
LevelData* CreateLevel(const wchar_t mapName[255] ) override;
2014-01-20 15:47:52 +01:00
void CreateTeam() override;
bool NewFrame() override;
void SetFPS( int FPS ) override;
void SetFrameTimeLength( float seconds ) override;
void SetMoveSubscription(GameEvent::ObjectMovedFunction functionPointer) override;
void SetDisableSubscription(GameEvent::ObjectDisabledFunction functionPointer) override;
void SetEnableSubscription(GameEvent::ObjectEnabledFunction functionPointer) override;
void SetHpSubscription(GameEvent::ObjectHpFunction functionPointer) override;
void SetRespawnSubscription(GameEvent::ObjectRespawnedFunction functionPointer) override;
void SetDeadSubscription(GameEvent::ObjectDeadFunction functionPointer) override;
void SetActionSubscription(GameEvent::AnimationEventFunction functionPointer) override;
void SetPickupSubscription(GameEvent::PickupEventFunction functionPointer) override;
void SetCollisionSubscription(GameEvent::CollisionEventFunction functionPointer) override;
2014-02-27 14:56:18 +01:00
void SetWeaponEnergySubscription(GameEvent::WeaponEnergyFunction functionPointer) override;
2014-01-20 15:47:52 +01:00
bool Initiate() override;
float GetFrameTime() const;
static void PhysicsOnMove(const Oyster::Physics::ICustomBody *object);
static void PhysicsOnDestroy(::Utility::DynamicMemory::UniquePointer<Oyster::Physics::ICustomBody> proto);
static void PhysicsOnDead(const Oyster::Physics::ICustomBody *object);
2014-01-20 15:47:52 +01:00
Utility::DynamicMemory::DynamicArray<PlayerData*> players;
LevelData* level;
float frameTime;
bool initiated;
GameEvent::ObjectMovedFunction onMoveFnc;
GameEvent::ObjectDisabledFunction onDisableFnc;
GameEvent::ObjectEnabledFunction onEnableFnc;
GameEvent::ObjectHpFunction onDamageTakenFnc;
GameEvent::ObjectRespawnedFunction onRespawnFnc;
GameEvent::ObjectDeadFunction onDeadFnc;
2014-02-26 09:11:45 +01:00
GameEvent::AnimationEventFunction onActionEventFnc;
GameEvent::PickupEventFunction onPickupEventFnc;
GameEvent::CollisionEventFunction onCollisionEventFnc;
2014-02-27 14:56:18 +01:00
GameEvent::WeaponEnergyFunction onEnergyUpdateFnc;
};
}
#endif