Example #1
0
void NPCManager::removeNpcFromMap(uint8_t npcID)
{
	map<uint8_t, NPC*>::const_iterator iter = m_npcMap.begin();
	for(; iter != m_npcMap.end(); ++iter)
	{
		NPC* pNPC = iter->second;
		if(pNPC->getID() == npcID)
		{
			pNPC->removeFromMap();
		}
	}
}
Example #2
0
// initialize NPC data
void NPCManager::initNpcData()
{
    //by Stanley
    CCFileData data(GameResourceManager::sharedManager()->storedFullPathFromRelativePath(NPC_BIN), "rb");
    unsigned char* buffer = data.getBuffer();
    int fileSize = data.getSize();
    int readSize = 0;
    
    if (fileSize > 0)
    {
        uint16_t numNpcs = 0;
        memcpy(&numNpcs, buffer + readSize, sizeof(numNpcs));
        readSize += sizeof(numNpcs);
        for(uint16_t i = 0; i < numNpcs; ++i)
        {
            // create NPC
			NPC* pNPC = new NPC(buffer, readSize);

			// TODO
            m_npcMap[pNPC->getID()] = pNPC;
        }
    }

}