projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update CMake to 3.2.1 in .travis.yml
[supertux.git]
/
src
/
badguy
/
dispenser.cpp
diff --git
a/src/badguy/dispenser.cpp
b/src/badguy/dispenser.cpp
index
da9514b
..
1f48673
100644
(file)
--- a/
src/badguy/dispenser.cpp
+++ b/
src/badguy/dispenser.cpp
@@
-39,7
+39,7
@@
Dispenser::Dispenser(const Reader& reader) :
type()
{
set_colgroup_active(COLGROUP_MOVING_STATIC);
type()
{
set_colgroup_active(COLGROUP_MOVING_STATIC);
-
sound_manager
->preload("sounds/squish.wav");
+
SoundManager::current()
->preload("sounds/squish.wav");
reader.get("cycle", cycle);
reader.get("badguy", badguys);
random = false; // default
reader.get("cycle", cycle);
reader.get("badguy", badguys);
random = false; // default
@@
-111,7
+111,7
@@
Dispenser::collision_squished(GameObject& object)
if (player){
player->bounce(*this);
}
if (player){
player->bounce(*this);
}
-
sound_manager
->play("sounds/squish.wav", get_pos());
+
SoundManager::current()
->play("sounds/squish.wav", get_pos());
broken = true;
return true;
}
broken = true;
return true;
}
@@
-145,7
+145,7
@@
Dispenser::active_update(float )
{
if (dispense_timer.check()) {
// auto always shoots in Tux's direction
{
if (dispense_timer.check()) {
// auto always shoots in Tux's direction
- if( autotarget ){
+ if( autotarget ){
if( sprite->animation_done()) {
sprite->set_action(dir == LEFT ? "working-left" : "working-right");
swivel = false;
if( sprite->animation_done()) {
sprite->set_action(dir == LEFT ? "working-left" : "working-right");
swivel = false;
@@
-154,7
+154,7
@@
Dispenser::active_update(float )
Player* player = this->get_nearest_player();
if( player && !swivel ){
Direction targetdir = (player->get_pos().x > get_pos().x) ? RIGHT : LEFT;
Player* player = this->get_nearest_player();
if( player && !swivel ){
Direction targetdir = (player->get_pos().x > get_pos().x) ? RIGHT : LEFT;
- if( dir != targetdir ){ // no target: swivel cannon
+ if( dir != targetdir ){ // no target: swivel cannon
swivel = true;
dir = targetdir;
sprite->set_action(dir == LEFT ? "swivel-left" : "swivel-right", 1);
swivel = true;
dir = targetdir;
sprite->set_action(dir == LEFT ? "swivel-left" : "swivel-right", 1);
@@
-178,8
+178,8
@@
Dispenser::launch_badguy()
Player* player = this->get_nearest_player();
if( player ){
launchdir = (player->get_pos().x > get_pos().x) ? RIGHT : LEFT;
Player* player = this->get_nearest_player();
if( player ){
launchdir = (player->get_pos().x > get_pos().x) ? RIGHT : LEFT;
- }
- }
+ }
+ }
if (badguys.size() > 1) {
if (random) {
if (badguys.size() > 1) {
if (random) {
@@
-199,10
+199,13
@@
Dispenser::launch_badguy()
log_warning << "random is outdated; use a list of badguys to select from." << std::endl;
return;
}
log_warning << "random is outdated; use a list of badguys to select from." << std::endl;
return;
}
+ if(badguy == "goldbomb") {
+ log_warning << "goldbomb is not allowed to be dispensed" << std::endl;
+ return;
+ }
try {
try {
- GameObject *game_object;
- MovingObject *moving_object;
+ GameObjectPtr game_object;
Vector spawnpoint;
Rectf object_bbox;
Vector spawnpoint;
Rectf object_bbox;
@@
-211,29
+214,33
@@
Dispenser::launch_badguy()
if (game_object == NULL)
throw std::runtime_error("Creating " + badguy + " object failed.");
if (game_object == NULL)
throw std::runtime_error("Creating " + badguy + " object failed.");
- moving_object = dynamic_cast<MovingObject *> (game_object);
- if (moving_object == NULL)
- throw std::runtime_error(badguy + " is not a moving object.");
+ BadGuy& bad_guy = dynamic_cast<BadGuy&>(*game_object);
- object_bbox =
moving_object->get_bbox
();
+ object_bbox =
bad_guy.get_bbox
();
- if (type == "dropper") {
- spawnpoint = get_anchor_pos (get_bbox (), ANCHOR_BOTTOM);
- spawnpoint.x -= 0.5 * object_bbox.get_width ();
+ if (type == "dropper")
+ {
+ spawnpoint = get_anchor_pos (get_bbox(), ANCHOR_BOTTOM);
+ spawnpoint.x -= 0.5 * object_bbox.get_width();
}
}
- else if ((type == "cannon") || (type == "rocketlauncher")) {
- spawnpoint = get_pos (); /* top-left corner of the cannon */
+ else if ((type == "cannon") || (type == "rocketlauncher"))
+ {
+ spawnpoint = get_pos(); /* top-left corner of the cannon */
if (launchdir == LEFT)
if (launchdir == LEFT)
- spawnpoint.x -= object_bbox.get_width
() + 1;
+ spawnpoint.x -= object_bbox.get_width() + 1;
else
else
- spawnpoint.x += get_bbox
().get_width
() + 1;
+ spawnpoint.x += get_bbox
().get_width
() + 1;
}
/* Now we set the real spawn position */
}
/* Now we set the real spawn position */
- moving_object->set_pos (spawnpoint);
+ bad_guy.set_pos(spawnpoint);
+
+ /* We don't want to count dispensed badguys in level stats */
+ if(bad_guy.countMe)
+ bad_guy.countMe = false;
- Sector::current()->add_object(
moving
_object);
- } catch(std::exception& e) {
+ Sector::current()->add_object(
game
_object);
+ } catch(
const
std::exception& e) {
log_warning << "Error dispensing badguy: " << e.what() << std::endl;
return;
}
log_warning << "Error dispensing badguy: " << e.what() << std::endl;
return;
}