~ubuntu-branches/ubuntu/natty/plee-the-bear/natty

« back to all changes in this revision

Viewing changes to plee-the-bear/src/ptb/item/code/small_honeypot.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Julien Jorge, Julien Jorge
  • Date: 2010-11-17 20:13:34 UTC
  • mfrom: (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20101117201334-o4dp7uq437to7oxb
Tags: 0.5.1-1
[ Julien Jorge ]
* New upstream release (Closes: #565062, #546514).
* Add armhf architecture (Closes: #604689).
* Remove patches integrated upstream: rpath-editors.diff, rpath-game.diff,
  editors-menu-section.diff.
* Bump the Standard-Version, no changes.
* Update my email address.
* Set build dependency of libclaw to 1.6.0.
* Add the missing ${misc:Depends} in debian/control.
* List gettext translations in bear-factory.install and plee-the-bear.install.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
  Plee the Bear
3
3
 
4
 
  Copyright (C) 2005-2009 Julien Jorge, Sebastien Angibaud
 
4
  Copyright (C) 2005-2010 Julien Jorge, Sebastien Angibaud
5
5
 
6
6
  This program is free software; you can redistribute it and/or modify it
7
7
  under the terms of the GNU General Public License as published by the
30
30
 
31
31
#include "universe/collision_info.hpp"
32
32
#include "generic_items/decorative_item.hpp"
33
 
#include "ptb/item/plee/plee.hpp"
 
33
#include "ptb/player.hpp"
34
34
#include "engine/game.hpp"
35
35
 
36
36
#include "engine/export.hpp"
51
51
 
52
52
/*----------------------------------------------------------------------------*/
53
53
/**
54
 
 * \brief Initialize the item.
 
54
 * \brief Load the media required by this class.
55
55
 */
56
 
void ptb::small_honeypot::build()
 
56
void ptb::small_honeypot::pre_cache()
57
57
{
58
 
  super::build();
59
 
 
60
 
  switch(get_type())
61
 
    {
62
 
    case fire_power:
63
 
      set_animation
64
 
        ( get_level_globals().get_animation
65
 
          ("animation/powerup/small_fire.canim") );
66
 
      break;
67
 
    case air_power:
68
 
      set_animation
69
 
        ( get_level_globals().get_animation
70
 
          ("animation/powerup/small_air.canim") );
71
 
      break;
72
 
    case water_power:
73
 
      set_animation
74
 
        ( get_level_globals().get_animation
75
 
          ("animation/powerup/small_water.canim") );
76
 
      break;
77
 
    default:
78
 
      {
79
 
        CLAW_ASSERT( false, 
80
 
                     "'unknown_type' is not a valid power for this class." );
81
 
      }
82
 
    } 
83
 
} // small_honeypot::build()
84
 
 
 
58
  super::pre_cache();
 
59
 
 
60
  get_level_globals().load_animation("animation/powerup/small_air.canim");
 
61
  get_level_globals().load_animation("animation/powerup/small_fire.canim");
 
62
  get_level_globals().load_animation("animation/powerup/small_water.canim");
 
63
} // small_honeypot::pre_cache()
 
64
 
85
65
/*----------------------------------------------------------------------------*/
86
66
/**
87
67
 * \brief Check if the collision is with a player.
91
71
void ptb::small_honeypot::collision_check_and_apply
92
72
( bear::engine::base_item& that, bear::universe::collision_info& info )
93
73
{
94
 
  plee* p = dynamic_cast<plee*>(&that);
95
 
  
 
74
  player* p = dynamic_cast<player*>(&that);
 
75
 
96
76
  if ( p != NULL )
97
77
    {
98
 
      if ( ! get_bonus_given() &&
99
 
           ( info.get_collision_side() != bear::universe::zone::middle_zone ) )
 
78
      if ( !get_bonus_given() &&
 
79
           ( info.get_collision_side() != bear::universe::zone::middle_zone )
 
80
           && ( p->get_index() <= 2 ) &&
 
81
           ( ( get_type() != base_bonus::air_power ) ||
 
82
             ( !game_variables::get_air_power(p->get_index()) ) ) &&
 
83
           ( ( get_type() != base_bonus::fire_power ) ||
 
84
             ( !game_variables::get_fire_power(p->get_index()) ) ) &&
 
85
           ( ( get_type() != base_bonus::water_power ) ||
 
86
             ( !game_variables::get_water_power(p->get_index()) ) ) )
100
87
        give_bonus(p);
101
88
    }
102
89
} // small_honeypot::collision_check_and_apply()
112
99
{
113
100
  collision_check_and_apply(that, info);
114
101
} // small_honeypot::collision()
 
102
 
 
103
/*----------------------------------------------------------------------------*/
 
104
/**
 
105
 * \brief Do the actions related to a change in the bonus type.
 
106
 * \param t The new type of the bonus.
 
107
 */
 
108
void ptb::small_honeypot::do_set_type(base_bonus_type t)
 
109
{
 
110
  switch(t)
 
111
    {
 
112
    case fire_power:
 
113
      set_animation
 
114
        ( get_level_globals().get_animation
 
115
          ("animation/powerup/small_fire.canim") );
 
116
      break;
 
117
    case air_power:
 
118
      set_animation
 
119
        ( get_level_globals().get_animation
 
120
          ("animation/powerup/small_air.canim") );
 
121
      break;
 
122
    case water_power:
 
123
      set_animation
 
124
        ( get_level_globals().get_animation
 
125
          ("animation/powerup/small_water.canim") );
 
126
      break;
 
127
    default:
 
128
      {
 
129
        CLAW_FAIL( "Not a valid power for this class." );
 
130
      }
 
131
    }
 
132
} // small_honeypot::do_set_type()