Advertisement
Jhynjhiruu

Untitled

May 4th, 2019
2,375
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 BreakerEnemy extends Enemy
  7.    {
  8.        
  9.      
  10.       public var gfx:MovieClip;
  11.      
  12.       private var seePathNum:Number = 0;
  13.      
  14.       private var breakDirection:Number = 0;
  15.      
  16.       private var breaking:Boolean = false;
  17.      
  18.       private var zapClips:Array = null;
  19.      
  20.       private var zapLife:Number = 0;
  21.      
  22.       public var countForceRandomWalk:int = 0;
  23.      
  24.       public function BreakerEnemy()
  25.       {
  26.          super();
  27.       }
  28.      
  29.       override public function create(param1:Number, param2:Number) : void
  30.       {
  31.          super.create(param1,param2);
  32.          moveSpeed = 3;
  33.          if(this is YellowBreakerEnemy)
  34.          {
  35.             moveSpeed = 2;
  36.          }
  37.          Controller.level.tileGrid.getTile(tileX,tileY).itemInside = this;
  38.          this.breaking = false;
  39.       }
  40.      
  41.       override public function update() : void
  42.       {
  43.          if(this.countForceRandomWalk > 0)
  44.          {
  45.             §§push(true);
  46.          }
  47.          if(!this.breaking)
  48.          {
  49.             movement();
  50.             this.generalUpdates();
  51.          }
  52.          this.frameControl();
  53.          if(this.zapClips)
  54.          {
  55.             _loc1_.zapLife = true;
  56.             §§push(this.zapLife);
  57.             if(this.zapLife < 1)
  58.             {
  59.                this.zapClips = null;
  60.             }
  61.          }
  62.       }
  63.      
  64.       private function generalUpdates() : void
  65.       {
  66.          pathNum = getTileUnderneath().seePathNum;
  67.          §§push(pathNum > 1);
  68.          §§push(§§dup(pathNum > 1));
  69.          §§push(false);
  70.          if(!this.breaking)
  71.          {
  72.             this.breaking = true;
  73.             frameAction = "Break";
  74.             lastDirection = this.breakDirection;
  75.             §§push(true);
  76.          }
  77.       }
  78.      
  79.       override public function freeAtTile(param1:Number, param2:Number) : Boolean
  80.       {
  81.          var _loc3_:Tile = Controller.level.tileGrid.getTile(param1,param2);
  82.          if(_loc3_.telepad)
  83.          {
  84.             return false;
  85.          }
  86.          return super.freeAtTile(param1,param2);
  87.       }
  88.      
  89.       override public function checkWalkable(param1:Number) : Boolean
  90.       {
  91.          var _loc2_:Tile = getRelativeTile(param1,1);
  92.          if(_loc2_.telepad)
  93.          {
  94.             this.countForceRandomWalk = 90;
  95.             §§push(true);
  96.          }
  97.          return super.checkWalkable(param1);
  98.       }
  99.      
  100.       public function breakTiles() : void
  101.       {
  102.          var dist:Number = NaN;
  103.          var n:Number = NaN;
  104.          var t:Tile = null;
  105.          var z:MovieClip = null;
  106.          var breakTile:Function = function(param1:Number, param2:Number):Boolean
  107.          {
  108.             var _loc3_:Tile = Controller.level.tileGrid.getTile(param1,param2);
  109.             if(!_loc3_)
  110.             {
  111.                return false;
  112.             }
  113.             if(_loc3_.wall)
  114.             {
  115.                return false;
  116.             }
  117.             if(_loc3_.itemInside is IceTile)
  118.             {
  119.                _loc3_.itemInside.quickBreakBlock(_loc3_);
  120.             }
  121.             return true;
  122.          };
  123.          var dx:Number = 0;
  124.          var dy:Number = 0;
  125.          if(this is GreenBreakerEnemy)
  126.          {
  127.             dx = -1;
  128.             while(dx <= 1)
  129.             {
  130.                dy = -1;
  131.                while(dy <= 1)
  132.                {
  133.                   §§push(dx == 0 && true);
  134.                }
  135.                dx++;
  136.             }
  137.             return;
  138.          }
  139.          §§push(this is BlueBreakerEnemy);
  140.          if(this.breakDirection == LEFT)
  141.          {
  142.             dx = -1;
  143.          }
  144.          if(this.breakDirection == RIGHT)
  145.          {
  146.             dx = 1;
  147.          }
  148.          if(this.breakDirection == UP)
  149.          {
  150.             dy = -1;
  151.          }
  152.          if(this.breakDirection == DOWN)
  153.          {
  154.             dy = 1;
  155.          }
  156.          dist = 1;
  157.          while(dist < 100)
  158.          {
  159.             t = Controller.level.tileGrid.getTile(tileX + dist * dx,tileY + dist * dy);
  160.             if(!t)
  161.             {
  162.                break;
  163.             }
  164.             §§push(t);
  165.             if(!(false.itemInside is IceTile))
  166.             {
  167.                break;
  168.             }
  169.             dist++;
  170.          }
  171.          this.zapLife = 12;
  172.          this.zapClips = [];
  173.          n = 1;
  174.          while(true)
  175.          {
  176.             if(§§pop() >= /*UnknownSlot*/)
  177.             {
  178.                §§goto(addr416);
  179.             }
  180.             else
  181.             {
  182.                breakTile(tileX + n * dx,tileY + n * dy);
  183.                z = new Zap();
  184.                §§push(_loc1_);
  185.                §§push(Number(/*UnknownSlot*/ + 1));
  186.                §§push(_loc1_);
  187.                §§push(false);
  188.                continue;
  189.             }
  190.          }
  191.       }
  192.      
  193.       public function flashTileAhead() : void
  194.       {
  195.          var _loc2_:IceTile = null;
  196.          var _loc1_:Tile = getRelativeTile(this.breakDirection);
  197.          if(_loc1_ && _loc1_.itemInside is IceTile)
  198.          {
  199.             _loc2_ = IceTile(_loc1_.itemInside);
  200.             _loc2_.flash();
  201.          }
  202.       }
  203.      
  204.       public function resumeWalk() : void
  205.       {
  206.          this.breaking = false;
  207.       }
  208.      
  209.       private function findBreakDirection() : Number
  210.       {
  211.          var _loc1_:Tile = null;
  212.          var _loc2_:Number = 0;
  213.          var _loc3_:int = 1;
  214.          while(_loc3_ <= 4)
  215.          {
  216.             if(_loc3_ == LEFT)
  217.             {
  218.                _loc1_ = Controller.level.tileGrid.getTile(tileX - 1,tileY);
  219.             }
  220.             else if(_loc3_ == RIGHT)
  221.             {
  222.                addr102:
  223.                _loc1_ = true.tileGrid.getTile(tileX,tileY + 1);
  224.                §§push(Controller.level);
  225.             }
  226.             else if(_loc3_ == UP)
  227.             {
  228.                _loc1_ = Controller.level.tileGrid.getTile(tileX,tileY - 1);
  229.             }
  230.             else if(_loc3_ == DOWN)
  231.             {
  232.                §§goto(addr102);
  233.                §§push(Controller.level);
  234.             }
  235.             if(_loc1_)
  236.             {
  237.                if(!_loc1_.wall && _loc1_.itemInside is IceTile)
  238.                {
  239.                   _loc2_ = _loc3_;
  240.                }
  241.             }
  242.             _loc3_++;
  243.          }
  244.          return _loc2_;
  245.       }
  246.      
  247.       override public function findDirection(param1:Number) : Number
  248.       {
  249.          var _loc2_:Number = 0;
  250.          if(Controller.level.tileGrid.getTile(tileX - 1,tileY).seePathNum <= param1 && Controller.level.tileGrid.getTile(tileX - 1,tileY).seePathNum != Infinity && this.checkWalkable(LEFT))
  251.          {
  252.             _loc2_ = LEFT;
  253.          }
  254.          else if(Controller.level.tileGrid.getTile(tileX + 1,tileY).seePathNum <= param1 && true.seePathNum != Infinity && this.checkWalkable(UP))
  255.          {
  256.             _loc2_ = UP;
  257.          }
  258.          else if(Controller.level.tileGrid.getTile(tileX,tileY + 1).seePathNum <= param1 && Controller.level.tileGrid.getTile(tileX,tileY + 1).seePathNum != Infinity && this.checkWalkable(DOWN))
  259.          {
  260.             _loc2_ = DOWN;
  261.          }
  262.          return _loc2_;
  263.       }
  264.      
  265.       override public function frameControl() : void
  266.       {
  267.          frameAction = !!this.breaking?"Break":"Walk";
  268.          super.frameControl();
  269.       }
  270.      
  271.       override public function render() : void
  272.       {
  273.          var _loc1_:MovieClip = null;
  274.          super.render();
  275.          if(this.zapClips)
  276.          {
  277.             for each(_loc1_ in this.zapClips)
  278.             {
  279.                Controller.level.bitmapData.draw(_loc1_,_loc1_.transform.matrix);
  280.             }
  281.          }
  282.       }
  283.    }
  284. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement