Ejemplo n.º 1
0
/*
 * decide phase execution
 */
void BallTaking::update(BallTakingOutput& output)
{
  output.isLeavingPossible = false;
  ballData(output);
  output.isTakable = takable.isFilled() && takable.getAverage() == 1;

  if(theMotionSelection.ratios[MotionRequest::takeBall] > 0)
  { 
    //finished
    if(phaseLeavingPossible && phase == 5)
    {
      output.isLeavingPossible = true;
      //todo odometry offset

      side = 0;
      phase = 0;
      phaseStart = 0;
      phaseLeavingPossible = false;

      return;
    }
    else if(phaseLeavingPossible)
    {
      phase++;
      phaseStart = theFrameInfo.time;
      phaseLeavingPossible = false;
    }
     
         if(phase == 0) phaseZero(output);
    else if(phase == 1) phaseOne(output);
    else if(phase == 2) phaseTwo(output);
    else if(phase == 3) phaseThree(output);
    else if(phase == 4) phaseFour(output);
    else if(phase == 5) phaseFive(output);

    int hardness = 90;
    output.jointHardness.hardness[JointData::LHipRoll] = hardness;
    output.jointHardness.hardness[JointData::LHipPitch] = hardness;
    output.jointHardness.hardness[JointData::LKneePitch] = hardness;
    output.jointHardness.hardness[JointData::LAnklePitch] = hardness;
    output.jointHardness.hardness[JointData::LAnkleRoll] = hardness;
    output.jointHardness.hardness[JointData::RHipRoll] = hardness;
    output.jointHardness.hardness[JointData::RHipPitch] = hardness;
    output.jointHardness.hardness[JointData::RKneePitch] = hardness;
    output.jointHardness.hardness[JointData::RAnklePitch] = hardness;
    output.jointHardness.hardness[JointData::RAnkleRoll] = hardness;
    
    output.angles[JointData::LShoulderPitch] = JointData::ignore;
    output.angles[JointData::LShoulderRoll] = JointData::ignore;
    output.angles[JointData::RShoulderPitch] = JointData::ignore;
    output.angles[JointData::RShoulderRoll] = JointData::ignore;
    output.angles[JointData::LElbowRoll] = JointData::ignore;
    output.angles[JointData::LElbowYaw] = JointData::ignore;
    output.angles[JointData::RElbowRoll] = JointData::ignore;
    output.angles[JointData::RElbowYaw] = JointData::ignore;
    
    output.angles[JointData::HeadPitch] = JointData::ignore;
    output.angles[JointData::HeadYaw] = JointData::ignore;
  }
}
Ejemplo n.º 2
0
void BigMoney::update(float deltaTime, Player* player)
{
	m_collisionBox = { Vector2f(m_position.x - 175 + 100, m_position.y - 175), 250, 250 };

	switch (m_phaseNumber)
	{
		case 1:
		{
			phaseOne();
		} break;
		case 2:
		{
			phaseTwo(deltaTime, player);
		} break;
		case 3:
		{
			phaseThree(deltaTime);
		} break;
	}

	for (int i = 0; i < MAX_PROJECTILE_AMOUNT; i++)
	{
		if (m_Projectiles[i].isActive()) m_Projectiles[i].update(deltaTime);
	}

	//Check for collision with the projectiles for bosses and the player
	for (int i = 0; i < MAX_PROJECTILE_AMOUNT; i++)
		if (m_Projectiles[i].isActive())
			if (Collision(m_Projectiles[i].getCollisionBox(), player->getCollisionBox()) &&
				m_collisionTimer.getTicks() > 2000)
			{
				m_collisionTimer.start();
				if (player->getPlayerHealth() > 0) player->hit();
			}
	
	//Special collision case for implosion attack
	for (int i = 500; i < 700; i++)
	{
		if (m_Projectiles[i].isActive() && m_phaseNumber != 2)
		{
			if (Collision(m_Projectiles[i].getCollisionBox(), m_collisionBox))
			{
				GLfloat scale = m_Projectiles[i].getXScale() - 3 * deltaTime;
				m_Projectiles[i].setScale(scale, scale);
				if (scale <= 0.05f)
				{
					m_Projectiles[i].setScale(1.f, 1.f);
					m_Projectiles[i].setActive(false);
				}
			}
		}
	}
	
	//Player hits boss
	for (int i = 0; i < player->getWeapon()->getBulletAmount(); i++)
	{
		if (player->getWeapon()->getProjectiles()[i].isActive())
		{
			if (Collision(m_collisionBox, player->getWeapon()->getProjectiles()[i].getCollisionBox()))
			{
				if (m_bossCollisionTimer.getTicks() > 1500)
				{
					m_bossCollisionTimer.start();
					switch (m_phaseNumber)
					{
					case 1:
					{
						m_health -= 3.75;
					} break;
					case 2:
					{
						m_health -= 3;
					} break;
					case 3:
					{
						m_health -= 5;
					} break;
					}
				}
				player->getWeapon()->getProjectiles()[i].reload(Vector2f(0, 0), Vector2f(0, 0), 0, 0);
			}
		}
	}

	m_healthBarParticleEmitter->setLifeDuration(3.f / (100 / m_health));
	m_healthBarParticleEmitter->setLifeVariance(1.f / (100 / m_health));
	m_healthBarParticleEmitter->update(deltaTime, Vector2f(randFloat(2.f, 4.f), randFloat(0.05f / (m_health / 100), -0.05f / (m_health / 100))));

	if (m_phaseNumber == 3 && m_health == 0)
	{
		Warp::getInstance().setPosition(m_position);
		Warp::getInstance().update(deltaTime);
	}
}