import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Verwaltet Wegelagerer
 * 
 * @author Marek Parucha
 * @version 1.0
 */
public class Wegelagerer extends Actor
{
   Actor m = null;
   Actor n = null;
   /** kosten des Wegelagerers
     */
   protected int kosten;
   /** Geschwindigkeit des Wegelagerers
     */
   protected int Speed;
   /** leben des Wegelagerers
     */
   protected int Live;
   /** Animation des Wegelagerers
     */
   protected Animation animation;
   /** sound des Wegelagerers
     */
   protected GreenfootSound sound;
   
   boolean firstRun = true;
   
   public void act() 
   {
        
        animation.act();
        if( this.getImage() != animation.getImage())
        {
            this.setImage(animation.getImage());
        }
        if(firstRun)
        {
            Spieleverwaltung.removeMoney(kosten);
            animation.startLoop();
            firstRun = false;
        }
        
        m = getOneIntersectingObject(Monsters.class);
           
        if(m != null  && n != m)
        {
            //sound.play();
            ((Monsters)m).monsterRemovesSpeed(Speed);
            ((Monsters)m).removeLife(Live);
            
            n = m;
        }
   }    
   
}
