void Game::loadHeroes() { TiXmlDocument *document = new TiXmlDocument("res/Heroes.xml"); if(!document->LoadFile(TIXML_ENCODING_UTF8)) { std::cout << "Error! file .... "; return; } TiXmlElement *xml_resources = document->FirstChildElement("resources"); if (xml_resources == nullptr) return; TiXmlElement *xml_hero = xml_resources->FirstChildElement("hero"); if (xml_hero == nullptr) return; while(xml_hero != nullptr) { HeroTemplate *hero = new HeroTemplate(); // resource load Resources resource; hero->setName(xml_hero->Attribute("name")); string atk_snd = xml_hero->Attribute("atk_snd"); string skl_snd = xml_hero->Attribute("skl_snd"); string texture = xml_hero->Attribute("texture"); string image = xml_hero->Attribute("image"); string image2 = xml_hero->Attribute("image2"); resource.loadAttackSound(atk_snd); resource.loadSkillSound(skl_snd); resource.loadTexture(texture); resource.loadImage(image); resource.loadImage2(image2); hero->setResources(resource); // stats load int hp, dmg_min, dmg_max, init, cost; Kind kind; Element element; Actions actions; xml_hero->QueryIntAttribute("hp", &hp); xml_hero->QueryIntAttribute("dmg_min", &dmg_min); xml_hero->QueryIntAttribute("dmg_max", &dmg_max); kind = strToKind(xml_hero->Attribute("kind")); element = strToElement(xml_hero->Attribute("elem")); xml_hero->QueryIntAttribute("init", &init); strToActions(xml_hero->Attribute("skill"), &actions); xml_hero->QueryIntAttribute("cost", &cost); hero->setStats(Stats(HP(hp), Damage(dmg_min, dmg_max), Kind(kind), Element(element), Initiative(init), actions, cost)); heroes.push_back(hero); xml_hero = xml_hero->NextSiblingElement("hero"); } }