Advertisement
Jhynjhiruu

Untitled

May 4th, 2019
2,288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. package com.nitrome.badicecream
  3. {
  4.    import flash.display.MovieClip;
  5.    
  6.    public class LogEnemy extends Enemy
  7.    {
  8.        
  9.      
  10.       private var rolling:Boolean = false;
  11.      
  12.       private var transitionAnimation:Boolean = false;
  13.      
  14.       private var stomp:MovieClip = null;
  15.      
  16.       public function LogEnemy()
  17.       {
  18.          super();
  19.       }
  20.      
  21.       override public function create(param1:Number, param2:Number) : void
  22.       {
  23.          super.create(param1,param2);
  24.          moveSpeed = 3;
  25.          randomWalk = true;
  26.       }
  27.      
  28.       private function startRolling() : void
  29.       {
  30.          this.transitionAnimation = true;
  31.          this.rolling = true;
  32.          frameAction = "StartRoll";
  33.       }
  34.      
  35.       public function endTransitionAnimation() : void
  36.       {
  37.       }
  38.      
  39.       public function doStomp() : void
  40.       {
  41.          this.stomp = new Stomp();
  42.          this.stomp.x = x;
  43.          this.stomp.y = y + 18;
  44.       }
  45.      
  46.       private function endRolling() : void
  47.       {
  48.          this.transitionAnimation = true;
  49.          this.rolling = false;
  50.          frameAction = "EndRoll";
  51.       }
  52.      
  53.       override public function update() : void
  54.       {
  55.          if(!this.transitionAnimation)
  56.          {
  57.             if(this.rolling)
  58.             {
  59.                moveSpeed = 10;
  60.                movement();
  61.             }
  62.             else
  63.             {
  64.                moveSpeed = 3;
  65.                movement();
  66.                randomWalkUpdate();
  67.             }
  68.          }
  69.          frameControl();
  70.       }
  71.      
  72.       override protected function stepped() : void
  73.       {
  74.          var _loc1_:Number = NaN;
  75.          var _loc2_:Boolean = false;
  76.          var _loc3_:Number = NaN;
  77.          var _loc4_:Tile = null;
  78.          if(!this.rolling)
  79.          {
  80.             for each(_loc1_ in [UP,DOWN,LEFT,RIGHT])
  81.             {
  82.                if(lastDirection == LEFT && _loc1_ == RIGHT)
  83.                {
  84.                   continue;
  85.                }
  86.                if(lastDirection == RIGHT && _loc1_ == LEFT)
  87.                {
  88.                   continue;
  89.                }
  90.                if(lastDirection == UP && _loc1_ == DOWN)
  91.                {
  92.                   continue;
  93.                }
  94.                §§push(lastDirection == DOWN);
  95.                if(§§dup(lastDirection == DOWN))
  96.                {
  97.                   §§pop();
  98.                   addr188:
  99.                   while(true)
  100.                   {
  101.                      _loc4_ = getRelativeTile(_loc1_,_loc3_);
  102.                      if(!_loc4_ || _loc4_.wall || _loc4_.itemInside is IceTile)
  103.                      {
  104.                         break;
  105.                      }
  106.                      if(_loc4_.itemInside is Player)
  107.                      {
  108.                         if(_loc3_ > 1)
  109.                         {
  110.                            _loc2_ = true;
  111.                            break;
  112.                         }
  113.                         break;
  114.                      }
  115.                      _loc3_ = true;
  116.                      §§push(_loc3_);
  117.                   }
  118.                   §§push(_loc1_);
  119.                   §§push(true);
  120.                   if(_loc2_)
  121.                   {
  122.                      moveDirection = lastDirection = _loc1_;
  123.                      this.startRolling();
  124.                      break;
  125.                   }
  126.                   continue;
  127.                }
  128.                if(§§pop())
  129.                {
  130.                   continue;
  131.                }
  132.                _loc2_ = false;
  133.                _loc3_ = 1;
  134.                while(true)
  135.                {
  136.                   §§goto(addr188);
  137.                }
  138.             }
  139.          }
  140.          if(this.rolling)
  141.          {
  142.             moveDirection = lastDirection;
  143.             if(checkWalkable(lastDirection))
  144.             {
  145.                walk(moveDirection = lastDirection);
  146.             }
  147.             else
  148.             {
  149.                moveDirection = 0;
  150.                this.endRolling();
  151.                NitromeGame.sound_manager.playSound("log_roll_hit");
  152.             }
  153.          }
  154.       }
  155.      
  156.       override public function render() : void
  157.       {
  158.          renderExtra(this.stomp);
  159.          super.render();
  160.       }
  161.    }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement