示例#1
0
void MonsterManager::EditMonster(Monster* monster)
{
	for (int i=0; i<m_pListCtrl->GetItemCount(); ++i) {
		CString strID = m_pListCtrl->GetItemText(i, 0);
		UINT uinId = atoi(strID);
		Monster* pMon = this->FindMonster(uinId);
		if (pMon == NULL) continue;
		if (pMon->GetID() != monster->GetID()) continue;
		MONINFO& info = pMon->GetMonInfo();

		int index = i;

		CString strTmp;

		strTmp.Format("[%d]%s(%d¼¶)", pMon->GetBaseID(), Misc::utf8ToGbk(pMon->getBaseName()).c_str(), pMon->GetLevel());
		m_pListCtrl->SetItemText(index, 1, strTmp);		// Ãû³Æ

		strTmp.Format("%d", info.num);
		m_pListCtrl->SetItemText(index, 2, strTmp);		// ÊýÁ¿

		strTmp.Format("%d", info.ai);
		m_pListCtrl->SetItemText(index, 3, strTmp);		// ÖÇÄÜ

		strTmp.Format("%d", info.speed);
		m_pListCtrl->SetItemText(index, 4, strTmp);		// ÒÆËÙ

		strTmp.Format("%d", info.view);
		m_pListCtrl->SetItemText(index, 5, strTmp);		// ÊÓÒ°

		strTmp.Format("%d", info.dropInfo[0].dropType);
		m_pListCtrl->SetItemText(index, 6, strTmp);		// BOSSµôÂä

		strTmp.Format("%d", info.dropInfo[0].dropId);
		m_pListCtrl->SetItemText(index, 7, strTmp);		// µôÂä±àºÅ

		strTmp.Format("%d", info.dropInfo[0].dropProb);
		m_pListCtrl->SetItemText(index, 8, strTmp);		// µôÂä¸ÅÂÊ

		strTmp.Format("%d", info.reviveTime);
		m_pListCtrl->SetItemText(index, 9, strTmp);		// ¸´»îʱ¼ä
	}
}
示例#2
0
bool MonsterManager::SaveToFile()
{
	if (this->GetCount() == 0)
		return false;

	char szFile[260] = {0};
	sprintf(szFile, "%s/moninfo%u.xml", EditorConfig::Instance()->makeServerResPath(MONINFO_PATH), m_mapId);
	ofstream ofOut(szFile);

	char szLine[10 * 1024];
	ZeroMemory(szLine, sizeof(szLine));

	sprintf(szLine, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n\r\n");
	Misc::writeUTF8Str(ofOut, szLine);

	sprintf(szLine, "<moninfo>\r\n\r\n");
	Misc::writeUTF8Str(ofOut, szLine);


	map<UINT,Monster*>::iterator itBegin = m_objMap.begin();
	map<UINT,Monster*>::iterator itEnd = m_objMap.end();
	while (itBegin != itEnd) {
		Monster* pMon = itBegin->second;
		MONINFO& info = pMon->GetMonInfo();	

		sprintf(szLine, "\t<mon BaseId=\"%d\" Num=\"%d\" AI=\"%d\" Speed=\"%d\" View=\"%d\" BirthX=\"%d\" BirthY=\"%d\" BirthWidth=\"%d\" BirthHeight=\"%d\" DropId=\"%d\" DropProb=\"%d\" DropType=\"%d\" ReviveTime=\"%d\" />\r\n",
			pMon->GetBaseID(), info.num, info.ai, info.speed, info.view, info.birthRect.x, info.birthRect.y, info.birthRect.cx, info.birthRect.cy,
			info.dropInfo[0].dropId, info.dropInfo[0].dropProb, info.dropInfo[0].dropType, info.reviveTime);
		Misc::writeUTF8Str(ofOut, szLine);
	
		++itBegin;
	}

	sprintf(szLine, "\r\n</moninfo>\r\n\r\n");
	Misc::writeUTF8Str(ofOut, szLine);

	return true;
}