home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / batman_cobble.swf / scripts / frame_16 / DoAction_21.as < prev    next >
Encoding:
Text File  |  2006-06-13  |  4.8 KB  |  192 lines

  1. _global.elevatorLogic = function()
  2. {
  3.    if(!_root.onPlatform)
  4.    {
  5.       if(this.hitBox.hitTest(_root.game.player) && _root.playerDy >= 0)
  6.       {
  7.          if(this._y != this.limit)
  8.          {
  9.             this.moving = true;
  10.          }
  11.          if(this._y < this.limit)
  12.          {
  13.             this.dy = 12;
  14.          }
  15.          else
  16.          {
  17.             _root.game.player._y -= 32;
  18.             this.dy = -12;
  19.          }
  20.          _root.currentPlatform = this;
  21.          _root.onPlatform = true;
  22.       }
  23.    }
  24.    else if(_root.currentPlatform == this)
  25.    {
  26.       if(this.hitBox.hitTest(_root.game.player))
  27.       {
  28.          _root.onPlatform = true;
  29.          if(!_root.playerJumping)
  30.          {
  31.             _root.playerDy = this.dy;
  32.             _root.gravity = 0;
  33.             if(this.dy > 0)
  34.             {
  35.                _root.game.player._y -= _root.game.player._y - this._y + _root.playerHeight + 20;
  36.             }
  37.             else
  38.             {
  39.                _root.game.player._y -= _root.game.player._y - this._y + _root.playerHeight + 40;
  40.             }
  41.          }
  42.          else
  43.          {
  44.             _root.onPlatform = false;
  45.             _root.currentPlatform = 0;
  46.             _root.playerDy = -36 + this.dy / 3;
  47.             _root.gravity = _root.globalGravity;
  48.          }
  49.       }
  50.       else if(_root.currentPlatform == this)
  51.       {
  52.          if(Math.abs(_root.game.player._y - this._y) > 160)
  53.          {
  54.             _root.onPlatform = false;
  55.          }
  56.          else if(_root.playerJumping)
  57.          {
  58.             _root.onPlatform = false;
  59.          }
  60.       }
  61.       if(this.dy > 0)
  62.       {
  63.          if(this._y >= this.limit)
  64.          {
  65.             this.dy = 0;
  66.             _root.onPlatform = false;
  67.             _root.currentPlatform = 0;
  68.             _root.playerDy = 0;
  69.             _root.gravity = _root.globalGravity;
  70.             this._y = this.limit;
  71.             delete this.onEnterFrame;
  72.          }
  73.       }
  74.       else if(this.dy < 0)
  75.       {
  76.          if(this._y <= this.limit)
  77.          {
  78.             this.dy = 0;
  79.             _root.onPlatform = false;
  80.             _root.currentPlatform = 0;
  81.             _root.playerDy = 0;
  82.             _root.gravity = _root.globalGravity;
  83.             this._y = this.limit;
  84.             delete this.onEnterFrame;
  85.          }
  86.       }
  87.    }
  88.    if(this.dy < 0 && this._y > this.limit || this.dy > 0 && this._y < this.limit)
  89.    {
  90.       this._y += this.dy;
  91.    }
  92. };
  93. _global.liftLogic = function()
  94. {
  95.    this.distx = Math.abs(this._x - _root.game.player._x);
  96.    if(this._currentFrame <= 50)
  97.    {
  98.       this.dy = -6;
  99.    }
  100.    else
  101.    {
  102.       this.dy = 6;
  103.    }
  104.    if(!_root.onPlatform)
  105.    {
  106.       if(this.hitBox.hitTest(_root.game.player) && this.distx < 300)
  107.       {
  108.          if(this.hitBox2.hitTest(_root.game.player))
  109.          {
  110.             _root.currentPlatform = this;
  111.             _root.onPlatform = true;
  112.             _root.playerDy = this.dy;
  113.             _root.gravity = 0;
  114.          }
  115.       }
  116.    }
  117.    else if(_root.currentPlatform == this)
  118.    {
  119.       if(this.hitBox.hitTest(_root.game.player))
  120.       {
  121.          if(!_root.playerJumping)
  122.          {
  123.             _root.game.player._y -= 6;
  124.             _root.gravity = 0;
  125.             _root.playerDy = this.dy;
  126.             _root.onPlatform = true;
  127.          }
  128.          else
  129.          {
  130.             _root.onPlatform = false;
  131.             _root.currentPlatform = 0;
  132.             _root.playerDy = -36;
  133.             _root.gravity = _root.globalGravity;
  134.          }
  135.          if(this.distx > 300)
  136.          {
  137.             _root.playerDy = 7;
  138.             _root.onPlatform = false;
  139.             _root.gravity = _root.globalGravity;
  140.             _root.currentPlatform = 0;
  141.          }
  142.       }
  143.       else if(this.distx < 300 && !_root.playerJumping)
  144.       {
  145.          if(this.hitBox2.hitTest(_root.game.player))
  146.          {
  147.             _root.onPlatform = true;
  148.             _root.playerDy = this.dy;
  149.             if(this.hitBox3.hitTest(_root.game.player))
  150.             {
  151.                _root.game.player._y += 3;
  152.             }
  153.          }
  154.       }
  155.       else
  156.       {
  157.          if(!_root.playerJumping)
  158.          {
  159.             _root.playerDy = 7;
  160.          }
  161.          _root.onPlatform = false;
  162.          _root.gravity = _root.globalGravity;
  163.          _root.currentPlatform = 0;
  164.       }
  165.    }
  166. };
  167. _global.beltLogic = function()
  168. {
  169.    if(this.hitTest(_root.game.player))
  170.    {
  171.       _root.game.player._x += this.dx;
  172.    }
  173. };
  174. _global.stompLogic = function()
  175. {
  176.    if(this.hitTest(_root.game.player) && this._currentframe < 30)
  177.    {
  178.       if(!this.done)
  179.       {
  180.          _root.punch2.start();
  181.          _root.playerState = "hurt";
  182.          _root.playerHealth -= 10;
  183.          _root.playerInvincible = true;
  184.          this.done = true;
  185.       }
  186.    }
  187.    else
  188.    {
  189.       this.done = false;
  190.    }
  191. };
  192.