mirror of
https://github.com/glest/glest-source.git
synced 2025-08-16 21:33:59 +02:00
- added support for multiple animation models for each skill and display a them randomly during game play
This commit is contained in:
@@ -66,10 +66,27 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
|||||||
string currentPath = dir;
|
string currentPath = dir;
|
||||||
endPathWithSlash(currentPath);
|
endPathWithSlash(currentPath);
|
||||||
|
|
||||||
string path= sn->getChild("animation")->getAttribute("path")->getRestrictedValue(currentPath);
|
//string path= sn->getChild("animation")->getAttribute("path")->getRestrictedValue(currentPath);
|
||||||
animation= Renderer::getInstance().newModel(rsGame);
|
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);
|
animation->load(path, false, &loadedFileList, &parentLoader);
|
||||||
loadedFileList[path].push_back(make_pair(parentLoader,sn->getChild("animation")->getAttribute("path")->getRestrictedValue()));
|
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
|
//particles
|
||||||
if(sn->hasChild("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) {
|
string SkillType::skillClassToStr(SkillClass skillClass) {
|
||||||
switch(skillClass){
|
switch(skillClass){
|
||||||
case scStop: return "Stop";
|
case scStop: return "Stop";
|
||||||
|
@@ -82,9 +82,11 @@ protected:
|
|||||||
int hpCost;
|
int hpCost;
|
||||||
int speed;
|
int speed;
|
||||||
int animSpeed;
|
int animSpeed;
|
||||||
Model *animation;
|
vector<Model *> animations;
|
||||||
SoundContainer sounds;
|
SoundContainer sounds;
|
||||||
float soundStartTime;
|
float soundStartTime;
|
||||||
|
RandomGen random;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UnitParticleSystemTypes unitParticleSystemTypes;
|
UnitParticleSystemTypes unitParticleSystemTypes;
|
||||||
|
|
||||||
@@ -102,7 +104,7 @@ public:
|
|||||||
int getHpCost() const {return hpCost;}
|
int getHpCost() const {return hpCost;}
|
||||||
int getSpeed() const {return speed;}
|
int getSpeed() const {return speed;}
|
||||||
int getAnimSpeed() const {return animSpeed;}
|
int getAnimSpeed() const {return animSpeed;}
|
||||||
Model *getAnimation() const {return animation;}
|
Model *getAnimation() const;
|
||||||
StaticSound *getSound() const {return sounds.getRandSound();}
|
StaticSound *getSound() const {return sounds.getRandSound();}
|
||||||
float getSoundStartTime() const {return soundStartTime;}
|
float getSoundStartTime() const {return soundStartTime;}
|
||||||
|
|
||||||
|
@@ -109,6 +109,7 @@ public:
|
|||||||
XmlAttribute *getAttribute(const string &name,bool mustExist=true) const;
|
XmlAttribute *getAttribute(const string &name,bool mustExist=true) const;
|
||||||
XmlNode *getChild(unsigned int i) const;
|
XmlNode *getChild(unsigned int i) const;
|
||||||
XmlNode *getChild(const string &childName, unsigned int childIndex=0) 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 hasChildAtIndex(const string &childName, int childIndex=0) const;
|
||||||
bool hasChild(const string &childName) const;
|
bool hasChild(const string &childName) const;
|
||||||
XmlNode *getParent() const;
|
XmlNode *getParent() const;
|
||||||
|
@@ -275,6 +275,16 @@ XmlNode *XmlNode::getChild(unsigned int i) const {
|
|||||||
return children[i];
|
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{
|
XmlNode *XmlNode::getChild(const string &childName, unsigned int i) const{
|
||||||
if(i>=children.size()){
|
if(i>=children.size()){
|
||||||
|
Reference in New Issue
Block a user