import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.*;
/**
 * Write a description of class bombcheck here.
 * 
 * @author Florian, Jonathan
 * @version (a version number or a date)
 */
public class Bombcheck extends Element

{
    public static boolean bombavailable = false;
    private List<Actor> objects = new ArrayList<Actor>();
    private int sizex = 30;
    private int sizey = 30;
    private long bombavailablemillis = 0;
    private long lastpickup = 0;
    private static double count = 1;
    private String[] BombenGefunden = {"Glückwunsch!", "Du hast 5 Bomben gefunden", "", "Benutze sie als Waffe gegen die Zombies", "Drücke B zum Setzen"};
    private static boolean isSmaller = false;
    private GreenfootImage img;
    public Bombcheck()
    {
        img = new GreenfootImage("Skins/Waffe/bomb.png");

        setImage("Skins/leer.png");

    }

    /**
     * Act - do whatever the bombcheck wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // Add your action code here.

        if (isTouching(Linch.class))
        {
            if(!bombavailable){
                Background.msg(BombenGefunden);
                bombavailablemillis = System.currentTimeMillis();
                Bomb.available = true;
            }
            bombavailable = true;
            if (System.currentTimeMillis()-lastpickup>1000)
            {
                Bomb.amount = Bomb.amount+5;
                lastpickup = System.currentTimeMillis();
            }
        }
        if(bombavailable){

            setLocation(320,240);
            if(count <=1000 && !isSmaller){
                count = count*1.1+5;                
            }else if(count > 1000 && !isSmaller){
                isSmaller = true;
            }else if(count >= 1 && isSmaller){
                count= count/1.3;
            }else if(count < 1 && isSmaller){
                getWorld().removeObject(this);
            }
            GreenfootImage img2 = new GreenfootImage("Skins/Waffe/bomb.png");
            img2.scale((int)(sizex+count), (int)(sizey+count));
            setImage(img2);
        }else{
            setImage(img);
        }

    }    
}
