Ejemplo n.º 1
0
Object::Object(Sint16 xcord, Sint16 ycord, const ParameterMap& param):
  parameters(param),
  state(NOTHING),
  event(NULL),
  otype(OTYPE_COMMON),
  delete_flag(false) {
    onum=++scenario->max_obj_num;

    /* Parameters */
    if (hasParam(parameters,"anim")) {
        ParameterMap anim_param=getParameters(parameters["anim"],':');
        anim_orig=loadAnimation(anim_param);
    } else if (hasParam(parameters,"image")) {
        ParameterMap anim_param;
        anim_param["image"]=parameters["image"];
        anim_param["image_hor_frames"]="1";
        anim_orig=loadAnimation(anim_param);
    } else anim_orig=EmptyAnimationPtr(new EmptyAnimation());
    if (hasParam(parameters,"name")) name=parameters["name"];
      else name="Object";
    if (hasParam(parameters,"w")) pos.w=atoi(parameters["w"].c_str());
      else if (anim_orig->isValid()) pos.w=anim_orig->getFrameDim().w;
      else pos.w=(Uint16)(DATA_LVLPLAYER_W*sqrt(config.lvlscale>=0 ? config.lvlscale : -1/config.lvlscale)+0.5);
    if (hasParam(parameters,"h")) pos.h=atoi(parameters["h"].c_str());
      else if (anim_orig->isValid()) pos.h=anim_orig->getFrameDim().h;
      else pos.h=(Uint16)(DATA_LVLPLAYER_H*sqrt(config.lvlscale>=0 ? config.lvlscale : -1/config.lvlscale)+0.5);
    pos.x=xcord;
    pos.y=ycord;
    animation=anim_orig;
}
Ejemplo n.º 2
0
Erik::Erik(Sint16 xcord, Sint16 ycord, const ParameterMap& param):
  Player(xcord,ycord,param),
  jump(V_JUMP),
  jump2(V_JUMP2) {
    weapon=Weapon(-1,W_PRESSURE,WS_PRESSURE);

    /* Parameters */
    if (hasParam(parameters,"anim_erik_jump_left"))          anim_erik_jump_left=loadAnimation(getParameters(parameters["anim_erik_jump_left"],':'));
    if (hasParam(parameters,"anim_erik_jump_right"))         anim_erik_jump_right=loadAnimation(getParameters(parameters["anim_erik_jump_right"],':'));
    if (hasParam(parameters,"anim_erik_jump2_left"))         anim_erik_jump2_left=loadAnimation(getParameters(parameters["anim_erik_jump2_left"],':'));
    if (hasParam(parameters,"anim_erik_jump2_right"))        anim_erik_jump2_right=loadAnimation(getParameters(parameters["anim_erik_jump2_right"],':'));
    if (hasParam(parameters,"anim_erik_start_run_left"))     anim_erik_start_run_left=loadAnimation(getParameters(parameters["anim_erik_start_run_left"],':'));
    if (hasParam(parameters,"anim_erik_start_run_right"))    anim_erik_start_run_right=loadAnimation(getParameters(parameters["anim_erik_start_run_right"],':'));
    if (hasParam(parameters,"anim_erik_run_left"))           anim_erik_run_left=loadAnimation(getParameters(parameters["anim_erik_run_left"],':'));
    if (hasParam(parameters,"anim_erik_run_right"))          anim_erik_run_right=loadAnimation(getParameters(parameters["anim_erik_run_right"],':'));
    if (hasParam(parameters,"anim_erik_swim_left"))          anim_erik_swim_left=loadAnimation(getParameters(parameters["anim_erik_swim_left"],':'));
    if (hasParam(parameters,"anim_erik_swim_right"))         anim_erik_swim_right=loadAnimation(getParameters(parameters["anim_erik_swim_right"],':'));
    if (hasParam(parameters,"anim_erik_swim_up_left"))       anim_erik_swim_up_left=loadAnimation(getParameters(parameters["anim_erik_swim_up_left"],':'));
    if (hasParam(parameters,"anim_erik_swim_up_right"))      anim_erik_swim_up_right=loadAnimation(getParameters(parameters["anim_erik_swim_up_right"],':'));
    if (hasParam(parameters,"anim_erik_hit_water_left"))     anim_erik_hit_water_left=loadAnimation(getParameters(parameters["anim_erik_hit_water_left"],':'));
    if (hasParam(parameters,"anim_erik_hit_water_right"))    anim_erik_hit_water_right=loadAnimation(getParameters(parameters["anim_erik_hit_water_right"],':'));

    if (!hasParam(parameters,"audio_hit")) au_hit=scenario->sndcache->loadWAV("erikhit.wav");

    if (hasParam(parameters,"audio_jump")) au_jump=scenario->sndcache->loadWAV(parameters["audio_jump"]);
      else au_jump=scenario->sndcache->loadWAV("rboots.wav");
    if (hasParam(parameters,"audio_run")) au_jump=scenario->sndcache->loadWAV(parameters["audio_run"]);
      else au_run=NULL;
}
Ejemplo n.º 3
0
bool EnemyTool::loadAnimations(std::string graphicpath, std::string fname)
{
	SpriteMap* gfx = ((SpriteMap*) graphic);
	int nCols = 0, nRows = 0;

	// Carga el archivo de config y lee
	FILE* f = fopen(fname.c_str(), "rb");

	// Si el archivo es inválido, no se puede hacer nada
	if (f == NULL)
		return false;

	// 1. Ancho y alto de imagen (?)
	if (fscanf(f, "%d %d", &nCols, &nRows) < 2)
		return false;

	// creamos el gráfico de la herramienta
	graphic = new SpriteMap(graphicpath, nCols, nRows, game->getGfxEngine());

	// 2. Leer las animaciones
	loadAnimation(UP, "up", f);
	loadAnimation(DOWN, "down", f);
	loadAnimation(LEFT, "left", f);
	loadAnimation(RIGHT, "right", f);

	fclose(f);

	return true;
}
Ejemplo n.º 4
0
Baleog::Baleog(Sint16 xcord, Sint16 ycord, const ParameterMap& param):
  Player(xcord,ycord,param) {
    weapon=Weapon(-1,W_STRIKE);

    /* Parameters */
    if (hasParam(parameters,"anim_baleog_sword_left")) anim_baleog_sword_left=loadAnimation(getParameters(parameters["anim_baleog_sword_left"],':'));
      else anim_baleog_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),8,BP_MD,ATYPE_ONCE);
    if (hasParam(parameters,"anim_baleog_sword_right")) anim_baleog_sword_right=loadAnimation(getParameters(parameters["anim_baleog_sword_right"],':'));
      else anim_baleog_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),8,BP_MD,ATYPE_ONCE);

    if (hasParam(parameters,"audio_sword")) au_sword=scenario->sndcache->loadWAV(parameters["audio_sword"]);
      else au_sword=scenario->sndcache->loadWAV("swrdsw2.wav");
}
Ejemplo n.º 5
0
Zombie::Zombie(Sint16 xcord, Sint16 ycord, const ParameterMap& param):
  Monster(xcord,ycord,param),
  T_Attack_Bite(1500) {
    weapon=Weapon(-1,W_STRIKE);

    /* Parameters */
    if (!hasParam(parameters,"anim_left"))  anim_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),2,BP_MD,ATYPE_LOOP,2);
    if (!hasParam(parameters,"anim_right")) anim_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),2,BP_MD,ATYPE_LOOP,2);

    if (!hasParam(parameters,"maxspeedx")) maxspeedx=80;
    if (hasParam(parameters,"audio_attack")) au_attack=scenario->sndcache->loadWAV(parameters["audio_attack"]);
      else au_attack=scenario->sndcache->loadWAV("clang.wav");
}
Ejemplo n.º 6
0
bool RoleShow::init()
{
	bool bRet = false;
	if(!CCNode::init())
	{
		return bRet;
	}

	m_location = CCPointZero;
	m_size = CCSizeZero;

	bulletSpeed = 10;
	heroAngle = 2;
	m_blackBullet = 0;
	m_ironmanBullet = 0;
	m_ironmanBulletTwo = 0;

	wolfBullectIndex = 0;
	pFiregun = NULL;
	epIndexOrien = true;

	loadAnimation();

	schedule(schedule_selector(RoleShow::process));

	schedule(schedule_selector(RoleShow::roleChangeAngle),0.037f);

	schedule(schedule_selector(RoleShow::addBullet),0.3);

	bRet = true;

	return bRet;
}
Ejemplo n.º 7
0
void AnimatedModel::load(const std::string & file) {
	LuaScript script(file);
	loadImage(script);
	loadTexturePack(script);
	loadAnimation(script);
	setUp();
}
Ejemplo n.º 8
0
void EffectManager::addEffect(EffectDef &effect, int duration, int magnitude, bool item, int trigger, int passive_id, int source_type) {
	int effect_type = getType(effect.type);

	// if we're already immune, don't add negative effects
	if (immunity_damage && (effect_type == EFFECT_DAMAGE || effect_type == EFFECT_DAMAGE_PERCENT))
		return;
	else if (immunity_slow && effect_type == EFFECT_SPEED && magnitude < 100)
		return;
	else if (immunity_stun && effect_type == EFFECT_STUN)
		return;
	else if (immunity_knockback && effect_type == EFFECT_KNOCKBACK)
		return;

	// only allow one knockback effect at a time
	if (effect_type == EFFECT_KNOCKBACK && knockback_speed != 0)
		return;

	for (size_t i=effect_list.size(); i>0; i--) {
		if (effect_list[i-1].name == effect.id) {
			if (trigger > -1 && effect_list[i-1].trigger == trigger)
				return; // trigger effects can only be cast once per trigger

			if (!effect.can_stack)
				removeEffect(i-1);
		}
		// if we're adding an immunity effect, remove all negative effects
		if (effect_type == EFFECT_IMMUNITY)
			clearNegativeEffects();
		else if (effect_type == EFFECT_IMMUNITY_DAMAGE)
			clearNegativeEffects(EFFECT_IMMUNITY_DAMAGE);
		else if (effect_type == EFFECT_IMMUNITY_SLOW)
			clearNegativeEffects(EFFECT_IMMUNITY_SLOW);
		else if (effect_type == EFFECT_IMMUNITY_STUN)
			clearNegativeEffects(EFFECT_IMMUNITY_STUN);
		else if (effect_type == EFFECT_IMMUNITY_KNOCKBACK)
			clearNegativeEffects(EFFECT_IMMUNITY_KNOCKBACK);
	}

	Effect e;

	e.name = effect.id;
	e.icon = effect.icon;
	e.type = effect_type;
	e.render_above = effect.render_above;

	if (effect.animation != "") {
		anim->increaseCount(effect.animation);
		e.animation = loadAnimation(effect.animation);
		e.animation_name = effect.animation;
	}

	e.ticks = e.duration = duration;
	e.magnitude = e.magnitude_max = magnitude;
	e.item = item;
	e.trigger = trigger;
	e.passive_id = passive_id;
	e.source_type = source_type;

	effect_list.push_back(e);
}
Ejemplo n.º 9
0
	void setAnimation(ComponentHandle cmp, const Path& path)
	{
		auto& animable = m_animables[{cmp.index}];
		unloadAnimation(animable.animation);
		animable.animation = loadAnimation(path);
		animable.time = 0;
	}
Ejemplo n.º 10
0
Barrel::Barrel(Ogre::Vector3 position, Ogre::Quaternion orientation,
  const std::string& name, Ogre::SceneNode* sceneNode,
  Ogre::Real speed, Ogre::Radian turnSpeed,
  Ogre::Entity& entityMesh) :
  MovableEntity(position, orientation, name, sceneNode, speed, turnSpeed),
  selected(false),
  node(NULL) {

	animation = NULL;
	loadAnimation();

	for(unsigned int i = 0; i < numModels; ++i) {
		modelNodes.push_back(sceneNode);
		animationState = entityMesh.getAnimationState("Sneak");
		animationState->setEnabled(true);
		animationState->setLoop(true);
		animationSpeeds.push_back(Ogre::Real(1.5f));
		animationStates.push_back(animationState);
	}
	
	std::string selectid = Factory::getID() + "." + name + "/selected";
	Ogre::Entity* pointerMesh = Game::getScene()->createEntity(selectid, "target.mesh");
	pointerMesh->setMaterialName("target");

	node = sceneNode->createChildSceneNode();
    node->attachObject(pointerMesh);
	node->setVisible(selected);
	node->setPosition(position);
}
Ejemplo n.º 11
0
void EffectManager::addEffect(std::string id, int icon, int duration, int magnitude, std::string type, std::string animation, bool additive, bool item, int trigger, bool render_above, int passive_id, int source_type) {
	// if we're already immune, don't add negative effects
	if (immunity) {
		if (type == "damage") return;
		else if (type == "speed" && magnitude < 100) return;
		else if (type == "stun") return;
	}

	// only allow one forced_move effect
	// TODO remove this limitation
	if (forced_move) {
		if (type == "forced_move") return;
	}

	for (unsigned i=0; i<effect_list.size(); i++) {
		if (effect_list[i].id == id) {
			if (trigger > -1 && effect_list[i].trigger == trigger) return; // trigger effects can only be cast once per trigger
			if (effect_list[i].duration <= duration && effect_list[i].type != "death_sentence") {
				effect_list[i].ticks = effect_list[i].duration = duration;
				if (effect_list[i].animation) effect_list[i].animation->reset();
			}
			if (effect_list[i].duration > duration && effect_list[i].type == "death_sentence") {
				effect_list[i].ticks = effect_list[i].duration = duration;
				if (effect_list[i].animation) effect_list[i].animation->reset();
			}
			if (additive) break; // this effect will stack
			if (effect_list[i].magnitude_max <= magnitude) {
				effect_list[i].magnitude = effect_list[i].magnitude_max = magnitude;
				if (effect_list[i].animation) effect_list[i].animation->reset();
			}
			return; // we already have this effect
		}
		// if we're adding an immunity effect, remove all negative effects
		if (type == "immunity") {
			clearNegativeEffects();
		}
	}

	Effect e;

	e.id = id;
	e.icon = icon;
	e.ticks = e.duration = duration;
	e.magnitude = e.magnitude_max = magnitude;
	e.type = type;
	e.item = item;
	e.trigger = trigger;
	e.render_above = render_above;
	e.passive_id = passive_id;
	e.source_type = source_type;

	if (animation != "") {
		anim->increaseCount(animation);
		e.animation = loadAnimation(animation);
		e.animation_name = animation;
	}

	effect_list.push_back(e);
}
Ejemplo n.º 12
0
void GargoyleEnemy::setSummoned(int strength, int damage, int count, const sf::Time& ttl) {
	m_isSummoned = true;
	m_spellStrength = strength;
	m_spellCount = count;
	m_spellAdditionalDamage = damage;
	loadSpells();
	loadAnimation(m_spellStrength - 1);
	setAlly(ttl);
}
Ejemplo n.º 13
0
	bool MD5Animation::init(const char* filename)
	{
		if (!loadAnimation(filename))
		{
			return false;
		}
		shutDownAnimation();
		return true;
	}
Ejemplo n.º 14
0
EmptyAnimationPtr Object::loadAnimation(string anim_name,
                                        double scale_factor,
                                        BasePointType abp_type,
                                        Uint16 aanimation_type,
                                        double afps,
                                        AllignType aallign_type) {
    /* Parse animation data file */
    ifstream file;
    string tmpline;
    string loadfile=config.datadir+config.anim_file;

    file.open(loadfile.c_str());
    if (!file) {
        cout << "Failed to open the animation data file: " << loadfile << " => Couldn't load " << anim_name << " animation!\n" << endl;
        return EmptyAnimationPtr(new EmptyAnimation());
    } else {
        string arg1,arg2,arg3,arg4,arg5,arg6;
        string tmp_anim_name="";
        string imagename="";
        Uint16 astart_pos=0;
        Uint16 aframes=1;

        Uint16 description_type=DESC_NONE;

        while (getline(file,tmpline)) {
            arg1=arg2=arg3=arg4=arg5=arg6="";
            std::istringstream tmpstream(tmpline);
            tmpstream >> arg1 >> arg2 >> arg3 >> arg4 >> arg5 >> arg6;

            if        (arg1 == "DESCRIPTION") {
                description_type=DESC_NONE;  
            } else if (arg1 == "ANIMATION") {
                if (arg2 == "LVLANIM") {
                    description_type=DESC_ANIM_LVLANIM;
                } else {
                    description_type=DESC_NONE;
                }
            }
     
            if (description_type==DESC_ANIM_LVLANIM) {
                if (arg1.empty() || arg2.empty() || arg3.empty() || arg4.empty()) {
                } else {
                    tmp_anim_name=arg1;
                    imagename=arg2;
                    astart_pos=(Uint16)atoi(arg3.c_str());
                    aframes=(Uint16)atoi(arg4.c_str());

                    if (anim_name==tmp_anim_name) {
                        return loadAnimation(imgcache->loadImage(imagename,scale_factor),aframes,abp_type,aanimation_type,afps,astart_pos,aallign_type);
                    }
                }
            }
        }
    }
    cout << "Animation " << anim_name << " not found!" << endl;
    return EmptyAnimationPtr(new EmptyAnimation());
}
Ejemplo n.º 15
0
Loot::Loot(const Loot &other) {
	stack.item = other.stack.item;
	stack.quantity = other.stack.quantity;
	pos.x = other.pos.x;
	pos.y = other.pos.y;
	loadAnimation(other.gfx);
	animation->syncTo(other.animation);
	currency = other.currency;
	tip = other.tip;
}
Ejemplo n.º 16
0
Loot::Loot(const Loot &other) {
	stack.item = other.stack.item;
	stack.quantity = other.stack.quantity;
	pos.x = other.pos.x;
	pos.y = other.pos.y;
	loadAnimation(other.gfx);
	animation->syncTo(other.animation);
	tip = other.tip;
	dropped_by_hero = other.dropped_by_hero;
}
Ejemplo n.º 17
0
Bomb::Bomb(Sint16 xcord, Sint16 ycord, const ParameterMap& param):
  Item(xcord,ycord,param) {
    /* Parameters */
    if (!hasParam(parameters,"image")) anim_orig=loadAnimation(scenario->imgcache->loadImage(1,"bomb_fire.bmp"));
    if (hasParam(parameters,"image_bomb")) triggered_bomb_param["image"]=parameters["image_bomb"];
      else triggered_bomb_param["image"]="bomb_fire.bmp";
    if (hasParam(parameters,"countdown"))  triggered_bomb_param["countdown"]="3000";
      else triggered_bomb_param["countdown"]=parameters["countdown"];
    if (hasParam(parameters,"audio_bomb")) triggered_bomb_param["audio_bomb"]=parameters["audio_bomb"];
      else triggered_bomb_param["audio_bomb"]="explsn.wav";
}
Ejemplo n.º 18
0
void Loader::loadAnimations()
{
    if(m_pScene->HasAnimations ())
    {
        for(int i =0;i<m_pScene->mNumAnimations;i++)
        {
            CMC_AnimateData * animate = new CMC_AnimateData();
            animate->m_name = m_pScene->mAnimations[i]->mName.C_Str ();
            loadAnimation (m_pScene->mRootNode,i,animate);
            m_model->m_animates.push_back (animate);
        }
    }
}
Ejemplo n.º 19
0
Loot::Loot(const Loot &other) {
	stack.item = other.stack.item;
	stack.quantity = other.stack.quantity;
	pos.x = other.pos.x;
	pos.y = other.pos.y;
	loadAnimation(other.gfx);
	if (animation)
		animation->syncTo(other.animation);
	tip = other.tip;
	dropped_by_hero = other.dropped_by_hero;
	on_ground = other.on_ground;
	sound_played = other.sound_played;
}
Ejemplo n.º 20
0
ModelInterface::ModelInterface(TextureManager* manager, const QString filename)
: has_animations(false)
, meshes(0)
, animations(0)
, bones(0)
, textureManager(manager)
{
    if(filename.contains("/"))
    {
        int index = filename.lastIndexOf("/") + 1;

        filePath = filename.left(index);
        fileName = filename.right(filename.size() - index);
    }
    else
        fileName = filename;

    Assimp::Importer importer;
    importer.SetPropertyInteger(AI_CONFIG_PP_LBW_MAX_WEIGHTS, 4);

    const aiScene* scene = importer.ReadFile(filename.toStdString(), aiProcess_GenSmoothNormals | aiProcess_Triangulate | aiProcess_CalcTangentSpace/* | aiProcess_FlipUVs*/);

    if(!scene || scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
    {
        throw QString("The file wasn't successfuly opened");

        return;
    }

    if(scene->HasAnimations())
    {
        has_animations = true;
        bones          = loadBones(scene);

        buildSkeleton(scene->mRootNode, NULL);

        animations = new Animations();
        animations->setBones(bones);

        for(uint i = 0; i < scene->mNumAnimations; ++i)
            animations->add(loadAnimation(scene->mAnimations[i], i));
    }

    meshes = new Meshes();

    for(uint i = 0; i < scene->mNumMeshes; ++i)
        meshes->add(loadMesh(scene->mMeshes[i], scene->mMaterials[scene->mMeshes[i]->mMaterialIndex], i));

    initialize(scene);
    // try delete scene probably crash
}
Ejemplo n.º 21
0
EffectManager& EffectManager::operator= (const EffectManager &emSource) {
	effect_list.resize(emSource.effect_list.size());

	for (unsigned i=0; i<effect_list.size(); i++) {
		effect_list[i].id = emSource.effect_list[i].id;
		effect_list[i].icon = emSource.effect_list[i].icon;
		effect_list[i].ticks = emSource.effect_list[i].ticks;
		effect_list[i].duration = emSource.effect_list[i].duration;
		effect_list[i].type = emSource.effect_list[i].type;
		effect_list[i].magnitude = emSource.effect_list[i].magnitude;
		effect_list[i].magnitude_max = emSource.effect_list[i].magnitude_max;
		effect_list[i].item = emSource.effect_list[i].item;
		effect_list[i].trigger = emSource.effect_list[i].trigger;
		effect_list[i].render_above = emSource.effect_list[i].render_above;
		effect_list[i].passive_id = emSource.effect_list[i].passive_id;

		if (emSource.effect_list[i].animation_name != "") {
			effect_list[i].animation_name = emSource.effect_list[i].animation_name;
			anim->increaseCount(effect_list[i].animation_name);
			effect_list[i].animation = loadAnimation(effect_list[i].animation_name);
		}
	}
	damage = emSource.damage;
	hpot = emSource.hpot;
	mpot = emSource.mpot;
	speed = emSource.speed;
	immunity = emSource.immunity;
	stun = emSource.stun;
	forced_speed = emSource.forced_speed;
	forced_move = emSource.forced_move;
	revive = emSource.revive;
	convert = emSource.convert;
	death_sentence = emSource.death_sentence;
	fear = emSource.fear;
	bonus_offense = emSource.bonus_offense;
	bonus_defense = emSource.bonus_defense;
	bonus_physical = emSource.bonus_physical;
	bonus_mental = emSource.bonus_mental;
	for (unsigned i=0; i<STAT_COUNT; i++) {
		bonus[i] = emSource.bonus[i];
	}
	triggered_others = emSource.triggered_others;
	triggered_block = emSource.triggered_block;
	triggered_hit = emSource.triggered_hit;
	triggered_halfdeath = emSource.triggered_halfdeath;
	triggered_joincombat = emSource.triggered_joincombat;
	triggered_death = emSource.triggered_death;

	return *this;
}
Ejemplo n.º 22
0
Monster::Monster(Sint16 xcord, Sint16 ycord, const ParameterMap& param):
  Character(xcord,ycord,param),
  Dai(0),
  Dattack(0) {
    state=STATE_FALL;
    otype|=OTYPE_MONSTER;
    enemy_types|=OTYPE_PLAYER;
    dense_types|=OTYPE_PLAYER;

    /* Parameters */
    if (hasParam(parameters,"anim_left")) anim_left=loadAnimation(getParameters(parameters["anim_left"],':'));
      else anim_left.reset(new EmptyAnimation(&anim_right));
    if (hasParam(parameters,"anim_right")) anim_right=loadAnimation(getParameters(parameters["anim_right"],':'));
      else anim_right.reset(new EmptyAnimation(&anim_orig));
    if (!hasParam(parameters,"maxhealth")) maxhealth=1;
    if (!hasParam(parameters,"health")) health=min(1,(int)maxhealth);
    if (!hasParam(parameters,"maxspeedx")) maxspeedx=50;
    if (!hasParam(parameters,"maxspeedy")) maxspeedy=0;
    if (hasParam(parameters,"audio_hit")) au_hit=scenario->sndcache->loadWAV(parameters["audio_hit"]);
      else au_hit=scenario->sndcache->loadWAV("monhit.wav");

    animation.reset(new EmptyAnimation((state&STATE_LEFT) ? &anim_left : &anim_right));
}
Ejemplo n.º 23
0
void Loader::loadAnimation(const aiNode *pNode,int index,CMC_AnimateData * animate)
{
    std::string NodeName(pNode->mName.data);
    if(!m_pScene->HasAnimations ())
    {
        m_model->m_hasAnimation = false;
        return ;
    }
    const aiAnimation* pAnimation = m_pScene->mAnimations[index];
    const aiNodeAnim * pNodeAnim = findNodeAnim(pAnimation, NodeName);
    if(pNodeAnim)//that node is a animation bone.
    {
        auto animateBone = new CMC_AnimateBone();
        animateBone->m_boneName = NodeName;
        //load position key.
        for(int i =0;i<pNodeAnim->mNumPositionKeys;i++)
        {
            auto v = pNodeAnim->mPositionKeys[i];
            CMC_TranslateKey key;
            key.time = v.mTime;
            key.trans = QVector3D (v.mValue.x,v.mValue.y,v.mValue.z);
            animateBone->addTranslate (key);
        }
        //load scale key
        for(int i =0;i<pNodeAnim->mNumScalingKeys;i++)
        {
            auto v = pNodeAnim->mScalingKeys[i];
            CMC_ScaleKey key;
            key.time = v.mTime;
            key.scale = QVector3D (v.mValue.x,v.mValue.y,v.mValue.z);
            animateBone->addScale (key);
        }
        //load rotation key
        for(int i =0;i<pNodeAnim->mNumPositionKeys;i++)
        {
            auto v = pNodeAnim->mRotationKeys[i];
            CMC_RotateKey key;
            key.time = v.mTime;
            key.rotate = QQuaternion(v.mValue.w,v.mValue.x,v.mValue.y,v.mValue.z);
            animateBone->addRotate (key);
        }

        animate->addAnimateBone (animateBone);
        animate->m_ticksPerSecond = pAnimation->mTicksPerSecond;
        animate->m_duration = pAnimation->mDuration;
    }
    for (uint i = 0 ; i < pNode->mNumChildren ; i++) {
        loadAnimation( pNode->mChildren[i],index,animate);
    }
}
Ejemplo n.º 24
0
void states::setStates(int frames[], int maxFrames, int separator, int horizontal, int tileH, int tileW)
{
	tileHeight = tileH;
	tileWidth = tileW;
	sep = separator;
	ht = horizontal;

	tilePos tmp;
	for(int i=0;i<maxFrames;i++)
	{
		//std::cout <<"SetSates |" << i << ":" << maxFrames << std::endl;
		//std::cout <<"frames |" << frames[i] << std::endl;
		loadAnimation(maxFrames,frames[i]);
	}

}
Ejemplo n.º 25
0
void ComposerEngine::playAnimation(uint16 animId, int16 x, int16 y, int16 eventParam) {
	// First, we check if this animation is already playing,
	// and if it is, we sabotage that running one first.
	for (Common::List<Animation *>::iterator i = _anims.begin(); i != _anims.end(); i++) {
		Animation *anim = *i;
		if (anim->_id != animId)
			continue;

		stopAnimation(*i);
	}

	Animation *anim = NULL;
	loadAnimation(anim, animId, x, y, eventParam);
	_anims.push_back(anim);
	runEvent(kEventAnimStarted, animId, eventParam, 0);
}
Ejemplo n.º 26
0
bool Enemy1::loadMedia(SDL_Renderer* gRenderer)
{
	if (!LoadFromFile(path_.c_str(), gRenderer))
	{
		printf("Failed to load walking animation texture!\n");
		return false;
	}
	std::string animNames[] = { "WALLKING", "PUNCH", "FALLING" };
	loadAnimation(animNames);
	destY = posY_;
	destX = posX_;

	return true;


}
Ejemplo n.º 27
0
// The assignment operator mainly used in internal vector managing,
// e.g. in vector::erase()
Loot& Loot::operator= (const Loot &other) {
	if (gfx != "")
		anim->decreaseCount(gfx);
	delete animation;

	loadAnimation(other.gfx);
	animation->syncTo(other.animation);

	stack.item = other.stack.item;
	stack.quantity = other.stack.quantity;
	pos.x = other.pos.x;
	pos.y = other.pos.y;
	currency = other.currency;
	tip = other.tip;

	return *this;
}
Ejemplo n.º 28
0
void EffectManager::addEffect(EffectDef &effect, int duration, int magnitude, bool item, int trigger, int passive_id, int source_type) {
	// if we're already immune, don't add negative effects
	if (immunity) {
		if (effect.type == "damage") return;
		else if (effect.type == "speed" && magnitude < 100) return;
		else if (effect.type == "stun") return;
	}

	for (unsigned i=effect_list.size(); i>0; i--) {
		if (effect_list[i-1].name == effect.name) {
			if (trigger > -1 && effect_list[i-1].trigger == trigger)
				return; // trigger effects can only be cast once per trigger

			if (!effect.can_stack)
				removeEffect(i-1);
		}
		// if we're adding an immunity effect, remove all negative effects
		if (effect.type == "immunity") {
			clearNegativeEffects();
		}
	}

	Effect e;

	e.name = effect.name;
	e.icon = effect.icon;
	e.type = effect.type;
	e.render_above = effect.render_above;

	if (effect.animation != "") {
		anim->increaseCount(effect.animation);
		e.animation = loadAnimation(effect.animation);
		e.animation_name = effect.animation;
	}

	e.ticks = e.duration = duration;
	e.magnitude = e.magnitude_max = magnitude;
	e.item = item;
	e.trigger = trigger;
	e.passive_id = passive_id;
	e.source_type = source_type;

	effect_list.push_back(e);
}
Ejemplo n.º 29
0
Stalfos::Stalfos(Point pos, bool canBeCollidedWith){
	position = pos;
	width = Global::TileWidth;
	height = Global::TileHeight;
	isCollideable = canBeCollidedWith;
	loadAnimation();
	isInvincible = false;
	healthPoint = 2;
	strength = 1;
	currentInvincibleFrame = 0;
	pushbackStep = 0;
	setupMask(&fullMask, width, height, sf::Color::Magenta);
	setupMask(&mask, width, height, sf::Color::Magenta);
	dir = Direction::None;
	getNextDirection(Direction::None);
	walkAnimIndex = 0;
	isParalyzed = false;
	currentParalyzeTime = 0;
}
Ejemplo n.º 30
0
void SpriteDef::loadAction(XmlNodePtr node, int variant_offset)
{
    const std::string actionName = XML::getProperty(node, "name", "");
    const std::string imageSetName = XML::getProperty(node, "imageset", "");
    const unsigned hp = XML::getProperty(node, "hp", 100);

    ImageSetIterator si = mImageSets.find(imageSetName);
    if (si == mImageSets.end())
    {
        logger->log("Warning: imageset \"%s\" not defined in %s",
            imageSetName.c_str(), getIdPath().c_str());
        return;
    }
    ImageSet *imageSet = si->second;

    if (actionName == SpriteAction::INVALID)
    {
        logger->log("Warning: Unknown action \"%s\" defined in %s",
            actionName.c_str(), getIdPath().c_str());
        return;
    }
    Action *action = new Action;
    action->setNumber(hp);
    addAction(hp, actionName, action);

    // dirty hack to fix bad resources in tmw server
    if (actionName == "attack_stab")
        addAction(hp, "attack", action);

    // When first action set it as default direction
    Actions::const_iterator i = mActions.find(hp);
    if ((*i).second->size() == 1)
        addAction(hp, SpriteAction::DEFAULT, action);

    // Load animations
    for_each_xml_child_node(animationNode, node)
    {
        if (xmlNameEqual(animationNode, "animation"))
            loadAnimation(animationNode, action, imageSet, variant_offset);
    }
}