import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color; 
/**
 * Erzeugt einen Radius um die Tower
 * 
 * @author Marek Parucha
 * @version 1.0
 */
public class Radius extends Drawing
{
    /**
     * erstellt einen Kreis
     * @param 'towerDistance': Radius des Towers
     * @param 'actor': Zugehöriger tower des Kreises
     */
    public Radius(int towerDistance, Towers actor)
    {
        towerDistanceDrawing = towerDistance;
        distanceOvalTransparency=new GreenfootImage(towerDistanceDrawing*2,towerDistanceDrawing*2);
        distanceOval=new GreenfootImage(towerDistanceDrawing*2,towerDistanceDrawing*2);
        tower = actor;
        
    }
    /**
     * Act - do whatever the Radius wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        
         
         try
         {
            if (!tower.isMonsterInDistance()&&monsterIsIntersecting)
            {
                getImage().clear();
                makeRadius(java.awt.Color.WHITE);
                monsterIsIntersecting = false;
            }
            else if(tower.isMonsterInDistance()&&!monsterIsIntersecting)
            {
            
                getImage().clear();
                makeRadius(java.awt.Color.RED);
                monsterIsIntersecting = true;
            }
            }
                
            catch(IllegalStateException e)
            {
               getWorld().removeObject(this);
            }

    }    
    
    /**
     * Falls ein Objekt der Klasse 'Drawing' erstellt wird, wird entweder makeRadius oder makeString ausgeführt
     */
    @Override
    protected void addedToWorld(World world)
    {
        makeRadius(java.awt.Color.WHITE);
    }
}
