Advertisement
Jhynjhiruu

Untitled

May 4th, 2019
2,284
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 TowerEnemy extends Enemy
  7.    {
  8.        
  9.      
  10.       public var okToMove:Boolean = false;
  11.      
  12.       public var moves:Number = 0;
  13.      
  14.       private var stomp:MovieClip = null;
  15.      
  16.       public function TowerEnemy()
  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.          Controller.level.tileGrid.getTile(tileX,tileY).itemInside = this;
  26.       }
  27.      
  28.       override public function update() : void
  29.       {
  30.          var _loc1_:MovieClip = null;
  31.          if(frameAction == "Walk")
  32.          {
  33.             _loc1_ = MovieClip(getChildAt(0));
  34.             if(_loc1_.currentFrame == 15)
  35.             {
  36.                this.okToMove = true;
  37.             }
  38.             if(_loc1_.currentFrame == 27)
  39.             {
  40.                this.doStomp();
  41.             }
  42.             if(_loc1_.currentFrame == 35)
  43.             {
  44.                this.nextMove();
  45.             }
  46.          }
  47.          this.movement();
  48.          this.frameControl();
  49.       }
  50.      
  51.       override public function movement() : void
  52.       {
  53.          if(!this.okToMove)
  54.          {
  55.             return;
  56.          }
  57.          super.movement();
  58.       }
  59.      
  60.       override public function randomWalkUpdate() : void
  61.       {
  62.          super.randomWalkUpdate();
  63.       }
  64.      
  65.       override protected function stepped() : void
  66.       {
  67.          super.stepped();
  68.       }
  69.      
  70.       public function nextMove() : void
  71.       {
  72.          this.moves++;
  73.       }
  74.      
  75.       override public function frameControl() : void
  76.       {
  77.       }
  78.      
  79.       public function teleport() : void
  80.       {
  81.          var _loc2_:Tile = null;
  82.          var _loc3_:Tile = null;
  83.          var _loc1_:Array = [];
  84.          for each(_loc2_ in Controller.level.tileGrid.list)
  85.          {
  86.             if(!_loc2_.wall)
  87.             {
  88.                if(!(_loc2_.itemInside || _loc2_.collectibleInside))
  89.                {
  90.                   _loc1_.push(_loc2_);
  91.                }
  92.             }
  93.          }
  94.          getTileUnderneath().itemInside = null;
  95.          _loc3_ = _loc1_[Math.floor(_loc1_.length * Math.random())];
  96.          tileX = _loc3_.gridX;
  97.          tileY = _loc3_.gridY;
  98.          x = (tileX + 0.5) * Controller.TILE_SIZE;
  99.          y = tileY * Controller.TILE_SIZE;
  100.          _loc3_.itemInside = this;
  101.          frameAction = "TeleportIn";
  102.       }
  103.      
  104.       public function finishTeleportAnimation() : void
  105.       {
  106.          frameAction = "Walk";
  107.          this.moves = 0;
  108.       }
  109.      
  110.       public function doStomp() : void
  111.       {
  112.          this.stomp = new Stomp();
  113.          this.stomp.x = x;
  114.          this.stomp.y = y + 18;
  115.       }
  116.      
  117.       override public function render() : void
  118.       {
  119.          renderExtra(this.stomp);
  120.          super.render();
  121.       }
  122.    }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement