本文整理汇总了C++中Skill::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ Skill::SetName方法的具体用法?C++ Skill::SetName怎么用?C++ Skill::SetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skill
的用法示例。
在下文中一共展示了Skill::SetName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doc
SkillManager::SkillManager(void)
{
error_ = false;
/* Populate upgrade paths, costs etc*/
TiXmlDocument doc("Skills.xml");
doc.LoadFile();
if(doc.Error())
{
Logger::ErrorOut() << "Unable to load skills.xml\n";
Logger::ErrorOut() << "Error: " << doc.ErrorDesc() << "\n";
}
TiXmlElement* root = doc.FirstChildElement("Skills");
if(root)
{
TiXmlElement* skill = root->FirstChildElement("Skill");
while(skill)
{
std::vector<SkillLevel> upgrades;
std::string name;
std::string alignment;
unsigned int init_cost = 0;
error_ |= (skill->QueryValueAttribute("name", &name) != TIXML_SUCCESS);
error_ |= (skill->QueryValueAttribute("alignment", &alignment) != TIXML_SUCCESS);
TiXmlElement* initialcost = skill->FirstChildElement("InitialCost");
if(initialcost)
{
std::string init_cost_str = initialcost->GetText();
init_cost = boost::lexical_cast<unsigned int, std::string>(init_cost_str);
} else
{
Logger::ErrorOut() << "No initial cost for skill " << name << "\n";
error_ = true;
}
//TODO upgrades
TiXmlElement* upgrade = skill->FirstChildElement("Upgrade");
while(upgrade)
{
std::string upgrade_name;
upgrade->QueryValueAttribute("name", &upgrade_name);
SkillLevel sl(upgrade_name);
int ltv_rank = 1;
TiXmlElement* level = upgrade->FirstChildElement("Level");
while(level)
{
int rank = 0;
int cost = 0;
error_ |= (level->QueryIntAttribute("rank", &rank) != TIXML_SUCCESS);
error_ |= (level->QueryIntAttribute("cost", &cost) != TIXML_SUCCESS);
error_ |= (rank != ltv_rank + 1);
ltv_rank = rank;
sl.AddRank(cost);
level = level->NextSiblingElement("Level");
}
upgrades.push_back(sl);
upgrade = upgrade->NextSiblingElement("Upgrade");
}
if(error_)
break;
else
{
Skill* sk = new Skill();
sk->SetCost(init_cost);
sk->SetName(name);
for(std::vector<SkillLevel>::iterator it = upgrades.begin(); it != upgrades.end(); ++it)
{
sk->AddUpgrade(*it);
}
if(alignment == "good")
sk->SetAlignment(SkillAlignment::Good);
else if(alignment == "evil")
sk->SetAlignment(SkillAlignment::Evil);
else if(alignment == "neutral")
sk->SetAlignment(SkillAlignment::Neutral);
else
{
Logger::ErrorOut() << "Skill alignment can only be 'good', 'evil' or 'neutral'\n";
error_ = true;
break;
}
if(cheat_)
sk->SetUnlocked(true);
skills_.push_back(sk);
}
skill = skill->NextSiblingElement("Skill");
}
} else
{
Logger::ErrorOut() << "Malformed skills.xml, no root element 'Skills'\n";
error_ = true;
}
}