Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package sk.tuke.oop.aliens;
- import sk.tuke.oop.aliens.actor.AbstractActor;
- import sk.tuke.oop.framework.Animation;
- /**
- *
- * @author Dado
- */
- public class Cooler extends AbstractActor {
- public Reactor reactor;
- private Animation coolerAnimation;
- private Animation offAnimation;
- private boolean locked = true;
- public Cooler(Reactor curReactor){
- // create animation object
- coolerAnimation = new Animation("resources/images/fan.png", 32, 32, 200);
- // play animation repeatedly
- coolerAnimation.setPingPong(true);
- // create animation object
- offAnimation = new Animation("resources/images/fan.png", 32, 32, 0);
- // play animation repeatedly
- offAnimation.setPingPong(true);
- setAnimation(offAnimation);
- reactor = curReactor;
- }
- public void turnOn() {
- this.locked = false;
- }
- public void turnOff() {
- this.locked = true;
- }
- public boolean isOn() {
- return (!this.locked);
- }
- @Override
- public void act(){
- if(!locked ){
- reactor.getTemperature() -= 1;
- setAnimation(coolerAnimation);
- }else {
- setAnimation(offAnimation);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement