Replaced Ref and RefCounter with std::shared_ptr<>
[supertux.git] / src / badguy / igel.cpp
index 857023d..457b22d 100644 (file)
@@ -29,7 +29,7 @@ const float RANGE_OF_VISION = 256; /**< range in px at which we can see bullets
 } // namespace
 
 Igel::Igel(const Reader& reader) :
-  WalkingBadguy(reader, "images/creatures/igel/igel.sprite", "walking-left", "walking-right"), 
+  WalkingBadguy(reader, "images/creatures/igel/igel.sprite", "walking-left", "walking-right"),
   turn_recover_timer()
 {
   walk_speed = IGEL_SPEED;
@@ -79,7 +79,7 @@ Igel::active_update(float elapsed_time)
   // check if we see a fire bullet
   Sector* sector = Sector::current();
   for (Sector::GameObjects::iterator i = sector->gameobjects.begin(); i != sector->gameobjects.end(); ++i) {
-    Bullet* bullet = dynamic_cast<Bullet*>(*i);
+    Bullet* bullet = dynamic_cast<Bullet*>(i->get());
     if (!bullet) continue;
     if (bullet->get_type() != FIRE_BONUS) continue;
     if (can_see(*bullet)) wants_to_flee = true;
@@ -99,8 +99,9 @@ Igel::active_update(float elapsed_time)
 HitResponse
 Igel::collision_bullet(Bullet& bullet, const CollisionHit& hit)
 {
-  // default reaction if hit on front side
-  if (((dir == LEFT) && hit.left) || ((dir == RIGHT) && hit.right)) {
+  // default reaction if hit on front side or for freeze and unfreeze
+  if (((dir == LEFT) && hit.left) || ((dir == RIGHT) && hit.right) ||
+    (bullet.get_type() == ICE_BONUS) || ((bullet.get_type() == FIRE_BONUS) && (frozen))) {
     return BadGuy::collision_bullet(bullet, hit);
   }
 
@@ -110,6 +111,12 @@ Igel::collision_bullet(Bullet& bullet, const CollisionHit& hit)
 }
 
 bool
+Igel::is_freezable() const
+{
+  return true;
+}
+
+bool
 Igel::collision_squished(GameObject& )
 {
   // this will hurt