Exemple #1
0
/**
 * \brief This function is called by the map when the game is suspended or resumed.
 *
 * This is a redefinition of MapEntity::set_suspended() to suspend the timer
 * which makes the pickable item disappear after a few seconds.
 *
 * \param suspended true to suspend the entity, false to resume it
 */
void Pickable::set_suspended(bool suspended) {

  Detector::set_suspended(suspended); // suspend the animation and the movement

  if (shadow_sprite != nullptr) {
    shadow_sprite->set_suspended(suspended);
  }

  if (!suspended) {
    // suspend the timers

    uint32_t now = System::now();

    if (!can_be_picked && get_when_suspended() != 0) {
      allow_pick_date = now + (allow_pick_date - get_when_suspended());
    }

    if (will_disappear) {

      // the game is being resumed
      // recalculate the blinking date and the disappearing date
      if (get_when_suspended() != 0) {
        blink_date = now + (blink_date - get_when_suspended());
        disappear_date = now + (disappear_date - get_when_suspended());
      }
    }
  }
}
Exemple #2
0
/**
 * \brief This function is called by the map when the game is suspended or resumed.
 * \param suspended true to suspend the entity, false to resume it
 */
void Bomb::set_suspended(bool suspended) {

  Detector::set_suspended(suspended); // suspend the animation and the movement

  if (!suspended && get_when_suspended() != 0) {
    // recalculate the timer
    uint32_t diff = System::now() - get_when_suspended();
    explosion_date += diff;
  }
}
Exemple #3
0
/**
 * \brief Suspends or resumes this movement.
 * \param suspended true to suspend the movement, false to resume it
 */
void PathMovement::set_suspended(bool suspended) {

  PixelMovement::set_suspended(suspended);

  if (!suspended
      && get_when_suspended() != 0
      && stop_snapping_date != 0) {
    stop_snapping_date += System::now() - get_when_suspended();
  }
}
Exemple #4
0
void StraightMovement::set_suspended(bool suspended) {
	Movement::set_suspended(suspended);
	if(!suspended) {
		if(get_when_suspended() != 0) {
			uint32_t difference = System::now() - get_when_suspended();
			// Sets next move date.
			next_move_date_x += difference;
			next_move_date_y += difference;
		}
	}
}
Exemple #5
0
/**
 * \brief Suspends or resumes the movement
 * \param suspended true to suspend the movement, false to resume it
 */
void CircleMovement::set_suspended(bool suspended) {

  Movement::set_suspended(suspended);

  if (get_when_suspended() != 0) {
    uint32_t diff = System::now() - get_when_suspended();
    next_angle_change_date += diff;
    next_radius_change_date += diff;
    end_movement_date += diff;
    restart_date += diff;
  }
}
/**
 * @brief Suspends or resumes the movement.
 *
 * This function is called by the entity when the game is suspended or resumed.
 *
 * @param suspended true to suspend the movement, false to resume it
 */
void StraightMovement::set_suspended(bool suspended) {

  Movement::set_suspended(suspended);

  if (!suspended) {

    // recalculate the next move date
    if (get_when_suspended() != 0) {
      uint32_t diff = System::now() - get_when_suspended();
      next_move_date_x += diff;
      next_move_date_y += diff;
    }
  }
}
void Hero::BackToSolidGroundState::set_suspended(bool suspended) {

  State::set_suspended(suspended);

  if (!suspended && end_date != 0) {
    end_date += System::now() - get_when_suspended();
  }
}
Exemple #8
0
/**
 * \brief Suspends or resumes the entity.
 * \param suspended true to suspend the entity, false to resume it
 */
void Crystal::set_suspended(bool suspended) {

    Entity::set_suspended(suspended);

    if (!suspended) {
        next_possible_hit_date += System::now() - get_when_suspended();
    }
}
Exemple #9
0
/**
 * \brief Notifies this state that the game was just suspended or resumed.
 * \param suspended true if the game is suspended
 */
void Hero::SwimmingState::set_suspended(bool suspended) {

  PlayerMovementState::set_suspended(suspended);

  if (!is_suspended() && fast_swimming) {
    end_fast_swim_date += System::now() - get_when_suspended();
  }
}
Exemple #10
0
/**
 * \brief Notifies this state that the game was just suspended or resumed.
 * \param suspended true if the game is suspended
 */
void Hero::FreeState::set_suspended(bool suspended) {

  PlayerMovementState::set_suspended(suspended);

  if (!suspended) {
    start_pushing_date += System::now() - get_when_suspended();
  }
}
Exemple #11
0
/**
 * \brief Notifies this state that the game was just suspended or resumed.
 * \param suspended true if the game is suspended
 */
void Hero::SwordTappingState::set_suspended(bool suspended) {

  State::set_suspended(suspended);

  if (!suspended) {
    next_sound_date += System::now() - get_when_suspended();
  }
}
Exemple #12
0
void StraightMovement::set_next_move_date_y(uint32_t next_move_date_y) {
	if(is_suspended()) {
		uint32_t delay = next_move_date_y - System::now();
		this->next_move_date_y = get_when_suspended() + delay;
	} else {
		this->next_move_date_y = next_move_date_y;
	}
}
/**
 * \brief Notifies this state that the game was just suspended or resumed.
 * \param suspended true if the game is suspended
 */
void Hero::VictoryState::set_suspended(bool suspended) {

  HeroState::set_suspended(suspended);

  if (!suspended) {
    end_victory_date += System::now() - get_when_suspended();
  }
}
Exemple #14
0
/**
 * \brief Suspends or resumes this movement.
 * \param suspended true to suspend the movement, false to resume it
 */
