/[enigma]/enigma/src/stones_simple.cc
ViewVC logotype

Diff of /enigma/src/stones_simple.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.36 by dheck, Sat Jul 12 10:04:47 2003 UTC revision 1.37 by reallysoft, Sun Jul 13 19:29:15 2003 UTC
# Line 354  namespace Line 354  namespace
354    
355    
356          SwapStone(Stone *exchanged_with, Direction dir)          SwapStone(Stone *exchanged_with, Direction dir)
357              : Stone("st-swap")              : Stone(exchanged_with->get_kind()) // fake kind
358              , state(GO)              , state(GO)
359              , in_exchange_with(exchanged_with)              , in_exchange_with(exchanged_with)
360              , move_dir(dir)              , move_dir(dir)
# Line 367  namespace Line 367  namespace
367              Stone::on_creation();              Stone::on_creation();
368          }          }
369    
370            void on_removal() {
371                if (state != IDLE) {
372                    g_timer.remove_alarm(this);
373                }
374            }
375    
376          void alarm() {          void alarm() {
377              switch (state) {              switch (state) {
378                  case COME:                  case COME:
# Line 378  namespace Line 384  namespace
384                      assert(in_exchange_with);                      assert(in_exchange_with);
385                      Stone   *st = in_exchange_with;                      Stone   *st = in_exchange_with;
386                      GridPos  p  = get_pos();                      GridPos  p  = get_pos();
387                        state       = IDLE;
388                      KillStone(p);                      KillStone(p);
389                      SetStone(p, st);                      SetStone(p, st);
390                      st->on_move();                      st->on_move();
# Line 394  namespace Line 401  namespace
401                  GridPos oldp = get_pos();                  GridPos oldp = get_pos();
402                  GridPos newp = move(oldp, impulse.dir);                  GridPos newp = move(oldp, impulse.dir);
403    
404                  if (Stone *st = YieldStone(newp)) {                  if (!IsLevelBorder(newp)) {
405                      if (!st->is_kind("borderstone")) {                      if (Stone *st = YieldStone(newp)) {
406                          Stone *self = YieldStone(oldp);                          Stone *self = YieldStone(oldp);
407                          SetStone(newp, self);                          SetStone(newp, self);
408                          state       = COME;                          state       = COME;
# Line 403  namespace Line 410  namespace
410                          set_alarm();                          set_alarm();
411                          init_model();                          init_model();
412    
413                          SetStone(oldp, new SwapStone(st, impulse.dir));                          SetStone(oldp, new SwapStone(st, impulse.dir)); // sets alarm
414                          play_sound ("st-move");                          play_sound ("st-move");
415                          player::IncMoveCounter(2);                          player::IncMoveCounter(2);
416                      }                      }
# Line 932  namespace Line 939  namespace
939          // When st-wood is created it randomly becomes st-wood1 or st-wood2.          // When st-wood is created it randomly becomes st-wood1 or st-wood2.
940          void on_creation() {          void on_creation() {
941              if (is_kind("st-wood")) {              if (is_kind("st-wood")) {
942                  GridPos p = get_pos();                  ReplaceStone(get_pos(), MakeStone(IntegerRand(0, 1) ? "st-wood1" :  "st-wood2"));
                 KillStone(p);  
                 SetStone(p, MakeStone(IntegerRand(0, 1) ? "st-wood1" :  "st-wood2"));  
943                  return;                  return;
944              }              }
945              MovableStone::on_creation();              MovableStone::on_creation();
# Line 942  namespace Line 947  namespace
947    
948          void fall() {          void fall() {
949              GridPos p = get_pos();              GridPos p = get_pos();
950              if (Floor *fl=GetFloor(p)) {              if (!world::IsLevelBorder(p)) {
951                  const string &k = fl->get_kind();                  if (Floor *fl=GetFloor(p)) {
952                  if (k == "fl-abyss" || k=="fl-water" || k=="fl-swamp") {                      const string &k = fl->get_kind();
953                      if (!world::IsLevelBorder(p)) {                      if (k == "fl-abyss" || k=="fl-water" || k=="fl-swamp") {
954                          SetFloor(p, MakeFloor(is_kind("st-wood1") ? "fl-stwood1" : "fl-stwood2"));                          SetFloor(p, MakeFloor(is_kind("st-wood1") ? "fl-stwood1" : "fl-stwood2"));
955                          KillStone(p);                          KillStone(p);
956                      }                      }
# Line 973  namespace Line 978  namespace
978          void init_model() { set_anim("st-wood-growing"); }          void init_model() { set_anim("st-wood-growing"); }
979          void animcb() {          void animcb() {
980              Stone *st = world::MakeStone("st-wood1");              Stone *st = world::MakeStone("st-wood1");
981              world::SetStone(get_pos(), st);              world::ReplaceStone(get_pos(), st);
982          }          }
983      };      };
984  }  }
# Line 1065  namespace Line 1070  namespace
1070  // :interval        seconds between two "ticks"  // :interval        seconds between two "ticks"
1071  // :loop  // :loop
1072  // :action,target   as usual  // :action,target   as usual
1073    // :invisible
1074  //----------------------------------------  //----------------------------------------
1075    
1076  /** \page st-timer Timer Stone  /** \page st-timer Timer Stone
# Line 1078  single event after a certain amount of t Line 1084  single event after a certain amount of t
1084  - \b interval:  number of seconds before \b action is performed  - \b interval:  number of seconds before \b action is performed
1085  - \b loop:      if 1, restart the timer after performing \b action  - \b loop:      if 1, restart the timer after performing \b action
1086  - \b action, \b target: as usual  - \b action, \b target: as usual
1087    - \b invisible : if 1, stone is invisible
1088    
1089  \subsection timerm Messages  \subsection timerm Messages
1090    
# Line 1102  namespace Line 1109  namespace
1109              set_attrib("interval", 1.0);              set_attrib("interval", 1.0);
1110              set_attrib("loop", 1.0);              set_attrib("loop", 1.0);
1111              set_attrib("on", 1.0);              set_attrib("on", 1.0);
1112                set_attrib("invisible", 0.0);
1113    
1114              // set_on(true);   DOESN'T WORK! calls init_model()              // set_on(true);   DOESN'T WORK! calls init_model()
1115          }          }
# Line 1111  namespace Line 1119  namespace
1119              double_attrib("interval", &interval);              double_attrib("interval", &interval);
1120              return interval;              return interval;
1121          }          }
1122          void init_model() { set_model(is_on() ? "st-timer" : "st-timeroff"); }          void init_model() {
1123                if (int_attrib("invisible")) {
1124                    set_model("invisible");
1125                }
1126                else {
1127                    set_model(is_on() ? "st-timer" : "st-timeroff");
1128                }
1129            }
1130    
1131          void on_creation() {          void on_creation() {
1132              set_alarm();              set_alarm();

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26