GL - Merge branch 'GameLogic'

This commit is contained in:
lindaandersson 2014-01-15 08:19:35 +01:00
commit 9a32c44e49
6 changed files with 74 additions and 74 deletions

View File

@ -1,6 +1,9 @@
#include "AttatchmentSocket.h" #include "AttatchmentSocket.h"
#include "IAttatchment.h" #include "IAttatchment.h"
#include "DynamicArray.h"
using namespace GameLogic; using namespace GameLogic;
using namespace Utility::DynamicMemory;
struct AttatchmentSocket::PrivateData struct AttatchmentSocket::PrivateData
{ {
@ -14,7 +17,7 @@ struct AttatchmentSocket::PrivateData
} }
IAttatchment *attatchment; SmartPointer<IAttatchment> attatchment;
}myData; }myData;
@ -26,10 +29,7 @@ AttatchmentSocket::AttatchmentSocket(void)
AttatchmentSocket::~AttatchmentSocket(void) AttatchmentSocket::~AttatchmentSocket(void)
{ {
if (myData->attatchment)
{
delete myData->attatchment;
}
} }
IAttatchment* AttatchmentSocket::GetAttatchment() IAttatchment* AttatchmentSocket::GetAttatchment()
@ -39,18 +39,12 @@ IAttatchment* AttatchmentSocket::GetAttatchment()
void AttatchmentSocket::SetAttatchment(IAttatchment *attatchment) void AttatchmentSocket::SetAttatchment(IAttatchment *attatchment)
{ {
if (myData->attatchment)
{
delete myData->attatchment;
}
myData->attatchment = attatchment; myData->attatchment = attatchment;
} }
void AttatchmentSocket::RemoveAttatchment() void AttatchmentSocket::RemoveAttatchment()
{ {
if (myData->attatchment)
{ myData->attatchment = 0;
delete myData->attatchment;
}
} }

View File

