93 lines
2.2 KiB
C++
93 lines
2.2 KiB
C++
|
|
/****************************************************************************
|
|||
|
|
Copyright (c) 2014-2016 Beijing TianRuiDiAn Network Technology Co.,Ltd.
|
|||
|
|
Copyright (c) 2014-2016 ShenZhen Redbird Network Polytron Technologies Inc.
|
|||
|
|
|
|||
|
|
http://www.hotniao.com
|
|||
|
|
|
|||
|
|
All of the content of the software, including code, pictures,
|
|||
|
|
resources, are original. For unauthorized users, the company
|
|||
|
|
reserves the right to pursue its legal liability.
|
|||
|
|
****************************************************************************/
|
|||
|
|
|
|||
|
|
#include "GameCreator.h"
|
|||
|
|
#include <assert.h>
|
|||
|
|
|
|||
|
|
static CGameCreator* sGameCreate = nullptr;
|
|||
|
|
|
|||
|
|
CGameCreator* CGameCreator::getInstance()
|
|||
|
|
{
|
|||
|
|
if (nullptr == sGameCreate)
|
|||
|
|
{
|
|||
|
|
sGameCreate = new (std::nothrow) CGameCreator();
|
|||
|
|
}
|
|||
|
|
return sGameCreate;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CGameCreator::destroyInstance()
|
|||
|
|
{
|
|||
|
|
CC_SAFE_DELETE(sGameCreate);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int CGameCreator::getRegistGameCount()
|
|||
|
|
{
|
|||
|
|
return _creators.size();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CGameCreator::addGame(uint16 wKindId, GAMETYPE type, GAME_CREATE_SELECTOR createGameSelector, GAME_CREATE_NODE createNodeSelector)
|
|||
|
|
{
|
|||
|
|
ItemCreator creator;
|
|||
|
|
creator.type = type;
|
|||
|
|
creator.wKindId = wKindId;
|
|||
|
|
creator.gameSelector = createGameSelector;
|
|||
|
|
creator.createNodeSelector = createNodeSelector;
|
|||
|
|
|
|||
|
|
assert(creator.validGame());
|
|||
|
|
auto value = std::make_pair(wKindId, creator);
|
|||
|
|
_creators.insert(value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GameFrameBase* CGameCreator::startGameClient(uint16 uNameId)
|
|||
|
|
{
|
|||
|
|
auto iter = _creators.find(uNameId);
|
|||
|
|
if (iter != _creators.end())
|
|||
|
|
{
|
|||
|
|
ItemCreator* creator = &(*iter).second;
|
|||
|
|
if (creator->valid())
|
|||
|
|
{
|
|||
|
|
cocos2d::log("start game client begin...");
|
|||
|
|
GameFrameBase* game = creator->gameSelector();
|
|||
|
|
cocos2d::log("start game client end...");
|
|||
|
|
return game;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return nullptr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CreateRoomBase* CGameCreator::getCreateNode(uint16 uNameId)
|
|||
|
|
{
|
|||
|
|
auto iter = _creators.find(uNameId);
|
|||
|
|
if (iter != _creators.end())
|
|||
|
|
{
|
|||
|
|
ItemCreator* creator = &(*iter).second;
|
|||
|
|
if (creator->valid())
|
|||
|
|
{
|
|||
|
|
cocos2d::log("start game client begin...");
|
|||
|
|
CreateRoomBase* game = creator->createNodeSelector();
|
|||
|
|
cocos2d::log("start game client end...");
|
|||
|
|
return game;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return nullptr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CGameCreator::CGameCreator()
|
|||
|
|
: _currentCreator(nullptr)
|
|||
|
|
, _validCount(0)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CGameCreator::~CGameCreator()
|
|||
|
|
{
|
|||
|
|
}
|