Advertisement
Guest User

cool

a guest
Nov 23rd, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.47 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package sk.tuke.oop.aliens;
  7.  
  8. import sk.tuke.oop.aliens.actor.AbstractActor;
  9. import sk.tuke.oop.framework.Animation;
  10.  
  11. /**
  12.  *
  13.  * @author Dado
  14.  */
  15. public class Cooler extends AbstractActor {
  16.     public Reactor reactor;
  17.     private Animation coolerAnimation;
  18.     private Animation offAnimation;
  19.     private boolean locked = true;
  20.     public Cooler(Reactor curReactor){
  21.         // create animation object
  22.         coolerAnimation = new Animation("resources/images/fan.png", 32, 32, 200);
  23.         // play animation repeatedly
  24.         coolerAnimation.setPingPong(true);
  25.        
  26.         // create animation object
  27.         offAnimation = new Animation("resources/images/fan.png", 32, 32, 0);
  28.         // play animation repeatedly
  29.         offAnimation.setPingPong(true);
  30.        
  31.         setAnimation(offAnimation);
  32.         reactor = curReactor;
  33.     }
  34.    
  35.     public void turnOn() {
  36.         this.locked = false;
  37.     }
  38.  
  39.     public void turnOff() {
  40.         this.locked = true;
  41.     }
  42.  
  43.     public boolean isOn() {
  44.  
  45.         return (!this.locked);
  46.     }
  47.    
  48.     @Override
  49.     public void act(){
  50.         if(!locked ){
  51.             reactor.getTemperature() -= 1;
  52.             setAnimation(coolerAnimation);
  53.         }else {
  54.             setAnimation(offAnimation);
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement