当前位置: 首页>>代码示例>>C++>>正文


C++ Monster::SetName方法代码示例

本文整理汇总了C++中Monster::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ Monster::SetName方法的具体用法?C++ Monster::SetName怎么用?C++ Monster::SetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Monster的用法示例。


在下文中一共展示了Monster::SetName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(){

	//Declare the characters
	Hero Player;
	Monster Ogre;

	//Set the main characters in game properties
	Player.SetName("Budi");
	Player.SetHealth(1000);
	Player.SetAttack(30);
	Player.SetJob("Magician");
	Player.SetTown("Furedator");

	
	Ogre.SetName("Ograr");
	Ogre.SetHealth(1500);
	Ogre.SetAttack(15);
	Ogre.SetClan("Myrtr");
	
	cout << "Nama playernya adalah " << Player.GetName() << endl;
	cout << "Player memiliki health " << Player.GetHealth() << endl;
	cout << "Attack player adalah " << Player.GetAttack() << endl;
	cout << "Job player adalah " << Player.GetJob() << endl;
	cout << "Kota asal player adalah " << Player.GetTown() << endl;

	
	cout << "Nama monsternya adalah " << Ogre.GetName() << endl;
	cout << "Monsternya memiliki health " << Ogre.GetHealth() << endl;
	cout << "Attack Monsternya adalah " << Ogre.GetAttack() << endl;
	cout << "Clan Monsternya dari " << Ogre.GetClan() << endl;
	



	return 0;
}
开发者ID:igrir,项目名称:ECG,代码行数:36,代码来源:main.cpp

示例2: LoadMonster

bool MonsterManager::LoadMonster(UINT mapId)
{
	char xmlfile[260] = {0};
	sprintf(xmlfile, "moninfo%u.xml", mapId);


	m_mapId = mapId;

	m_pListCtrl->DeleteAllItems();
	Release();

	char szFile[260] = {0};
	sprintf(szFile, "%s/%s", EditorConfig::Instance()->makeServerResPath(MONINFO_PATH), xmlfile);

	xml_document doc;  
	File file;
	if (!file.open(szFile))
		return false;

	doc.load_buffer(file.getBufferPtr(), file.getLength());

	ushort count = 0;
	ushort index = 0;
	for (pugi::xml_node node1=doc.child("moninfo").child("mon"); node1; node1=node1.next_sibling()) {
		MONINFO info;
		info.mapId = mapId;
		int baseId = node1.attribute("BaseId").as_int();
		int num = node1.attribute("Num").as_int();
		index++;

		info.race = baseId;
		info.num = num;

		info.ai = node1.attribute("AI").as_int();
		info.speed = node1.attribute("Speed").as_int();
		info.view = node1.attribute("View").as_int();

		info.dropInfo[0].dropId = node1.attribute("DropId").as_int();
		info.dropInfo[0].dropProb = node1.attribute("DropProb").as_int();
		info.dropInfo[0].dropType = node1.attribute("DropType").as_int();

		info.dropInfo[1].dropId = node1.attribute("DropId2").as_int();
		info.dropInfo[1].dropProb = node1.attribute("DropProb2").as_int();
		info.dropInfo[1].dropType = node1.attribute("DropType2").as_int();

		info.dropInfo[2].dropId = node1.attribute("DropId3").as_int();
		info.dropInfo[2].dropProb = node1.attribute("DropProb3").as_int();
		info.dropInfo[2].dropType = node1.attribute("DropType3").as_int();

		info.reviveTime = node1.attribute("ReviveTime").as_int();
		info.isSiegeWar = node1.attribute("SiegeWar").as_int();
		info.isEventMon = node1.attribute("EventMon").as_int();
		info.birthRect.x = node1.attribute("BirthX").as_int();
		info.birthRect.y = node1.attribute("BirthY").as_int();
		info.birthRect.cx = node1.attribute("BirthWidth").as_int();
		info.birthRect.cy = node1.attribute("BirthHeight").as_int();

		const stMonBase* base = GameTable::getMonBase(baseId);
		if (!base) {
			LOGE("¶ÁÈ¡¹ÖÎï·Ö²¼³ö´í£¬²»´æÔڵĹÖÎïÀàÐÍ, file=%s, race=%u", szFile, baseId);
			continue;
		}

		Monster* pMon = new Monster;
		pMon->SetName(base->name);
		pMon->SetNum(num);
		pMon->FillInfo(info);
		pMon->Load(base->id);
		pMon->SetGridPos(info.birthRect.x, info.birthRect.y);

		if (!this->AddMonster(pMon)) {
			SAFE_DELETE(pMon);
			TRACE("²åÈë¹ÖÎïʧ°Ü, file=%s, race=%u", szFile, info.race);
			continue;
		}
	}


	return true;
}
开发者ID:ueverything,项目名称:easyserver,代码行数:80,代码来源:MonsterManager.cpp


注:本文中的Monster::SetName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。