Пример #1
0
void Player::draw(const RenderData &renderData) {
   SPtr<Material> material = model->getMaterial();
   material->setSelected(isInvincible());

   Character::draw(renderData);

   aura->setScale(glm::vec3(getAuraRadius()));
   aura->setPosition(position);
   aura->draw(renderData);
}
Пример #2
0
		void Ship2::update(unsigned long elapsed_millis) {
			Ship::update(elapsed_millis);
			if (_ship1->isColliding(_physics->getPosition(),_shieldrad)) {
				if(_ship1->isInvincible() && isInvincible()) {
					cg::Vector2d collisionPoint = cg::Vector2d( (getXposition() + _ship1->getXposition())/2 , (getYposition() + _ship1->getYposition())/2);
					cg::Vector2d ship2Velocity = getVelocity();
					shock(collisionPoint, 0.5 * _ship1->getMass()*length(_ship1->getVelocity()));
					_ship1->shock(collisionPoint, 0.5 * _physics->getMass()*length(ship2Velocity));
					return;
				}
				explode();
				return;
			}
		}
Пример #3
0
void BuddyPlayer::hurt(int x){
    if (! isInvincible()){
        Character::hurt(x);
    }
}
Пример #4
0
void enemy::bigWolfAI(float elapsed)
{
	if (global_map->dialogueActive() || isInvincible())
		return;

	unsigned int switchTo = DATA_NONE;
	chargeD = 0;
	switch(bossPhase)
	{
	case 0:
		//no phase
		//switch to phase 1
		if(rand() % 100 <= bossProb)
		{
			switchTo = 1;
			bossProb = global_data->getValue(DATA_BOSSDATA, magic, 12);
		}
		else
		{
			switchTo = 3;
			bossProb = global_data->getValue(DATA_BOSSDATA, magic, 13);
		}
		break;
	case 1:
		//charge buildup phase
		{
			float bTM = global_data->getValue(DATA_BOSSDATA, magic, 1) * 0.01f;
			if (bossTimer <= bTM / 3)
				setAttackAnim(global_data->getValue(DATA_BOSSDATA, magic, 0) * BOSSTOOLM);
			else
				setAttackAnim(-1);
			if (bossTimer <= bTM * 2 / 3)
			{
				move(-facingX, elapsed * global_data->getValue(DATA_BOSSDATA, magic, 11) * 0.01f);

				if (x > global_map->getWidth() / 2)
					facingX = -1;
				else
					facingX = 1;
			}

			bossTimer -= elapsed;
			if (bossTimer <= 0)
			{
				global_map->forceSound(global_data->getValue(DATA_BOSSDATA, magic, 15));
				switchTo = 2; //start charging!
			}
		}
		break;
	case 2:
		//charge phase
		setAttackAnim(-1);
		float lowestD;
		if (facingX == 1)
			lowestD = abs(global_map->getWidth() - x - getMaskWidth() / 2);
		else
			lowestD = x + getMaskWidth() / 2;

		if (lowestD <= TILESIZE * 1.5 + getMaskWidth() / 2)
		{
			if (!walking()) //you've stopped moving
				switchTo = 0; //switch to a random phase
		}
		else
		{
			chargeD = global_data->getValue(DATA_BOSSDATA, magic, 10);
			move(facingX, elapsed);
		}
		break;
	case 3:
		//spray charge
		{
			float bTM = global_data->getValue(DATA_BOSSDATA, magic, 4) * 0.01f;

			bossTimer -= elapsed;

			if (bossTimer <= 0)
				switchTo = 4;
			else if (bossTimer > bTM / 2)
				setAttackAnim(-1);
			else
			{
				if (x > global_map->getWidth() / 2)
					facingX = -1;
				else
					facingX = 1;

				bossToolAnimSlideScale(global_data->getValue(DATA_BOSSDATA, magic, 2), global_data->getValue(DATA_BOSSDATA, magic, 3), 1 - 2 * bossTimer / bTM);
			}
		}
		break;
	case 4:
		//spray
		{
			float bTM = global_data->getValue(DATA_BOSSDATA, magic, 8) * 0.01f;
			float pInterval = bTM / global_data->getValue(DATA_BOSSDATA, magic, 6);
			float bTBefore = bossTimer;
			bossTimer -= elapsed;
			if (bossTimer < 0)
				bossTimer = 0;
			//now how many pIntervals have passed?
			while (true)
			{
				float nearestInterval = 0;
				while (nearestInterval <= bTBefore)
					nearestInterval += pInterval;
				if (nearestInterval > bTBefore)
					nearestInterval -= pInterval;

				if (nearestInterval >= bossTimer)
				{
					bTBefore -= pInterval;
					
					//make a projectile
					float angle;
					if (facingX == 1)
						angle = 0;
					else
						angle = (float) M_PI;
					float angleA = global_data->getValue(DATA_BOSSDATA, magic, 7) * (float) M_PI / 180;
					angle += (rand() % 200 - 100) * 0.01f * angleA;
					global_map->forceSound(global_data->getValue(DATA_BOSSDATA, magic, 14));
					global_map->addProjectile(projectileStartX(), projectileStartY(), cos(angle), sin(angle),
												global_data->getValue(DATA_BOSSDATA, magic, 5), global_data->getValue(DATA_BOSSDATA, magic, 9),
												DATA_NONE, TYPE_ENEMY, DATA_NONE, false);
				}
				else
					break; //there is no interval that is below btbefore and over bosstimer
			}
			if (bossTimer <= 0)
				switchTo = 0;
			else
				bossToolAnimSlideScale(global_data->getValue(DATA_BOSSDATA, magic, 2), global_data->getValue(DATA_BOSSDATA, magic, 3), bossTimer / bTM);
		}
		break;
	}

	if (switchTo != DATA_NONE)
	{
		bossPhase = switchTo;
		switch(bossPhase)
		{
		case 0:
			//no phase
			break;
		case 1:
			//charge buildup timer length
			bossTimer = global_data->getValue(DATA_BOSSDATA, magic, 1) * 0.01f;
			break;
		case 2:
			//charge
			break;
		case 3:
			//spray charge
			bossTimer = global_data->getValue(DATA_BOSSDATA, magic, 4) * 0.01f;
			break;
		case 4:
			//spray
			bossTimer = global_data->getValue(DATA_BOSSDATA, magic, 8) * 0.01f;
			break;
		}
	}
}