minor gameflow changes

This commit is contained in:
Ruben 2016-09-15 16:17:20 +01:00
parent 7ba9c2c431
commit 4187be4eaf
6 changed files with 144 additions and 27 deletions

View file

@ -47,7 +47,7 @@ public enum Emotion {
case ANGER:
return Color.RED;
case CONTEMPT:
return Color.BLUE;
return Color.WHITE;
case DISGUST:
return Color.GREEN;
case FEAR:

View file

@ -20,6 +20,7 @@ import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
@ -37,6 +38,8 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
final static String LOG_TAG = "EmotionHero-Mirror";
public final static String INTENT_EXTRA_SHOW_INTRO = "com.rubenvandeven.emotionhero.INTRO";
private CameraDetector detector;
@ -47,7 +50,12 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
SurfaceView cameraPreview;
ScenarioView scenarioView;
LinearLayout mainMenu;
TextView messageText;
TextView nextButton;
TextView readyButton;
TextView text1;
TextView text2;
boolean has_camera_permission = false;
@ -74,12 +82,19 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
final TextView startButton = (TextView) findViewById(R.id.startButton);
TextView highscoresButton = (TextView) findViewById(R.id.highscoresButton);
TextView creditsButton = (TextView) findViewById(R.id.creditsButton);
mainMenu = (LinearLayout) findViewById(R.id.mainMenu);
nextButton = (TextView) findViewById(R.id.nextButton);
readyButton = (TextView) findViewById(R.id.readyButton);
text1 = (TextView) findViewById(R.id.introText1);
text2 = (TextView) findViewById(R.id.introText2);
Typeface font = Typeface.createFromAsset(getAssets(), "unifont-9.0.02.ttf");
startButton .setTypeface(font);
highscoresButton .setTypeface(font);
creditsButton .setTypeface(font);
messageText.setTypeface(font);
nextButton.setTypeface(font);
readyButton.setTypeface(font);
//We create a custom SurfaceView that resizes itself to match the aspect ratio of the incoming camera frames
cameraPreview = new SurfaceView(this) {
@ -162,23 +177,6 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
colorAnimation.start();
startButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MirrorMenuActivity.this, IntroductionActivity.class);
// if(!player.getPlayerInfo().canContinueLevel()) {
// intent = new Intent(MirrorMenuActivity.this, IntroductionActivity.class);
// } else {
// loadGameDialog = ProgressDialog.show(MirrorMenuActivity.this, "",
// MirrorMenuActivity.this.getResources().getString(R.string.load_game_activity), true);
// intent = new Intent(MirrorMenuActivity.this, GamingActivity.class);
// }
startActivity(intent);
detector.stop();
detector = null;
}
});
// merge with 'start button'
@ -206,6 +204,46 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
rs = RenderScript.create(this);
startButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
gotoIntro();
}
});
nextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
nextButton.setVisibility(View.GONE);
readyButton.setVisibility(View.VISIBLE);
text1.setVisibility(View.GONE);
text2.setVisibility(View.VISIBLE);
}
});
readyButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MirrorMenuActivity.this, ProgressActivity.class);
finish();
startActivity(intent);
}
});
// all setup, see wheter we immediately continue to intro:
boolean showIntro = getIntent().getBooleanExtra(INTENT_EXTRA_SHOW_INTRO, false);
if(showIntro) {
gotoIntro();
}
}
protected void gotoIntro() {
nextButton.setVisibility(View.VISIBLE);
text1.setVisibility(View.VISIBLE);
mainMenu.setVisibility(View.GONE);
}
@Override

View file

@ -43,6 +43,20 @@ public class ProgressActivity extends AppCompatActivity {
super.onResume();
// rebuild layout on each onResume, so that updated scores are refreshed
buildLayout();
hideLoadingDialog();
}
protected ProgressDialog dialog;
public void showLoadingDialog() {
dialog = ProgressDialog.show(ProgressActivity.this, "",
getApplicationContext().getResources().getString(R.string.load_game_activity), true);
}
public void hideLoadingDialog() {
if(dialog != null) {
dialog.cancel();
}
}
public void buildLayout() {
@ -63,8 +77,11 @@ public class ProgressActivity extends AppCompatActivity {
introText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ProgressActivity.this, IntroductionActivity.class);
showLoadingDialog();
Intent intent = new Intent(ProgressActivity.this, MirrorMenuActivity.class);
intent.putExtra(MirrorMenuActivity.INTENT_EXTRA_SHOW_INTRO, true);
startActivity(intent);
finish();
}
});
@ -131,8 +148,7 @@ public class ProgressActivity extends AppCompatActivity {
intent.putExtra(HighscoreActivity.INTENT_EXTRA_LVL_ID, scenario.id);
} else {
// "PLAY NOW!"
ProgressDialog dialog = ProgressDialog.show(getApplicationContext(), "",
getApplicationContext().getResources().getString(R.string.load_game_activity), true);
showLoadingDialog();
intent = new Intent(ProgressActivity.this, GamingActivity.class);
intent.putExtra(GamingActivity.INTENT_EXTRA_SCENARIO, scenario.id);
}

View file

