Esempio n. 1
0
void Weapon::Deselect()
{
  ActiveTeam().crosshair.SetActive(false);
  ActiveCharacter().SetFiringAngle(0);
  ActiveCharacter().SetMovement("breathe");
  MSG_DEBUG("weapon.change", "Deselect %s", m_name.c_str());
  p_Deselect();
}
Esempio n. 2
0
void JetPack::Refresh()
{
  if (active) {
    Point2d F(0.0, 0.0);
    const UDMoveIntention * ud_move_intention = ActiveCharacter().GetLastUDMoveIntention();
    if (ud_move_intention && ud_move_intention->GetDirection() == DIRECTION_UP) {
      F.y = -(ActiveCharacter().GetMass() * GameMode::GetInstance()->gravity + JETPACK_FORCE);
    }
    const LRMoveIntention * lr_move_intention = ActiveCharacter().GetLastLRMoveIntention();
    if (lr_move_intention && IsInAir()) {
      LRDirection direction = lr_move_intention->GetDirection();
      if (direction == DIRECTION_LEFT)
        F.x = -JETPACK_FORCE;
      else
        F.x = JETPACK_FORCE;
      ActiveCharacter().SetDirection(direction);
    }

    if (F.IsNull() && m_flying)
      StopFlying();
    else if (!F.IsNull() && !m_flying)
      StartFlying();

    ActiveCharacter().SetExternForceXY(F);

    if (!F.IsNull()) {
      // We are using fuel !!!
      uint current = GameTime::GetInstance()->Read() ;
      int64_t delta = current - m_last_fuel_down;

      while (delta >= DELTA_FUEL_DOWN) {
        if (EnoughAmmoUnit()) {
          UseAmmoUnit();
          m_last_fuel_down += DELTA_FUEL_DOWN ;
          delta -= DELTA_FUEL_DOWN ;
        } else {
          p_Deselect();
          break;
        }
      }

    }
  }
}