package com.Tutorial
{
    import com.adamatomic.flixel.*;
    public class Printer extends FlxSprite
    {
        [Embed(source='../../data/computer.png')] private var ImgPrinter:Class;
        [Embed(source='../../data/printersound.mp3')] private var SndPrinter:Class;
        private var _move_speed:int = 400;
        private var _jump_power:int = 800;   
        private var _max_health:int = 10;
        private var _hurt_counter:Number = 0;
        private var _can_jump:Boolean = true;
        private var _last_jump:Number = 0;
		public var printing:Boolean = false;
		
        public function Printer(X:Number,Y:Number):void
        {
            super(ImgPrinter, X, Y, true, true);//Max speeds
            maxVelocity.x = 200;
            maxVelocity.y = 200;
            health = 1;
            acceleration.y = 0;
            drag.x = 300;
            width = 14;
            height = 14;
            offset.x = 0;
            offset.y = 0;
            addAnimation("empty", [0],0);
            addAnimation("printing", [1,2,3],0.38,false);
			play("empty");
        }

		public function hasPaper():Boolean
		{
			return (_curFrame == 2);
		}
		
		public function getPaper():void
		{
			if (_curFrame == 2)
			{
				play("empty",false);
			}
		}
		
		public function doPrint():void 
		{
			printing = true;
			if (_curFrame == 0)
			{
				play("printing", false);
				FlxG.play(SndPrinter);
			}
		}
        override public function update():void
        {
            if(dead)
            {
                if(finished) exists = false;
                else
                    super.update();
                return;
            }            			
			
            super.update();
        }

        override public function hitFloor():Boolean
        {
            _can_jump = true;
            return super.hitFloor();
        }
        
        override public function hurt(Damage:Number):void
        {
            _hurt_counter = 1;
            return super.hurt(Damage);
        }       
    }
}