Exemple #1
0
Cat::Cat(const Filesystem::AbsolutePath & filename):
ObjectNonAttack( 0, 0 ),
state( IDLE1 ){

	path = filename;

	setMaxHealth( 1 );
	setHealth( 1 );
	
	TokenReader tr;
	try{
		Token * head;
		head = tr.readTokenFromFile(path.path());
		if ( *head != "cat" ){
			throw LoadException(__FILE__, __LINE__, "File does not begin with 'Cat'" );
		}

		while ( head->hasTokens() ){
			Token * next = head->readToken();
			if ( *next == "animation" ){
				Animation * animation = new Animation( next, 0 );
				animations[ animation->getName() ] = animation;
			}
		}
		if ( animations.size() == 0 ){
			throw LoadException(__FILE__, __LINE__, "No animation given" );
		}
        } catch (const TokenException & ex){
            // Global::debug(0) << "Could not read "<< filename.path() <<": "<< ex.getReason()<<endl;
            throw LoadException(__FILE__, __LINE__, ex, "Could not open file " + filename.path());
        }
	current_animation = animations[ "idle1" ];

	meow = Sound(Storage::instance().find(Filesystem::RelativePath("misc/cat/meow.wav")).path());
}
void player::setClass(characterClass input)
{
    playerClass=input;
    setHealth(20);
    setMaxHealth(20);
    setLevel(1);
    setExperience(0);
    setXpToLevel(10);

    return;
}
void Monster::onEnter()
{
	Character::onEnter();

	schedule(schedule_selector(Monster::onUpdate));

	int MonsterIdx = m_iMonsterID - 1;

	setCurSpeed(GI.getMonsterConfig()[MonsterIdx].fMoveSpeed);
	setMaxSpeed(GI.getMonsterConfig()[MonsterIdx].fMoveSpeed);
	setMaxHealth(GI.getMonsterConfig()[MonsterIdx].iHP);
	setCurHealth(GI.getMonsterConfig()[MonsterIdx].iHP);

	setMoveVector(ccp(1, 0));

	sprintf(CMonster, "spirit/monster/Monster%d", m_iMonsterID);
	std::string StrMonster(CMonster);

	// 设置动画
	// 0.右 1.下 2.左 3.上 
	m_pWalkAnim[0] = CCAnimation::create();
	m_pWalkAnim[0]->retain();
	m_pWalkAnim[0]->addSpriteFrameWithFileName( (StrMonster + std::string("_R_1.png")).c_str() );
	m_pWalkAnim[0]->addSpriteFrameWithFileName( (StrMonster + std::string("_R_2.png")).c_str() );
	m_pWalkAnim[0]->setDelayPerUnit(0.5f / getCurSpeed());

	m_pWalkAnim[1] = CCAnimation::create();
	m_pWalkAnim[1]->retain();
	m_pWalkAnim[1]->addSpriteFrameWithFileName( (StrMonster + std::string("_D_1.png")).c_str() );
	m_pWalkAnim[1]->addSpriteFrameWithFileName( (StrMonster + std::string("_D_2.png")).c_str() );
	m_pWalkAnim[1]->setDelayPerUnit(0.5f / getCurSpeed());

	m_pWalkAnim[2] = CCAnimation::create();
	m_pWalkAnim[2]->retain();
	m_pWalkAnim[2]->addSpriteFrameWithFileName( (StrMonster + std::string("_L_1.png")).c_str() );
	m_pWalkAnim[2]->addSpriteFrameWithFileName( (StrMonster + std::string("_L_2.png")).c_str() );
	m_pWalkAnim[2]->setDelayPerUnit(0.5f / getCurSpeed());

	m_pWalkAnim[3] = CCAnimation::create();
	m_pWalkAnim[3]->retain();
	m_pWalkAnim[3]->addSpriteFrameWithFileName( (StrMonster + std::string("_U_1.png")).c_str() );
	m_pWalkAnim[3]->addSpriteFrameWithFileName( (StrMonster + std::string("_U_2.png")).c_str() );
	m_pWalkAnim[3]->setDelayPerUnit(0.5f / getCurSpeed());

	// 设置技能
	m_pSkill = Skill::create(GI.getMonsterConfig()[MonsterIdx].iSkillID);
	addChild(m_pSkill);

	// 冰冻
	m_bIsFrozen = false;
	m_bForceToStop = false;
	m_bDropItemAfterDeath = true;
}
Exemple #4
0
Gib::Gib(const int x, const int y, const int z, double dx, double dy, double dz, const Graphics::Bitmap & image, const Util::ReferenceCount<Graphics::Bitmap> & bloodImage):
ObjectNonAttack(x, z),
dx(dx),
dy(dy),
dz(dz),
angle(0),
fade(0),
image(image),
bloodImage(bloodImage){
    setY(y);
    setMaxHealth(1);
    setHealth(1);

}
Exemple #5
0
void Unit::iniciarUnidad(PlayerType tj, PlayerColor cr, PlayerTeam eq, int maxVitalidad, int vitalidad, int maxEnergy, int energy){
    const int barWidth = 20;

//    QPainterPath path;
////    path.lineTo(10,0);
//    path.addEllipse(QRectF(-10, -10, 20, 20));
//    setShape(path);
//    includeBars = false;

    checkCounter = 0;

    setBorderWidth(2);
    setPlayerType(tj);
    setUnitColor(cr);
    setEquipo(eq);

    QRectF rectMA = MovilAgent::boundingRect();
    prepareGeometryChange();
    setMaxHealth(maxVitalidad);
    setHealth(vitalidad);
    setHealthBarPos(rectMA.topLeft() + QPointF(rectMA.width()/2 - barWidth/2, - 20));
    setHealthBarWidth(barWidth);
    setHealthBarHeight(4);
    setVisibleHealthBar(true);

    setMaxEnergy(maxEnergy);
    setEnergy(energy);
    setEnergyBarPos(rectMA.topLeft() + QPointF(rectMA.width()/2 - barWidth/2, - 10));
    setEnergyBarWidth(barWidth);
    setEnergyBarHeitght(4);
    setVisibleEnergyBar(true);

    setAcceptHoverEvents(true);

    PlayerColor pc;
    for(int i = 0; i < 8; i++){
        pc = (PlayerColor)i;
        if(pc == getUnitColor()){
            diplomacias[pc] = Alied;
        }else{
            diplomacias[pc] = Enemy;
        }
    }
    MovingActuator *actMov = dynamic_cast<MovingActuator*>(getActuator("movement"));

    connect(actMov, SIGNAL(positionChanged(QPointF)), SLOT(checkAll(QPointF)));
//    connect(actMov, SIGNAL(llegoADestinoFinal(QPointF)), SLOT(lastCheckPointReached(QPointF)));
}
Exemple #6
0
        Flame::Flame()
        {
                
                setTypeID(Boss_Flame);
                setCurrHealth(200);
                setMaxHealth(200);
                SetAttackRange(200);
                setAttackSpeed(0.25f);
                setAnchor(Vector2(1200,1200));
                setDefense(20);
                setSight(500);
                setLevel(6);

                setAllAnimationsArray();
                currentAnimation = allAnimations[Animation_East];
        }
Exemple #7
0
        Bruiser::Bruiser()
        {

                setTypeID(Boss_Bruiser);
                chargeDamage = 30;
                setCurrHealth(200);
                setMaxHealth(200);
                SetAttackRange(200);
                setAnchor(Vector2(1200,1200));
                setAttackSpeed(0.5f);
                setDefense(15);
                setSight(600);
                setLevel(5);

                setAllAnimationsArray();
                currentAnimation = allAnimations[Animation_East];
        }
Exemple #8
0
Cat::Cat( const Cat & cat ):
ObjectNonAttack( cat ),
state( IDLE1 ){
	setMaxHealth( cat.getMaxHealth() );
	setHealth( cat.getHealth() );
	path = cat.path;
	/*
	animation = new Animation( *Cat.animation, 0 );
	animation->reset();
	*/
	for ( map< string, Animation * >::const_iterator it = cat.animations.begin(); it != cat.animations.end(); it++ ){
		// animations.push_back( new Animation( **it, 0 ) );
		animations[ it->first ] = new Animation( *(it->second), 0 );

	}
	current_animation = animations[ "idle1" ];
	meow = cat.meow;
}
Exemple #9
0
        Flame::Flame(Vector2 const &_position, Vector2 const &_velocity, int _ID, float _currHealth,
                        int _direction)
        {
                setTypeID(Boss_Flame);
                setCurrHealth(_currHealth);
                setMaxHealth(200);
                setPosition(_position);
                setVelocity(_velocity);
                setDirection(_direction);
                setID(_ID);
                SetAttackRange(200);
                setAttackSpeed(0.25f);
                setDefense(20);
                setSight(500);
                setLevel(6);

                setAnchor(Vector2(1200,1200));
                setAllAnimationsArray();
                currentAnimation = allAnimations[Animation_East];
        }
Exemple #10
0
Slime::Slime(int x, int y, int slimeType, int level) : 
	Actor(ENEMY, x, y, 14, 10, true),
	mAnimation("graphics/slime" + toString(slimeType + 1) + ".bmp", 4),
	stateChangeTimer(0),
	mSlimeType(slimeType)
{
	mLevel = level;
	addState("idleleft", &mAnimation, 0, 0, 6, Actor::LEFT, false, false);
	addState("idleright", &mAnimation, 0, 0, 6, Actor::RIGHT, true, false);
	addState("walkleft", &mAnimation, -1, 0, 3, Actor::LEFT, false, false);
	addState("walkright", &mAnimation, 1, 0, 3, Actor::RIGHT, true, false);
	addState("walkup", &mAnimation, 0, -1, 3, Actor::UP, true, false);
	addState("walkdown", &mAnimation, 0, 1, 3, Actor::DOWN, false, false);

	setState(Random::get().getInt(2) == 0 ? "idleleft" : "idleright");
	stateChangeTimer = Random::get().getInt(10, 30);

	setMaxHealth(10 * (slimeType + 1));
	setHealth(getMaxHealth());
}
void player::levelUp()
{
    //Assigns to a random value at this point
    int currentAttribute;
    int randomAttribute = rand() % 3;
    switch(randomAttribute)
    {
        //Increases Damage
        case 0:
            currentAttribute = getBaseDamage() + 1;
            setBaseDamage(currentAttribute);
            break;
        //Increases Armor
        case 1:
            currentAttribute = getArmor() + 1;
            setArmor(currentAttribute);
            break;
        //Increase Health
        case 2:
            currentAttribute = getMaxHealth() + 1;
            setHealth(currentAttribute);
            setMaxHealth(currentAttribute);
            break;
    }


    experience=xpToLevel%experience;
    if((xpToLevel%2)>0)
    {
        xpToLevel=xpToLevel*1.5;
        xpToLevel++;
    }
    else
    {
        xpToLevel=xpToLevel*1.5;
    }
    int levelHolder=getLevel();
    levelHolder++;
    setLevel(levelHolder);
    return;
}
Exemple #12
0
        Bruiser::Bruiser(Vector2 const &_position, Vector2 const &_velocity, int _ID, float _currHealth,
                        int _direction)
        {
                setTypeID(Boss_Bruiser);
                chargeDamage = 30;
                setCurrHealth(_currHealth);
                setMaxHealth(200);
                setPosition(_position);
                setVelocity(_velocity);
                setDirection(_direction);
                setID(_ID);
                SetAttackRange(200);
                setAnchor(Vector2(1200,1200));
                setAttackSpeed(0.5f);
                setDefense(15);
                setSight(600);
                setLevel(5);

                setAllAnimationsArray();
                currentAnimation = allAnimations[Animation_East];
        }
Exemple #13
0
void cUnit::addMaxHealth(float d) { setMaxHealth(maxHealth + d); }