@ -1,9 +1,10 @@
#include "Game.h" #include "Game.h"
#include "Player.h" #include "Player.h"
#include "Level.h" #include "Level.h"
#include <GID.h> #include <DynamicArray.h>
using namespace GameLogic; using namespace GameLogic;
using namespace Utility::DynamicMemory;
struct Game::PrivateData struct Game::PrivateData
{ {
@ -16,9 +17,9 @@ struct Game::PrivateData
{ {
} }
//DynamicArray<SmartPointer<Player>> players;
Player **players; DynamicArray<SmartPointer<PlayerData>> players;
Level *level; SmartPointer<Level> level;
}myData; }myData;
@ -36,10 +37,6 @@ Game::~Game(void)
} }
} }
void Game::MovePlayer(int playerID, const PLAYER_MOVEMENT &movement)
{
}
void Game::PlayerUseWeapon(int playerID, const WEAPON_FIRE &Usage) void Game::PlayerUseWeapon(int playerID, const WEAPON_FIRE &Usage)
{ {
@ -58,7 +55,13 @@ void Game::GetAllPlayerPos()
Game::PlayerData Game::CreatePlayer() Game::PlayerData Game::CreatePlayer()
{ {
<<<<<<< HEAD
SmartPointer<Player> newPlayer = new Player();
myData->players.Push(newPlayer);
=======
return PlayerData(); return PlayerData();
>>>>>>> eb6ed13cceff0ce4380699391759883acf487107
} }
void Game::CreateTeam() void Game::CreateTeam()

View File

@ -1,53 +1,53 @@
/////////////////////////////////////////////////////////////////////
// Created by [Erik Persson] [2013]
/////////////////////////////////////////////////////////////////////
#ifndef GAME_H #ifndef GAME_H
#define GAME_H #define GAME_H
#include "GameLogicDef.h"
#include "GameLogicStates.h" #include "GameLogicStates.h"
namespace GameLogic namespace GameLogic
{ {
class DANBIAS_GAMELOGIC_DLL Game class Player;
class Game
{ {
public: public:
struct PlayerData struct PlayerData
{ {
private:
friend class Game;
Player *player;
public:
int playerID; int playerID;
int teamID; int teamID;
PlayerData()
{
playerID = 0;
teamID = 0;
}
PlayerData(int playerID,int teamID) PlayerData();
{
this->playerID = playerID; PlayerData(int playerID,int teamID);
this->teamID = teamID;
}
~PlayerData() ~PlayerData()
{ {
} }
};
public:
Game(void);
~Game(void);
/******************************************************** /********************************************************
* Moves the chosen player based on input * Moves the chosen player based on input
* @param playerID: ID of the player you want to recieve the message * @param playerID: ID of the player you want to recieve the message
* @param movement: enum value on what kind of action is to be taken * @param movement: enum value on what kind of action is to be taken
********************************************************/ ********************************************************/
void MovePlayer(int playerID, const PLAYER_MOVEMENT &movement); void MovePlayer(const PLAYER_MOVEMENT &movement);
};
public:
Game(void);
~Game(void);
/******************************************************** /********************************************************
* Uses the chosen players weapon based on input * Uses the chosen players weapon based on input

View File

@ -0,0 +1,14 @@
#include "Game.h"
#include "Player.h"
using namespace GameLogic;
Game::PlayerData::PlayerData()
{
}
void Game::PlayerData::MovePlayer(const PLAYER_MOVEMENT &movement)
{
}

View File

@ -5,8 +5,11 @@
#include "Player.h" #include "Player.h"
#include "PhysicsAPI.h" #include "PhysicsAPI.h"
#include "TeamManager.h" #include "TeamManager.h"
#include "DynamicArray.h"
using namespace GameLogic; using namespace GameLogic;
using namespace Utility::DynamicMemory;
struct Level::PrivateData struct Level::PrivateData
{ {
@ -18,17 +21,15 @@ struct Level::PrivateData
{ {
} }
TeamManager *teamManager; SmartPointer<TeamManager> teamManager;
StaticObject** staticObjects; DynamicArray<SmartPointer<StaticObject>> staticObjects;
int nrOfStaticObjects;
DynamicObject** dynamicObjects; DynamicArray<SmartPointer<DynamicObject>> dynamicObjects;
int nrOfDynamicObjects;
GameMode* gameMode; SmartPointer<GameMode> gameMode;
Oyster::Physics::ICustomBody *rigidBodyLevel; SmartPointer<Oyster::Physics::ICustomBody> rigidBodyLevel;
}myData; }myData;

View File

@ -1,8 +1,10 @@
#include "Weapon.h" #include "Weapon.h"
#include "AttatchmentSocket.h" #include "AttatchmentSocket.h"
#include "AttatchmentMassDriver.h" #include "AttatchmentMassDriver.h"
#include "DynamicArray.h"
using namespace GameLogic; using namespace GameLogic;
using namespace Utility::DynamicMemory;
struct Weapon::PrivateData struct Weapon::PrivateData
{ {
@ -12,7 +14,6 @@ struct Weapon::PrivateData
selectedAttatchment = 0; selectedAttatchment = 0;
currentNrOfAttatchments = 0; currentNrOfAttatchments = 0;
selectedSocketID = 0; selectedSocketID = 0;
maxNrOfSockets = 0;
attatchmentSockets = 0; attatchmentSockets = 0;
} }
@ -22,11 +23,9 @@ struct Weapon::PrivateData
WEAPON_STATE weaponState; WEAPON_STATE weaponState;
AttatchmentSocket **attatchmentSockets; DynamicArray<SmartPointer<AttatchmentSocket>> attatchmentSockets;
int maxNrOfSockets;
int currentNrOfAttatchments; int currentNrOfAttatchments;
SmartPointer<IAttatchment> selectedAttatchment;
IAttatchment *selectedAttatchment;
int selectedSocketID; int selectedSocketID;
}myData; }myData;
@ -39,23 +38,12 @@ Weapon::Weapon()
Weapon::Weapon(int MaxNrOfSockets) Weapon::Weapon(int MaxNrOfSockets)
{ {
myData = new PrivateData(); myData = new PrivateData();
myData->maxNrOfSockets = MaxNrOfSockets; myData->attatchmentSockets.Resize(MaxNrOfSockets);
myData->attatchmentSockets = new AttatchmentSocket*[MaxNrOfSockets];
for (int i = 0; i < MaxNrOfSockets; i++)
{
myData->attatchmentSockets[i] = new AttatchmentSocket();
}
} }
Weapon::~Weapon(void) Weapon::~Weapon(void)
{ {
for (int i = 0; i < myData->currentNrOfAttatchments; i++)
{
delete myData->attatchmentSockets[i];
}
delete[] myData->attatchmentSockets;
delete myData; delete myData;
} }
@ -95,7 +83,7 @@ bool Weapon::IsReloading()
bool Weapon::IsValidSocket(int socketID) bool Weapon::IsValidSocket(int socketID)
{ {
if(socketID < myData->maxNrOfSockets && socketID >= 0) if(socketID < myData->attatchmentSockets.Size() && socketID >= 0)
{ {
if (myData->attatchmentSockets[socketID]->GetAttatchment() != 0) if (myData->attatchmentSockets[socketID]->GetAttatchment() != 0)
{ {
@ -114,7 +102,7 @@ int Weapon::GetCurrentSocketID()
void Weapon::AddNewAttatchment(IAttatchment *attatchment, Player *owner) void Weapon::AddNewAttatchment(IAttatchment *attatchment, Player *owner)
{ {
if(myData->currentNrOfAttatchments < myData->maxNrOfSockets) if(myData->currentNrOfAttatchments < myData->attatchmentSockets.Size())
{ {
myData->attatchmentSockets[myData->currentNrOfAttatchments]->SetAttatchment(attatchment); myData->attatchmentSockets[myData->currentNrOfAttatchments]->SetAttatchment(attatchment);
myData->currentNrOfAttatchments++; myData->currentNrOfAttatchments++;