@ -44,6 +44,7 @@ public class ScenarioView extends SurfaceView implements SurfaceHolder.Callback
private Paint attrScoreLinePaint = new Paint();
private Paint linePaint = new Paint();
private Paint scorePaint = new Paint();
private Paint bonusScorePaint = new Paint();
private Paint scoreFinishedPaint = new Paint();
private Paint bonusBarPaint = new Paint();
@ -103,9 +104,13 @@ public class ScenarioView extends SurfaceView implements SurfaceHolder.Callback
_scenario = s;
scorePaint.setColor(Color.YELLOW);
scorePaint.setTextSize(50);
scorePaint.setTextSize(40);
scorePaint.setTypeface(Typeface.DEFAULT_BOLD);
bonusScorePaint.setColor(Color.rgb(132, 0, 255));
bonusScorePaint.setTextSize(20);
bonusScorePaint.setTypeface(Typeface.DEFAULT_BOLD);
bonusBarPaint.setColor(Color.rgb(132, 0, 255));
scoreFinishedPaint.setColor(Color.YELLOW);
@ -118,7 +123,7 @@ public class ScenarioView extends SurfaceView implements SurfaceHolder.Callback
linePaint.setColor(Color.GRAY);
linePaint.setStrokeWidth(5);
attrScorePaint.setColor(Color.DKGRAY);
attrScorePaint.setColor(Color.GRAY);
attrScoreLinePaint.setColor(Color.DKGRAY);
attrScoreLinePaint.setStrokeWidth(2);
@ -266,6 +271,7 @@ public class ScenarioView extends SurfaceView implements SurfaceHolder.Callback
// canvas.drawText(scoreText, (width - scoreTextBounds.width()) / 2, height - 10, usedScorePaint);
canvas.restore();
float hitWidth = width*(_scenario.getHitPercentage()/100);
float misWidth = width*(_scenario.getMissedPercentage()/100);
@ -274,7 +280,15 @@ public class ScenarioView extends SurfaceView implements SurfaceHolder.Callback
String scoreText = String.format("%1$.0f", _scenario.getHitTotalValue());
Rect scoreTextBounds = new Rect();
scorePaint.getTextBounds(scoreText, 0, scoreText.length(), scoreTextBounds);
canvas.drawText(scoreText, hitWidth, height*0.95f-scoreTextBounds.height()-5, scorePaint);
canvas.drawText(scoreText, hitWidth, height*0.95f-scoreTextBounds.height(), scorePaint);
float bonus =_scenario.getBonusTotalValue();
if(bonus > 0) {
String bonusText = String.format("+ %1$.0f", bonus);
Rect bonusTextBounds = new Rect();
bonusScorePaint.getTextBounds(bonusText, 0, bonusText.length(), bonusTextBounds);
canvas.drawText(bonusText, hitWidth+scoreTextBounds.width()+3, height*0.95f-bonusTextBounds.height()-10, bonusScorePaint);
}
canvas.drawRect(0, height*0.95f, width, height, mainPaint);

View file

@ -15,6 +15,7 @@
</RelativeLayout>
<LinearLayout
android:id="@+id/mainMenu"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -68,10 +69,10 @@
android:textAlignment="center"
android:keepScreenOn="true"
android:text="@string/dummy_content"
android:textColor="@color/textPrimary"
android:textColor="@color/textSecondary"
android:textSize="30sp"
android:textStyle="bold"
android:paddingBottom="30dp"
android:paddingBottom="60dp"
android:shadowColor="@android:color/black"
android:shadowDx="0"
android:shadowDy="0"
@ -98,4 +99,52 @@
android:layout_alignParentStart="true"
android:contentDescription="@string/app_name" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/logoEmotionHero"
android:paddingLeft="@dimen/fab_margin"
android:paddingRight="@dimen/fab_margin"
android:id="@+id/introText1"
android:text="@string/game_intro_text"
android:textColor="@color/textPrimary"
android:textSize="30sp"
android:visibility="gone"/>
<TextView
android:text="Yes!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:id="@+id/nextButton"
android:textSize="40sp"
android:textColor="@color/textHighlight"
android:layout_marginBottom="20dp"
android:visibility="gone"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/logoEmotionHero"
android:paddingLeft="@dimen/fab_margin"
android:paddingRight="@dimen/fab_margin"
android:id="@+id/introText2"
android:text="@string/game_intro_text2"
android:textColor="@color/textPrimary"
android:textSize="30sp"
android:visibility="gone"/>
<TextView
android:text="I'm ready!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:id="@+id/readyButton"
android:textSize="40sp"
android:textColor="@color/textHighlight"
android:layout_marginBottom="20dp"
android:visibility="gone" />
</RelativeLayout>

View file

@ -15,5 +15,5 @@
<string name="section_format">Hello World from section: %1$d</string>
<string name="load_game_activity">Loading training...</string>
<string name="game_intro_text">Are you ready to become the next <b>Emotion Hero</b>? With this program you train for the right emotional response in <i>every</i> situation.</string>
<string name="game_intro_text2">Feel the emotions as they are given by the dots on screen. If <i>you</i> feel them, <i>we</i> detect them.\nNote that you do not always need to go full throttle, we can detect eg. a 47% surprise score!</string>
<string name="game_intro_text2">The bar belows shows your current feelings.\nFeel the emotions as they are given by the dots on screen. If <i>you</i> feel them, <i>we</i> detect them!</string>
</resources>