mirror of
https://github.com/glest/glest-source.git
synced 2025-02-24 19:52:25 +01:00
- added support for multiple animation models for each skill and display a them randomly during game play
This commit is contained in:
parent
d0d31e4bfe
commit
e0860309c0
@ -66,10 +66,27 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
|
||||
string path= sn->getChild("animation")->getAttribute("path")->getRestrictedValue(currentPath);
|
||||
animation= Renderer::getInstance().newModel(rsGame);
|
||||
animation->load(path, false, &loadedFileList, &parentLoader);
|
||||
loadedFileList[path].push_back(make_pair(parentLoader,sn->getChild("animation")->getAttribute("path")->getRestrictedValue()));
|
||||
//string path= sn->getChild("animation")->getAttribute("path")->getRestrictedValue(currentPath);
|
||||
vector<XmlNode *> animationList = sn->getChildList("animation");
|
||||
for(unsigned int i = 0; i < animationList.size(); ++i) {
|
||||
string path= animationList[i]->getAttribute("path")->getRestrictedValue(currentPath);
|
||||
if(fileExists(path) == true) {
|
||||
Model *animation= Renderer::getInstance().newModel(rsGame);
|
||||
animation->load(path, false, &loadedFileList, &parentLoader);
|
||||
loadedFileList[path].push_back(make_pair(parentLoader,animationList[i]->getAttribute("path")->getRestrictedValue()));
|
||||
|
||||
animations.push_back(animation);
|
||||
//printf("**FOUND ANIMATION [%s]\n",path.c_str());
|
||||
}
|
||||
else {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line %d] WARNING CANNOT LOAD MODEL [%s] for parentLoader [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),parentLoader.c_str());
|
||||
}
|
||||
}
|
||||
if(animations.size() <= 0) {
|
||||
char szBuf[4096]="";
|
||||
sprintf(szBuf,"Error no animations found for skill [%s] for parentLoader [%s]",name.c_str(),parentLoader.c_str());
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
//particles
|
||||
if(sn->hasChild("particles")) {
|
||||
@ -105,6 +122,14 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
||||
}
|
||||
}
|
||||
|
||||
Model *SkillType::getAnimation() const {
|
||||
//int modelIndex = random.randRange(0,animations.size()-1);
|
||||
srand(time(NULL));
|
||||
int modelIndex = rand() % animations.size();
|
||||
//printf("!!RETURN ANIMATION [%d / %d]\n",modelIndex,animations.size()-1);
|
||||
return animations[modelIndex];
|
||||
}
|
||||
|
||||
string SkillType::skillClassToStr(SkillClass skillClass) {
|
||||
switch(skillClass){
|
||||
case scStop: return "Stop";
|
||||
|
@ -82,9 +82,11 @@ protected:
|
||||
int hpCost;
|
||||
int speed;
|
||||
int animSpeed;
|
||||
Model *animation;
|
||||
vector<Model *> animations;
|
||||
SoundContainer sounds;
|
||||
float soundStartTime;
|
||||
RandomGen random;
|
||||
|
||||
public:
|
||||
UnitParticleSystemTypes unitParticleSystemTypes;
|
||||
|
||||
@ -102,7 +104,7 @@ public:
|
||||
int getHpCost() const {return hpCost;}
|
||||
int getSpeed() const {return speed;}
|
||||
int getAnimSpeed() const {return animSpeed;}
|
||||
Model *getAnimation() const {return animation;}
|
||||
Model *getAnimation() const;
|
||||
StaticSound *getSound() const {return sounds.getRandSound();}
|
||||
float getSoundStartTime() const {return soundStartTime;}
|
||||
|
||||
|
@ -109,6 +109,7 @@ public:
|
||||
XmlAttribute *getAttribute(const string &name,bool mustExist=true) const;
|
||||
XmlNode *getChild(unsigned int i) const;
|
||||
XmlNode *getChild(const string &childName, unsigned int childIndex=0) const;
|
||||
vector<XmlNode *> getChildList(const string &childName) const;
|
||||
bool hasChildAtIndex(const string &childName, int childIndex=0) const;
|
||||
bool hasChild(const string &childName) const;
|
||||
XmlNode *getParent() const;
|
||||
|
@ -275,6 +275,16 @@ XmlNode *XmlNode::getChild(unsigned int i) const {
|
||||
return children[i];
|
||||
}
|
||||
|
||||
vector<XmlNode *> XmlNode::getChildList(const string &childName) const {
|
||||
vector<XmlNode *> list;
|
||||
for(unsigned int j = 0; j < children.size(); ++j) {
|
||||
if(children[j]->getName() == childName) {
|
||||
list.push_back(children[j]);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
XmlNode *XmlNode::getChild(const string &childName, unsigned int i) const{
|
||||
if(i>=children.size()){
|
||||
|
Loading…
x
Reference in New Issue
Block a user