Changeset b5aa714 in orbit


Ignore:
Timestamp:
12/31/13 08:25:40 (6 years ago)
Author:
Steve Castellotti <sc@…>
Branches:
master, Servo
Children:
af91708
Parents:
16249e0
Message:
  • updateScore added
Location:
iOS/Orbit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • iOS/Orbit/Orbit/controllers/FlightViewController.h

    r57848ad rb5aa714  
    1313#import <AVFoundation/AVFoundation.h> 
    1414#import "../SignalConverterDelegate.h" 
     15 
     16int minimumScoreTarget = 40; 
     17int scoreCurrent = 0; 
     18int scoreLast = 0; 
     19int scoreHigh = 0; 
    1520 
    1621@interface FlightViewController : UIViewController <SignalConverterDelegate> { 
     
    3641- (IBAction) testButtonPressed:(id) sender; 
    3742 
     43- (void) updateScores; 
     44 
    3845@end 
  • iOS/Orbit/Orbit/controllers/FlightViewController.m

    r812f274 rb5aa714  
    103103   self.powerPercent.text = [NSString stringWithFormat:@"%i%%", (int)(powerLevel * 100)]; 
    104104   [self updateStatusImage:[self statusFromSignal:signalStrength power:powerLevel]]; 
     105    
     106   [self updateScores]; 
    105107    
    106108} 
     
    201203} 
    202204 
     205- (void) updateScores 
     206{ 
     207 
     208   //   /** 
     209   //    * Score points based on target slider levels 
     210   //    * If you pass your goal with either Attention or Meditation 
     211   //    * the higher target of the two will counts as points per second. 
     212   //    * 
     213   //    * Minimum threshold for points is set as "minimumScoreTarget" 
     214   //    * 
     215   //    * For example, assume minimumScoreTarget is 40%. 
     216   //    * If your target Attention is 60% and you go past to reach 80% 
     217   //    * you will receive 20 points per second (60-40). If your 
     218   //    * target is 80% and you reach 80% you will receive 40 
     219   //    * points per second (80-40). 
     220   //    * 
     221   //    * You can set both Attention and Meditation targets at the 
     222   //    * same time. Reaching either will fly the helicopter but you 
     223   //    * will only receive points for the higher-scoring target of 
     224   //    * the two. 
     225   //    * 
     226   //    */ 
     227    
     228   int eegAttentionScore = 0; 
     229   int eegAttention = self.attention.progress * 100; 
     230   int eegAttentionTarget = self.attentionThreshold.value * 100; 
     231 
     232   int eegMeditationScore = 0; 
     233   int eegMeditation = self.meditation.progress * 100; 
     234   int eegMeditationTarget = self.meditationThreshold.value * 100; 
     235    
     236 
     237   if ((eegAttention >= eegAttentionTarget) && 
     238       (eegAttentionTarget > minimumScoreTarget)) 
     239      eegAttentionScore = eegAttentionTarget - minimumScoreTarget; 
     240    
     241   if ((eegMeditation >= eegMeditationTarget) && 
     242       (eegMeditationTarget > minimumScoreTarget)) 
     243      eegMeditationScore = eegMeditationTarget - minimumScoreTarget; 
     244    
     245   if (eegAttentionScore > eegMeditationScore) 
     246      scoreCurrent = scoreCurrent + eegAttentionScore; 
     247   else 
     248      scoreCurrent = scoreCurrent + eegMeditationScore; 
     249    
     250    
     251//   self.attentionPercent.text = [NSString stringWithFormat:@"%i%%", (int)(attentionLevel * 100)]; 
     252    
     253   self.scoresDisplay.text = [NSString stringWithFormat:@"%i%%", (int)scoreCurrent]; 
     254    
     255   
     256 
     257//   // Catch anyone gaming the system with one slider 
     258//   // below the minimum threshold and the other over. 
     259//   // For example, setting Meditation to 1% will keep helicopter 
     260//   // activated even if Attention is below target 
     261//   if ((eegAttention < eegAttentionTarget) && (eegMeditation < minimumScoreTarget)) 
     262//      resetCurrentScore(); 
     263//   if ((eegMeditation < eegMeditationTarget) && (eegAttention < minimumScoreTarget)) 
     264//      resetCurrentScore(); 
     265//   if ((eegAttention < minimumScoreTarget) && (eegMeditation < minimumScoreTarget)) 
     266//      resetCurrentScore(); 
     267 
     268 
     269} // updateScore 
     270 
     271 
     272// ################################################################ 
     273 
     274//public void resetCurrentScore() { 
     275//    
     276//   if (scoreCurrent > 0) 
     277//      textViewLastScore.setText(Integer.toString(scoreCurrent)); 
     278//   scoreCurrent = 0; 
     279//   textViewScore.setText(Integer.toString(scoreCurrent)); 
     280//    
     281//} // resetCurrentScore 
     282 
    203283@end 
Note: See TracChangeset for help on using the changeset viewer.