72 lines
1.7 KiB
Java
72 lines
1.7 KiB
Java
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
|
|
|
/**
|
|
* Write a description of class TemporaryGround here.
|
|
*
|
|
* @author (your name)
|
|
* @version (a version number or a date)
|
|
*/
|
|
public class TemporaryGround extends Plattform
|
|
{
|
|
private int Lebensdauer;
|
|
boolean warningHasHappend=false;
|
|
boolean deWarningHasHappend=true;
|
|
public TemporaryGround(int pLebensdauer)
|
|
{
|
|
Lebensdauer=pLebensdauer;
|
|
}
|
|
|
|
/**
|
|
* Act - do whatever the TemporaryGround 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.
|
|
this.Buffer();
|
|
Lebensdauer--;
|
|
if(Lebensdauer==0)
|
|
{
|
|
this.loescheMich();
|
|
}
|
|
if(Lebensdauer<60*3 && warningHasHappend==false) //3 Sekunden
|
|
{
|
|
this.warning();
|
|
}
|
|
if(Lebensdauer>=60*3 && deWarningHasHappend==false)
|
|
{
|
|
this.noMoreWarning();
|
|
}
|
|
}
|
|
|
|
public void warning()
|
|
{
|
|
this.setImage("TemporaryIsBreaking.png");
|
|
warningHasHappend=true;
|
|
deWarningHasHappend=false;
|
|
}
|
|
|
|
public void noMoreWarning()
|
|
{
|
|
this.setImage("TemporaryGround.png");
|
|
warningHasHappend=false;
|
|
deWarningHasHappend=true;
|
|
}
|
|
|
|
public void RefreshLifeToDuration(int pDuration)
|
|
{
|
|
Lebensdauer=pDuration;
|
|
}
|
|
|
|
public void Buffer()
|
|
{
|
|
{
|
|
Player player= this.getWorld().getObjects(Player.class).get(0);
|
|
if(this.intersects(player))
|
|
{
|
|
player.setLocation(player.getX(), this.getY()-this.getImage().getHeight());
|
|
}
|
|
}
|
|
}
|
|
}
|