Introduction, also changed startmenu

This commit is contained in:
Ruben 2016-09-12 00:00:26 +01:00
parent 4fe13ba57c
commit ddd0764e19
9 changed files with 179 additions and 20 deletions

View file

@ -67,6 +67,7 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.rubenvandeven.emotionhero.MirrorMenuActivity" />
</activity>
<activity android:name=".IntroductionActivity"></activity>
</application>
</manifest>

View file

@ -376,10 +376,17 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
// check whether this is the highest reached level by the player
// ... used by 'continue' button in main menu
Scenario nextScenario = new Scenario(currentScenario.getNextLevelId(), this);
if(currentScenario.minimumScore < currentScenario.game.score && nextScenario.isHigherThen(playerInfo.reachedLevelId)) {
// allow player to continue to next level :-)
playerInfo.reachedLevelId = nextScenario.id;
if(currentScenario.minimumScore < currentScenario.game.score) {
if(currentScenario.isFinalLevel()) {
playerInfo.completedAll = true;
} else {
Scenario nextScenario = new Scenario(currentScenario.getNextLevelId(), this);
if(nextScenario.isHigherThen(playerInfo.reachedLevelId)) {
// allow player to continue to next level :-)
playerInfo.reachedLevelId = nextScenario.id;
}
}
}
// scores.add(score);

View file

@ -0,0 +1,58 @@
package com.rubenvandeven.emotionhero;
import android.content.Intent;
import android.graphics.Typeface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;
/**
* Not to be confused with IntroActivity:
* this is the first game introduction (explaining the procedure etc.)
*/
public class IntroductionActivity extends AppCompatActivity {
TextView nextButton;
TextView readyButton;
TextView text1;
TextView text2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_introduction);
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");
nextButton.setTypeface(font);
readyButton.setTypeface(font);
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(IntroductionActivity.this, ProgressActivity.class);
finish();
startActivity(intent);
}
});
}
}

View file

@ -55,6 +55,8 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
RenderScript rs;
Player player;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -64,6 +66,8 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
}
setContentView(R.layout.activity_mirror_menu);
player = Player.getInstance(this);
RelativeLayout videoContentLayout = (RelativeLayout) findViewById(R.id.videoContent);
ImageView logoEmotionHero = (ImageView) findViewById(R.id.logoEmotionHero);
messageText = (TextView) findViewById(R.id.messageText);
@ -161,9 +165,14 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
startButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loadGameDialog = ProgressDialog.show(MirrorMenuActivity.this, "",
MirrorMenuActivity.this.getResources().getString(R.string.load_game_activity), true);
Intent intent = new Intent(MirrorMenuActivity.this, GamingActivity.class);
Intent intent;
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;
@ -171,14 +180,19 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
}
});
highscoresButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MirrorMenuActivity.this, ProgressActivity.class);
// intent.putExtra(HighscoreActivity.INTENT_EXTRA_LEVEL, player.getPlayerInfo().reachedLevelId);
startActivity(intent);
}
});
if(!player.getPlayerInfo().canContinueLevel()) {
highscoresButton.setVisibility(View.GONE);
} else {
highscoresButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MirrorMenuActivity.this, ProgressActivity.class);
// intent.putExtra(HighscoreActivity.INTENT_EXTRA_LEVEL, player.getPlayerInfo().reachedLevelId);
startActivity(intent);
}
});
}
creditsButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -189,6 +203,7 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
});
rs = RenderScript.create(this);
}
@Override

View file

@ -15,6 +15,7 @@ import java.util.UUID;
public class PlayerInfo {
public Map<Integer, ScoreList> levelScores = new HashMap<>();
public int reachedLevelId = -1;
public boolean completedAll = false;
public ScoreList getScoresForLevel(int lvl_id) {
ScoreList scoreList;
@ -69,6 +70,10 @@ public class PlayerInfo {
if(lvl_id == reachedLevelId) {
return true;
}
// always access to first level (where would one otherwise begin?)
if(Scenario.SCENARIOS.get(0) == lvl_id) {
return true;
}
return Scenario.isHigherLevel(reachedLevelId, lvl_id);
}

View file

@ -62,7 +62,7 @@ public class ProgressActivity extends AppCompatActivity {
introText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ProgressActivity.this, IntroActivity.class);
Intent intent = new Intent(ProgressActivity.this, IntroductionActivity.class);
startActivity(intent);
}
});
@ -145,16 +145,25 @@ public class ProgressActivity extends AppCompatActivity {
}
boolean completedAll = player.getPlayerInfo().completedAll;
TextView outroText = new TextView(this);
outroText.setText(String.format("Ending: %1$s", "\"All hail the Emotion Hero!\""));
// outroText.setText(String.format("%1$d. %2$s", si, "Em07i0n H3r0!"));
outroText.setTextSize(getResources().getDimensionPixelSize(R.dimen.gametitle_textsize));
outroText.setTextColor(getResources().getColor(R.color.textHighlight));
outroText.setTextColor(completedAll ? getResources().getColor(R.color.textHighlight) : getResources().getColor(R.color.textSecondary) );
outroText.setPadding(defaultMargin,defaultMargin,defaultMargin,defaultMargin);
outroText.setId(R.id.textView);
outroText.setTypeface(font);
// TODO: check if last level was sufficient (minscore/achievements)
if(completedAll) {
outroText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO: .. handle onclick!!
}
});
}
levelsLayout.addView(outroText);
}

View file

@ -221,9 +221,12 @@ public class ReviewActivity extends AppCompatActivity {
achievementTitle.setVisibility(View.VISIBLE);
achievementLayout.setVisibility(View.VISIBLE);
String achievementString = "";
String achievementString = game.achievements.size() > 1 ? "You've obtained special achievements!\n" : "You've obtained the special achievement ";
boolean firstAchievement = true;
for(Achievement achievement: game.achievements) {
if(achievementString.length() > 0) {
if(firstAchievement ) {
firstAchievement = false;
} else {
achievementString += "\n";
}
achievementString += String.format("%1$s", achievement.title);

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_introduction"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.rubenvandeven.emotionhero.IntroductionActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/introText1"
android:text="@string/game_intro_text"
android:textColor="@color/textPrimary"
android:textSize="30sp" />
<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" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
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

@ -14,4 +14,6 @@
<string name="action_settings">Settings</string>
<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>
</resources>