[ WP ] Write a story in JavaScript , C # , or another computer language .

string dreamType; 
 public LifeControl lifeControl; 
 float maxDreamLength = 2; 
 int restTime = 5; 
 string allTypes [ ]; 
 float [ ] dreamLength; 
 
 int currentIndex = 0; 
 float currentDream = 0; 
 
 void Start ( ) 
 { 
 
 allTypes = new string [ restTime ]; 
 dreamLength = new float [ restTime ]; 
 
 for ( int i=0; i < restTime; i++ ) 
 { 
 GetDream ( ); 
 } 
 currentIndex = 0; 
 } 
 
 void GetDream ( ) 
 { 
 int z = Random.Range ( 0,6 ); 
 if ( z==2 ) 
 { 
 allTypes [ currentIndex ] = `` Home sickness''; 
 } 
 else if ( z==3 ) 
 { 
 allTypes [ currentIndex ] = `` Nightmare''; 
 } 
 else 
 { 
 allTypes [ currentIndex ] = `` Anxiety''; 
 } 
 dreamLength [ currentIndex ] = Random.Range ( maxDreamLength/2, maxDreamLength*2 ); 
 currentIndex++; 
 } 
 
 void Update ( ) 
 { 
 currentDream+=Time.deltaTime; 
 if ( currentDream > =dreamLength [ currentIndex ] ) 
 { 
 currentIndex++; 
 if ( currentIndex > =restTime ) 
 AlarmClock ( ); 
 else 
 currentDream = 0; 
 } 
 } 
 
 public void AlarmClock ( ) 
 { 
 int groggy = 0; 
 if ( currentDream < dreamLength [ currentIndex ] /1.1f ) 
 groggy = 1; 
 else if ( currentDream < dreamLength [ currentIndex ] /1.5f ) 
 groggy = 2; 
 
 lifeControl.enabled = true; 
 lifeControl.selfControl = selfControl-groggy; 
 this.enabled = false; 
 } 

