Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.nitrome.badicecream
- {
- import flash.display.MovieClip;
- public class LogEnemy extends Enemy
- {
- private var rolling:Boolean = false;
- private var transitionAnimation:Boolean = false;
- private var stomp:MovieClip = null;
- public function LogEnemy()
- {
- super();
- }
- override public function create(param1:Number, param2:Number) : void
- {
- super.create(param1,param2);
- moveSpeed = 3;
- randomWalk = true;
- }
- private function startRolling() : void
- {
- this.transitionAnimation = true;
- this.rolling = true;
- frameAction = "StartRoll";
- }
- public function endTransitionAnimation() : void
- {
- }
- public function doStomp() : void
- {
- this.stomp = new Stomp();
- this.stomp.x = x;
- this.stomp.y = y + 18;
- }
- private function endRolling() : void
- {
- this.transitionAnimation = true;
- this.rolling = false;
- frameAction = "EndRoll";
- }
- override public function update() : void
- {
- if(!this.transitionAnimation)
- {
- if(this.rolling)
- {
- moveSpeed = 10;
- movement();
- }
- else
- {
- moveSpeed = 3;
- movement();
- randomWalkUpdate();
- }
- }
- frameControl();
- }
- override protected function stepped() : void
- {
- var _loc1_:Number = NaN;
- var _loc2_:Boolean = false;
- var _loc3_:Number = NaN;
- var _loc4_:Tile = null;
- if(!this.rolling)
- {
- for each(_loc1_ in [UP,DOWN,LEFT,RIGHT])
- {
- if(lastDirection == LEFT && _loc1_ == RIGHT)
- {
- continue;
- }
- if(lastDirection == RIGHT && _loc1_ == LEFT)
- {
- continue;
- }
- if(lastDirection == UP && _loc1_ == DOWN)
- {
- continue;
- }
- §§push(lastDirection == DOWN);
- if(§§dup(lastDirection == DOWN))
- {
- §§pop();
- addr188:
- while(true)
- {
- _loc4_ = getRelativeTile(_loc1_,_loc3_);
- if(!_loc4_ || _loc4_.wall || _loc4_.itemInside is IceTile)
- {
- break;
- }
- if(_loc4_.itemInside is Player)
- {
- if(_loc3_ > 1)
- {
- _loc2_ = true;
- break;
- }
- break;
- }
- _loc3_ = true;
- §§push(_loc3_);
- }
- §§push(_loc1_);
- §§push(true);
- if(_loc2_)
- {
- moveDirection = lastDirection = _loc1_;
- this.startRolling();
- break;
- }
- continue;
- }
- if(§§pop())
- {
- continue;
- }
- _loc2_ = false;
- _loc3_ = 1;
- while(true)
- {
- §§goto(addr188);
- }
- }
- }
- if(this.rolling)
- {
- moveDirection = lastDirection;
- if(checkWalkable(lastDirection))
- {
- walk(moveDirection = lastDirection);
- }
- else
- {
- moveDirection = 0;
- this.endRolling();
- NitromeGame.sound_manager.playSound("log_roll_hit");
- }
- }
- }
- override public function render() : void
- {
- renderExtra(this.stomp);
- super.render();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement