2016-08-16 19:25:28 +02:00
package com.rubenvandeven.emotionhero ;
2016-08-19 20:06:18 +02:00
import android.graphics.Bitmap ;
2016-09-09 14:00:41 +02:00
import android.graphics.Canvas ;
import android.graphics.Color ;
2016-09-15 16:23:38 +02:00
import android.graphics.Matrix ;
2016-09-09 14:00:41 +02:00
import android.graphics.Paint ;
import android.graphics.RectF ;
import android.support.v8.renderscript.RenderScript ;
2016-08-19 20:06:18 +02:00
import android.util.Log ;
2016-09-09 14:00:41 +02:00
import com.affectiva.android.affdex.sdk.Frame ;
2016-08-16 19:25:28 +02:00
import com.affectiva.android.affdex.sdk.detector.Face ;
import java.util.ArrayList ;
2016-09-20 18:23:49 +02:00
import java.util.Arrays ;
import java.util.Collections ;
2016-09-03 19:22:18 +02:00
import java.util.Date ;
2016-08-22 16:47:35 +02:00
import java.util.HashMap ;
2016-09-20 18:23:49 +02:00
import java.util.LinkedList ;
import java.util.List ;
2016-08-22 16:47:35 +02:00
import java.util.Map ;
2016-09-20 18:23:49 +02:00
import java.util.Random ;
2016-08-19 13:38:59 +02:00
import java.util.Timer ;
import java.util.TimerTask ;
2016-08-16 19:25:28 +02:00
2016-09-09 14:00:41 +02:00
import io.github.silvaren.easyrs.tools.Nv21Image ;
2016-08-16 19:25:28 +02:00
/ * *
* Created by ruben on 16 / 08 / 16 .
* /
2016-08-20 22:28:05 +02:00
public class Scenario {
public int id ;
2016-08-16 19:25:28 +02:00
2016-09-09 14:00:41 +02:00
public Frame . ByteArrayFrame currentFrame ;
2016-08-19 20:06:18 +02:00
2016-08-20 22:28:05 +02:00
public static final int LVL_NONE = 0 ;
public static final int LVL_ANGER = 1 ;
public static final int LVL_JOY = 2 ;
public static final int LVL_SURPRISE = 3 ;
2016-08-22 22:39:19 +02:00
public static final int LVL_SADDNESS = 4 ;
2016-08-20 22:28:05 +02:00
2016-09-16 19:04:01 +02:00
public static final int LVL_THESEVEN = 5 ;
public static final int LVL_SMILE = 6 ;
public static final int LVL_BUSINESS = 7 ;
public static final int LVL_REALLY = 8 ;
public static final int LVL_ACTNORMAL = 9 ;
// used for the kuleshov targets
public int [ ] kuleshovTargetIds ;
2016-08-20 22:28:05 +02:00
// the levels in the right order.
public static final ArrayList < Integer > SCENARIOS = new ArrayList < Integer > ( ) { {
2016-09-16 19:04:01 +02:00
add ( LVL_THESEVEN ) ;
add ( LVL_SMILE ) ;
add ( LVL_BUSINESS ) ;
add ( LVL_REALLY ) ;
add ( LVL_ACTNORMAL ) ;
2016-08-20 22:28:05 +02:00
} } ;
2016-08-19 13:38:59 +02:00
static int DESIRED_FPS = 25 ;
2016-08-16 19:25:28 +02:00
float duration = 0 ;
2016-09-06 15:35:40 +02:00
/ * *
* Minimum score to be able to pass to the next level .
2016-09-09 14:00:41 +02:00
* ( check minimumScore | | minimumAchievements )
2016-09-06 15:35:40 +02:00
* /
float minimumScore = 0 ;
2016-09-09 14:00:41 +02:00
/ * *
* Number of achievements required to have , before being able to go to next level
* ( check minimumScore | | minimumAchievements )
* /
2016-09-16 19:04:01 +02:00
int minimumAchievements = 0 ;
2016-09-09 14:00:41 +02:00
2016-09-10 16:51:34 +02:00
/ * *
* Achievements one get obtain in this level
* /
ArrayList < Achievement > achievements = new ArrayList < > ( ) ;
2016-09-03 19:22:18 +02:00
/ * *
* If a game is beign played .
* /
Game game ;
2016-08-19 13:38:59 +02:00
/ * *
* @deprecated
* /
2016-08-17 13:17:04 +02:00
long startTime = 0 ;
2016-08-19 13:38:59 +02:00
/ * *
* The timer that provides the tick
* /
Timer timer ;
/ * *
* Increment on each tick
* /
float runningTime = - 1 ;
boolean isRunning = false ;
private GamingActivity _activity ;
2016-09-08 00:32:28 +02:00
int maxScore = 0 ;
2016-09-09 14:00:41 +02:00
protected RenderScript rs ;
protected Paint squarePaint ;
2016-09-16 19:04:01 +02:00
protected int bitmapCount = 0 ;
/ * *
* LostFace starts false , stays false when face is found , the becomes
* true when losing the face
* /
protected boolean lostFace = false ;
2016-09-20 18:23:49 +02:00
public static int MAX_SNAPSHOTS = 5 ;
2016-09-21 15:58:49 +02:00
public boolean takeSnapshots ;
2016-09-20 18:23:49 +02:00
/ * *
* Which targets to capture an image of
* /
List < Target > snapTargets ;
2016-08-19 13:38:59 +02:00
/ * *
* The scorres in this moment , as to draw them on the screen .
* Indexes are Emotion ordinals
* /
2016-08-19 20:06:18 +02:00
private Face currentFace ;
2016-08-19 13:38:59 +02:00
2016-08-16 19:25:28 +02:00
ArrayList < Target > targets = new ArrayList < > ( ) ;
class Target {
2016-09-03 19:22:18 +02:00
public int index ;
2016-08-16 19:25:28 +02:00
public Emotion emotion ;
public float value ;
public float timestamp ;
2016-09-03 19:22:18 +02:00
public boolean isHit = false ;
2016-08-16 19:25:28 +02:00
}
/ * *
* Constructor
* /
2016-08-20 22:28:05 +02:00
public Scenario ( int lvl_id , GamingActivity activity )
2016-08-16 19:25:28 +02:00
{
2016-08-20 22:28:05 +02:00
// go to first scenario if unexisting is given
if ( ! SCENARIOS . contains ( lvl_id ) ) {
lvl_id = SCENARIOS . get ( 0 ) ;
}
this . id = lvl_id ;
_activity = activity ;
createTargets ( ) ;
}
public void init ( ) {
2016-08-19 13:38:59 +02:00
timer = new Timer ( " ScenarioTimer " ) ;
TimerTask tickTask ;
tickTask = new TimerTask ( ) {
@Override
public void run ( ) {
// if (System.currentTimeMillis() - scheduledExecutionTime() >=
// MAX_TARDINESS)
// return; // Too late; skip this execution.
tick ( ) ;
}
} ;
timer . schedule ( tickTask , 0 , 1000 / DESIRED_FPS ) ;
2016-09-10 01:03:10 +02:00
this . game = new Game ( null , this , 0 , 0 , new Date ( ) , null ) ;
2016-09-09 14:00:41 +02:00
rs = RenderScript . create ( _activity ) ;
squarePaint = new Paint ( ) ;
squarePaint . setColor ( Color . YELLOW ) ;
2016-09-20 18:23:49 +02:00
// determine before start which targets will be stored and send
// only do it randomly so we don't need to do ALL and yet have spread across the level.
snapTargets = pickNRandom ( targets , MAX_SNAPSHOTS ) ;
2016-09-21 15:58:49 +02:00
takeSnapshots = _activity . player . allowsSnapshots ( ) ;
2016-09-20 18:23:49 +02:00
}
public static List < Target > pickNRandom ( List < Target > lst , int n ) {
List < Target > copy = new LinkedList < Target > ( lst ) ;
Collections . shuffle ( copy ) ;
return copy . subList ( 0 , n ) ;
2016-08-19 13:38:59 +02:00
}
/ * *
* To be called on each timer tick
* /
2016-09-19 02:12:38 +02:00
public synchronized void tick ( )
2016-08-19 13:38:59 +02:00
{
2016-09-16 19:04:01 +02:00
if ( ! isRunning ) {
if ( lostFace ) {
game . lostFaceTime + = 1 . 0f / DESIRED_FPS ;
}
2016-08-19 13:38:59 +02:00
return ;
2016-09-16 19:04:01 +02:00
}
2016-08-19 13:38:59 +02:00
runningTime + = 1 . 0f / DESIRED_FPS ;
if ( isFinished ( ) ) {
stop ( ) ;
return ;
}
2016-09-03 19:22:18 +02:00
for ( Target target : targets ) {
2016-08-19 13:38:59 +02:00
// skip targets that are already scored
2016-09-03 19:22:18 +02:00
if ( target . isHit = = true ) {
2016-08-19 13:38:59 +02:00
continue ;
}
if ( target . timestamp < = runningTime ) {
2016-09-10 01:03:10 +02:00
Hit hit = new Hit ( target , game , currentFace ) ;
2016-08-19 13:38:59 +02:00
_activity . sound . play ( _activity . soundIds . get ( _activity . SOUND_SCORE ) , 1 , 1 ,
2016-09-15 16:23:38 +02:00
2 , 0 , hit . score / 200f + 0 . 5f ) ; // play back the sound slower
2016-08-20 23:58:32 +02:00
// depending on hit value
2016-09-15 16:23:38 +02:00
if ( hit . bonus > 0 ) {
_activity . sound . play ( _activity . soundIds . get ( _activity . SOUND_BONUS ) , 0 . 7f , 0 . 7f ,
1 , 0 , hit . bonus / 100f + 0 . 8f ) ; // play back the sound slower
// depending on bonus value
}
2016-09-03 19:22:18 +02:00
target . isHit = true ;
2016-09-09 14:00:41 +02:00
Bitmap outputBitmap = null ;
2016-09-21 15:58:49 +02:00
if ( currentFrame ! = null & & takeSnapshots & & snapTargets . contains ( target ) ) {
2016-09-09 14:00:41 +02:00
// convert NV21 byteArrayFrame from camera to RGB bitmap.
Frame . ByteArrayFrame byteArrayFrame = ( Frame . ByteArrayFrame ) currentFrame ;
outputBitmap = Nv21Image . nv21ToBitmap ( rs , byteArrayFrame . getByteArray ( ) , byteArrayFrame . getWidth ( ) , byteArrayFrame . getHeight ( ) ) ;
2016-09-16 19:04:01 +02:00
bitmapCount + + ;
2016-09-15 16:23:38 +02:00
Frame . ROTATE rotation = byteArrayFrame . getTargetRotation ( ) ;
// ie BY_90_CCW -90.0
Log . v ( " Scenario " , " frame rotation: " + rotation . toString ( ) + " " + rotation . toDouble ( ) ) ;
// process rotation... (maybe faster if done on byte array?)
if ( rotation ! = Frame . ROTATE . NO_ROTATION ) {
Matrix matrix = new Matrix ( ) ;
matrix . postRotate ( ( int ) rotation . toDouble ( ) ) ;
// int width = rotation == Frame.ROTATE.BY_180 ? outputBitmap.getWidth() : outputBitmap.getHeight();
// int height = rotation == Frame.ROTATE.BY_180 ? outputBitmap.getHeight() : outputBitmap.getWidth();
outputBitmap = Bitmap . createBitmap ( outputBitmap , 0 , 0 , outputBitmap . getWidth ( ) , outputBitmap . getHeight ( ) , matrix , true ) ;
}
2016-09-09 14:00:41 +02:00
2016-09-15 16:23:38 +02:00
// Deprecated: now we send only fragments of the images anyway.
// Canvas canvas = new Canvas(outputBitmap);
// RectF rect = Hit.getBoundingboxForPoints(currentFace.getFacePoints());
// canvas.drawRect(rect, squarePaint);
2016-09-09 14:00:41 +02:00
/ *
2016-09-15 16:23:38 +02:00
Also possible : only grayscale image - only loops over first part of the bytearray , is it faster ?
2016-09-09 14:00:41 +02:00
int [ ] pixels ;
int p ;
int size = width * height ;
for ( int i = 0 ; i < size ; i + + ) {
p = data [ i ] & 0xFF ;
pixels [ i ] = 0xff000000 | p < < 16 | p < < 8 | p ;
}
Bitmap bm = Bitmap . createBitmap ( pixels , width , height , Bitmap . Config . ARGB_8888 ) ;
* /
}
2016-09-10 01:03:10 +02:00
hit . frame = outputBitmap ;
2016-08-19 13:38:59 +02:00
}
}
2016-08-16 19:25:28 +02:00
}
2016-09-03 19:22:18 +02:00
public Target getTargetByIndex ( int target_index ) {
return targets . get ( target_index - 1 ) ;
}
2016-08-19 13:38:59 +02:00
2016-08-16 19:25:28 +02:00
/ * *
* Add a target on given timestamp
* @param emotion
* @param value
* @param timestamp
* /
2016-09-16 19:04:01 +02:00
public int setTarget ( Emotion emotion , float value , float timestamp )
2016-08-16 19:25:28 +02:00
{
2016-08-17 13:17:04 +02:00
// Log.e(GamingActivity.LOG_TAG, "Set target:" + Float.toString(timestamp) + " " + Float.toString(duration));
2016-08-19 13:38:59 +02:00
if ( ( timestamp + 1 ) > duration )
2016-08-16 19:25:28 +02:00
{
2016-08-19 13:38:59 +02:00
duration = timestamp + 1 ; // always a bit onger than last target, as it otherwise the game does not finish pretty
2016-08-16 19:25:28 +02:00
}
Target target = new Target ( ) ;
target . timestamp = timestamp ;
target . value = value ;
target . emotion = emotion ;
2016-09-03 19:22:18 +02:00
target . index = targets . size ( ) + 1 ;
2016-08-16 19:25:28 +02:00
targets . add ( target ) ;
2016-09-08 00:32:28 +02:00
maxScore = getMaxScore ( ) ;
2016-09-16 19:04:01 +02:00
return targets . indexOf ( target ) ;
2016-08-16 19:25:28 +02:00
}
/ * *
* Add target after existing targets , give delta with last item instead of absolute time .
* @param emotion
* @param value
* @param interval
* /
public void addTarget ( Emotion emotion , float value , float interval )
{
float timestamp ;
if ( targets . isEmpty ( ) ) {
timestamp = interval ;
} else {
timestamp = targets . get ( targets . size ( ) - 1 ) . timestamp + interval ;
}
setTarget ( emotion , value , timestamp ) ;
}
2016-08-20 23:58:32 +02:00
public float getHitTotalValue ( )
2016-08-16 19:25:28 +02:00
{
float value = 0 ;
2016-09-03 19:22:18 +02:00
for ( Hit hit : game . hits . values ( ) ) {
value + = hit . score ;
2016-08-16 19:25:28 +02:00
}
return value ;
}
2016-09-08 00:32:28 +02:00
public float getHitTotalMisValue ( )
{
float value = 0 ;
for ( Hit hit : game . hits . values ( ) ) {
value + = 100 - hit . score ;
}
return value ;
}
2016-09-10 01:03:10 +02:00
public float getBonusTotalValue ( )
{
float value = 0 ;
for ( Hit hit : game . hits . values ( ) ) {
value + = hit . bonus ;
}
return value ;
}
2016-09-08 00:32:28 +02:00
public float getHitPercentage ( ) {
return ( getHitTotalValue ( ) / maxScore ) * 100 ;
}
2016-09-10 01:03:10 +02:00
public float getBonusPercentage ( ) {
// maxScore for bonus == normal maxScore
return ( getBonusTotalValue ( ) / maxScore ) * 100 ;
}
2016-09-08 00:32:28 +02:00
public float getMissedPercentage ( ) {
return ( getHitTotalMisValue ( ) / maxScore ) * 100 ;
}
2016-08-16 19:25:28 +02:00
/ * *
* Check whether given timestamp is within duration of the scenario
* @param timestamp
* @return
* /
public boolean isWithinTime ( float timestamp )
{
return timestamp < = duration ;
}
2016-08-17 19:21:16 +02:00
public ArrayList < Target > getTargets ( ) {
return targets ;
}
2016-08-17 13:17:04 +02:00
2016-08-17 19:21:16 +02:00
/ * *
* Get the time within the scenario ( so since start ( ) has been called )
* /
public float getTime ( ) {
2016-08-19 13:38:59 +02:00
return runningTime ;
2016-08-17 13:17:04 +02:00
// if not started, don't move the labels, if started, move them by diff_y
2016-08-19 13:38:59 +02:00
// if(startTime == 0) {
// return 0;
// } else {
// float diff_t = ((System.currentTimeMillis() - startTime)) / (float) 1000;
// if(diff_t > duration) { // never larger than scenario duration
// return duration;
// }
// return diff_t;
// }
2016-08-17 13:17:04 +02:00
}
public void start ( )
{
startTime = System . currentTimeMillis ( ) ;
2016-08-19 13:38:59 +02:00
isRunning = true ;
}
public void pause ( ) {
isRunning = false ;
}
public void stop ( )
{
isRunning = false ;
}
// TODO: create AttributeScoreCollection class, with this method.
2016-09-20 18:23:49 +02:00
public synchronized void setCurrentFaceAndFrame ( Face face , Frame . ByteArrayFrame frame )
2016-08-19 13:38:59 +02:00
{
2016-08-19 20:06:18 +02:00
currentFace = face ;
2016-09-20 18:23:49 +02:00
currentFrame = frame ;
2016-08-19 13:38:59 +02:00
}
public boolean isFinished ( )
{
return runningTime > duration ;
2016-08-17 13:17:04 +02:00
}
2016-08-20 23:58:32 +02:00
public Score getScore ( ) {
2016-08-20 18:22:01 +02:00
if ( ! isFinished ( ) ) {
return null ;
}
2016-08-22 16:47:35 +02:00
Score score = new Score ( id , getHitTotalValue ( ) ) ;
score . setTargets ( targets ) ;
return score ;
2016-08-20 18:22:01 +02:00
}
public int getMaxScore ( ) {
return targets . size ( ) * 100 ;
}
2016-08-20 22:28:05 +02:00
public void createTargets ( ) {
2016-09-10 16:51:34 +02:00
AchievementCollection achievementCollection = AchievementCollection . getInstance ( ) ;
2016-08-20 22:28:05 +02:00
switch ( id ) {
case LVL_ANGER :
2016-08-30 16:56:21 +02:00
setTarget ( Emotion . ANGER , 100 , 1 ) ;
setTarget ( Emotion . ANGER , 100 , 2 ) ;
setTarget ( Emotion . ANGER , 10 , 3 ) ;
setTarget ( Emotion . ANGER , 20 , 4 ) ;
setTarget ( Emotion . ANGER , 40 , 5 ) ;
setTarget ( Emotion . ANGER , 70 , 6 ) ;
setTarget ( Emotion . ANGER , 100 , 7 ) ;
2016-09-10 16:51:34 +02:00
setMinimumScoreFromPercentage ( 10 ) ;
minimumAchievements = 2 ;
achievements . add ( achievementCollection . get ( 1 ) ) ;
achievements . add ( achievementCollection . get ( 3 ) ) ;
2016-08-20 23:58:32 +02:00
break ;
case LVL_JOY :
2016-08-30 16:56:21 +02:00
setTarget ( Emotion . JOY , 100 , 1 ) ;
setTarget ( Emotion . JOY , 100 , 2 ) ;
setTarget ( Emotion . JOY , 100 , 4 ) ;
setTarget ( Emotion . CONTEMPT , 20 , 4 ) ;
2016-08-20 22:28:05 +02:00
setTarget ( Emotion . ANGER , 100 , 5 ) ;
2016-08-30 16:56:21 +02:00
setTarget ( Emotion . JOY , 100 , 7 ) ;
setTarget ( Emotion . ANGER , 100 , 9 ) ;
setTarget ( Emotion . JOY , 100 , 11 ) ;
setTarget ( Emotion . JOY , 70 , 12 ) ;
setTarget ( Emotion . JOY , 60 , 13 ) ;
setTarget ( Emotion . JOY , 30 , 14 ) ;
setTarget ( Emotion . JOY , 10 , 14 . 5f ) ;
setTarget ( Emotion . ANGER , 100 , 16 ) ;
setTarget ( Emotion . JOY , 100 , 17 ) ;
setTarget ( Emotion . JOY , 100 , 18 ) ;
setTarget ( Emotion . JOY , 100 , 19 ) ;
setTarget ( Emotion . JOY , 100 , 20 ) ;
2016-09-10 16:51:34 +02:00
setMinimumScoreFromPercentage ( 10 ) ;
minimumAchievements = 2 ;
achievements . add ( achievementCollection . get ( 2 ) ) ;
achievements . add ( achievementCollection . get ( 4 ) ) ;
2016-08-20 22:28:05 +02:00
break ;
case LVL_SURPRISE :
setTarget ( Emotion . SURPRISE , 20 , 1 ) ;
setTarget ( Emotion . SURPRISE , 50 , 2 ) ;
setTarget ( Emotion . SURPRISE , 80 , 3 ) ;
setTarget ( Emotion . SURPRISE , 100 , 4 ) ;
2016-09-10 16:51:34 +02:00
setMinimumScoreFromPercentage ( 10 ) ;
minimumAchievements = 2 ;
achievements . add ( achievementCollection . get ( 5 ) ) ;
achievements . add ( achievementCollection . get ( 6 ) ) ;
2016-08-20 22:28:05 +02:00
break ;
2016-08-22 22:39:19 +02:00
case LVL_SADDNESS :
setTarget ( Emotion . SADNESS , 20 , 1 ) ;
setTarget ( Emotion . SADNESS , 50 , 2 ) ;
setTarget ( Emotion . SADNESS , 80 , 3 ) ;
setTarget ( Emotion . SADNESS , 100 , 4 ) ;
2016-09-10 16:51:34 +02:00
setMinimumScoreFromPercentage ( 10 ) ;
minimumAchievements = 2 ;
2016-08-22 22:39:19 +02:00
break ;
2016-09-16 19:04:01 +02:00
////////////////// new levels:
case LVL_THESEVEN :
int i = 2 ;
setTarget ( Emotion . JOY , 100 , i + + ) ;
setTarget ( Emotion . JOY , 100 , i + + ) ;
setTarget ( Emotion . JOY , 100 , i + + ) ;
i + + ;
i + + ;
setTarget ( Emotion . SADNESS , 100 , i + + ) ;
setTarget ( Emotion . SADNESS , 100 , i + + ) ;
setTarget ( Emotion . SADNESS , 100 , i + + ) ;
i + + ;
i + + ;
setTarget ( Emotion . ANGER , 100 , i + + ) ;
setTarget ( Emotion . ANGER , 100 , i + + ) ;
setTarget ( Emotion . ANGER , 100 , i + + ) ;
i + + ;
i + + ;
setTarget ( Emotion . SURPRISE , 100 , i + + ) ;
setTarget ( Emotion . SURPRISE , 100 , i + + ) ;
setTarget ( Emotion . SURPRISE , 100 , i + + ) ;
i + + ;
i + + ;
setTarget ( Emotion . DISGUST , 100 , i + + ) ;
setTarget ( Emotion . DISGUST , 100 , i + + ) ;
setTarget ( Emotion . DISGUST , 100 , i + + ) ;
i + + ;
i + + ;
setTarget ( Emotion . CONTEMPT , 100 , i + + ) ;
setTarget ( Emotion . CONTEMPT , 100 , i + + ) ;
setTarget ( Emotion . CONTEMPT , 100 , i + + ) ;
i + + ;
i + + ;
setTarget ( Emotion . FEAR , 100 , i + + ) ;
setTarget ( Emotion . FEAR , 100 , i + + ) ;
setTarget ( Emotion . FEAR , 100 , i + + ) ;
setMinimumScoreFromPercentage ( 40 ) ;
minimumAchievements = 2 ;
achievements . add ( achievementCollection . get ( 1 ) ) ;
achievements . add ( achievementCollection . get ( 2 ) ) ;
achievements . add ( achievementCollection . get ( 3 ) ) ;
achievements . add ( achievementCollection . get ( 4 ) ) ;
break ;
case LVL_SMILE :
int s = 2 ;
setTarget ( Emotion . JOY , 100 , s + + ) ;
setTarget ( Emotion . JOY , 100 , s + + ) ;
setTarget ( Emotion . JOY , 50 , s + + ) ;
setTarget ( Emotion . JOY , 50 , s + + ) ;
setTarget ( Emotion . JOY , 30 , s + + ) ;
setTarget ( Emotion . JOY , 30 , s + + ) ;
setTarget ( Emotion . JOY , 50 , s + + ) ;
setTarget ( Emotion . JOY , 50 , s + + ) ;
setTarget ( Emotion . JOY , 100 , s + + ) ;
setTarget ( Emotion . JOY , 100 , s + + ) ;
s + + ;
s + + ;
setTarget ( Emotion . SURPRISE , 100 , s + + ) ;
setTarget ( Emotion . SURPRISE , 100 , s + + ) ;
setTarget ( Emotion . SURPRISE , 50 , s + + ) ;
setTarget ( Emotion . SURPRISE , 50 , s + + ) ;
setTarget ( Emotion . SURPRISE , 100 , s + + ) ;
setTarget ( Emotion . SURPRISE , 100 , s + + ) ;
s + + ;
s + + ;
s + + ;
setTarget ( Emotion . JOY , 100 , s + + ) ;
setTarget ( Emotion . SURPRISE , 100 , s ) ;
setTarget ( Emotion . JOY , 100 , s + + ) ;
setTarget ( Emotion . SURPRISE , 100 , s ) ;
setTarget ( Emotion . JOY , 100 , s + + ) ;
setTarget ( Emotion . SURPRISE , 50 , s ) ;
setTarget ( Emotion . SURPRISE , 30 , s ) ;
s + + ;
s + + ;
setTarget ( Emotion . JOY , 100 , s + + ) ;
setTarget ( Emotion . ANGER , 1 , s ) ;
setTarget ( Emotion . CONTEMPT , 1 , s ) ;
setTarget ( Emotion . DISGUST , 1 , s ) ;
s + + ;
s + + ;
setTarget ( Emotion . DISGUST , 1 , s + + ) ;
setTarget ( Emotion . ANGER , 1 , s ) ;
setTarget ( Emotion . SURPRISE , 100 , s ) ;
setMinimumScoreFromPercentage ( 40 ) ;
minimumAchievements = 2 ;
achievements . add ( achievementCollection . get ( 5 ) ) ;
achievements . add ( achievementCollection . get ( 6 ) ) ;
achievements . add ( achievementCollection . get ( 7 ) ) ;
break ;
case LVL_BUSINESS :
int b = 2 ;
setTarget ( Emotion . ANGER , 100 , b + + ) ;
setTarget ( Emotion . ANGER , 100 , b + + ) ;
setTarget ( Emotion . ANGER , 50 , b + + ) ;
setTarget ( Emotion . ANGER , 50 , b + + ) ;
setTarget ( Emotion . ANGER , 30 , b + + ) ;
setTarget ( Emotion . ANGER , 30 , b + + ) ;
b + + ;
setTarget ( Emotion . DISGUST , 100 , b + + ) ;
setTarget ( Emotion . DISGUST , 50 , b + + ) ;
setTarget ( Emotion . DISGUST , 50 , b + + ) ;
setTarget ( Emotion . DISGUST , 30 , b + + ) ;
b + + ;
setTarget ( Emotion . CONTEMPT , 100 , b + + ) ;
setTarget ( Emotion . CONTEMPT , 50 , b + + ) ;
setTarget ( Emotion . CONTEMPT , 50 , b + + ) ;
setTarget ( Emotion . CONTEMPT , 30 , b + + ) ;
b + + ;
setTarget ( Emotion . SURPRISE , 100 , b + + ) ;
setTarget ( Emotion . SURPRISE , 100 , b + + ) ;
setTarget ( Emotion . SADNESS , 50 , b ) ;
setTarget ( Emotion . JOY , 50 , b + + ) ;
setTarget ( Emotion . DISGUST , 50 , b + + ) ;
setTarget ( Emotion . CONTEMPT , 30 , b + + ) ;
setTarget ( Emotion . CONTEMPT , 100 , b + + ) ;
setTarget ( Emotion . JOY , 100 , b + + ) ;
setTarget ( Emotion . SURPRISE , 100 , b + + ) ;
b + + ;
setTarget ( Emotion . SADNESS , 100 , b + + ) ;
setTarget ( Emotion . ANGER , 10 , b + + ) ;
setTarget ( Emotion . SADNESS , 100 , b + + ) ;
setTarget ( Emotion . ANGER , 10 , b + + ) ;
setTarget ( Emotion . SADNESS , 100 , b + + ) ;
setTarget ( Emotion . ANGER , 10 , b + + ) ;
setMinimumScoreFromPercentage ( 40 ) ;
minimumAchievements = 2 ;
achievements . add ( achievementCollection . get ( 8 ) ) ;
achievements . add ( achievementCollection . get ( 9 ) ) ;
achievements . add ( achievementCollection . get ( 10 ) ) ;
break ;
case LVL_REALLY :
int r = 2 ;
setTarget ( Emotion . FEAR , 100 , r + + ) ;
setTarget ( Emotion . FEAR , 50 , r + + ) ;
setTarget ( Emotion . FEAR , 30 , r + + ) ;
r + + ;
setTarget ( Emotion . SADNESS , 100 , r + + ) ;
setTarget ( Emotion . SADNESS , 50 , r + + ) ;
setTarget ( Emotion . SADNESS , 100 , r + + ) ;
r + + ;
setTarget ( Emotion . DISGUST , 100 , r + + ) ;
setTarget ( Emotion . DISGUST , 100 , r + + ) ;
setTarget ( Emotion . DISGUST , 50 , r + + ) ;
r + + ;
setTarget ( Emotion . DISGUST , 100 , r + + ) ;
setTarget ( Emotion . CONTEMPT , 30 , r ) ;
setTarget ( Emotion . DISGUST , 50 , r + + ) ;
setTarget ( Emotion . CONTEMPT , 50 , r ) ;
setTarget ( Emotion . DISGUST , 30 , r + + ) ;
setTarget ( Emotion . CONTEMPT , 100 , r ) ;
r + + ;
r + + ;
setTarget ( Emotion . SADNESS , 100 , r + + ) ;
setTarget ( Emotion . JOY , 50 , r + + ) ;
setTarget ( Emotion . SADNESS , 100 , r + + ) ;
setTarget ( Emotion . JOY , 50 , r + + ) ;
setTarget ( Emotion . SADNESS , 50 , r + + ) ;
setTarget ( Emotion . JOY , 100 , r + + ) ;
setTarget ( Emotion . SADNESS , 50 , r + + ) ;
setTarget ( Emotion . JOY , 100 , r ) ;
setTarget ( Emotion . SADNESS , 100 , r + + ) ;
setTarget ( Emotion . JOY , 50 , r ) ;
setMinimumScoreFromPercentage ( 40 ) ;
minimumAchievements = 2 ;
achievements . add ( achievementCollection . get ( 8 ) ) ;
achievements . add ( achievementCollection . get ( 9 ) ) ;
achievements . add ( achievementCollection . get ( 10 ) ) ;
achievements . add ( achievementCollection . get ( 11 ) ) ;
break ;
case LVL_ACTNORMAL :
float a = 2 ;
setTarget ( Emotion . ANGER , 100 , a + + ) ;
setTarget ( Emotion . DISGUST , 100 , a + + ) ;
setTarget ( Emotion . FEAR , 100 , a + + ) ;
setTarget ( Emotion . JOY , 100 , a + + ) ;
setTarget ( Emotion . SADNESS , 100 , a + + ) ;
setTarget ( Emotion . SURPRISE , 100 , a + + ) ;
a + + ;
setTarget ( Emotion . ANGER , 30 , a + + ) ;
setTarget ( Emotion . DISGUST , 30 , a + = 0 . 5 ) ;
setTarget ( Emotion . FEAR , 30 , a + = 0 . 5 ) ;
setTarget ( Emotion . JOY , 30 , a + = 0 . 5 ) ;
setTarget ( Emotion . SADNESS , 30 , a + = 0 . 5 ) ;
setTarget ( Emotion . SURPRISE , 30 , a + = 0 . 5 ) ;
a + + ;
setTarget ( Emotion . ANGER , 30 , a + + ) ;
setTarget ( Emotion . DISGUST , 30 , a ) ;
setTarget ( Emotion . ANGER , 30 , a + + ) ;
setTarget ( Emotion . DISGUST , 30 , a ) ;
setTarget ( Emotion . FEAR , 30 , a + + ) ;
setTarget ( Emotion . JOY , 30 , a ) ;
setTarget ( Emotion . FEAR , 30 , a + + ) ;
setTarget ( Emotion . JOY , 30 , a ) ;
setTarget ( Emotion . SADNESS , 30 , a + + ) ;
setTarget ( Emotion . SURPRISE , 30 , a ) ;
setTarget ( Emotion . SADNESS , 30 , a + + ) ;
setTarget ( Emotion . SURPRISE , 30 , a ) ;
a + + ;
a + + ;
setTarget ( Emotion . DISGUST , 20 , a + + ) ;
setTarget ( Emotion . CONTEMPT , 20 , a ) ;
setTarget ( Emotion . SURPRISE , 20 , a ) ;
setTarget ( Emotion . DISGUST , 10 , a + + ) ;
setTarget ( Emotion . CONTEMPT , 10 , a ) ;
setTarget ( Emotion . SURPRISE , 10 , a ) ;
setTarget ( Emotion . DISGUST , 5 , a + + ) ;
setTarget ( Emotion . CONTEMPT , 5 , a ) ;
setTarget ( Emotion . SURPRISE , 5 , a ) ;
// Kuleshov's target:
kuleshovTargetIds = new int [ 3 ] ;
kuleshovTargetIds [ 0 ] = setTarget ( Emotion . DISGUST , 1 , a + + ) ;
kuleshovTargetIds [ 1 ] = setTarget ( Emotion . CONTEMPT , 1 , a ) ;
kuleshovTargetIds [ 2 ] = setTarget ( Emotion . SURPRISE , 1 , a ) ;
// END OF KULESHOV
setTarget ( Emotion . DISGUST , 1 , a + + ) ;
setTarget ( Emotion . CONTEMPT , 1 , a ) ;
setTarget ( Emotion . SURPRISE , 1 , a ) ;
setTarget ( Emotion . ANGER , 1 , a + + ) ;
setTarget ( Emotion . CONTEMPT , 1 , a ) ;
setTarget ( Emotion . DISGUST , 1 , a ) ;
setTarget ( Emotion . FEAR , 1 , a ) ;
setTarget ( Emotion . JOY , 1 , a ) ;
setTarget ( Emotion . SADNESS , 1 , a ) ;
setTarget ( Emotion . SURPRISE , 1 , a ) ;
setMinimumScoreFromPercentage ( 40 ) ;
minimumAchievements = 2 ;
achievements . add ( achievementCollection . get ( 12 ) ) ;
achievements . add ( achievementCollection . get ( 13 ) ) ;
achievements . add ( achievementCollection . get ( 14 ) ) ;
break ;
2016-08-20 22:28:05 +02:00
}
}
2016-09-10 16:51:34 +02:00
public void setMinimumScoreFromPercentage ( float percentage ) {
this . minimumScore = maxScore * ( percentage / 100f ) ;
}
2016-08-20 22:28:05 +02:00
public int getNextLevelId ( ) {
int nextIdx = SCENARIOS . indexOf ( id ) + 1 ;
if ( SCENARIOS . size ( ) < = nextIdx ) {
return SCENARIOS . get ( 0 ) ;
}
return SCENARIOS . get ( nextIdx ) ;
}
public boolean isFinalLevel ( ) {
if ( SCENARIOS . get ( SCENARIOS . size ( ) - 1 ) = = id )
return true ;
return false ;
}
2016-08-22 16:47:35 +02:00
public boolean isHigherThen ( int lvl_id ) {
return isHigherLevel ( id , lvl_id ) ;
}
public static boolean isHigherLevel ( int lvl_id , int then_lvl_id ) {
if ( lvl_id = = then_lvl_id ) {
return false ;
}
return SCENARIOS . indexOf ( lvl_id ) > SCENARIOS . indexOf ( then_lvl_id ) ;
}
2016-08-23 01:35:33 +02:00
public String toString ( ) {
switch ( id ) {
case LVL_ANGER :
2016-09-11 23:35:38 +02:00
return " \" Smile like you mean it \" " ;
2016-09-07 16:18:42 +02:00
case LVL_JOY :
2016-09-11 23:35:38 +02:00
return " The seven " ;
2016-09-07 16:18:42 +02:00
case LVL_SURPRISE :
2016-09-11 23:35:38 +02:00
return " \" Let's talk business \" " ;
2016-09-07 16:18:42 +02:00
case LVL_SADDNESS :
2016-09-11 23:35:38 +02:00
return " A sad sad situation " ;
2016-09-16 19:04:01 +02:00
// new:
case LVL_THESEVEN :
return " Welcome to the seven " ;
case LVL_SMILE :
return " \" Smile like you mean it \" " ;
case LVL_BUSINESS :
return " \" Let's talk business \" " ;
case LVL_REALLY :
return " Show me what you really feel " ;
case LVL_ACTNORMAL :
return " Please act normally " ;
2016-09-07 16:18:42 +02:00
}
return " ... " ;
}
public String getDescription ( ) {
switch ( id ) {
case LVL_ANGER :
return " You're CEO of a big company. Remarkably, research shows that CEO's of big companies look generally more angry and disgusted when the company is doing well. \ n " +
" \ n " +
" However, you're company is not doing well. Make sure you hide this for the press that is watching every move! " ;
2016-08-23 01:35:33 +02:00
case LVL_JOY :
2016-09-07 16:18:42 +02:00
return " You're at a job interview, and you know your face is being monitored. \ n " +
" Make sure that you express your enthusiasm for the job! " ;
2016-08-23 01:35:33 +02:00
case LVL_SURPRISE :
2016-09-07 16:18:42 +02:00
return " Your friends have organised a surprise party and you've found out! However, you don't want them to know this. First keep calm and then make sure you're as surprised and joyful as possible! \ n " ;
2016-08-23 01:35:33 +02:00
case LVL_SADDNESS :
2016-09-07 16:18:42 +02:00
return " You're at the funeral of your great aunt. You don't really know her, but still want to show your respect. " ;
2016-08-23 01:35:33 +02:00
}
return " ... " ;
}
2016-09-03 19:22:18 +02:00
public Hit getHitForTarget ( Target target ) {
return game . hits . get ( target . index ) ;
}
2016-08-16 19:25:28 +02:00
}