void RandomMovement::set_suspended(bool suspended) {

  StraightMovement::set_suspended(suspended);

  if (!suspended) {
    next_direction_change_date += System::now() - get_when_suspended();
  }
}
/**
 * \brief Notifies this state that the game was just suspended or resumed.
 * \param suspended true if the game is suspended
 */
void Hero::SwordLoadingState::set_suspended(bool suspended) {

  PlayerMovementState::set_suspended(suspended);

  if (!suspended) {
    sword_loaded_date += System::now() - get_when_suspended();
  }
}
Exemple #16
0
/**
 * \brief Notifies this state that the game was just suspended or resumed.
 * \param suspended true if the game is suspended
 */
void Hero::HurtState::set_suspended(bool suspended) {

  State::set_suspended(suspended);

  if (!suspended) {
    uint32_t diff = System::now() - get_when_suspended();
    end_hurt_date += diff;
  }
}
Exemple #17
0
/**
 * \brief This function is called by the map when the game is suspended or resumed.
 *
 * This is a redefinition of MapEntity::set_suspended() to suspend the timer
 * of the chest being opened.
 *
 * \param suspended true to suspend the entity, false to resume it
 */
void Chest::set_suspended(bool suspended) {

  MapEntity::set_suspended(suspended);

  if (!suspended && treasure_date != 0) {
    // restore the timer
    treasure_date = System::now() + (treasure_date - get_when_suspended());
  }
}
Exemple #18
0
/**
 * \brief This function is called by the map when the game is suspended or resumed.
 * \param suspended true to suspend the entity, false to resume it
 */
void Destructible::set_suspended(bool suspended) {

  MapEntity::set_suspended(suspended); // suspend the animation and the movement

  if (!suspended && regeneration_date != 0) {
    // Recompute the date.
    regeneration_date += System::now() - get_when_suspended();
  }
}
Exemple #19
0
/**
 * \brief This function is called by the map when the game is suspended or resumed.
 * \param suspended true to suspend the entity, false to resume it
 */
void Arrow::set_suspended(bool suspended) {

  MapEntity::set_suspended(suspended); // suspend the movement

  if (!suspended) {
    // recalculate the timer
    disappear_date += System::now() - get_when_suspended();
  }
}
/**
 * \brief Notifies this state that the game was just suspended or resumed.
 * \param suspended true if the game is suspended
 */
void Hero::RunningState::set_suspended(bool suspended) {

  State::set_suspended(suspended);

  if (!suspended) {
    uint32_t diff = System::now() - get_when_suspended();
    next_phase_date += diff;
    next_sound_date += diff;
  }
}
Exemple #21
0
/**
 * \brief This function is called by the map when the game is suspended or resumed.
 * \param suspended true to suspend the entity, false to resume it
 */
void CarriedItem::set_suspended(bool suspended) {

  Entity::set_suspended(suspended); // suspend the animation and the movement

  if (is_throwing) {
    // suspend the shadow
    shadow_sprite->set_suspended(suspended);
  }

  if (!suspended && get_when_suspended() != 0) {
    // recalculate the timers
    uint32_t diff = System::now() - get_when_suspended();
    if (is_throwing) {
      next_down_date += diff;
    }
    if (can_explode()) {
      explosion_date += diff;
    }
  }
}
Exemple #22
0
/**
 * \brief Notifies this state that the game was just suspended or resumed.
 * \param suspended true if the game is suspended
 */
void Hero::StairsState::set_suspended(bool suspended) {

    State::set_suspended(suspended);

    if (carried_item != nullptr) {
        carried_item->set_suspended(suspended);
    }

    if (!suspended) {
        next_phase_date += System::now() - get_when_suspended();
    }
}
/**
 * \brief Starts this state.
 * \param previous_state the previous state
 */
void Hero::VictoryState::start(const HeroState* previous_state) {

  HeroState::start(previous_state);

  get_sprites().set_animation_victory();
  get_sprites().set_ignore_suspend(true);
  Sound::play("victory");

  // compute the date when the victory state is considered as finished,
  // but the game may be currently suspended
  uint32_t start_victory_date = is_suspended() ?
      get_when_suspended() : System::now();
  end_victory_date = start_victory_date + 1500;
}
Exemple #24
0
/**
 * \brief Suspends or resumes the entity.
 * \param suspended true to suspend the entity, false to resume it
 */
void Enemy::set_suspended(bool suspended) {

  Detector::set_suspended(suspended);

  if (!suspended) {
    uint32_t diff = System::now() - get_when_suspended();
    stop_hurt_date += diff;
    vulnerable_again_date += diff;
    if (can_attack_again_date != 0) {
      can_attack_again_date += diff;
    }
    start_shaking_date += diff;
    end_shaking_date += diff;
    next_explosion_date += diff;
  }
  get_lua_context().enemy_on_suspended(*this, suspended);
}
Exemple #25
0
/**
 * \brief Notifies the transition effect that it was just suspended
 * or resumed.
 * \param suspended true if suspended, false if resumed.
 */
void TransitionFade::notify_suspended(bool suspended) {

  if (!suspended) {
    next_frame_date += System::now() - get_when_suspended();
  }
}
/**
 * \brief Notifies the transition effect that it was just suspended
 * or resumed.
 * \param suspended true if suspended, false if resumed.
 */
void TransitionScrolling::notify_suspended(bool suspended) {

  if (!suspended) {
    next_scroll_date += System::now() - get_when_suspended();
  }
}