From 36d40e19973990a390a6b5169ab5d64af13f7ecb Mon Sep 17 00:00:00 2001 From: Cgumacal Date: Fri, 2 Dec 2016 11:20:27 -0800 Subject: [PATCH 01/22] up to date --- .../ninaly/adventuregame453/Part1.java | 217 +++++++++++++++--- 1 file changed, 184 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/com/example/ninaly/adventuregame453/Part1.java b/app/src/main/java/com/example/ninaly/adventuregame453/Part1.java index 319b7ff..4cad5c9 100644 --- a/app/src/main/java/com/example/ninaly/adventuregame453/Part1.java +++ b/app/src/main/java/com/example/ninaly/adventuregame453/Part1.java @@ -2,18 +2,14 @@ import android.app.Activity; import android.content.Intent; -import android.media.Image; import android.os.Bundle; +import android.provider.Settings; import android.view.View; import android.widget.Button; import android.widget.ImageButton; -import android.widget.TextView; import android.widget.Toast; import android.view.Gravity; -import java.lang.reflect.Array; -import java.util.Random; - public class Part1 extends Activity { int counter = 0; @@ -23,33 +19,6 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.part1_intro); - /* - swingButton = (Button) findViewById(R.id.swing); - askButton = (Button) findViewById(R.id.ask); - - - - swingButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { -<<<<<<< HEAD - -======= - setContentView(R.layout.part1_take_swing); - // Toast toast = Toast.makeText(Part1.this,"Hey! What's that for?! I'm not harmful.",Toast.LENGTH_SHORT); - // toast.setGravity(Gravity.CENTER,0,50); - // toast.show(); ->>>>>>> refs/remotes/origin/Nina_branch - } - }); - - askButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - setContentView(R.layout.part1_ask_fairy); - } - }); */ - } public void onClick(View view) { @@ -117,7 +86,7 @@ public void onClick(View view) { // From part1_dark_path.xml case R.id.runAwayButton: - setContentView(R.layout.part1_run_away_from_goblin); + setContentView(R.layout.part1_sword); break; // From part1_dark_path.xml @@ -125,7 +94,106 @@ public void onClick(View view) { setContentView(R.layout.part1_say_hello); break; + // From part1_dark_path.xml + case R.id.attackButton: + setContentView(R.layout.part1_attack_goblin); + break; + + // From part1_say_hello.xml + case R.id.attackGoblin: + setContentView(R.layout.part1_attack_goblin); + break; + + // From part1_say_hello.xml + case R.id.leaveButton: + setContentView(R.layout.part1_sword); + break; + + // From part1_say_hello.xml + case R.id.nodButton: + setContentView(R.layout.part1_nod_globin); + break; + + // From part1_attack_globin.xml + case R.id.keepLookingButton: + setContentView(R.layout.part1_keep_looking); + break; + + // From part1_attack_globin.xml + //add leave logic + // From part1_keep_looking.xml + case R.id.keepLookingButton2: + setContentView(R.layout.part1_keep_looking_again); + break; + + // From part1_keep_looking_again.xml + case R.id.gameOver: + setContentView(R.layout.part1_gameover); + break; + + // From part1_gameover.xml + case R.id.mainMenu: + setContentView(R.layout.activity_start_screen); + break; + + case R.id.quitGame: + System.exit(0); + break; + + //add part1_spanish_setting.xml + + // From part1_goblin_help.xml + case R.id.swordHelpFromGoblin: + setContentView(R.layout.part1_sword); + break; + + // From part1_sword.xml + case R.id.pullSword: + setContentView(R.layout.part1_pull_sword); + break; + + // From part1_sword.xml + case R.id.readInscription: + setContentView(R.layout.part1_read_inscription); + break; + + // From part1_sword.xml + case R.id.keepWalking: + setContentView(R.layout.part1_keep_walking); + break; + + // From part1_pull_sword.xml + case R.id.readInscription1: + setContentView(R.layout.part1_read_inscription); + break; + + // From part1_read_inscription.xml + case R.id.pullSword1: + setContentView(R.layout.part1_pull_sword2); + break; + + // From part1_read_inscription.xml + case R.id.leaveInscription: + setContentView(R.layout.part1_leave_inscription); + break; + + // From part1_keep_walking.xml + case R.id.part2Butt: + Intent part2 = new Intent(Part1.this, Cave.class); + startActivity(part2); + break; + + // From part1_leave_insscription.xml + case R.id.goToPart2: + Intent partdos = new Intent(Part1.this, Cave.class); + startActivity(partdos); + break; + + // From part1_pull_sword2.xml + case R.id.takeTheSword: + setContentView(R.layout.part1_leave_inscription); + break; } //end switch } //end onClick @@ -172,6 +240,89 @@ public void onImageClick(View view) { break; + case R.id.attackGoblinFairy: + Toast jumpHim = Toast.makeText(Part1.this, "I think I heard something... we should get out of here.", Toast.LENGTH_LONG); + jumpHim.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + jumpHim.show(); + break; + + case R.id.keepLookingFairy: + Toast kl = Toast.makeText(Part1.this, "Seriously.. we should leave now!", Toast.LENGTH_LONG); + kl.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + kl.show(); + break; + + case R.id.keepLookingFairy2: + Toast kla = Toast.makeText(Part1.this, "I told you we should've left! It's too late now.", Toast.LENGTH_LONG); + kla.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + kla.show(); + break; + + case R.id.leaveAfter: + Toast leave = Toast.makeText(Part1.this, "Oooo trying pulling the sword.", Toast.LENGTH_LONG); + leave.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + leave.show(); + break; + + case R.id.spanishFairy: + Toast spanish = Toast.makeText(Part1.this, "Is he speaking in Spanish? We need to learn spanish to understand. Change the language settings on your phone to Spanish to get the English translation. Pointing is rude so don't upset him.", Toast.LENGTH_LONG); + spanish.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + spanish.show(); + break; + + case R.id.angryGoblin: + Toast angry = Toast.makeText(Part1.this, "Uh oh, your pointing upsetted him. Do you still want to look around?", Toast.LENGTH_LONG); + angry.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + angry.show(); + break; + + case R.id.settingButton: + startActivityForResult(new Intent(Settings.ACTION_LOCALE_SETTINGS),0); + break; + + case R.id.goblinHelp: + Toast help = Toast.makeText(Part1.this, "The goblin was very friendly. Let's follow the path.", Toast.LENGTH_LONG); + help.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + help.show(); + break; + + case R.id.swordFairy: + Toast sword = Toast.makeText(Part1.this, "Hmm.... trying pulling the sword?", Toast.LENGTH_LONG); + sword.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + sword.show(); + break; + + case R.id.pullSwordFairy: + Toast fairy = Toast.makeText(Part1.this, "Try reading the inscription.", Toast.LENGTH_LONG); + fairy.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + fairy.show(); + break; + + case R.id.readInscriptionFairy: + Toast rf = Toast.makeText(Part1.this, "Have you done anything bad lately? Maybe we should go.", Toast.LENGTH_LONG); + rf.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + rf.show(); + break; + + case R.id.walkAwayFairy: + Toast wa = Toast.makeText(Part1.this, "Yay!!!!", Toast.LENGTH_LONG); + wa.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + wa.show(); + break; + + case R.id.pullSwordFairy2: + Toast ps = Toast.makeText(Part1.this, "If you didn't attack the goblin or if you didn't shoo me away, leave with the sword." + + "If you did attack the goblin or shoo me away, you are about to experience karma.", Toast.LENGTH_LONG); + ps.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + ps.show(); + break; + + case R.id.leaveFairy: + Toast leave1 = Toast.makeText(Part1.this, "I think we're almost home!", Toast.LENGTH_LONG); + leave1.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + leave1.show(); + break; + } //end switch } //end onImageClick From 576b00e9863fd2d7ab542cc03d49cf3a12a6831d Mon Sep 17 00:00:00 2001 From: Cgumacal Date: Fri, 2 Dec 2016 11:45:48 -0800 Subject: [PATCH 02/22] start points for testing --- .../java/com/example/ninaly/adventuregame453/StartScreen.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/example/ninaly/adventuregame453/StartScreen.java b/app/src/main/java/com/example/ninaly/adventuregame453/StartScreen.java index b472168..31f7843 100644 --- a/app/src/main/java/com/example/ninaly/adventuregame453/StartScreen.java +++ b/app/src/main/java/com/example/ninaly/adventuregame453/StartScreen.java @@ -24,7 +24,7 @@ public void onNewGameClick(View view){ SharedPreferences.Editor editor = points.edit(); editor.putInt("points", 0); - editor.putInt("evil-points", 0); + editor.putInt("evil-points", 5); editor.putBoolean("lantern", true); editor.putBoolean("sword", true); editor.putBoolean("emerald", true); @@ -33,7 +33,7 @@ public void onNewGameClick(View view){ editor.commit(); - Intent startNewGame = new Intent(StartScreen.this, Cave.class); + Intent startNewGame = new Intent(StartScreen.this, Part1.class); startActivity(startNewGame); } From 664618b2aa58f5ee4ad924b25d09059a9c5dd650 Mon Sep 17 00:00:00 2001 From: Cgumacal Date: Tue, 6 Dec 2016 15:34:07 -0800 Subject: [PATCH 03/22] part1 --- .../ninaly/adventuregame453/Part1.java | 74 ++++++++++++++++++- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/example/ninaly/adventuregame453/Part1.java b/app/src/main/java/com/example/ninaly/adventuregame453/Part1.java index 4cad5c9..6e5f21d 100644 --- a/app/src/main/java/com/example/ninaly/adventuregame453/Part1.java +++ b/app/src/main/java/com/example/ninaly/adventuregame453/Part1.java @@ -2,25 +2,91 @@ import android.app.Activity; import android.content.Intent; +import android.content.SharedPreferences; +import android.media.Image; import android.os.Bundle; import android.provider.Settings; import android.view.View; import android.widget.Button; import android.widget.ImageButton; +import android.widget.TextView; import android.widget.Toast; import android.view.Gravity; +import java.lang.reflect.Array; +import java.util.Random; + public class Part1 extends Activity { int counter = 0; + public static final String Data = "Progress_Data"; + int points, evilPoints, progress; + private boolean lantern, sword, emerald, key, treasure; + SharedPreferences progressData; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.part1_intro); + + progressData = getSharedPreferences(Data, 0); + points = progressData.getInt("points", 0); + evilPoints = progressData.getInt("evilPoints", 0); + progress = progressData.getInt("storyProgress", 0); + lantern = progressData.getBoolean("lantern", true); + sword = progressData.getBoolean("sword", true); + emerald = progressData.getBoolean("emerald", false); + key = progressData.getBoolean("key", true); + treasure = progressData.getBoolean("treasure", false); + + setContentView(progress); + + } + + @Override + protected void onResume() { + super.onResume(); } + @Override + protected void onPause() { + + SharedPreferences.Editor editor = progressData.edit(); + + editor.putInt("points", points); + editor.putInt("evil-points", evilPoints); + editor.putBoolean("lantern", lantern); + editor.putBoolean("sword", sword); + editor.putBoolean("emerald", emerald); + editor.putInt("part", 1); + editor.putInt("storyProgress", progress); + + editor.commit(); + + super.onPause(); + + } + + @Override + protected void onDestroy() { + + SharedPreferences.Editor editor = progressData.edit(); + + editor.putInt("points", points); + editor.putInt("evil-points", evilPoints); + editor.putBoolean("lantern", lantern); + editor.putBoolean("sword", sword); + editor.putBoolean("emerald", emerald); + editor.putInt("part", 1); + editor.putInt("storyProgress", progress); + + editor.commit(); + + super.onDestroy(); + } + + public void onClick(View view) { Button buttonClicked = (Button) view; @@ -36,6 +102,7 @@ public void onClick(View view) { // From part1_intro.xml // Asks fairy's purpose case R.id.ask1: + progress = R.layout.part1_ask_fairy; setContentView(R.layout.part1_ask_fairy); break; @@ -86,14 +153,16 @@ public void onClick(View view) { // From part1_dark_path.xml case R.id.runAwayButton: - setContentView(R.layout.part1_sword); + setContentView(R.layout.part1_run_away_from_goblin); break; // From part1_dark_path.xml case R.id.sayHelloButton: + progress = R.layout.part1_say_hello; setContentView(R.layout.part1_say_hello); break; + // From part1_dark_path.xml case R.id.attackButton: setContentView(R.layout.part1_attack_goblin); @@ -325,6 +394,5 @@ public void onImageClick(View view) { } //end switch } //end onImageClick - } From 09f873e80cef842b1fff17568608ea7ca073d111 Mon Sep 17 00:00:00 2001 From: kevnguyen14 Date: Tue, 6 Dec 2016 19:01:23 -0800 Subject: [PATCH 04/22] no message --- .idea/gradle.xml | 1 - .idea/misc.xml | 2 +- .idea/vcs.xml | 6 ++++++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .idea/vcs.xml diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 195e217..1bbc21d 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -12,7 +12,6 @@ - diff --git a/.idea/misc.xml b/.idea/misc.xml index 5d19981..1a3eaff 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..6564d52 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 114cbb7992dac5a69e88577ecdfac51eae342d9d Mon Sep 17 00:00:00 2001 From: kevnguyen14 Date: Tue, 6 Dec 2016 22:31:24 -0800 Subject: [PATCH 05/22] fixed xml, added in on pause and on destroy, added imagebutton on click method --- .../example/ninaly/adventuregame453/Cave.java | 374 +++++++++++------- .../ninaly/adventuregame453/StartScreen.java | 1 - .../res/layout/attackogrewithoutsword.xml | 29 +- .../main/res/layout/attackogrewithsword.xml | 15 +- app/src/main/res/layout/cavebeginning.xml | 39 +- app/src/main/res/layout/cavewithbreeze.xml | 26 +- app/src/main/res/layout/changeorientation.xml | 39 +- app/src/main/res/layout/darkcave.xml | 13 +- app/src/main/res/layout/highupcave.xml | 13 +- app/src/main/res/layout/jump.xml | 9 +- app/src/main/res/layout/keepattacking.xml | 12 +- app/src/main/res/layout/keepsneaking.xml | 12 +- app/src/main/res/layout/key.xml | 13 +- .../main/res/layout/killtheogreinhissleep.xml | 44 ++- app/src/main/res/layout/night.xml | 44 +-- app/src/main/res/layout/ogrecave.xml | 63 +-- app/src/main/res/layout/opendoor.xml | 44 ++- app/src/main/res/layout/picklock.xml | 9 +- app/src/main/res/layout/regularcave.xml | 42 +- app/src/main/res/layout/run.xml | 12 +- app/src/main/res/layout/sneakaround.xml | 59 +-- app/src/main/res/layout/sneakintothecave.xml | 40 +- .../res/layout/throwswordtocuttherope.xml | 11 +- .../res/layout/travelforwardwithlight.xml | 27 +- .../res/layout/travelforwardwithoutlight.xml | 25 +- app/src/main/res/layout/usekey.xml | 13 +- app/src/main/res/layout/walkacross.xml | 31 +- app/src/main/res/values/colors.xml | 3 +- 28 files changed, 599 insertions(+), 463 deletions(-) diff --git a/app/src/main/java/com/example/ninaly/adventuregame453/Cave.java b/app/src/main/java/com/example/ninaly/adventuregame453/Cave.java index c6a3f58..5d6c24a 100644 --- a/app/src/main/java/com/example/ninaly/adventuregame453/Cave.java +++ b/app/src/main/java/com/example/ninaly/adventuregame453/Cave.java @@ -48,13 +48,13 @@ protected void onCreate(Bundle savedInstanceState) { progressData = getSharedPreferences(Data, 0); points = progressData.getInt("points", 0); evilPoints = progressData.getInt("evilPoints", 0); - progress = progressData.getInt("storyProgress", 0); + progress = progressData.getInt("storyProgress", R.layout.cavebeginning); lantern = progressData.getBoolean("lantern", true); sword = progressData.getBoolean("sword", true); emerald = progressData.getBoolean("emerald", false); key = progressData.getBoolean("key", true); treasure = progressData.getBoolean("treasure", false); - setContentView(R.layout.cavebeginning); + setContentView(progress); mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); curTime = lastUpdate = (long) 0.0; @@ -72,116 +72,76 @@ public void checkIfItsNight() { public void onClick(View view){ switch(view.getId()) { - case R.id.hint1: - Toast toast = Toast.makeText(this, "I sense the presense of a vile being in one of the caves. -Fairy", Toast.LENGTH_LONG); - toast.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast.show(); - break; case R.id.ogrecave: + progress = R.layout.ogrecave; setContentView(R.layout.ogrecave); checkIfItsNight(); break; case R.id.regularcave: + progress = R.layout.regularcave; setContentView(R.layout.regularcave); Button button = (Button) findViewById(R.id.highupcave); break; - case R.id.hint2: - Toast toast2 = Toast.makeText(this, "You can pause and resume gameplay later. -Fairy", Toast.LENGTH_LONG); - toast2.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast2.show(); - break; case R.id.sneakaround: + progress = R.layout.sneakaround; setContentView(R.layout.sneakaround); checkIfItsNight(); break; - case R.id.hint3: - Toast toast3 = Toast.makeText(this, "He saw us, I'd recommend fighting him. -Fairy", Toast.LENGTH_LONG); - toast3.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast3.show(); - break; case R.id.keepsneaking: + progress = R.layout.keepattacking; setContentView(R.layout.keepsneaking); checkIfItsNight(); break; - case R.id.hint4: - Toast toast4 = Toast.makeText(this, "My master, you have died! -Fairy", Toast.LENGTH_LONG); - toast4.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast4.show(); - break; case R.id.attackogre: - if(sword == true) - setContentView(R.layout.attackogrewithsword); - else - setContentView(R.layout.attackogrewithoutsword); - checkIfItsNight(); - break; - case R.id.hint5: - Toast toast5 = Toast.makeText(this, "We're doing pretty well, lets keep going at it. -Fairy", Toast.LENGTH_LONG); - toast5.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast5.show(); + checkIfItsNight(); + if(sword == true) { + progress = R.layout.attackogrewithsword; + setContentView(R.layout.attackogrewithsword);} + else { + progress = R.layout.attackogrewithoutsword; + setContentView(R.layout.attackogrewithoutsword);} break; case R.id.keepattacking: + progress = R.layout.keepattacking; setContentView(R.layout.keepattacking); checkIfItsNight(); break; case R.id.giveup: + progress = R.layout.regularcave; setContentView(R.layout.regularcave); - - break; - case R.id.hint6: - Toast toast6 = Toast.makeText(this, "Oh no we have no choice but to fight without the sword. -Fairy", Toast.LENGTH_LONG); - toast6.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast6.show(); - break; - case R.id.hint7: - Toast toast7 = Toast.makeText(this, "He was just too strong for us. -Fairy", Toast.LENGTH_LONG); - toast7.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast7.show(); - break; - case R.id.hint8: - Toast toast8 = Toast.makeText(this, "He seems to be asleep from 6PM to 12AM. -Fairy", Toast.LENGTH_LONG); - toast8.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast8.show(); break; case R.id.sneakintocave: + progress = R.layout.sneakintothecave; setContentView(R.layout.sneakintothecave); break; case R.id.killogre: + progress = R.layout.killtheogreinhissleep; setContentView(R.layout.killtheogreinhissleep); break; - case R.id.hint9: - Toast toast9 = Toast.makeText(this, "Wow! A shiny emerald! We should take it! -Fairy", Toast.LENGTH_LONG); - toast9.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast9.show(); - break; case R.id.takeit: + progress = R.layout.regularcave; emerald = true; setContentView(R.layout.regularcave); break; case R.id.leaveit: + progress = R.layout.regularcave; setContentView(R.layout.regularcave); break; - case R.id.hint10: - Toast toast10 = Toast.makeText(this, "Sometimes you have to play smart! Let's explore! -Fairy", Toast.LENGTH_LONG); - toast10.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast10.show(); - break; case R.id.checkthecave: + progress = R.layout.sneakintothecave; setContentView(R.layout.sneakintothecave); break; case R.id.leave: + progress = R.layout.regularcave; setContentView(R.layout.regularcave); break; - case R.id.hint11: - Toast toast11 = Toast.makeText(this, "Sorry, even I don't know where to go! -Fairy", Toast.LENGTH_LONG); - toast11.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast11.show(); - break; case R.id.darkcave: + progress = R.layout.darkcave; setContentView(R.layout.darkcave); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL); break; case R.id.highupcave: + progress = R.layout.highupcave; setContentView(R.layout.highupcave); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); Button throwsword = (Button) findViewById(R.id.throwsword); @@ -189,108 +149,58 @@ public void onClick(View view){ throwsword.setEnabled(false); break; case R.id.cavewithabreeze: + progress = R.layout.cavewithbreeze; setContentView(R.layout.cavewithbreeze); break; - case R.id.hint12: - if(lantern == false) { - Toast toast12 = Toast.makeText(this, "It's dark... Im scared! We should go back... -Fairy", Toast.LENGTH_LONG); - toast12.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast12.show(); - } - else { - Toast toast12 = Toast.makeText(this, "You have a flashlight, shake your device to turn it on! -Fairy", Toast.LENGTH_LONG); - toast12.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast12.show(); - } - break; case R.id.goback: + progress = R.layout.regularcave; setContentView(R.layout.regularcave); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; case R.id.travelforward: - if(lit == true) - setContentView(R.layout.travelforwardwithlight); - else - setContentView(R.layout.travelforwardwithoutlight); - break; - case R.id.hint13: - Toast toast13 = Toast.makeText(this, "This dark room is dark and creepy, lets leave! -Fairy", Toast.LENGTH_LONG); - toast13.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast13.show(); + if(lit == true) { + progress = R.layout.travelforwardwithlight; + setContentView(R.layout.travelforwardwithlight);} + else { + progress = R.layout.travelforwardwithoutlight; + setContentView(R.layout.travelforwardwithoutlight);} break; case R.id.run: + progress = R.layout.run; setContentView(R.layout.run); break; - case R.id.hint14: - Toast toast14 = Toast.makeText(this, "You died! It was by a spider monster. -Fairy", Toast.LENGTH_LONG); - toast14.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast14.show(); - break; - case R.id.hint15: - Toast toast15 = Toast.makeText(this, "I see something shiny! -Fairy", Toast.LENGTH_LONG); - toast15.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast15.show(); - break; case R.id.rummage: + progress = R.layout.key; setContentView(R.layout.key); key = true; break; - case R.id.hint16: - Toast toast16 = Toast.makeText(this, "What a nice find! -Fairy", Toast.LENGTH_LONG); - toast16.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast16.show(); - break; - case R.id.hint17: - Toast toast17 = Toast.makeText(this, "Hmm try moving your device around to drop the bridge. -Fairy", Toast.LENGTH_LONG); - toast17.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast17.show(); - break; case R.id.jump: + progress = R.layout.jump; setContentView(R.layout.jump); break; case R.id.throwsword: sword = false; + progress = R.layout.throwswordtocuttherope; setContentView(R.layout.throwswordtocuttherope); break; - case R.id.hint18: - Toast toast18 = Toast.makeText(this, "Master! Why'd you go and do that?!. -Fairy", Toast.LENGTH_LONG); - toast18.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast18.show(); - break; - case R.id.hint19: - Toast toast19 = Toast.makeText(this, "It was fun while it lasted. On to a new master! -Fairy", Toast.LENGTH_LONG); - toast19.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast19.show(); - break; - case R.id.hint20: - Toast toast20 = Toast.makeText(this, "Good job you can cross the bridge now! -Fairy", Toast.LENGTH_LONG); - toast20.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast20.show(); - break; case R.id.walkacross: + progress = R.layout.walkacross; setContentView(R.layout.walkacross); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; - case R.id.hint21: - Toast toast21 = Toast.makeText(this, "Look it's a door, wonder what's behind... -Fairy", Toast.LENGTH_LONG); - toast21.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast21.show(); - break; case R.id.opendoor: + progress = R.layout.opendoor; setContentView(R.layout.opendoor); Button bkey = (Button) findViewById(R.id.usekey); if(key == false) bkey.setEnabled(false); break; - case R.id.hint22: - Toast toast22 = Toast.makeText(this, "Do you have the skills to pick the lock? If not, use the key. -Fairy", Toast.LENGTH_LONG); - toast22.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast22.show(); - break; case R.id.picklock: + progress = R.layout.picklock; setContentView(R.layout.picklock); break; case R.id.usekey: + progress = R.layout.usekey; setContentView(R.layout.usekey); ImageView iv = (ImageView) findViewById(R.id.treasure); TextView tv = (TextView) findViewById(R.id.text2); @@ -309,21 +219,6 @@ public void onClick(View view){ tv.setText("..."); break; } - case R.id.hint23: - Toast toast23 = Toast.makeText(this, "Good thing I can fly. -Fairy", Toast.LENGTH_LONG); - toast23.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast23.show(); - break; - case R.id.hint24: - Toast toast24 = Toast.makeText(this, "Wow what a find! -Fairy", Toast.LENGTH_LONG); - toast24.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast24.show(); - break; - case R.id.hint25: - Toast toast25 = Toast.makeText(this, "Onwards to our next journey! -Fairy", Toast.LENGTH_LONG); - toast25.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); - toast25.show(); - break; case R.id.gotocastle: SharedPreferences.Editor editor = progressData.edit(); @@ -345,6 +240,144 @@ public void onClick(View view){ /** * game over screen */ + setContentView(R.layout.part1_gameover); + break; + } + } + + public void onClick2(View view){ + switch(view.getId()) { + case R.id.hint1: + Toast toast = Toast.makeText(this, "I sense the presense of a vile being in one of the caves. -Fairy", Toast.LENGTH_LONG); + toast.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast.show(); + break; + case R.id.hint2: + Toast toast2 = Toast.makeText(this, "You can pause and resume gameplay later. -Fairy", Toast.LENGTH_LONG); + toast2.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast2.show(); + break; + case R.id.hint3: + Toast toast3 = Toast.makeText(this, "He saw us, I'd recommend fighting him. -Fairy", Toast.LENGTH_LONG); + toast3.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast3.show(); + break; + case R.id.hint4: + Toast toast4 = Toast.makeText(this, "My master, you have died! -Fairy", Toast.LENGTH_LONG); + toast4.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast4.show(); + break; + case R.id.hint5: + Toast toast5 = Toast.makeText(this, "We're doing pretty well, lets keep going at it. -Fairy", Toast.LENGTH_LONG); + toast5.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast5.show(); + break; + case R.id.hint6: + Toast toast6 = Toast.makeText(this, "Oh no we have no choice but to fight without the sword. -Fairy", Toast.LENGTH_LONG); + toast6.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast6.show(); + break; + case R.id.hint7: + Toast toast7 = Toast.makeText(this, "He was just too strong for us. -Fairy", Toast.LENGTH_LONG); + toast7.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast7.show(); + break; + case R.id.hint8: + Toast toast8 = Toast.makeText(this, "He seems to be asleep from 6PM to 12AM. -Fairy", Toast.LENGTH_LONG); + toast8.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast8.show(); + break; + case R.id.hint9: + Toast toast9 = Toast.makeText(this, "Wow! A shiny emerald! We should take it! -Fairy", Toast.LENGTH_LONG); + toast9.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast9.show(); + break; + case R.id.hint10: + Toast toast10 = Toast.makeText(this, "Sometimes you have to play smart! Let's explore! -Fairy", Toast.LENGTH_LONG); + toast10.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast10.show(); + break; + case R.id.hint11: + Toast toast11 = Toast.makeText(this, "Sorry, even I don't know where to go! -Fairy", Toast.LENGTH_LONG); + toast11.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast11.show(); + break; + case R.id.hint12: + if(lantern == false) { + Toast toast12 = Toast.makeText(this, "It's dark... Im scared! We should go back... -Fairy", Toast.LENGTH_LONG); + toast12.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast12.show(); + } + else { + Toast toast12 = Toast.makeText(this, "You have a flashlight, shake your device to turn it on! -Fairy", Toast.LENGTH_LONG); + toast12.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast12.show(); + } + break; + case R.id.hint13: + Toast toast13 = Toast.makeText(this, "This dark room is dark and creepy, lets leave! -Fairy", Toast.LENGTH_LONG); + toast13.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast13.show(); + break; + case R.id.hint14: + Toast toast14 = Toast.makeText(this, "You died! It was by a spider monster. -Fairy", Toast.LENGTH_LONG); + toast14.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast14.show(); + break; + case R.id.hint15: + Toast toast15 = Toast.makeText(this, "I see something shiny! -Fairy", Toast.LENGTH_LONG); + toast15.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast15.show(); + break; + case R.id.hint16: + Toast toast16 = Toast.makeText(this, "What a nice find! -Fairy", Toast.LENGTH_LONG); + toast16.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast16.show(); + break; + case R.id.hint17: + Toast toast17 = Toast.makeText(this, "Hmm try moving your device around to drop the bridge. -Fairy", Toast.LENGTH_LONG); + toast17.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast17.show(); + break; + case R.id.hint18: + Toast toast18 = Toast.makeText(this, "Master! Why'd you go and do that?!. -Fairy", Toast.LENGTH_LONG); + toast18.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast18.show(); + break; + case R.id.hint19: + Toast toast19 = Toast.makeText(this, "It was fun while it lasted. On to a new master! -Fairy", Toast.LENGTH_LONG); + toast19.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast19.show(); + break; + case R.id.hint20: + Toast toast20 = Toast.makeText(this, "Good job you can cross the bridge now! -Fairy", Toast.LENGTH_LONG); + toast20.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast20.show(); + break; + case R.id.hint21: + Toast toast21 = Toast.makeText(this, "Look it's a door, wonder what's behind... -Fairy", Toast.LENGTH_LONG); + toast21.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast21.show(); + break; + case R.id.hint22: + Toast toast22 = Toast.makeText(this, "Do you have the skills to pick the lock? If not, use the key. -Fairy", Toast.LENGTH_LONG); + toast22.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast22.show(); + break; + case R.id.hint23: + Toast toast23 = Toast.makeText(this, "Good thing I can fly. -Fairy", Toast.LENGTH_LONG); + toast23.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast23.show(); + break; + case R.id.hint24: + Toast toast24 = Toast.makeText(this, "Wow what a find! -Fairy", Toast.LENGTH_LONG); + toast24.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast24.show(); + break; + case R.id.hint25: + Toast toast25 = Toast.makeText(this, "Onwards to our next journey! -Fairy", Toast.LENGTH_LONG); + toast25.setGravity(Gravity.TOP | Gravity.RIGHT, 0, 110); + toast25.show(); break; } } @@ -355,14 +388,21 @@ public void onConfigurationChanged(Configuration newConfig) { } protected void onResume() { + SharedPreferences.Editor editor = progressData.edit(); + + editor.putInt("points", points); + editor.putInt("evil-points", evilPoints); + editor.putBoolean("lantern", lantern); + editor.putBoolean("sword", sword); + editor.putBoolean("emerald", emerald); + editor.putInt("part", 2); + editor.putInt("storyProgress", progress); + + editor.commit(); super.onResume(); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL); } - protected void onPause() { - super.onPause(); - mSensorManager.unregisterListener(this); - } @Override public void onSensorChanged(SensorEvent event) { @@ -399,4 +439,42 @@ public void onSensorChanged(SensorEvent event) { public void onAccuracyChanged(Sensor sensor, int accuracy) { } + + @Override + protected void onPause() { + + SharedPreferences.Editor editor = progressData.edit(); + + editor.putInt("points", points); + editor.putInt("evil-points", evilPoints); + editor.putBoolean("lantern", lantern); + editor.putBoolean("sword", sword); + editor.putBoolean("emerald", emerald); + editor.putInt("part", 2); + editor.putInt("storyProgress", progress); + + editor.commit(); + + super.onPause(); + mSensorManager.unregisterListener(this); + + } + + @Override + protected void onDestroy() { + + SharedPreferences.Editor editor = progressData.edit(); + + editor.putInt("points", points); + editor.putInt("evil-points", evilPoints); + editor.putBoolean("lantern", lantern); + editor.putBoolean("sword", sword); + editor.putBoolean("emerald", emerald); + editor.putInt("part", 2); + editor.putInt("storyProgress", progress); + + editor.commit(); + + super.onDestroy(); + } } diff --git a/app/src/main/java/com/example/ninaly/adventuregame453/StartScreen.java b/app/src/main/java/com/example/ninaly/adventuregame453/StartScreen.java index 31f7843..00bead2 100644 --- a/app/src/main/java/com/example/ninaly/adventuregame453/StartScreen.java +++ b/app/src/main/java/com/example/ninaly/adventuregame453/StartScreen.java @@ -47,7 +47,6 @@ public void onContinueClick(View view){ }else if (points.getInt("part",1) == 2){ resumeGame = new Intent(StartScreen.this, Cave.class); startActivity(resumeGame); - }else{ resumeGame = new Intent(StartScreen.this, Part3Castle.class); startActivity(resumeGame); diff --git a/app/src/main/res/layout/attackogrewithoutsword.xml b/app/src/main/res/layout/attackogrewithoutsword.xml index 58b9f8c..31a3f19 100644 --- a/app/src/main/res/layout/attackogrewithoutsword.xml +++ b/app/src/main/res/layout/attackogrewithoutsword.xml @@ -18,7 +18,7 @@ android:layout_height= "100dp" android:id="@+id/hint7" android:layout_alignParentRight="true" - android:onClick="onClick" + android:onClick="onClick2" /> +