/************************************************ * * * MonitorEffect class: Defines Monitor * * behaviour (The HUD in the simulator) * * * * Created by S.Cartwright ©2000 * * * ************************************************/ package source; //**********************************************************************************************// //The main class definition public class MonitorEffect{ //**********************************************************************************************// //The class variables public int monitorTimer,stage,monitorSnow,maxSnow,snowOff; public static final int PICTURE=0,SNOW=1,BLANK=2; protected int getNewTimerForThis(int stage) { int newTimer; if(stage==3) stage=SNOW;//Change local variable only switch(stage) { case PICTURE: newTimer=(int)(Math.random()*100)+100 ;break; case SNOW : newTimer=(int)(Math.random()*20)+15 ;break; case BLANK : newTimer=(int)(Math.random()*30)+10 ;break; default: newTimer=100; } return(newTimer); } public MonitorEffect(int snowOffset,int snowMax) { stage=PICTURE;monitorSnow=0; maxSnow=snowMax+1; snowOff=snowOffset; monitorTimer=this.getNewTimerForThis(stage); } public void destroy() { } public int getSnowFrame() { int r; do{r=(int)(Math.random()*maxSnow);}while(r==monitorSnow); monitorSnow=r; return(r+snowOff); } public int getMonitorStatus() { int lStage=stage; if(lStage==3) lStage=SNOW; return(lStage); } public void nextMonitorStatus(boolean thereIsRadiation) { if(--monitorTimer==0) { if(++stage==4) stage=0; monitorTimer=this.getNewTimerForThis(stage); if(thereIsRadiation&&stage==PICTURE) monitorTimer/=4; } } }