summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsm0a9f4@gmail.com <sm0a9f4@gmail.com@1dde52a2-2b62-11df-8484-2f92f965d510>2011-01-16 07:13:43 +0000
committersm0a9f4@gmail.com <sm0a9f4@gmail.com@1dde52a2-2b62-11df-8484-2f92f965d510>2011-01-16 07:13:43 +0000
commit2b1168acefb6a4104bb7f008df6ac51fcd1de7ec (patch)
tree2247290427c4d912ca640fcf051f9ceb87d6c339
parent9d4cc2572d37983607df38b0f4216ed76ac51814 (diff)
downloadreplicaisland-2b1168acefb6a4104bb7f008df6ac51fcd1de7ec.tar.gz
+ Fixed lots of bugs. Most notably a divide-by-zero case in the collision system.
+ Add fades to all activity transitions (seems unreliable, though; race condition?) + Add Extras Menu, unlockable Linear Mode and Level Select + Add difficulty settings: Baby, Kids, and Adult + Add on-screen control interface; add support for muli-touch input events + Add debug mode frame rate readout (game thread only) + Changed most broken game play elements: enemy spawner and shadow slime + Added post-game statistics screen + Added fist-run control setup dialog + Fixed unescaped single quote characters (sorry!) git-svn-id: http://replicaisland.googlecode.com/svn/trunk@7 1dde52a2-2b62-11df-8484-2f92f965d510
-rw-r--r--AndroidManifest.xml27
-rw-r--r--default.properties2
-rw-r--r--res/anim/activity_fade_in.xml6
-rw-r--r--res/anim/activity_fade_out.xml8
-rw-r--r--res/anim/button_slide.xml33
-rw-r--r--res/anim/fade_in_out.xml8
-rw-r--r--res/anim/menu_hide_left.xml7
-rw-r--r--res/anim/menu_hide_right.xml7
-rw-r--r--res/anim/menu_show_left.xml7
-rw-r--r--res/anim/menu_show_right.xml7
-rw-r--r--res/drawable/object_sign.pngbin0 -> 384 bytes
-rw-r--r--res/drawable/ui_button_adults.pngbin0 -> 5050 bytes
-rw-r--r--res/drawable/ui_button_baby.pngbin0 -> 3704 bytes
-rw-r--r--res/drawable/ui_button_controls.pngbin0 -> 6473 bytes
-rw-r--r--res/drawable/ui_button_extras.pngbin0 -> 5073 bytes
-rw-r--r--res/drawable/ui_button_kids.pngbin0 -> 3320 bytes
-rw-r--r--res/drawable/ui_button_level_select.pngbin0 -> 6960 bytes
-rw-r--r--res/drawable/ui_button_linear_mode.pngbin0 -> 7121 bytes
-rw-r--r--res/drawable/ui_button_options.pngbin5422 -> 5520 bytes
-rw-r--r--res/drawable/ui_locked.pngbin0 -> 1330 bytes
-rw-r--r--res/drawable/ui_movement_slider_base.pngbin0 -> 1090 bytes
-rw-r--r--res/drawable/ui_movement_slider_button_off.pngbin0 -> 2925 bytes
-rw-r--r--res/drawable/ui_movement_slider_button_on.pngbin0 -> 3456 bytes
-rw-r--r--res/drawable/ui_new.pngbin0 -> 895 bytes
-rw-r--r--res/layout/difficulty_menu.xml80
-rw-r--r--res/layout/extras_menu.xml79
-rw-r--r--res/layout/game_over.xml61
-rw-r--r--res/layout/level_select.xml2
-rw-r--r--res/layout/main.xml21
-rw-r--r--res/layout/mainmenu.xml157
-rw-r--r--res/raw/level_2_6_grass.binbin7578 -> 7578 bytes
-rw-r--r--res/raw/level_3_11_sewer.binbin14063 -> 14063 bytes
-rw-r--r--res/raw/level_4_5_underground.binbin25078 -> 25078 bytes
-rw-r--r--res/raw/objecttestmap.binbin12863 -> 12863 bytes
-rw-r--r--res/raw/performancetest4.binbin3063 -> 3063 bytes
-rw-r--r--res/values/kabocha.xml2
-rw-r--r--res/values/strings.xml89
-rw-r--r--res/values/wanda.xml2
-rw-r--r--res/xml/level_tree.xml6
-rw-r--r--res/xml/linear_level_tree.xml252
-rw-r--r--res/xml/preferences.xml13
-rw-r--r--src/com/replica/replicaisland/AdultsDifficultyConstants.java91
-rw-r--r--src/com/replica/replicaisland/AndouKun.java285
-rw-r--r--src/com/replica/replicaisland/AnimationPlayerActivity.java14
-rw-r--r--src/com/replica/replicaisland/BabyDifficultyConstants.java91
-rw-r--r--src/com/replica/replicaisland/ButtonConstants.java7
-rw-r--r--src/com/replica/replicaisland/ContextParameters.java1
-rw-r--r--src/com/replica/replicaisland/CrusherAndouComponent.java53
-rw-r--r--src/com/replica/replicaisland/DiaryActivity.java13
-rw-r--r--src/com/replica/replicaisland/DifficultyConstants.java31
-rw-r--r--src/com/replica/replicaisland/DifficultyMenuActivity.java172
-rw-r--r--src/com/replica/replicaisland/DrawableFactory.java2
-rw-r--r--src/com/replica/replicaisland/EventRecorder.java42
-rw-r--r--src/com/replica/replicaisland/ExtrasMenuActivity.java235
-rw-r--r--src/com/replica/replicaisland/FadeDrawableComponent.java4
-rw-r--r--src/com/replica/replicaisland/GLSurfaceView.java4
-rw-r--r--src/com/replica/replicaisland/Game.java72
-rw-r--r--src/com/replica/replicaisland/GameObjectFactory.java287
-rw-r--r--src/com/replica/replicaisland/GameOverActivity.java173
-rw-r--r--src/com/replica/replicaisland/HudSystem.java93
-rw-r--r--src/com/replica/replicaisland/InputGameInterface.java95
-rw-r--r--src/com/replica/replicaisland/InputSystem.java63
-rw-r--r--src/com/replica/replicaisland/InputTouchScreen.java115
-rw-r--r--src/com/replica/replicaisland/KidsDifficultyConstants.java91
-rw-r--r--src/com/replica/replicaisland/LaunchProjectileComponent.java5
-rw-r--r--src/com/replica/replicaisland/LevelSelectActivity.java20
-rw-r--r--src/com/replica/replicaisland/LevelTree.java8
-rw-r--r--src/com/replica/replicaisland/LifetimeComponent.java15
-rw-r--r--src/com/replica/replicaisland/MainMenuActivity.java220
-rw-r--r--src/com/replica/replicaisland/MultiTouchFilter.java43
-rw-r--r--src/com/replica/replicaisland/PlayerComponent.java68
-rw-r--r--src/com/replica/replicaisland/PreferenceConstants.java53
-rw-r--r--src/com/replica/replicaisland/RenderSystem.java2
-rw-r--r--src/com/replica/replicaisland/SetPreferencesActivity.java27
-rw-r--r--src/com/replica/replicaisland/SingleTouchFilter.java21
-rw-r--r--src/com/replica/replicaisland/SoundSystem.java9
-rw-r--r--src/com/replica/replicaisland/TouchFilter.java34
-rw-r--r--src/com/replica/replicaisland/UIConstants.java40
78 files changed, 3058 insertions, 417 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 80119ef..4069c42 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.replica.replicaisland" android:versionName="1.3" android:versionCode="13">
+ package="com.replica.replicaisland"
+ android:versionName="1.4"
+ android:versionCode="14"
+ android:installLocation="preferExternal">
+
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:debuggable="false"
- android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
+ android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<activity android:name=".MainMenuActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
@@ -41,12 +45,25 @@
<activity android:name="AnimationPlayerActivity"
android:screenOrientation="landscape"
android:configChanges="keyboardHidden|orientation" />
-
+
+ <activity android:name="ExtrasMenuActivity"
+ android:screenOrientation="landscape"
+ android:configChanges="keyboardHidden|orientation" />
+
+ <activity android:name="DifficultyMenuActivity"
+ android:screenOrientation="landscape"
+ android:configChanges="keyboardHidden|orientation" />
+
+ <activity android:name="GameOverActivity"
+ android:screenOrientation="landscape"
+ android:configChanges="keyboardHidden|orientation"/>
+
</application>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission xmlns:android="http://schemas.android.com/apk/res/android"
android:name="android.permission.INTERNET"/>
- <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
+ <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="8"/>
+
<!-- Actually, this game works fine on small screens, but the only one out
right now has no 3D acceleration, so it's slow and unplayable. -->
<supports-screens android:largeScreens="true"
@@ -54,5 +71,7 @@
android:anyDensity="true"
android:normalScreens="true"/>
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> -->
+
+
</manifest>
diff --git a/default.properties b/default.properties
index 62bef18..2059bc2 100644
--- a/default.properties
+++ b/default.properties
@@ -9,6 +9,6 @@
apk-configurations=
# Project target.
-target=android-4
+target=android-8
# Indicates whether an apk should be generated for each density.
split.density=false
diff --git a/res/anim/activity_fade_in.xml b/res/anim/activity_fade_in.xml
new file mode 100644
index 0000000..3fefeee
--- /dev/null
+++ b/res/anim/activity_fade_in.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<alpha xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/linear_interpolator"
+ android:fromAlpha="0.0"
+ android:toAlpha="1.0"
+ android:duration="500" /> \ No newline at end of file
diff --git a/res/anim/activity_fade_out.xml b/res/anim/activity_fade_out.xml
new file mode 100644
index 0000000..134da31
--- /dev/null
+++ b/res/anim/activity_fade_out.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<alpha xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/linear_interpolator"
+ android:fromAlpha="1.0"
+ android:toAlpha="0.0"
+ android:duration="500"
+ android:zAdjustment="top"
+ /> \ No newline at end of file
diff --git a/res/anim/button_slide.xml b/res/anim/button_slide.xml
index 3949c76..2186fad 100644
--- a/res/anim/button_slide.xml
+++ b/res/anim/button_slide.xml
@@ -1,28 +1,5 @@
-<set xmlns:android="http://schemas.android.com/apk/res/android"
- android:shareInterpolator="false">
-
- <translate
- android:interpolator="@android:anim/accelerate_decelerate_interpolator"
- android:fromYDelta="200"
- android:toYDelta="-10"
- android:duration="600"
- android:fillAfter="false"/>
-
-
- <translate
- android:interpolator="@android:anim/accelerate_decelerate_interpolator"
- android:fromYDelta="-10"
- android:toYDelta="10"
- android:duration="150"
- android:fillAfter="false"
- android:startOffset="600"/>
-
- <translate
- android:interpolator="@android:anim/accelerate_decelerate_interpolator"
- android:fromYDelta="10"
- android:toYDelta="0"
- android:duration="200"
- android:fillAfter="false"
- android:startOffset="750"/>
-</set>
- \ No newline at end of file
+<?xml version="1.0" encoding="utf-8"?>
+<alpha xmlns:android="http://schemas.android.com/apk/res/android"
+ android:fromAlpha="0.0"
+ android:toAlpha="1.0"
+ android:duration="1000" /> \ No newline at end of file
diff --git a/res/anim/fade_in_out.xml b/res/anim/fade_in_out.xml
new file mode 100644
index 0000000..a174c07
--- /dev/null
+++ b/res/anim/fade_in_out.xml
@@ -0,0 +1,8 @@
+<alpha xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/accelerate_decelerate_interpolator"
+ android:fromAlpha="1.0"
+ android:toAlpha="0.0"
+ android:duration="500"
+ android:repeatCount="-1"
+ android:repeatMode="reverse"
+ android:fillAfter="true"/> \ No newline at end of file
diff --git a/res/anim/menu_hide_left.xml b/res/anim/menu_hide_left.xml
new file mode 100644
index 0000000..417b3a2
--- /dev/null
+++ b/res/anim/menu_hide_left.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<translate xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/accelerate_decelerate_interpolator"
+ android:fromXDelta="0"
+ android:toXDelta="-960"
+ android:duration="700"
+ android:fillAfter="true"/> \ No newline at end of file
diff --git a/res/anim/menu_hide_right.xml b/res/anim/menu_hide_right.xml
new file mode 100644
index 0000000..d829bf3
--- /dev/null
+++ b/res/anim/menu_hide_right.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<translate xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/accelerate_decelerate_interpolator"
+ android:fromXDelta="0"
+ android:toXDelta="960"
+ android:duration="700"
+ android:fillAfter="true"/> \ No newline at end of file
diff --git a/res/anim/menu_show_left.xml b/res/anim/menu_show_left.xml
new file mode 100644
index 0000000..01604b3
--- /dev/null
+++ b/res/anim/menu_show_left.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<translate xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/accelerate_decelerate_interpolator"
+ android:fromXDelta="960"
+ android:toXDelta="0"
+ android:duration="700"
+ android:fillAfter="true"/> \ No newline at end of file
diff --git a/res/anim/menu_show_right.xml b/res/anim/menu_show_right.xml
new file mode 100644
index 0000000..2f1d0b6
--- /dev/null
+++ b/res/anim/menu_show_right.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<translate xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/accelerate_decelerate_interpolator"
+ android:fromXDelta="-960"
+ android:toXDelta="0"
+ android:duration="700"
+ android:fillAfter="true"/> \ No newline at end of file
diff --git a/res/drawable/object_sign.png b/res/drawable/object_sign.png
new file mode 100644
index 0000000..e715592
--- /dev/null
+++ b/res/drawable/object_sign.png
Binary files differ
diff --git a/res/drawable/ui_button_adults.png b/res/drawable/ui_button_adults.png
new file mode 100644
index 0000000..98f437b
--- /dev/null
+++ b/res/drawable/ui_button_adults.png
Binary files differ
diff --git a/res/drawable/ui_button_baby.png b/res/drawable/ui_button_baby.png
new file mode 100644
index 0000000..b8cd7f4
--- /dev/null
+++ b/res/drawable/ui_button_baby.png
Binary files differ
diff --git a/res/drawable/ui_button_controls.png b/res/drawable/ui_button_controls.png
new file mode 100644
index 0000000..e0ca809
--- /dev/null
+++ b/res/drawable/ui_button_controls.png
Binary files differ
diff --git a/res/drawable/ui_button_extras.png b/res/drawable/ui_button_extras.png
new file mode 100644
index 0000000..71e5ebc
--- /dev/null
+++ b/res/drawable/ui_button_extras.png
Binary files differ
diff --git a/res/drawable/ui_button_kids.png b/res/drawable/ui_button_kids.png
new file mode 100644
index 0000000..e7d0874
--- /dev/null
+++ b/res/drawable/ui_button_kids.png
Binary files differ
diff --git a/res/drawable/ui_button_level_select.png b/res/drawable/ui_button_level_select.png
new file mode 100644
index 0000000..514dbca
--- /dev/null
+++ b/res/drawable/ui_button_level_select.png
Binary files differ
diff --git a/res/drawable/ui_button_linear_mode.png b/res/drawable/ui_button_linear_mode.png
new file mode 100644
index 0000000..4f989ee
--- /dev/null
+++ b/res/drawable/ui_button_linear_mode.png
Binary files differ
diff --git a/res/drawable/ui_button_options.png b/res/drawable/ui_button_options.png
index b07f22e..e54e6a1 100644
--- a/res/drawable/ui_button_options.png
+++ b/res/drawable/ui_button_options.png
Binary files differ
diff --git a/res/drawable/ui_locked.png b/res/drawable/ui_locked.png
new file mode 100644
index 0000000..c23c591
--- /dev/null
+++ b/res/drawable/ui_locked.png
Binary files differ
diff --git a/res/drawable/ui_movement_slider_base.png b/res/drawable/ui_movement_slider_base.png
new file mode 100644
index 0000000..6e1a6d1
--- /dev/null
+++ b/res/drawable/ui_movement_slider_base.png
Binary files differ
diff --git a/res/drawable/ui_movement_slider_button_off.png b/res/drawable/ui_movement_slider_button_off.png
new file mode 100644
index 0000000..0e12d11
--- /dev/null
+++ b/res/drawable/ui_movement_slider_button_off.png
Binary files differ
diff --git a/res/drawable/ui_movement_slider_button_on.png b/res/drawable/ui_movement_slider_button_on.png
new file mode 100644
index 0000000..0bcad3b
--- /dev/null
+++ b/res/drawable/ui_movement_slider_button_on.png
Binary files differ
diff --git a/res/drawable/ui_new.png b/res/drawable/ui_new.png
new file mode 100644
index 0000000..3151b87
--- /dev/null
+++ b/res/drawable/ui_new.png
Binary files differ
diff --git a/res/layout/difficulty_menu.xml b/res/layout/difficulty_menu.xml
new file mode 100644
index 0000000..a10c045
--- /dev/null
+++ b/res/layout/difficulty_menu.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+ <ImageView
+ android:id="@+id/mainMenuBackground"
+ android:src="@drawable/title_background"
+ android:adjustViewBounds="true"
+ android:gravity="center_vertical"
+ android:scaleType="fitXY"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"/>
+
+ <LinearLayout
+ android:background="@drawable/custom_toast_border"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_gravity="center"
+ android:padding="10dp">
+
+ <ImageView
+ android:id="@+id/babyButton"
+ android:src="@drawable/ui_button_baby"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:clickable="true" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor= "#FFFFFF"
+ android:textSize="14sp"
+ android:focusable="false"
+ android:layout_gravity="center_horizontal"
+ android:text="@string/baby_description"
+ android:id="@+id/babyText"/>
+
+ <ImageView
+ android:id="@+id/kidsButton"
+ android:src="@drawable/ui_button_kids"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:clickable="true"
+ android:layout_marginTop="15dp"/>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor= "#FFFFFF"
+ android:textSize="14sp"
+ android:focusable="false"
+ android:layout_gravity="center_horizontal"
+ android:text="@string/kids_description"
+ android:id="@+id/kidsText"/>
+
+ <ImageView
+ android:id="@+id/adultsButton"
+ android:src="@drawable/ui_button_adults"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:clickable="true"
+ android:layout_marginTop="15dp"/>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor= "#FFFFFF"
+ android:textSize="14sp"
+ android:focusable="false"
+ android:layout_gravity="center_horizontal"
+ android:text="@string/adults_description"
+ android:id="@+id/adultsText"/>
+
+ </LinearLayout>
+</FrameLayout> \ No newline at end of file
diff --git a/res/layout/extras_menu.xml b/res/layout/extras_menu.xml
new file mode 100644
index 0000000..f2a09ea
--- /dev/null
+++ b/res/layout/extras_menu.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+ <ImageView
+ android:id="@+id/mainMenuBackground"
+ android:src="@drawable/title_background"
+ android:adjustViewBounds="true"
+ android:gravity="center_vertical"
+ android:scaleType="fitXY"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"/>
+
+ <ImageView
+ android:id="@+id/mainMenuTitle"
+ android:src="@drawable/title"
+ android:adjustViewBounds="true"
+ android:layout_width="336dp"
+ android:layout_height="153dp"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginTop="20dp"/>
+
+ <LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:gravity="bottom" android:layout_gravity="bottom|center_horizontal" android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="vertical">
+
+ <FrameLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="10dp"
+ android:layout_gravity="center_horizontal">
+ <ImageView
+ android:id="@+id/linearModeButton"
+ android:src="@drawable/ui_button_linear_mode"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:clickable="true" />
+ <ImageView
+ android:id="@+id/linearModeLocked"
+ android:src="@drawable/ui_locked"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="10dp"
+ android:layout_gravity="center_horizontal">
+ <ImageView
+ android:id="@+id/levelSelectButton"
+ android:src="@drawable/ui_button_level_select"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:clickable="true" />
+ <ImageView
+ android:id="@+id/levelSelectLocked"
+ android:src="@drawable/ui_locked"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ />
+ </FrameLayout>
+
+
+ <ImageView
+ android:id="@+id/controlsButton"
+ android:src="@drawable/ui_button_controls"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="10dp"
+ android:paddingBottom="10dp"
+ android:clickable="true"
+ android:layout_gravity="center_horizontal"/>
+ </LinearLayout>
+
+</FrameLayout> \ No newline at end of file
diff --git a/res/layout/game_over.xml b/res/layout/game_over.xml
new file mode 100644
index 0000000..d152a62
--- /dev/null
+++ b/res/layout/game_over.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FrameLayout
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ xmlns:android="http://schemas.android.com/apk/res/android" android:background="#FFFFFF">
+ <ImageView
+ android:id="@+id/mainMenuBackground"
+ android:src="@drawable/title_background"
+ android:adjustViewBounds="true"
+ android:scaleType="fitXY"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" android:gravity="right" android:tint="#88FFFFFF"/>
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5sp">
+ <TextView android:text="@string/game_results_title" android:layout_height="wrap_content" android:textSize="40sp" android:layout_width="wrap_content" android:layout_gravity="center_horizontal" android:textColor="#000000" android:textStyle="bold" android:typeface="serif"/>
+ <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
+ <TextView android:text="@string/game_results_pearls_collected" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textColor="#000000" android:textStyle="bold" android:typeface="serif" android:textSize="20sp"/>
+ <view
+ class = "com.replica.replicaisland.GameOverActivity$IncrementingTextView"
+ android:id ="@+id/pearl_percent"
+ android:text="100%"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:textSize="20sp"
+ android:layout_gravity="right|center_vertical"
+ android:textColor="#000000" android:textStyle="bold"
+ android:typeface="serif" android:gravity="right"/>
+ </LinearLayout>
+ <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
+ <TextView android:text="@string/game_results_robots_destroyed" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textSize="20sp" android:textColor="#000000" android:textStyle="bold" android:typeface="serif"/>
+ <view
+ class = "com.replica.replicaisland.GameOverActivity$IncrementingTextView"
+ android:id ="@+id/enemy_percent"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:layout_gravity="right|center_vertical"
+ android:textColor="#000000" android:textStyle="bold"
+ android:typeface="serif" android:gravity="right" android:text="0" android:textSize="20sp"/>
+ </LinearLayout>
+ <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
+ <TextView android:text="@string/game_results_total_play_time" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textSize="20sp" android:textColor="#000000" android:textStyle="bold" android:typeface="serif"/>
+ <view
+ class = "com.replica.replicaisland.GameOverActivity$IncrementingTextView"
+ android:id ="@+id/total_play_time"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:textSize="20sp"
+ android:layout_gravity="right|center_vertical"
+ android:textColor="#000000" android:textStyle="bold"
+ android:typeface="serif" android:gravity="right" android:text="3:21:34"/>
+ </LinearLayout>
+ <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
+ <TextView android:text="@string/game_results_ending" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textSize="20sp" android:textColor="#000000" android:textStyle="bold" android:typeface="serif"/>
+ <TextView android:id ="@+id/ending" android:text="@string/game_results_kabocha_ending" android:layout_height="wrap_content" android:layout_width="fill_parent" android:textColor="#000000" android:textStyle="bold" android:typeface="serif" android:gravity="right" android:textSize="15sp" android:layout_gravity="right|center_vertical"/>
+
+ </LinearLayout>
+ <TextView android:text="@string/game_results_unlocks_message" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:textColor="#000000" android:textStyle="bold" android:typeface="serif" android:textSize="16sp" android:gravity="center_horizontal" android:layout_gravity="top|center_horizontal"/>
+ <Button android:id ="@+id/ok" android:text="@string/game_results_ok_button" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="bottom|center_horizontal"/>
+ </LinearLayout>
+ </FrameLayout>
+ \ No newline at end of file
diff --git a/res/layout/level_select.xml b/res/layout/level_select.xml
index 1051fc1..ebf7c44 100644
--- a/res/layout/level_select.xml
+++ b/res/layout/level_select.xml
@@ -5,7 +5,7 @@
android:layout_height="fill_parent"
>
<ListView android:id="@+id/android:list"
- android:layout_width="fill_parent"
+ android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:dividerHeight = "0dp"
android:footerDividersEnabled = "false"
diff --git a/res/layout/main.xml b/res/layout/main.xml
index a56180e..884e864 100644
--- a/res/layout/main.xml
+++ b/res/layout/main.xml
@@ -18,6 +18,27 @@
android:layout_gravity="center"
android:visibility="gone"/>
+ <LinearLayout
+ android:id="@+id/levelNameBox"
+ android:visibility="gone"
+ android:background="@drawable/custom_toast_border"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="10dp"
+ android:layout_gravity="bottom|center_horizontal"
+ android:layout_marginBottom="60dp">
+ <TextView
+ android:id="@+id/levelName"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textColor="#FFFFFF"
+ android:layout_gravity="center_horizontal"
+ android:text="Memory #001" android:textSize="20sp"
+ android:textStyle="bold"
+ android:typeface="sans"/>
+ </LinearLayout>
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pleaseWaitMessage"
android:orientation="horizontal"
diff --git a/res/layout/mainmenu.xml b/res/layout/mainmenu.xml
index 34cd0fa..e292095 100644
--- a/res/layout/mainmenu.xml
+++ b/res/layout/mainmenu.xml
@@ -1,84 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
-<AbsoluteLayout
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- xmlns:android="http://schemas.android.com/apk/res/android">
- <ImageView
+<FrameLayout
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+ <ImageView
android:id="@+id/mainMenuBackground"
android:src="@drawable/title_background"
android:adjustViewBounds="true"
android:gravity="center_vertical"
android:scaleType="fitXY"
android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_x="0dp"
- android:layout_y="0dp" />
- <LinearLayout
- android:layout_width="fill_parent"
+ android:layout_height="fill_parent"/>
+
+
+ <ImageView
+ android:id="@+id/mainMenuTitle"
+ android:src="@drawable/title"
+ android:adjustViewBounds="true"
+ android:layout_width="336dp"
+ android:layout_height="153dp"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginTop="20dp"/>
+
+ <LinearLayout
+ android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_x="0dp"
- android:layout_y="20dp"
- android:gravity="center_horizontal" >
- <ImageView
- android:id="@+id/mainMenuTitle"
- android:src="@drawable/title"
- android:adjustViewBounds="true"
- android:layout_width="336dp"
- android:layout_height="153dp"
- android:gravity="center_horizontal" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_x="0dp"
- android:layout_y="0dp"
- android:orientation="vertical"
- android:gravity="bottom">
-
-
- <ImageView
- android:id="@+id/startButton"
- android:src="@drawable/ui_button_start"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"
- android:clickable="true"/>
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="20dip"
- xmlns:android="http://schemas.android.com/apk/res/android"/>
-
- <ImageView
- android:id="@+id/optionButton"
- android:src="@drawable/ui_button_options"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"
- android:clickable="true"/>
-
- <LinearLayout
- android:layout_width="fill_parent"
- xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="20dip"/>
-
- <TextView
- android:layout_gravity="bottom|fill_horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:ellipsize="marquee"
- android:background="#99000000"
- android:textColor= "#FFFFFF"
- android:textColorHighlight="#FFFFFF"
- android:text="@string/whats_new_ticker"
- android:lines="1"
- android:marqueeRepeatLimit="marquee_forever"
- android:textSize="14sp"
- android:fadingEdge="horizontal"
- android:fadingEdgeLength="5dp"
- android:focusable="false"
- android:id="@+id/ticker"
- android:singleLine="true"/>
- </LinearLayout>
-
-</AbsoluteLayout> \ No newline at end of file
+ android:orientation="vertical"
+ android:gravity="bottom"
+ android:id="@+id/mainSectionMenu">
+
+
+ <ImageView
+ android:id="@+id/startButton"
+ android:src="@drawable/ui_button_start"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:clickable="true" />
+
+ <ImageView
+ android:id="@+id/extrasButton"
+ android:src="@drawable/ui_button_extras"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:paddingTop="10dp"
+ android:clickable="true" />
+
+
+
+ <ImageView
+ android:id="@+id/optionButton"
+ android:src="@drawable/ui_button_options"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:paddingTop="10dp"
+ android:clickable="true" />
+
+
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="marquee"
+ android:background="#99000000"
+ android:textColor= "#FFFFFF"
+ android:textColorHighlight="#FFFFFF"
+ android:text="@string/whats_new_ticker"
+ android:lines="1"
+ android:marqueeRepeatLimit="marquee_forever"
+ android:textSize="14sp"
+ android:fadingEdge="horizontal"
+ android:fadingEdgeLength="5dp"
+ android:focusable="false"
+ android:id="@+id/ticker"
+ android:singleLine="true" android:layout_gravity="bottom|left"/>
+ </LinearLayout>
+
+ <ImageView
+ android:id="@+id/extrasNew"
+ android:src="@drawable/ui_new"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:paddingLeft="280dp"
+ android:paddingTop="160dp"
+ android:visibility="invisible"/>
+
+</FrameLayout> \ No newline at end of file
diff --git a/res/raw/level_2_6_grass.bin b/res/raw/level_2_6_grass.bin
index 79a4066..7cde1d8 100644
--- a/res/raw/level_2_6_grass.bin
+++ b/res/raw/level_2_6_grass.bin
Binary files differ
diff --git a/res/raw/level_3_11_sewer.bin b/res/raw/level_3_11_sewer.bin
index 4f47dde..d903c19 100644
--- a/res/raw/level_3_11_sewer.bin
+++ b/res/raw/level_3_11_sewer.bin
Binary files differ
diff --git a/res/raw/level_4_5_underground.bin b/res/raw/level_4_5_underground.bin
index f0634a8..d6fd059 100644
--- a/res/raw/level_4_5_underground.bin
+++ b/res/raw/level_4_5_underground.bin
Binary files differ
diff --git a/res/raw/objecttestmap.bin b/res/raw/objecttestmap.bin
index cb98392..1019db2 100644
--- a/res/raw/objecttestmap.bin
+++ b/res/raw/objecttestmap.bin
Binary files differ
diff --git a/res/raw/performancetest4.bin b/res/raw/performancetest4.bin
index fc3adaa..9e30d1a 100644
--- a/res/raw/performancetest4.bin
+++ b/res/raw/performancetest4.bin
Binary files differ
diff --git a/res/values/kabocha.xml b/res/values/kabocha.xml
index 58086a8..4b1cbfb 100644
--- a/res/values/kabocha.xml
+++ b/res/values/kabocha.xml
@@ -20,7 +20,7 @@ Jolly good! You learn exactly as quickly as I calculated you would. Fantastiqu
</string>
<string name="Kabocha_0_2_2_2">
-Now, rolling around is a pleasurable way to move, but to really travel in style you should fly. <b>Tap the blue button on the lower left-hand side of the screen to jump, and hold it down to fly.</b> Be careful though--your batteries can only hold you aloft for a short time before they need to recharge. Watch the meter at the top left of the screen to see your remaining flight power.
+Now, rolling around is a pleasurable way to move, but to really travel in style you should fly. <b>Tap the blue button on the bottom of the screen to jump, and hold it down to fly.</b> Be careful though--your batteries can only hold you aloft for a short time before they need to recharge. Watch the meter at the top left of the screen to see your remaining flight power.
</string>
<string name="Kabocha_0_2_2_3">
diff --git a/res/values/strings.xml b/res/values/strings.xml
index be55c34..bfb8417 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -32,6 +32,9 @@
<string name="preference_configure_controls">Configure Controls</string>
<string name="preference_enable_click_attack">Click Attack</string>
<string name="preference_enable_click_attack_summary">Use the trackball click or directional pad center button to attack.</string>
+<string name="preference_enable_screen_controls">On-Screen Controls</string>
+<string name="preference_enable_screen_controls_summary">Displays movement pad and buttons on screen. Suggested for devices without a d-pad or trackball. Requires mulitouch.</string>
+
<string name="preference_enable_tilt_controls">Tilt Controls</string>
<string name="preference_enable_tilt_controls_summary">EXPERIMENTAL! Tilt the phone left and right to drive the Android around. Good for devices with no trackball or d-pad.</string>
@@ -65,13 +68,23 @@
<string name="preference_about_summary">Replica Island was made by Chris Pruett and Genki Mine, and produced by Tom Moss.</string>
<string name="preference_visit_site">Go to the Replica Island web site</string>
<string name="preference_thanks_title">Special Thanks</string>
-<string name="preference_thanks_summary">Special Thanks to Adrian Havill, Casey Richardson, Jason Chen, Tim Mansfield, and the Android Team for their support of this project.</string>
+<string name="preference_thanks_summary">Special Thanks to Eido Inoue, Casey Richardson, Jason Chen, Tim Mansfield, and the Android Team for their support of this project.</string>
<string name="preference_licence_title">License</string>
<string name="preference_licence_summary">Portions of this game are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.</string>
<string name="preference_misc">More Information</string>
<string name="preference_enable_debug">Debug Log</string>
<string name="preference_enable_debug_summary">Output various logs to logcat. This option will slow the game down.</string>
+<string name="game_results_title">GAME RESULTS</string>
+<string name="game_results_pearls_collected">PEARLS COLLECTED:</string>
+<string name="game_results_robots_destroyed">ROBOTS DESTROYED:</string>
+<string name="game_results_total_play_time">TOTAL PLAY TIME:</string>
+<string name="game_results_ending">ENDING ACHIEVED:</string>
+<string name="game_results_unlocks_message">You can now access Linear Mode and the Level Select from the Extras menu!</string>
+<string name="game_results_kabocha_ending">BAD ENDING #1 - Kabocha Wins</string>
+<string name="game_results_rokudou_ending">BAD ENDING #2 - Rokudou Wins</string>
+<string name="game_results_wanda_ending">GOOD ENDING - World Saved!</string>
+<string name="game_results_ok_button">Game Over!</string>
<string name="saved_game_erased_notification">Saved Game Erased</string>
@@ -80,29 +93,27 @@
<string name="quit_game_dialog_cancel">Cancel</string>
<string name="quit_game_dialog_message">Return to main menu?</string>
+<string name="new_game_dialog_title">Start New Game?</string>
+<string name="new_game_dialog_ok">Start New Game</string>
+<string name="new_game_dialog_cancel">Cancel</string>
+<string name="new_game_dialog_message">Starting a new game in this mode will erase your current game in progress. Are you sure you want to start a new game?</string>
+
+<string name="extras_locked_dialog_title">Extra Locked!</string>
+<string name="extras_locked_dialog_ok">Get to it!</string>
+<string name="extras_locked_dialog_message">This extra feature is still locked. Beat the game one time to unlock it!</string>
+
+
<string name="nav_type">Trackball</string>
<string name="whats_new_dialog_title">Replica Island</string>
<string name="whats_new_dialog_ok">Rock on!</string>
-<string name="whats_new_dialog_message">Thanks for downloading Replica Island.\n\n
+<string name="whats_new_dialog_message">Thanks for downloading Replica Island. Over 1.5 million people have played Replica Island!\n\n
<b>New in this version:</b>\n
-\t• Fixed blackouts and crashes on Cliq, Backflip, etc. If you have problems try <b>Safe Mode</b> in the options screen.\n
-\t• Improved controls, especially for Droid and other d-pad devices.\n
-\t• Added <b>Motion Sensitivity</b> option to control options. Optical pad users (HTC Desire, Samsung Moment, etc) may want to turn sensitivity down a bit.\n
-\t• Various performance and stability improvements.\n
-\n
-As of version 1.3, more than 500,000 users have downloaded Replica Island. Thank you for your support!
-\n
-\n
-<b>New in version 1.21:</b>\n
-\t• Fixed crash when adjusting tilt sensitivity on Samsung Moment.\n
-\t• Added debug log option. \n
-\n
-<b>New in version 1.2:</b>\n
-\t• Crash fixes and general stability improvements. \n
-\t• Keyboard configuration for devices with hard keyboards. \n
-\t• Tilt control sensitivity controls. \n
-\t• Fixed missing graphics on confusing Memory #034 puzzle. \n
+- Unlockable extra modes: Linear Story Mode and Level Select.\n
+- On-screen controls for devices with no buttons.\n
+- Difficulty settings for new games. \n
+- Play statistics shown when you finish the game.\n
+- Lots of bugs fixed!\n
\n
\n
This is an open source project. If you are interested in how it works, or would like to use it to make your
@@ -112,7 +123,42 @@ own games, check out the source at our web site, replicaisland.net.
Also note that this game sends anonymous play statistics back to a server. If you’d rather not
allow that, you can turn it off in the options screen.</string>
-<string name="whats_new_ticker">New in this version: Fix blackouts on broken phones (Cliq, Backflip, etc), improved controls, adjustable control sensitivity, various performance and stability improvements.</string>
+<string name="control_setup_dialog_title">Control Setup</string>
+<string name="control_setup_dialog_ok">Leave it this way</string>
+<string name="control_setup_dialog_change">Change control settings</string>
+<string name="control_setup_dialog_message">
+Based on your device hardware, the following control scheme has been automatically selected:
+&lt;br>
+&lt;br>
+&lt;small>%1s&lt;/small>
+&lt;br>
+&lt;br>Replica Island supports many different control configurations. Control options can be changed at
+any time using the Configure Controls button in Options.
+&lt;br>
+&lt;br>
+Are you ok with the control system selected above, or would you like to set up your control
+settings manually now?</string>
+<string name="control_setup_dialog_trackball">&lt;b>Trackball / Trackpad&lt;/b> - Sensitivity can be adjusted in Options.</string>
+<string name="control_setup_dialog_dpad">&lt;b>Keyboard / Pad&lt;/b> - Key mappings can be changed in Options.</string>
+<string name="control_setup_dialog_screen">&lt;b>On-Screen Pad&lt;/b></string>
+<string name="control_setup_dialog_tilt">&lt;b>Tilt&lt;/b> - Sensitivity can be adjusted in Options.</string>
+
+<string name="onscreen_tilt_dialog_title">New Control Scheme!</string>
+<string name="onscreen_tilt_dialog_ok">On-Screen Pad</string>
+<string name="onscreen_tilt_dialog_cancel">Stick with Tilt</string>
+<string name="onscreen_tilt_dialog_message">This version of Replica Island adds an option for
+<b>On-Screen Controls</b> for multi-touch devices. Your device supports this new
+mode, but your options are currently set to <b>Tilt</b> controls. Would you like to try the
+new On-Screen Controls instead, or stick with Tilt?
+\n<small>You can change this setting at any time by choosing Configure Controls under Options.</small>
+</string>
+
+<string name="whats_new_ticker">New in this version: On-screen controls, app-to-sd card support, unlockable extra modes, game statistics after winning, lots of minor (and not so minor) bugs fixed.</string>
+
+<string name="baby_description">No challenge at all.</string>
+<string name="kids_description">A comfortable ride to the end.</string>
+<string name="adults_description">True accomplishment requires hardship.</string>
+
<!-- Toast Messages -->
<string name="memory_playback_start">MEMORY PLAYBACK START</string>
@@ -183,6 +229,7 @@ allow that, you can turn it off in the options screen.</string>
<string name = "level_performance_test">Performance Test</string>
<string name = "level_performance_test2">Performance Test 2</string>
<string name = "level_performance_test3">Performance Test 3</string>
+<string name = "level_performance_test4">Google IO Performance Test</string>
<string name = "level_npc_motion_test">NPC Motion Test</string>
<!-- Level time codes -->
@@ -338,7 +385,7 @@ When I find The Source, I am going to use it to cure myself of whatever it is th
<string name="Diary13">
He lied he lied he lied he lied. Rokudou is a liar. He seeks only to control. He says he wants The Source to save the world, to rid it of the fat cats who play the planet like a marionette. He he he HE is the fat cat, the puppeteer. He shall not have The Source. It shall be mine. Mine mine mine mine mine. 73, 79, 83, 89, 97, 101, 103, 107, 109, 113.\n
\n
-The Source is here. It is down here, in the dark. I can feel its heat, a warmth like the sun against my cheek. But no, I mustn't go to it, not not not not yet. If I find it, Rokudou will take it from me and it will be check check check check mate. No, Kabochanomizu is cautious. Kabochanomizu is careful. I shall retreat to the surface. I know enough now to build things. I will return only when I can guarantee my success. Rokudou will grovel before me and the world will know Kabochanomizu as its savior.\n
+The Source is here. It is down here, in the dark. I can feel its heat, a warmth like the sun against my cheek. But no, I mustn’t go to it, not not not not yet. If I find it, Rokudou will take it from me and it will be check check check check mate. No, Kabochanomizu is cautious. Kabochanomizu is careful. I shall retreat to the surface. I know enough now to build things. I will return only when I can guarantee my success. Rokudou will grovel before me and the world will know Kabochanomizu as its savior.\n
</string>
<string name="Diary14">
diff --git a/res/values/wanda.xml b/res/values/wanda.xml
index e58a644..53f0b2a 100644
--- a/res/values/wanda.xml
+++ b/res/values/wanda.xml
@@ -101,7 +101,7 @@ Kyle was my friend, but to you he was just an obstacle to overcome. You probabl
</string>
<string name="Wanda_2_6_1_1">
-Hey Mr. Android, are you stuck? Here, I'll clear a path for you.
+Hey Mr. Android, are you stuck? Here, I’ll clear a path for you.
</string>
<string name="Wanda_2_6_2_1">
diff --git a/res/xml/level_tree.xml b/res/xml/level_tree.xml
index 2b83f09..437cf73 100644
--- a/res/xml/level_tree.xml
+++ b/res/xml/level_tree.xml
@@ -312,17 +312,13 @@
</group>
<!--
- <group>
- <level resource="@raw/performancetest4" title = "@string/level_performance_test2" time = "@string/level_test_time"/>
-</group>
-
-
<group>
<level resource="@raw/puzzles_test" title = "@string/level_puzzle_test" time = "@string/level_test_time"/>
<level resource="@raw/objecttestmap" title = "@string/level_object_test" time = "@string/level_test_time"/>
<level resource="@raw/performancetest" title = "@string/level_performance_test" time = "@string/level_test_time"/>
<level resource="@raw/performancetest2" title = "@string/level_performance_test2" time = "@string/level_test_time"/>
<level resource="@raw/performancetest3" title = "@string/level_performance_test3" time = "@string/level_test_time"/>
+ <level resource="@raw/performancetest4" title = "@string/level_performance_test4" time = "@string/level_test_time"/>
<level resource="@raw/npc_motion_test" title = "@string/level_npc_motion_test" time = "@string/level_test_time"/>
</group>
-->
diff --git a/res/xml/linear_level_tree.xml b/res/xml/linear_level_tree.xml
new file mode 100644
index 0000000..b89ddfb
--- /dev/null
+++ b/res/xml/linear_level_tree.xml
@@ -0,0 +1,252 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<levelTree>
+
+ <group><level resource="@raw/level_0_2_lab" title = "@string/level_0_2_lab" time = "@string/level_0_2_time" >
+ <dialog>
+ <character1 resource ="@xml/level_0_2_dialog_kabocha"/>
+ <character2 resource ="@xml/level_0_2_dialog_kabocha_2"/>
+ </dialog>
+ </level></group>
+
+ <group><level resource="@raw/level_0_3_lab" title = "@string/level_0_3_lab" time = "@string/level_0_3_time" >
+ <dialog>
+ <character1 resource ="@xml/level_0_3_dialog_kabocha"/>
+ </dialog>
+ </level></group>
+
+ <group><level resource="@raw/level_1_1_island" title = "@string/level_1_1_island" time = "@string/level_1_1_time" >
+ <dialog>
+ <diary resource ="@string/Diary1"/>
+ <character1 resource ="@xml/level_1_1_dialog_wanda"/>
+ </dialog>
+ </level></group>
+
+ <group><level resource="@raw/level_1_2_island" title = "@string/level_1_2_island" time = "@string/level_1_2_time" /></group>
+ <group><level resource="@raw/level_1_3_island" title = "@string/level_1_3_island" time = "@string/level_1_3_time" >
+ <dialog>
+ <diary resource ="@string/Diary2"/>
+ </dialog>
+ </level></group>
+
+ <!-- <group><level resource="@raw/level_1_4_island" title = "@string/level_1_4_island" time = "@string/level_1_4_time"/></group> -->
+
+ <group><level resource="@raw/level_1_5_island" title = "@string/level_1_5_island" time = "@string/level_1_5_time">
+ <dialog>
+ <character1 resource ="@xml/level_1_5_dialog_wanda"/>
+ <diary resource ="@string/Diary4"/>
+ </dialog>
+ </level></group>
+
+ <group><level resource="@raw/level_1_6_island" title = "@string/level_1_6_island" time = "@string/level_1_6_time" >
+ <dialog>
+ <character1 resource ="@xml/level_1_6_dialog_wanda"/>
+ </dialog>
+ </level></group>
+
+ <!-- <group><level resource="@raw/level_1_7_island" title = "@string/level_1_7_island" time = "@string/level_1_7_time" >
+ </level></group>
+-->
+
+ <group><level resource="@raw/level_1_8_island" title = "@string/level_1_8_island" time = "@string/level_1_8_time" /></group>
+
+
+ <group><level resource="@raw/level_1_9_island" title = "@string/level_1_9_island" time = "@string/level_1_9_time" >
+ <dialog>
+ <character1 resource ="@xml/level_1_9_dialog_wanda"/>
+ <diary resource ="@string/Diary14"/>
+ </dialog>
+ </level></group>
+
+
+ <group><level resource="@raw/level_2_1_grass" title = "@string/level_2_1_grass" time = "@string/level_2_1_time" >
+ <dialog>
+ <character1 resource ="@xml/level_2_1_dialog_kyle"/>
+ </dialog>
+ </level></group>
+ <group><level resource="@raw/level_2_2_grass" title = "@string/level_2_2_grass" time = "@string/level_2_2_time"/></group>
+ <group><level resource="@raw/level_2_3_grass" title = "@string/level_2_3_grass" time = "@string/level_2_3_time">
+ <dialog>
+ <character1 resource ="@xml/level_2_3_dialog_kyle"/>
+ <diary resource ="@string/Diary5"/>
+ </dialog>
+ </level></group>
+ <group><level resource="@raw/level_2_4_grass" title = "@string/level_2_4_grass" time = "@string/level_2_4_time" >
+ <dialog>
+ <character1 resource ="@xml/level_2_4_dialog_kyle"/>
+ </dialog>
+ </level></group>
+ <group><level resource="@raw/level_2_5_grass" title = "@string/level_2_5_grass" time = "@string/level_2_5_time" >
+ <dialog>
+ <character1 resource ="@xml/level_2_5_dialog_kyle"/>
+ <diary resource ="@string/Diary8"/>
+ </dialog>
+ </level></group>
+ <group><level resource="@raw/level_2_6_grass" title = "@string/level_2_6_grass" time = "@string/level_2_6_time" >
+ <dialog>
+ <character1 resource ="@xml/level_2_6_dialog_wanda"/>
+ <diary resource ="@string/Diary10"/>
+ </dialog>
+ </level></group>
+ <group><level resource="@raw/level_2_7_grass" title = "@string/level_2_7_grass" time = "@string/level_2_7_time" >
+ <dialog>
+ <character1 resource ="@xml/level_2_7_dialog_kyle"/>
+ </dialog>
+ </level></group>
+ <group><level resource="@raw/level_2_8_grass" title = "@string/level_2_8_grass" time = "@string/level_2_8_time" >
+ <dialog>
+ <character1 resource ="@xml/level_2_8_dialog_kyle"/>
+ <diary resource ="@string/Diary11"/>
+ </dialog>
+ </level></group>
+ <group><level resource="@raw/level_2_9_grass" title = "@string/level_2_9_grass" time = "@string/level_2_9_time" >
+ <dialog>
+ <character1 resource ="@xml/level_2_9_dialog_wanda"/>
+ <character2 resource ="@xml/level_2_9_dialog_kyle"/>
+ <diary resource ="@string/Diary15"/>
+ </dialog>
+ </level></group>
+
+ <group><level resource="@raw/level_3_1_grass" title = "@string/level_3_1_sewer" time = "@string/level_3_1_time" /></group>
+ <group><level resource="@raw/level_3_2_sewer" title = "@string/level_3_2_sewer" time = "@string/level_3_2_time" /></group>
+
+ <group><level resource="@raw/level_3_3_sewer" title = "@string/level_3_3_sewer" time = "@string/level_3_3_time" >
+ <dialog>
+ <character1 resource ="@xml/level_3_3_dialog_wanda"/>
+ <diary resource ="@string/Diary12"/>
+ </dialog>
+ </level></group>
+
+
+ <group><level resource="@raw/level_3_4_sewer" title = "@string/level_3_4_sewer" time = "@string/level_3_4_time">
+ </level></group>
+
+ <group><level resource="@raw/level_0_1_sewer_kyle" title = "@string/level_0_1_sewer_kyle" time = "@string/level_3_4_time" restartable="false">
+ <dialog>
+ <character1 resource ="@xml/level_3_4_dialog_kyle"/>
+ </dialog>
+ </level></group>
+
+ <group><level resource="@raw/level_0_1_sewer_wanda" title = "@string/level_0_1_sewer_wanda" time = "@string/level_0_1_time" waitmessage="true">
+ <dialog>
+ <character1 resource ="@xml/level_0_1_dialog_wanda"/>
+ </dialog>
+ </level></group>
+
+ <group><level resource="@raw/level_3_5_sewer" title = "@string/level_3_5_sewer" time = "@string/level_3_5_time">
+ <dialog>
+ <character1 resource ="@xml/level_3_5_dialog_wanda"/>
+ </dialog>
+ </level></group>
+
+
+
+ <group><level resource="@raw/level_3_6_sewer" title = "@string/level_3_6_sewer" time = "@string/level_3_6_time"/></group>
+
+
+
+ <group><level resource="@raw/level_3_7_sewer" title = "@string/level_3_7_sewer" time = "@string/level_3_7_time">
+ <dialog>
+ <character1 resource ="@xml/level_3_7_dialog_wanda"/>
+ <diary resource ="@string/Diary3"/>
+ </dialog>
+ </level></group>
+
+
+ <group><level resource="@raw/level_3_8_sewer" title = "@string/level_3_8_sewer" time = "@string/level_3_8_time">
+ <dialog>
+ <character1 resource ="@xml/level_3_8_dialog_kyle"/>
+ </dialog>
+ </level></group>
+
+
+ <group><level resource="@raw/level_3_9_sewer" title = "@string/level_3_9_sewer" time = "@string/level_3_9_time">
+ <dialog>
+ <character1 resource ="@xml/level_3_9_dialog_kyle"/>
+ <character2 resource ="@xml/level_3_9_dialog_rokudou"/>
+ <diary resource ="@string/Diary6"/>
+ </dialog>
+ </level></group>
+
+
+
+
+ <group><level resource="@raw/level_3_10_sewer" title = "@string/level_3_10_sewer" time = "@string/level_3_10_time">
+ <dialog>
+ <character1 resource ="@xml/level_3_10_dialog_kyle"/>
+ </dialog>
+ </level></group>
+
+ <group><level resource="@raw/level_3_11_sewer" title = "@string/level_3_11_sewer" time = "@string/level_3_11_time">
+ <dialog>
+ <character1 resource ="@xml/level_3_11_dialog_wanda"/>
+ </dialog>
+ </level></group>
+
+ <group><level resource="@raw/level_4_1_underground" title = "@string/level_4_1_underground" time = "@string/level_4_1_time">
+ <dialog>
+ <character1 resource ="@xml/level_4_1_dialog_wanda"/>
+ <character2 resource ="@xml/level_4_1_dialog_rokudou"/>
+ <!-- <character2 resource ="@xml/level_4_1_misc"/> -->
+ <diary resource ="@string/Diary7"/>
+ </dialog>
+ </level></group>
+
+
+ <group><level resource="@raw/level_4_2_underground" title = "@string/level_4_2_underground" time = "@string/level_4_2_time">
+ <dialog>
+ <character1 resource ="@xml/level_4_2_dialog_wanda"/>
+ <diary resource ="@string/Diary9"/>
+ </dialog>
+ </level></group>
+
+
+
+ <group><level resource="@raw/level_4_3_underground" title = "@string/level_4_3_underground" time = "@string/level_4_3_time">
+ <dialog>
+ <character1 resource ="@xml/level_4_3_dialog_kabocha"/>
+ </dialog>
+ </level></group>
+
+
+ <group><level resource="@raw/level_4_4_underground" title = "@string/level_4_4_underground" time = "@string/level_4_4_time">
+ <dialog>
+ <character2 resource ="@xml/level_4_4_dialog_rokudou"/>
+ </dialog>
+ </level></group>
+
+
+ <group><level resource="@raw/level_4_5_underground" title = "@string/level_4_5_underground" time = "@string/level_4_5_time">
+ <dialog>
+ <character1 resource ="@xml/level_4_5_dialog_wanda"/>
+ </dialog>
+ </level></group>
+
+
+
+ <group><level resource="@raw/level_4_7_underground" title = "@string/level_4_7_underground" time = "@string/level_4_7_time">
+ <dialog>
+ <character1 resource ="@xml/level_4_7_dialog_wanda"/>
+ <character2 resource ="@xml/level_4_7_dialog_rokudou"/>
+ <diary resource ="@string/Diary13"/>
+ </dialog>
+ </level></group>
+
+ <group><level resource="@raw/level_4_8_underground" title = "@string/level_4_8_underground" time = "@string/level_4_8_time"/></group>
+
+
+
+ <group><level resource="@raw/level_4_9_underground" title = "@string/level_4_9_underground" time = "@string/level_4_9_time">
+ <dialog>
+ <character1 resource ="@xml/level_4_9_dialog_wanda"/>
+ </dialog>
+ </level></group>
+
+ <group><level resource="@raw/level_final_boss_lab" title = "@string/level_final_boss_lab" time = "@string/level_final_boss_time">
+ <dialog>
+ <character1 resource ="@xml/level_final_boss_dialog"/>
+ </dialog>
+ </level></group>
+
+</levelTree>
+
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index a263025..d86ab1a 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -30,6 +30,7 @@
/>
<PreferenceScreen
+ android:key="controlConfigScreen"
android:title="@string/preference_configure_controls"
xmlns:replica="http://schemas.android.com/apk/res/com.replica.replicaisland">
<CheckBoxPreference
@@ -64,7 +65,16 @@
replica:minText="@string/preference_movement_min"
android:persistent="true"/>
-
+ <CheckBoxPreference
+ android:key="enableScreenControls"
+ android:title="@string/preference_enable_screen_controls"
+ android:summaryOn="@string/preference_enable_screen_controls_summary"
+ android:summaryOff="@string/preference_enable_screen_controls_summary"
+ android:defaultValue="false"
+ android:persistent="true"
+ android:disableDependentsState="true"
+ />
+
<CheckBoxPreference
android:key="enableTiltControls"
android:title="@string/preference_enable_tilt_controls"
@@ -72,6 +82,7 @@
android:summaryOff="@string/preference_enable_tilt_controls_summary"
android:defaultValue="false"
android:persistent="true"
+ android:dependency="enableScreenControls"
/>
<com.replica.replicaisland.SliderPreference
diff --git a/src/com/replica/replicaisland/AdultsDifficultyConstants.java b/src/com/replica/replicaisland/AdultsDifficultyConstants.java
new file mode 100644
index 0000000..aeaca77
--- /dev/null
+++ b/src/com/replica/replicaisland/AdultsDifficultyConstants.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.replica.replicaisland;
+
+public class AdultsDifficultyConstants extends DifficultyConstants {
+
+ private static final float FUEL_AIR_REFILL_SPEED = 0.15f;
+ private static final float FUEL_GROUND_REFILL_SPEED = 2.0f;
+ public static final int MAX_PLAYER_LIFE = 2;
+ private static final int COINS_PER_POWERUP = 30;
+
+ public static final float GLOW_DURATION = 10.0f;
+
+ // DDA boosts
+ private static final int DDA_STAGE_1_ATTEMPTS = 4;
+ private static final int DDA_STAGE_2_ATTEMPTS = 8;
+ private static final int DDA_STAGE_1_LIFE_BOOST = 1;
+ private static final int DDA_STAGE_2_LIFE_BOOST = 2;
+ private static final float DDA_STAGE_1_FUEL_AIR_REFILL_SPEED = 0.15f;
+ private static final float DDA_STAGE_2_FUEL_AIR_REFILL_SPEED = 0.22f;
+
+ @Override
+ public float getFuelAirRefillSpeed() {
+ return FUEL_AIR_REFILL_SPEED;
+ }
+
+ @Override
+ public float getFuelGroundRefillSpeed() {
+ return FUEL_GROUND_REFILL_SPEED;
+ }
+
+ @Override
+ public int getMaxPlayerLife() {
+ return MAX_PLAYER_LIFE;
+ }
+
+ @Override
+ public int getCoinsPerPowerup() {
+ return COINS_PER_POWERUP;
+ }
+
+ @Override
+ public float getGlowDuration() {
+ return GLOW_DURATION;
+ }
+
+ @Override
+ public int getDDAStage1Attempts() {
+ return DDA_STAGE_1_ATTEMPTS;
+ }
+
+ @Override
+ public int getDDAStage2Attempts() {
+ return DDA_STAGE_2_ATTEMPTS;
+ }
+
+ @Override
+ public int getDDAStage1LifeBoost() {
+ return DDA_STAGE_1_LIFE_BOOST;
+ }
+
+ @Override
+ public int getDDAStage2LifeBoost() {
+ return DDA_STAGE_2_LIFE_BOOST;
+ }
+
+ @Override
+ public float getDDAStage1FuelAirRefillSpeed() {
+ return DDA_STAGE_1_FUEL_AIR_REFILL_SPEED;
+ }
+
+ @Override
+ public float getDDAStage2FuelAirRefillSpeed() {
+ return DDA_STAGE_2_FUEL_AIR_REFILL_SPEED;
+ }
+
+}
diff --git a/src/com/replica/replicaisland/AndouKun.java b/src/com/replica/replicaisland/AndouKun.java
index ed91b0d..23ca928 100644
--- a/src/com/replica/replicaisland/AndouKun.java
+++ b/src/com/replica/replicaisland/AndouKun.java
@@ -16,6 +16,9 @@
package com.replica.replicaisland;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -37,6 +40,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
+import android.widget.TextView;
/**
* Core activity for the game. Sets up a surface view for OpenGL, bootstraps
@@ -56,44 +60,33 @@ public class AndouKun extends Activity implements SensorEventListener {
private static final int ROLL_TO_FACE_BUTTON_DELAY = 400;
- public static final String PREFERENCE_LEVEL_ROW = "levelRow";
- public static final String PREFERENCE_LEVEL_INDEX = "levelIndex";
- public static final String PREFERENCE_LEVEL_COMPLETED = "levelsCompleted";
- public static final String PREFERENCE_SOUND_ENABLED = "enableSound";
- public static final String PREFERENCE_SAFE_MODE = "safeMode";
- public static final String PREFERENCE_SESSION_ID = "session";
- public static final String PREFERENCE_LAST_VERSION = "lastVersion";
- public static final String PREFERENCE_STATS_ENABLED = "enableStats";
- public static final String PREFERENCE_CLICK_ATTACK = "enableClickAttack";
- public static final String PREFERENCE_TILT_CONTROLS = "enableTiltControls";
- public static final String PREFERENCE_TILT_SENSITIVITY = "tiltSensitivity";
- public static final String PREFERENCE_MOVEMENT_SENSITIVITY = "movementSensitivity";
- public static final String PREFERENCE_ENABLE_DEBUG = "enableDebug";
-
- public static final String PREFERENCE_LEFT_KEY = "keyLeft";
- public static final String PREFERENCE_RIGHT_KEY = "keyRight";
- public static final String PREFERENCE_ATTACK_KEY = "keyAttack";
- public static final String PREFERENCE_JUMP_KEY = "keyJump";
-
- public static final String PREFERENCE_NAME = "ReplicaIslandPrefs";
-
public static final int QUIT_GAME_DIALOG = 0;
// If the version is a negative number, debug features (logging and a debug menu)
// are enabled.
- public static final int VERSION = 13;
+ public static final int VERSION = 14;
private GLSurfaceView mGLSurfaceView;
private Game mGame;
private boolean mMethodTracing;
private int mLevelRow;
private int mLevelIndex;
+ private float mTotalGameTime;
+ private int mRobotsDestroyed;
+ private int mPearlsCollected;
+ private int mPearlsTotal;
+ private int mLastEnding = -1;
+ private int mLinearMode = 0;
+ private int mDifficulty = 1;
+ private boolean mExtrasUnlocked;
private SensorManager mSensorManager;
private SharedPreferences.Editor mPrefsEditor;
private long mLastTouchTime = 0L;
private long mLastRollTime = 0L;
private View mPauseMessage = null;
private View mWaitMessage = null;
+ private View mLevelNameBox = null;
+ private TextView mLevelName = null;
private Animation mWaitFadeAnimation = null;
private EventReporter mEventReporter;
@@ -106,8 +99,8 @@ public class AndouKun extends Activity implements SensorEventListener {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- SharedPreferences prefs = getSharedPreferences(PREFERENCE_NAME, MODE_PRIVATE);
- final boolean debugLogs = prefs.getBoolean(PREFERENCE_ENABLE_DEBUG, false);
+ SharedPreferences prefs = getSharedPreferences(PreferenceConstants.PREFERENCE_NAME, MODE_PRIVATE);
+ final boolean debugLogs = prefs.getBoolean(PreferenceConstants.PREFERENCE_ENABLE_DEBUG, false);
if (VERSION < 0 || debugLogs) {
DebugLog.setDebugLogging(true);
@@ -122,6 +115,8 @@ public class AndouKun extends Activity implements SensorEventListener {
mGLSurfaceView = (GLSurfaceView) findViewById(R.id.glsurfaceview);
mPauseMessage = findViewById(R.id.pausedMessage);
mWaitMessage = findViewById(R.id.pleaseWaitMessage);
+ mLevelNameBox = findViewById(R.id.levelNameBox);
+ mLevelName = (TextView)findViewById(R.id.levelName);
mWaitFadeAnimation = AnimationUtils.loadAnimation(this, R.anim.wait_message_fade);
@@ -139,71 +134,108 @@ public class AndouKun extends Activity implements SensorEventListener {
float ratio =((float)dm.widthPixels) / dm.heightPixels;
defaultWidth = (int)(defaultHeight * ratio);
}
- mGame.bootstrap(this, dm.widthPixels, dm.heightPixels, defaultWidth, defaultHeight);
- mGLSurfaceView.setRenderer(mGame.getRenderer());
+
mLevelRow = 0;
mLevelIndex = 0;
mPrefsEditor = prefs.edit();
- mLevelRow = prefs.getInt(PREFERENCE_LEVEL_ROW, 0);
- mLevelIndex = prefs.getInt(PREFERENCE_LEVEL_INDEX, 0);
- int completed = prefs.getInt(PREFERENCE_LEVEL_COMPLETED, 0);
+ // Make sure that old game information is cleared when we start a new game.
+ if (getIntent().getBooleanExtra("newGame", false)) {
+ mPrefsEditor.remove(PreferenceConstants.PREFERENCE_LEVEL_ROW);
+ mPrefsEditor.remove(PreferenceConstants.PREFERENCE_LEVEL_INDEX);
+ mPrefsEditor.remove(PreferenceConstants.PREFERENCE_LEVEL_COMPLETED);
+ mPrefsEditor.remove(PreferenceConstants.PREFERENCE_LINEAR_MODE);
+ mPrefsEditor.remove(PreferenceConstants.PREFERENCE_TOTAL_GAME_TIME);
+ mPrefsEditor.remove(PreferenceConstants.PREFERENCE_PEARLS_COLLECTED);
+ mPrefsEditor.remove(PreferenceConstants.PREFERENCE_PEARLS_TOTAL);
+ mPrefsEditor.remove(PreferenceConstants.PREFERENCE_ROBOTS_DESTROYED);
+ mPrefsEditor.remove(PreferenceConstants.PREFERENCE_DIFFICULTY);
+ mPrefsEditor.commit();
+ }
+
+
+ mLevelRow = prefs.getInt(PreferenceConstants.PREFERENCE_LEVEL_ROW, 0);
+ mLevelIndex = prefs.getInt(PreferenceConstants.PREFERENCE_LEVEL_INDEX, 0);
+ int completed = prefs.getInt(PreferenceConstants.PREFERENCE_LEVEL_COMPLETED, 0);
+ mTotalGameTime = prefs.getFloat(PreferenceConstants.PREFERENCE_TOTAL_GAME_TIME, 0.0f);
+ mRobotsDestroyed = prefs.getInt(PreferenceConstants.PREFERENCE_ROBOTS_DESTROYED, 0);
+ mPearlsCollected = prefs.getInt(PreferenceConstants.PREFERENCE_PEARLS_COLLECTED, 0);
+ mPearlsTotal = prefs.getInt(PreferenceConstants.PREFERENCE_PEARLS_TOTAL, 0);
+ mLinearMode = prefs.getInt(PreferenceConstants.PREFERENCE_LINEAR_MODE,
+ getIntent().getBooleanExtra("linearMode", false) ? 1 : 0);
+ mExtrasUnlocked = prefs.getBoolean(PreferenceConstants.PREFERENCE_EXTRAS_UNLOCKED, false);
+ mDifficulty = prefs.getInt(PreferenceConstants.PREFERENCE_DIFFICULTY, getIntent().getIntExtra("difficulty", 1));
+
+ mGame.bootstrap(this, dm.widthPixels, dm.heightPixels, defaultWidth, defaultHeight, mDifficulty);
+ mGLSurfaceView.setRenderer(mGame.getRenderer());
+
+
+ int levelTreeResource = R.xml.level_tree;
+ if (mLinearMode != 0) {
+ levelTreeResource = R.xml.linear_level_tree;
+ }
+
// Android activity lifecycle rules make it possible for this activity to be created
// and come to the foreground without the MainMenu Activity ever running, so in that
// case we need to make sure that this static data is valid.
- if (!LevelTree.isLoaded()) {
- LevelTree.loadLevelTree(R.xml.level_tree, this);
+ if (!LevelTree.isLoaded(levelTreeResource)) {
+ LevelTree.loadLevelTree(levelTreeResource, this);
LevelTree.loadAllDialog(this);
}
- if (!LevelTree.levelIsValid(mLevelRow, mLevelIndex)) {
- // bad data? Let's try to recover.
-
- // is the row valid?
- if (LevelTree.rowIsValid(mLevelRow)) {
- // In that case, just start the row over.
- mLevelIndex = 0;
- completed = 0;
- } else if (LevelTree.rowIsValid(mLevelRow - 1)) {
- // If not, try to back up a row.
- mLevelRow--;
- mLevelIndex = 0;
- completed = 0;
- }
-
-
- if (!LevelTree.levelIsValid(mLevelRow, mLevelIndex)) {
- // if all else fails, start the game over.
- mLevelRow = 0;
- mLevelIndex = 0;
- completed = 0;
- }
- }
-
- LevelTree.updateCompletedState(mLevelRow, completed);
-
- mGame.setPendingLevel(LevelTree.get(mLevelRow, mLevelIndex));
- if (LevelTree.get(mLevelRow, mLevelIndex).showWaitMessage) {
- showWaitMessage();
+ if (getIntent().getBooleanExtra("startAtLevelSelect", false)) {
+ Intent i = new Intent(this, LevelSelectActivity.class);
+ i.putExtra("unlockAll", true);
+ startActivityForResult(i, ACTIVITY_CHANGE_LEVELS);
} else {
- hideWaitMessage();
+ if (!LevelTree.levelIsValid(mLevelRow, mLevelIndex)) {
+ // bad data? Let's try to recover.
+
+ // is the row valid?
+ if (LevelTree.rowIsValid(mLevelRow)) {
+ // In that case, just start the row over.
+ mLevelIndex = 0;
+ completed = 0;
+ } else if (LevelTree.rowIsValid(mLevelRow - 1)) {
+ // If not, try to back up a row.
+ mLevelRow--;
+ mLevelIndex = 0;
+ completed = 0;
+ }
+
+
+ if (!LevelTree.levelIsValid(mLevelRow, mLevelIndex)) {
+ // if all else fails, start the game over.
+ mLevelRow = 0;
+ mLevelIndex = 0;
+ completed = 0;
+ }
+ }
+
+ LevelTree.updateCompletedState(mLevelRow, completed);
+
+ mGame.setPendingLevel(LevelTree.get(mLevelRow, mLevelIndex));
+ if (LevelTree.get(mLevelRow, mLevelIndex).showWaitMessage) {
+ showWaitMessage();
+ } else {
+ hideWaitMessage();
+ }
}
-
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
// This activity uses the media stream.
setVolumeControlStream(AudioManager.STREAM_MUSIC);
- mSessionId = prefs.getLong(PREFERENCE_SESSION_ID, System.currentTimeMillis());
+ mSessionId = prefs.getLong(PreferenceConstants.PREFERENCE_SESSION_ID, System.currentTimeMillis());
mEventReporter = null;
mEventReporterThread = null;
- final boolean statsEnabled = prefs.getBoolean(PREFERENCE_STATS_ENABLED, true);
+ final boolean statsEnabled = prefs.getBoolean(PreferenceConstants.PREFERENCE_STATS_ENABLED, true);
if (statsEnabled) {
mEventReporter = new EventReporter();
mEventReporterThread = new Thread(mEventReporter);
@@ -255,8 +287,8 @@ public class AndouKun extends Activity implements SensorEventListener {
super.onResume();
// Preferences may have changed while we were paused.
- SharedPreferences prefs = getSharedPreferences(PREFERENCE_NAME, MODE_PRIVATE);
- final boolean debugLogs = prefs.getBoolean(PREFERENCE_ENABLE_DEBUG, false);
+ SharedPreferences prefs = getSharedPreferences(PreferenceConstants.PREFERENCE_NAME, MODE_PRIVATE);
+ final boolean debugLogs = prefs.getBoolean(PreferenceConstants.PREFERENCE_ENABLE_DEBUG, false);
if (VERSION < 0 || debugLogs) {
DebugLog.setDebugLogging(true);
@@ -269,20 +301,21 @@ public class AndouKun extends Activity implements SensorEventListener {
mGame.onResume(this, false);
- final boolean soundEnabled = prefs.getBoolean(PREFERENCE_SOUND_ENABLED, true);
- final boolean safeMode = prefs.getBoolean(PREFERENCE_SAFE_MODE, false);
- final boolean clickAttack = prefs.getBoolean(PREFERENCE_CLICK_ATTACK, true);
- final boolean tiltControls = prefs.getBoolean(PREFERENCE_TILT_CONTROLS, false);
- final int tiltSensitivity = prefs.getInt(PREFERENCE_TILT_SENSITIVITY, 50);
- final int movementSensitivity = prefs.getInt(PREFERENCE_MOVEMENT_SENSITIVITY, 100);
-
- final int leftKey = prefs.getInt(PREFERENCE_LEFT_KEY, KeyEvent.KEYCODE_DPAD_LEFT);
- final int rightKey = prefs.getInt(PREFERENCE_RIGHT_KEY, KeyEvent.KEYCODE_DPAD_RIGHT);
- final int jumpKey = prefs.getInt(PREFERENCE_JUMP_KEY, KeyEvent.KEYCODE_SPACE);
- final int attackKey = prefs.getInt(PREFERENCE_ATTACK_KEY, KeyEvent.KEYCODE_SHIFT_LEFT);
+ final boolean soundEnabled = prefs.getBoolean(PreferenceConstants.PREFERENCE_SOUND_ENABLED, true);
+ final boolean safeMode = prefs.getBoolean(PreferenceConstants.PREFERENCE_SAFE_MODE, false);
+ final boolean clickAttack = prefs.getBoolean(PreferenceConstants.PREFERENCE_CLICK_ATTACK, true);
+ final boolean tiltControls = prefs.getBoolean(PreferenceConstants.PREFERENCE_TILT_CONTROLS, false);
+ final int tiltSensitivity = prefs.getInt(PreferenceConstants.PREFERENCE_TILT_SENSITIVITY, 50);
+ final int movementSensitivity = prefs.getInt(PreferenceConstants.PREFERENCE_MOVEMENT_SENSITIVITY, 100);
+ final boolean onScreenControls = prefs.getBoolean(PreferenceConstants.PREFERENCE_SCREEN_CONTROLS, false);
+
+ final int leftKey = prefs.getInt(PreferenceConstants.PREFERENCE_LEFT_KEY, KeyEvent.KEYCODE_DPAD_LEFT);
+ final int rightKey = prefs.getInt(PreferenceConstants.PREFERENCE_RIGHT_KEY, KeyEvent.KEYCODE_DPAD_RIGHT);
+ final int jumpKey = prefs.getInt(PreferenceConstants.PREFERENCE_JUMP_KEY, KeyEvent.KEYCODE_SPACE);
+ final int attackKey = prefs.getInt(PreferenceConstants.PREFERENCE_ATTACK_KEY, KeyEvent.KEYCODE_SHIFT_LEFT);
mGame.setSoundEnabled(soundEnabled);
- mGame.setControlOptions(clickAttack, tiltControls, tiltSensitivity, movementSensitivity);
+ mGame.setControlOptions(clickAttack, tiltControls, tiltSensitivity, movementSensitivity, onScreenControls);
mGame.setKeyConfig(leftKey, rightKey, jumpKey, attackKey);
mGame.setSafeMode(safeMode);
@@ -332,7 +365,8 @@ public class AndouKun extends Activity implements SensorEventListener {
boolean result = true;
if (keyCode == KeyEvent.KEYCODE_BACK) {
final long time = System.currentTimeMillis();
- if (time - mLastRollTime > ROLL_TO_FACE_BUTTON_DELAY) {
+ if (time - mLastRollTime > ROLL_TO_FACE_BUTTON_DELAY &&
+ time - mLastTouchTime > ROLL_TO_FACE_BUTTON_DELAY) {
showDialog(QUIT_GAME_DIALOG);
result = true;
}
@@ -343,7 +377,8 @@ public class AndouKun extends Activity implements SensorEventListener {
mGame.onResume(this, true);
} else {
final long time = System.currentTimeMillis();
- if (time - mLastRollTime > ROLL_TO_FACE_BUTTON_DELAY) {
+ if (time - mLastRollTime > ROLL_TO_FACE_BUTTON_DELAY &&
+ time - mLastTouchTime > ROLL_TO_FACE_BUTTON_DELAY) {
showPauseMessage();
mGame.onPause();
}
@@ -440,6 +475,8 @@ public class AndouKun extends Activity implements SensorEventListener {
if (resultCode == RESULT_OK) {
mLevelRow = intent.getExtras().getInt("row");
mLevelIndex = intent.getExtras().getInt("index");
+ LevelTree.updateCompletedState(mLevelRow, 0);
+
saveGame();
mGame.setPendingLevel(LevelTree.get(mLevelRow, mLevelIndex));
@@ -451,6 +488,11 @@ public class AndouKun extends Activity implements SensorEventListener {
}
} else if (requestCode == ACTIVITY_ANIMATION_PLAYER) {
+ int lastAnimation = intent.getIntExtra("animation", -1);
+ // record ending events.
+ if (lastAnimation > -1) {
+ mGame.setLastEnding(lastAnimation);
+ }
// on finishing animation playback, force a level change.
onGameFlowEvent(GameFlowEvent.EVENT_GO_TO_NEXT_LEVEL, 0);
}
@@ -510,6 +552,10 @@ public class AndouKun extends Activity implements SensorEventListener {
mLevelRow++;
}
+ mTotalGameTime += mGame.getGameTime();
+ mRobotsDestroyed += mGame.getRobotsDestroyed();
+ mPearlsCollected += mGame.getPearlsCollected();
+ mPearlsTotal += mGame.getPearlsTotal();
if (mLevelRow < LevelTree.levels.size()) {
final LevelTree.Level currentLevel = LevelTree.get(mLevelRow, mLevelIndex);
@@ -517,6 +563,15 @@ public class AndouKun extends Activity implements SensorEventListener {
// go to the level select.
Intent i = new Intent(this, LevelSelectActivity.class);
startActivityForResult(i, ACTIVITY_CHANGE_LEVELS);
+ if (UIConstants.mOverridePendingTransition != null) {
+ try {
+ UIConstants.mOverridePendingTransition.invoke(AndouKun.this, R.anim.activity_fade_in, R.anim.activity_fade_out);
+ } catch (InvocationTargetException ite) {
+ DebugLog.d("Activity Transition", "Invocation Target Exception");
+ } catch (IllegalAccessException ie) {
+ DebugLog.d("Activity Transition", "Illegal Access Exception");
+ }
+ }
} else {
// go directly to the next level
mGame.setPendingLevel(currentLevel);
@@ -542,9 +597,23 @@ public class AndouKun extends Activity implements SensorEventListener {
// We beat the game!
mLevelRow = 0;
mLevelIndex = 0;
+ mLastEnding = mGame.getLastEnding();
+ mExtrasUnlocked = true;
saveGame();
mGame.stop();
+ Intent i = new Intent(this, GameOverActivity.class);
+ startActivity(i);
+ if (UIConstants.mOverridePendingTransition != null) {
+ try {
+ UIConstants.mOverridePendingTransition.invoke(AndouKun.this, R.anim.activity_fade_in, R.anim.activity_fade_out);
+ } catch (InvocationTargetException ite) {
+ DebugLog.d("Activity Transition", "Invocation Target Exception");
+ } catch (IllegalAccessException ie) {
+ DebugLog.d("Activity Transition", "Illegal Access Exception");
+ }
+ }
finish();
+
}
break;
case GameFlowEvent.EVENT_SHOW_DIARY:
@@ -553,6 +622,15 @@ public class AndouKun extends Activity implements SensorEventListener {
level.diaryCollected = true;
i.putExtra("text", level.dialogResources.diaryEntry);
startActivity(i);
+ if (UIConstants.mOverridePendingTransition != null) {
+ try {
+ UIConstants.mOverridePendingTransition.invoke(AndouKun.this, R.anim.activity_fade_in, R.anim.activity_fade_out);
+ } catch (InvocationTargetException ite) {
+ DebugLog.d("Activity Transition", "Invocation Target Exception");
+ } catch (IllegalAccessException ie) {
+ DebugLog.d("Activity Transition", "Illegal Access Exception");
+ }
+ }
break;
case GameFlowEvent.EVENT_SHOW_DIALOG_CHARACTER1:
@@ -576,6 +654,15 @@ public class AndouKun extends Activity implements SensorEventListener {
i = new Intent(this, AnimationPlayerActivity.class);
i.putExtra("animation", index);
startActivityForResult(i, ACTIVITY_ANIMATION_PLAYER);
+ if (UIConstants.mOverridePendingTransition != null) {
+ try {
+ UIConstants.mOverridePendingTransition.invoke(AndouKun.this, R.anim.activity_fade_in, R.anim.activity_fade_out);
+ } catch (InvocationTargetException ite) {
+ DebugLog.d("Activity Transition", "Invocation Target Exception");
+ } catch (IllegalAccessException ie) {
+ DebugLog.d("Activity Transition", "Illegal Access Exception");
+ }
+ }
break;
}
@@ -584,10 +671,18 @@ public class AndouKun extends Activity implements SensorEventListener {
protected void saveGame() {
if (mPrefsEditor != null) {
final int completed = LevelTree.packCompletedLevels(mLevelRow);
- mPrefsEditor.putInt(PREFERENCE_LEVEL_ROW, mLevelRow);
- mPrefsEditor.putInt(PREFERENCE_LEVEL_INDEX, mLevelIndex);
- mPrefsEditor.putInt(PREFERENCE_LEVEL_COMPLETED, completed);
- mPrefsEditor.putLong(PREFERENCE_SESSION_ID, mSessionId);
+ mPrefsEditor.putInt(PreferenceConstants.PREFERENCE_LEVEL_ROW, mLevelRow);
+ mPrefsEditor.putInt(PreferenceConstants.PREFERENCE_LEVEL_INDEX, mLevelIndex);
+ mPrefsEditor.putInt(PreferenceConstants.PREFERENCE_LEVEL_COMPLETED, completed);
+ mPrefsEditor.putLong(PreferenceConstants.PREFERENCE_SESSION_ID, mSessionId);
+ mPrefsEditor.putFloat(PreferenceConstants.PREFERENCE_TOTAL_GAME_TIME, mTotalGameTime);
+ mPrefsEditor.putInt(PreferenceConstants.PREFERENCE_LAST_ENDING, mLastEnding);
+ mPrefsEditor.putInt(PreferenceConstants.PREFERENCE_ROBOTS_DESTROYED, mRobotsDestroyed);
+ mPrefsEditor.putInt(PreferenceConstants.PREFERENCE_PEARLS_COLLECTED, mPearlsCollected);
+ mPrefsEditor.putInt(PreferenceConstants.PREFERENCE_PEARLS_TOTAL, mPearlsTotal);
+ mPrefsEditor.putInt(PreferenceConstants.PREFERENCE_LINEAR_MODE, mLinearMode);
+ mPrefsEditor.putBoolean(PreferenceConstants.PREFERENCE_EXTRAS_UNLOCKED, mExtrasUnlocked);
+ mPrefsEditor.putInt(PreferenceConstants.PREFERENCE_DIFFICULTY, mDifficulty);
mPrefsEditor.commit();
}
}
@@ -596,12 +691,19 @@ public class AndouKun extends Activity implements SensorEventListener {
if (mPauseMessage != null) {
mPauseMessage.setVisibility(View.VISIBLE);
}
+ if (mLevelNameBox != null && mLevelName != null) {
+ mLevelName.setText(LevelTree.get(mLevelRow, mLevelIndex).name);
+ mLevelNameBox.setVisibility(View.VISIBLE);
+ }
}
protected void hidePauseMessage() {
if (mPauseMessage != null) {
mPauseMessage.setVisibility(View.GONE);
}
+ if (mLevelNameBox != null) {
+ mLevelNameBox.setVisibility(View.GONE);
+ }
}
protected void showWaitMessage() {
@@ -628,9 +730,9 @@ public class AndouKun extends Activity implements SensorEventListener {
public void onSensorChanged(SensorEvent event) {
synchronized (this) {
if (event.sensor.getType() == Sensor.TYPE_ORIENTATION) {
- final float x = event.values[0];
- final float y = event.values[1];
- final float z = event.values[2];
+ final float x = event.values[1];
+ final float y = event.values[2];
+ final float z = event.values[0];
mGame.onOrientationEvent(x, y, z);
}
}
@@ -646,6 +748,15 @@ public class AndouKun extends Activity implements SensorEventListener {
.setPositiveButton(R.string.quit_game_dialog_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
finish();
+ if (UIConstants.mOverridePendingTransition != null) {
+ try {
+ UIConstants.mOverridePendingTransition.invoke(AndouKun.this, R.anim.activity_fade_in, R.anim.activity_fade_out);
+ } catch (InvocationTargetException ite) {
+ DebugLog.d("Activity Transition", "Invocation Target Exception");
+ } catch (IllegalAccessException ie) {
+ DebugLog.d("Activity Transition", "Illegal Access Exception");
+ }
+ }
}
})
.setNegativeButton(R.string.quit_game_dialog_cancel, null)
diff --git a/src/com/replica/replicaisland/AnimationPlayerActivity.java b/src/com/replica/replicaisland/AnimationPlayerActivity.java
index 02fd89d..7476e97 100644
--- a/src/com/replica/replicaisland/AnimationPlayerActivity.java
+++ b/src/com/replica/replicaisland/AnimationPlayerActivity.java
@@ -17,6 +17,8 @@
package com.replica.replicaisland;
+import java.lang.reflect.InvocationTargetException;
+
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
@@ -49,6 +51,15 @@ public class AnimationPlayerActivity extends Activity {
@Override
public void handleMessage(Message msg) {
AnimationPlayerActivity.this.finish();
+ if (UIConstants.mOverridePendingTransition != null) {
+ try {
+ UIConstants.mOverridePendingTransition.invoke(AnimationPlayerActivity.this, R.anim.activity_fade_in, R.anim.activity_fade_out);
+ } catch (InvocationTargetException ite) {
+ DebugLog.d("Activity Transition", "Invocation Target Exception");
+ } catch (IllegalAccessException ie) {
+ DebugLog.d("Activity Transition", "Illegal Access Exception");
+ }
+ }
}
public void sleep(long delayMillis) {
@@ -137,6 +148,9 @@ public class AnimationPlayerActivity extends Activity {
}
+ // Pass the calling intent back so that we can figure out which animation just played.
+ setResult(RESULT_OK, callingIntent);
+
}
@Override
diff --git a/src/com/replica/replicaisland/BabyDifficultyConstants.java b/src/com/replica/replicaisland/BabyDifficultyConstants.java
new file mode 100644
index 0000000..ede24ce
--- /dev/null
+++ b/src/com/replica/replicaisland/BabyDifficultyConstants.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.replica.replicaisland;
+
+public class BabyDifficultyConstants extends DifficultyConstants {
+
+ private static final float FUEL_AIR_REFILL_SPEED = 0.22f;
+ private static final float FUEL_GROUND_REFILL_SPEED = 4.0f;
+ public static final int MAX_PLAYER_LIFE = 5;
+ private static final int COINS_PER_POWERUP = 15;
+
+ public static final float GLOW_DURATION = 20.0f;
+
+ // DDA boosts
+ private static final int DDA_STAGE_1_ATTEMPTS = 3;
+ private static final int DDA_STAGE_2_ATTEMPTS = 5;
+ private static final int DDA_STAGE_1_LIFE_BOOST = 1;
+ private static final int DDA_STAGE_2_LIFE_BOOST = 3;
+ private static final float DDA_STAGE_1_FUEL_AIR_REFILL_SPEED = 0.30f;
+ private static final float DDA_STAGE_2_FUEL_AIR_REFILL_SPEED = 0.40f;
+
+ @Override
+ public float getFuelAirRefillSpeed() {
+ return FUEL_AIR_REFILL_SPEED;
+ }
+
+ @Override
+ public float getFuelGroundRefillSpeed() {
+ return FUEL_GROUND_REFILL_SPEED;
+ }
+
+ @Override
+ public int getMaxPlayerLife() {
+ return MAX_PLAYER_LIFE;
+ }
+
+ @Override
+ public int getCoinsPerPowerup() {
+ return COINS_PER_POWERUP;
+ }
+
+ @Override
+ public float getGlowDuration() {
+ return GLOW_DURATION;
+ }
+
+ @Override
+ public int getDDAStage1Attempts() {
+ return DDA_STAGE_1_ATTEMPTS;
+ }
+
+ @Override
+ public int getDDAStage2Attempts() {
+ return DDA_STAGE_2_ATTEMPTS;
+ }
+
+ @Override
+ public int getDDAStage1LifeBoost() {
+ return DDA_STAGE_1_LIFE_BOOST;
+ }
+
+ @Override
+ public int getDDAStage2LifeBoost() {
+ return DDA_STAGE_2_LIFE_BOOST;
+ }
+
+ @Override
+ public float getDDAStage1FuelAirRefillSpeed() {
+ return DDA_STAGE_1_FUEL_AIR_REFILL_SPEED;
+ }
+
+ @Override
+ public float getDDAStage2FuelAirRefillSpeed() {
+ return DDA_STAGE_2_FUEL_AIR_REFILL_SPEED;
+ }
+
+}
diff --git a/src/com/replica/replicaisland/ButtonConstants.java b/src/com/replica/replicaisland/ButtonConstants.java
index bfde6ed..029bbdb 100644
--- a/src/com/replica/replicaisland/ButtonConstants.java
+++ b/src/com/replica/replicaisland/ButtonConstants.java
@@ -26,4 +26,11 @@ public final class ButtonConstants {
public static final int STOMP_BUTTON_REGION_Y = 0;
public static final int STOMP_BUTTON_REGION_WIDTH = 70;
public static final int STOMP_BUTTON_REGION_HEIGHT = 80;
+
+ public static final int MOVEMENT_SLIDER_REGION_X = 0;
+ public static final int MOVEMENT_SLIDER_REGION_Y = 0;
+ public static final int MOVEMENT_SLIDER_REGION_WIDTH = 220;
+ public static final int MOVEMENT_SLIDER_REGION_HEIGHT = 200;
+ public static final int MOVEMENT_SLIDER_BAR_WIDTH = 140;
+ public static final int MOVEMENT_SLIDER_X = 20;
}
diff --git a/src/com/replica/replicaisland/ContextParameters.java b/src/com/replica/replicaisland/ContextParameters.java
index c2689ab..b335685 100644
--- a/src/com/replica/replicaisland/ContextParameters.java
+++ b/src/com/replica/replicaisland/ContextParameters.java
@@ -29,6 +29,7 @@ public class ContextParameters extends BaseObject {
public float viewScaleY;
public boolean supportsDrawTexture;
public boolean supportsVBOs;
+ public int difficulty;
public ContextParameters() {
super();
diff --git a/src/com/replica/replicaisland/CrusherAndouComponent.java b/src/com/replica/replicaisland/CrusherAndouComponent.java
new file mode 100644
index 0000000..a4daaee
--- /dev/null
+++ b/src/com/replica/replicaisland/CrusherAndouComponent.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.replica.replicaisland;
+
+public class CrusherAndouComponent extends GameComponent {
+ private ChangeComponentsComponent mSwap;
+
+ public CrusherAndouComponent() {
+ super();
+ setPhase(ComponentPhases.THINK.ordinal());
+ reset();
+ }
+
+ @Override
+ public void reset() {
+ mSwap = null;
+ }
+
+ @Override
+ public void update(float timeDelta, BaseObject parent) {
+ GameObject parentObject = (GameObject)parent;
+
+ if (mSwap.getCurrentlySwapped()) {
+ if (parentObject.touchingGround()) {
+ parentObject.setCurrentAction(GameObject.ActionType.IDLE);
+ }
+ } else {
+ InputSystem input = sSystemRegistry.inputSystem;
+ if (input.getTouchScreen().getTriggered(sSystemRegistry.timeSystem.getGameTime())) {
+ parentObject.setCurrentAction(GameObject.ActionType.ATTACK);
+ mSwap.activate(parentObject);
+ }
+ }
+ }
+
+ public void setSwap(ChangeComponentsComponent swap) {
+ mSwap = swap;
+ }
+}
diff --git a/src/com/replica/replicaisland/DiaryActivity.java b/src/com/replica/replicaisland/DiaryActivity.java
index 5a2778c..1d080c6 100644
--- a/src/com/replica/replicaisland/DiaryActivity.java
+++ b/src/com/replica/replicaisland/DiaryActivity.java
@@ -16,6 +16,8 @@
package com.replica.replicaisland;
+import java.lang.reflect.InvocationTargetException;
+
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
@@ -31,7 +33,16 @@ public class DiaryActivity extends Activity {
private OnClickListener mKillDiaryListener = new OnClickListener() {
public void onClick(View arg0) {
- finish();
+ finish();
+ if (UIConstants.mOverridePendingTransition != null) {
+ try {
+ UIConstants.mOverridePendingTransition.invoke(DiaryActivity.this, R.anim.activity_fade_in, R.anim.activity_fade_out);
+ } catch (InvocationTargetException ite) {
+ DebugLog.d("Activity Transition", "Invocation Target Exception");
+ } catch (IllegalAccessException ie) {
+ DebugLog.d("Activity Transition", "Illegal Access Exception");
+ }
+ }
}
};
diff --git a/src/com/replica/replicaisland/DifficultyConstants.java b/src/com/replica/replicaisland/DifficultyConstants.java
new file mode 100644
index 0000000..2d020dc
--- /dev/null
+++ b/src/com/replica/replicaisland/DifficultyConstants.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.replica.replicaisland;
+
+public abstract class DifficultyConstants {
+ public abstract float getFuelAirRefillSpeed();
+ public abstract float getFuelGroundRefillSpeed();
+ public abstract int getMaxPlayerLife();
+ public abstract int getCoinsPerPowerup();
+ public abstract float getGlowDuration();
+ public abstract int getDDAStage1Attempts();
+ public abstract int getDDAStage2Attempts();
+ public abstract int getDDAStage1LifeBoost();
+ public abstract int getDDAStage2LifeBoost();
+ public abstract float getDDAStage1FuelAirRefillSpeed();
+ public abstract float getDDAStage2FuelAirRefillSpeed();
+}
diff --git a/src/com/replica/replicaisland/DifficultyMenuActivity.java b/src/com/replica/replicaisland/DifficultyMenuActivity.java
new file mode 100644
index 0000000..7e01b0c
--- /dev/null
+++ b/src/com/replica/replicaisland/DifficultyMenuActivity.java
@@ -0,0 +1,172 @@
+package com.replica.replicaisland;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.media.AudioManager;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+
+public class DifficultyMenuActivity extends Activity {
+ private View mBabyButton;
+ private View mKidsButton;
+ private View mAdultsButton;
+ private View mBackground;
+ private View mBabyText;
+ private View mKidsText;
+ private View mAdultsText;
+ private Animation mButtonFlickerAnimation;
+ private Animation mFadeOutAnimation;
+ private Animation mAlternateFadeOutAnimation;
+
+ private View.OnClickListener sBabyButtonListener = new View.OnClickListener() {
+ public void onClick(View v) {
+
+ Intent i = new Intent(getBaseContext(), AndouKun.class);
+ i.putExtras(getIntent());
+ i.putExtra("difficulty", 0);
+
+ v.startAnimation(mButtonFlickerAnimation);
+ mFadeOutAnimation.setAnimationListener(new StartActivityAfterAnimation(i));
+ mBackground.startAnimation(mFadeOutAnimation);
+ mKidsButton.startAnimation(mAlternateFadeOutAnimation);
+ mAdultsButton.startAnimation(mAlternateFadeOutAnimation);
+
+ mBabyText.startAnimation(mAlternateFadeOutAnimation);
+ mKidsText.startAnimation(mAlternateFadeOutAnimation);
+ mAdultsText.startAnimation(mAlternateFadeOutAnimation);
+ }
+ };
+
+ private View.OnClickListener sKidsButtonListener = new View.OnClickListener() {
+ public void onClick(View v) {
+
+ Intent i = new Intent(getBaseContext(), AndouKun.class);
+ i.putExtras(getIntent());
+ i.putExtra("difficulty", 1);
+
+ v.startAnimation(mButtonFlickerAnimation);
+ mFadeOutAnimation.setAnimationListener(new StartActivityAfterAnimation(i));
+ mBackground.startAnimation(mFadeOutAnimation);
+ mBabyButton.startAnimation(mAlternateFadeOutAnimation);
+ mAdultsButton.startAnimation(mAlternateFadeOutAnimation);
+
+ mBabyText.startAnimation(mAlternateFadeOutAnimation);
+ mKidsText.startAnimation(mAlternateFadeOutAnimation);
+ mAdultsText.startAnimation(mAlternateFadeOutAnimation);
+ }
+ };
+
+ private View.OnClickListener sAdultsButtonListener = new View.OnClickListener() {
+ public void onClick(View v) {
+
+ Intent i = new Intent(getBaseContext(), AndouKun.class);
+ i.putExtras(getIntent());
+ i.putExtra("difficulty", 2);
+
+ v.startAnimation(mButtonFlickerAnimation);
+ mFadeOutAnimation.setAnimationListener(new StartActivityAfterAnimation(i));
+ mBackground.startAnimation(mFadeOutAnimation);
+ mBabyButton.startAnimation(mAlternateFadeOutAnimation);
+ mKidsButton.startAnimation(mAlternateFadeOutAnimation);
+
+ mBabyText.startAnimation(mAlternateFadeOutAnimation);
+ mKidsText.startAnimation(mAlternateFadeOutAnimation);
+ mAdultsText.startAnimation(mAlternateFadeOutAnimation);
+ }
+ };
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.difficulty_menu);
+
+
+ mBabyButton = findViewById(R.id.babyButton);
+ mKidsButton = findViewById(R.id.kidsButton);
+ mAdultsButton = findViewById(R.id.adultsButton);
+ mBabyText = findViewById(R.id.babyText);
+ mKidsText = findViewById(R.id.kidsText);
+ mAdultsText = findViewById(R.id.adultsText);
+ mBackground = findViewById(R.id.mainMenuBackground);
+
+ mBabyButton.setOnClickListener(sBabyButtonListener);
+ mKidsButton.setOnClickListener(sKidsButtonListener);
+ mAdultsButton.setOnClickListener(sAdultsButtonListener);
+
+ mButtonFlickerAnimation = AnimationUtils.loadAnimation(this, R.anim.button_flicker);
+ mFadeOutAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
+ mAlternateFadeOutAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
+
+ // Keep the volume control type consistent across all activities.
+ setVolumeControlStream(AudioManager.STREAM_MUSIC);
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ boolean result = true;
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ finish();
+
+ if (UIConstants.mOverridePendingTransition != null) {
+ try {
+ UIConstants.mOverridePendingTransition.invoke(DifficultyMenuActivity.this, R.anim.activity_fade_in, R.anim.activity_fade_out);
+ } catch (InvocationTargetException ite) {
+ DebugLog.d("Activity Transition", "Invocation Target Exception");
+ } catch (IllegalAccessException ie) {
+ DebugLog.d("Activity Transition", "Illegal Access Exception");
+ }
+ }
+ } else {
+ result = super.onKeyDown(keyCode, event);
+ }
+ return result;
+ }
+
+ protected class StartActivityAfterAnimation implements Animation.AnimationListener {
+ private Intent mIntent;
+
+ StartActivityAfterAnimation(Intent intent) {
+ mIntent = intent;
+ }
+
+
+ public void onAnimationEnd(Animation animation) {
+ mBabyButton.setVisibility(View.INVISIBLE);
+ mBabyButton.clearAnimation();
+ mKidsButton.setVisibility(View.INVISIBLE);
+ mKidsButton.clearAnimation();
+ mAdultsButton.setVisibility(View.INVISIBLE);
+ mAdultsButton.clearAnimation();
+ startActivity(mIntent);
+ finish(); // This activity dies when it spawns a new intent.
+
+ if (UIConstants.mOverridePendingTransition != null) {
+ try {
+ UIConstants.mOverridePendingTransition.invoke(DifficultyMenuActivity.this, R.anim.activity_fade_in, R.anim.activity_fade_out);
+ } catch (InvocationTargetException ite) {
+ DebugLog.d("Activity Transition", "Invocation Target Exception");
+ } catch (IllegalAccessException ie) {
+ DebugLog.d("Activity Transition", "Illegal Access Exception");
+ }
+ }
+ }
+
+ public void onAnimationRepeat(Animation animation) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onAnimationStart(Animation animation) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+}
diff --git a/src/com/replica/replicaisland/DrawableFactory.java b/src/com/replica/replicaisland/DrawableFactory.java
index 10e8db3..02d6b9c 100644
--- a/src/com/replica/replicaisland/DrawableFactory.java
+++ b/src/com/replica/replicaisland/DrawableFactory.java
@@ -23,7 +23,7 @@ package com.replica.replicaisland;
* pools of objects so no actual allocations occur after bootstrap.
*/
public class DrawableFactory extends BaseObject {
- private final static int BITMAP_POOL_SIZE = 512;
+ private final static int BITMAP_POOL_SIZE = 768;
private DrawableBitmapPool mBitmapPool;
private ScrollableBitmapPool mScrollableBitmapPool;
diff --git a/src/com/replica/replicaisland/EventRecorder.java b/src/com/replica/replicaisland/EventRecorder.java
index a8e4d4b..315c10c 100644
--- a/src/com/replica/replicaisland/EventRecorder.java
+++ b/src/com/replica/replicaisland/EventRecorder.java
@@ -17,12 +17,21 @@
package com.replica.replicaisland;
public class EventRecorder extends BaseObject {
+ public final static int COUNTER_ROBOTS_DESTROYED = 0;
+ public final static int COUNTER_PEARLS_COLLECTED = 1;
+ public final static int COUNTER_PEARLS_TOTAL = 2;
+
private Vector2 mLastDeathPosition = new Vector2();
+ private int mLastEnding = -1;
+ private int mRobotsDestroyed = 0;
+ private int mPearlsCollected = 0;
+ private int mPearlsTotal = 0;
@Override
public void reset() {
- // TODO Auto-generated method stub
-
+ mRobotsDestroyed = 0;
+ mPearlsCollected = 0;
+ mPearlsTotal = 0;
}
synchronized void setLastDeathPosition(Vector2 position) {
@@ -32,5 +41,34 @@ public class EventRecorder extends BaseObject {
synchronized Vector2 getLastDeathPosition() {
return mLastDeathPosition;
}
+
+ synchronized void setLastEnding(int ending) {
+ mLastEnding = ending;
+ }
+
+ synchronized int getLastEnding() {
+ return mLastEnding;
+ }
+
+ synchronized void incrementEventCounter(int event) {
+ if (event == COUNTER_ROBOTS_DESTROYED) {
+ mRobotsDestroyed++;
+ } else if (event == COUNTER_PEARLS_COLLECTED) {
+ mPearlsCollected++;
+ } else if (event == COUNTER_PEARLS_TOTAL) {
+ mPearlsTotal++;
+ }
+ }
+
+ synchronized int getRobotsDestroyed() {
+ return mRobotsDestroyed;
+ }
+
+ synchronized int getPearlsCollected() {
+ return mPearlsCollected;
+ }
+ synchronized int getPearlsTotal() {
+ return mPearlsTotal;
+ }
}
diff --git a/src/com/replica/replicaisland/ExtrasMenuActivity.java b/src/com/replica/replicaisland/ExtrasMenuActivity.java
new file mode 100644
index 0000000..bdf7fe1
--- /dev/null
+++ b/src/com/replica/replicaisland/ExtrasMenuActivity.java
@@ -0,0 +1,235 @@
+package com.replica.replicaisland;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.media.AudioManager;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+
+public class ExtrasMenuActivity extends Activity {
+ private View mLinearModeButton;
+ private View mLevelSelectButton;
+ private View mControlsButton;
+ private View mBackground;
+ private View mLevelSelectLocked;
+ private View mLinearModeLocked;
+ private Animation mButtonFlickerAnimation;
+ private Animation mFadeOutAnimation;
+ private Animation mAlternateFadeOutAnimation;
+ private Animation mLockedAnimation;
+
+ private int mPendingGameStart;
+
+
+ public static final int NEW_GAME_DIALOG = 0;
+ public static final int EXTRAS_LOCKED_DIALOG = 1;
+
+ private static final int START_LINEAR_MODE = 0;
+ private static final int START_LEVEL_SELECT = 1;
+
+
+ private View.OnClickListener sLinearModeButtonListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ SharedPreferences prefs = getSharedPreferences(PreferenceConstants.PREFERENCE_NAME, MODE_PRIVATE);
+ final int row = prefs.getInt(PreferenceConstants.PREFERENCE_LEVEL_ROW, 0);
+ final int index = prefs.getInt(PreferenceConstants.PREFERENCE_LEVEL_INDEX, 0);
+ if (row != 0 || index != 0) {
+ mPendingGameStart = START_LINEAR_MODE;
+ showDialog(NEW_GAME_DIALOG);
+ } else {
+ startGame(START_LINEAR_MODE);
+ }
+ }
+ };
+
+ private View.OnClickListener sLevelSelectButtonListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ SharedPreferences prefs = getSharedPreferences(PreferenceConstants.PREFERENCE_NAME, MODE_PRIVATE);
+ final int row = prefs.getInt(PreferenceConstants.PREFERENCE_LEVEL_ROW, 0);
+ final int index = prefs.getInt(PreferenceConstants.PREFERENCE_LEVEL_INDEX, 0);
+ if (row != 0 || index != 0) {
+ mPendingGameStart = START_LEVEL_SELECT;
+ showDialog(NEW_GAME_DIALOG);
+ } else {
+ startGame(START_LEVEL_SELECT);
+ }
+ }
+ };
+
+ private View.OnClickListener sLockedSelectButtonListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ showDialog(EXTRAS_LOCKED_DIALOG);
+ }
+ };
+
+ private View.OnClickListener sControlsButtonListener = new View.OnClickListener() {
+ public void onClick(View v) {
+
+ Intent i = new Intent(getBaseContext(), SetPreferencesActivity.class);
+ i.putExtra("controlConfig", true);
+
+ v.startAnimation(mButtonFlickerAnimation);
+ mFadeOutAnimation.setAnimationListener(new StartActivityAfterAnimation(i));
+ mBackground.startAnimation(mFadeOutAnimation);
+ mLinearModeButton.startAnimation(mAlternateFadeOutAnimation);
+ mLevelSelectButton.startAnimation(mAlternateFadeOutAnimation);
+ }
+ };
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.extras_menu);
+
+ SharedPreferences prefs = getSharedPreferences(PreferenceConstants.PREFERENCE_NAME, MODE_PRIVATE);
+ final boolean extrasUnlocked = prefs.getBoolean(PreferenceConstants.PREFERENCE_EXTRAS_UNLOCKED, false);
+
+ mLinearModeButton = findViewById(R.id.linearModeButton);
+ mLevelSelectButton = findViewById(R.id.levelSelectButton);
+ mControlsButton = findViewById(R.id.controlsButton);
+ mLinearModeLocked = findViewById(R.id.linearModeLocked);
+ mLevelSelectLocked = findViewById(R.id.levelSelectLocked);
+
+ mBackground = findViewById(R.id.mainMenuBackground);
+
+ mButtonFlickerAnimation = AnimationUtils.loadAnimation(this, R.anim.button_flicker);
+ mFadeOutAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
+ mAlternateFadeOutAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
+
+
+ if (extrasUnlocked) {
+ mLinearModeButton.setOnClickListener(sLinearModeButtonListener);
+ mLevelSelectButton.setOnClickListener(sLevelSelectButtonListener);
+ mLinearModeLocked.setVisibility(View.GONE);
+ mLevelSelectLocked.setVisibility(View.GONE);
+ } else {
+ mLockedAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_in_out);
+
+ mLinearModeButton.setOnClickListener(sLockedSelectButtonListener);
+ mLevelSelectButton.setOnClickListener(sLockedSelectButtonListener);
+ mLinearModeLocked.startAnimation(mLockedAnimation);
+ mLevelSelectLocked.startAnimation(mLockedAnimation);
+ }
+ mControlsButton.setOnClickListener(sControlsButtonListener);
+
+
+
+ // Keep the volume control type consistent across all activities.
+ setVolumeControlStream(AudioManager.STREAM_MUSIC);
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ boolean result = true;
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ finish();
+
+ if (UIConstants.mOverridePendingTransition != null) {
+ try {
+ UIConstants.mOverridePendingTransition.invoke(ExtrasMenuActivity.this, R.anim.activity_fade_in, R.anim.activity_fade_out);
+ } catch (InvocationTargetException ite) {
+ DebugLog.d("Activity Transition", "Invocation Target Exception");
+ } catch (IllegalAccessException ie) {
+ DebugLog.d("Activity Transition", "Illegal Access Exception");
+ }
+ }
+ } else {
+ result = super.onKeyDown(keyCode, event);
+ }
+ return result;
+ }
+
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ Dialog dialog = null;
+ if (id == NEW_GAME_DIALOG) {
+
+ dialog = new AlertDialog.Builder(this)
+ .setTitle(R.string.new_game_dialog_title)
+ .setPositiveButton(R.string.new_game_dialog_ok, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ startGame(mPendingGameStart);
+ }
+ })
+ .setNegativeButton(R.string.new_game_dialog_cancel, null)
+ .setMessage(R.string.new_game_dialog_message)
+ .create();
+ } else if (id == EXTRAS_LOCKED_DIALOG) {
+ dialog = new AlertDialog.Builder(this)
+ .setTitle(R.string.extras_locked_dialog_title)
+ .setPositiveButton(R.string.extras_locked_dialog_ok, null)
+ .setMessage(R.string.extras_locked_dialog_message)
+ .create();
+ }
+ return dialog;
+ }
+
+ protected void startGame(int type) {
+ if (type == START_LINEAR_MODE) {
+ Intent i = new Intent(getBaseContext(), DifficultyMenuActivity.class);
+ i.putExtra("linearMode", true);
+ i.putExtra("newGame", true);
+ mLinearModeButton.startAnimation(mButtonFlickerAnimation);
+ mButtonFlickerAnimation.setAnimationListener(new StartActivityAfterAnimation(i));
+
+ } else if (type == START_LEVEL_SELECT) {
+ Intent i = new Intent(getBaseContext(), DifficultyMenuActivity.class);
+ i.putExtra("startAtLevelSelect", true);
+ i.putExtra("newGame", true);
+ mLevelSelectButton.startAnimation(mButtonFlickerAnimation);
+ mButtonFlickerAnimation.setAnimationListener(new StartActivityAfterAnimation(i));
+
+ }
+ }
+
+ protected class StartActivityAfterAnimation implements Animation.AnimationListener {
+ private Intent mIntent;
+
+ StartActivityAfterAnimation(Intent intent) {
+ mIntent = intent;
+ }
+
+
+ public void onAnimationEnd(Animation animation) {
+ mLinearModeButton.setVisibility(View.INVISIBLE);
+ mLinearModeButton.clearAnimation();
+ mLevelSelectButton.setVisibility(View.INVISIBLE);
+ mLevelSelectButton.clearAnimation();
+ mControlsButton.setVisibility(View.INVISIBLE);
+ mControlsButton.clearAnimation();
+ startActivity(mIntent);
+ finish();
+ if (UIConstants.mOverridePendingTransition != null) {
+ try {
+ UIConstants.mOverridePendingTransition.invoke(ExtrasMenuActivity.this, R.anim.activity_fade_in, R.anim.activity_fade_out);
+ } catch (InvocationTargetException ite) {
+ DebugLog.d("Activity Transition", "Invocation Target Exception");
+ } catch (IllegalAccessException ie) {
+ DebugLog.d("Activity Transition", "Illegal Access Exception");
+ }
+ }
+ }
+
+ public void onAnimationRepeat(Animation animation) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onAnimationStart(Animation animation) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+}
diff --git a/src/com/replica/replicaisland/FadeDrawableComponent.java b/src/com/replica/replicaisland/FadeDrawableComponent.java
index bfcb301..e47cb48 100644
--- a/src/com/replica/replicaisland/FadeDrawableComponent.java
+++ b/src/com/replica/replicaisland/FadeDrawableComponent.java
@@ -153,4 +153,8 @@ public class FadeDrawableComponent extends GameComponent {
public void setRenderComponent(RenderComponent component) {
mRenderComponent = component;
}
+
+ public void resetPhase() {
+ mActivateTime = 0.0f;
+ }
}
diff --git a/src/com/replica/replicaisland/GLSurfaceView.java b/src/com/replica/replicaisland/GLSurfaceView.java
index d187e40..2eb5737 100644
--- a/src/com/replica/replicaisland/GLSurfaceView.java
+++ b/src/com/replica/replicaisland/GLSurfaceView.java
@@ -1283,7 +1283,9 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback
// to figure this out.
if (framesSinceResetHack > 1 || !mSafeMode) {
mRenderer.onDrawFrame(gl);
- }
+ } else {
+ DebugLog.w("GLThread", "Safe Mode Wait...");
+ }
framesSinceResetHack++;
diff --git a/src/com/replica/replicaisland/Game.java b/src/com/replica/replicaisland/Game.java
index 95b3517..f60db67 100644
--- a/src/com/replica/replicaisland/Game.java
+++ b/src/com/replica/replicaisland/Game.java
@@ -17,8 +17,10 @@
package com.replica.replicaisland;
import android.content.Context;
+import android.os.Build;
import android.view.KeyEvent;
import android.view.MotionEvent;
+import android.view.WindowManager;
import android.widget.Toast;
/**
@@ -40,6 +42,7 @@ public class Game extends AllocationGuard {
private LevelTree.Level mLastLevel;
private boolean mGLDataLoaded;
private ContextParameters mContextParameters;
+ private TouchFilter mTouchFilter;
public Game() {
super();
@@ -56,7 +59,7 @@ public class Game extends AllocationGuard {
* isn't yet available.
* @param context
*/
- public void bootstrap(Context context, int viewWidth, int viewHeight, int gameWidth, int gameHeight) {
+ public void bootstrap(Context context, int viewWidth, int viewHeight, int gameWidth, int gameHeight, int difficulty) {
if (!mBootstrapComplete) {
mRenderer = new GameRenderer(context, this, gameWidth, gameHeight);
@@ -73,7 +76,15 @@ public class Game extends AllocationGuard {
params.viewScaleX = (float)viewWidth / gameWidth;
params.viewScaleY = (float)viewHeight / gameHeight;
params.context = context;
+ params.difficulty = difficulty;
BaseObject.sSystemRegistry.contextParameters = params;
+
+ final int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
+ if (sdkVersion < Build.VERSION_CODES.ECLAIR) {
+ mTouchFilter = new SingleTouchFilter();
+ } else {
+ mTouchFilter = new MultiTouchFilter();
+ }
// Short-term textures are cleared between levels.
TextureLibrary shortTermTextureLibrary = new TextureLibrary();
@@ -96,6 +107,10 @@ public class Game extends AllocationGuard {
InputSystem input = new InputSystem();
BaseObject.sSystemRegistry.inputSystem = input;
BaseObject.sSystemRegistry.registerForReset(input);
+
+ WindowManager windowMgr = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
+ int rotationIndex = windowMgr.getDefaultDisplay().getOrientation();
+ input.setScreenRotation(rotationIndex);
InputGameInterface inputInterface = new InputGameInterface();
gameRoot.add(inputInterface);
@@ -166,7 +181,13 @@ public class Game extends AllocationGuard {
new DrawableBitmap(longTermTextureLibrary.allocateTexture(
R.drawable.ui_button_stomp_off), 0, 0),
new DrawableBitmap(longTermTextureLibrary.allocateTexture(
- R.drawable.ui_button_stomp_on), 0, 0));
+ R.drawable.ui_button_stomp_on), 0, 0),
+ new DrawableBitmap(longTermTextureLibrary.allocateTexture(
+ R.drawable.ui_movement_slider_base), 0, 0),
+ new DrawableBitmap(longTermTextureLibrary.allocateTexture(
+ R.drawable.ui_movement_slider_button_off), 0, 0),
+ new DrawableBitmap(longTermTextureLibrary.allocateTexture(
+ R.drawable.ui_movement_slider_button_on), 0, 0));
Texture[] digitTextures = {
longTermTextureLibrary.allocateTexture(R.drawable.ui_0),
longTermTextureLibrary.allocateTexture(R.drawable.ui_1),
@@ -209,7 +230,9 @@ public class Game extends AllocationGuard {
BaseObject.sSystemRegistry.vibrationSystem = new VibrationSystem();
- BaseObject.sSystemRegistry.eventRecorder = new EventRecorder();
+ EventRecorder eventRecorder = new EventRecorder();
+ BaseObject.sSystemRegistry.eventRecorder = eventRecorder;
+ BaseObject.sSystemRegistry.registerForReset(eventRecorder);
gameRoot.add(collision);
@@ -252,6 +275,9 @@ public class Game extends AllocationGuard {
// Reset the level
BaseObject.sSystemRegistry.levelSystem.reset();
+ // Ensure sounds have stopped.
+ BaseObject.sSystemRegistry.soundSystem.stopAll();
+
// Reset systems that need it.
BaseObject.sSystemRegistry.reset();
@@ -278,6 +304,9 @@ public class Game extends AllocationGuard {
manager.destroyAll();
manager.commitUpdates();
+ // Ensure sounds have stopped.
+ BaseObject.sSystemRegistry.soundSystem.stopAll();
+
// Reset systems that need it.
BaseObject.sSystemRegistry.reset();
@@ -306,7 +335,6 @@ public class Game extends AllocationGuard {
mGLDataLoaded = true;
-
mCurrentLevel = level;
mPendingLevel = null;
@@ -318,6 +346,7 @@ public class Game extends AllocationGuard {
hud.startFade(true, 1.0f);
}
+
CustomToastSystem toast = BaseObject.sSystemRegistry.customToastSystem;
if (toast != null) {
if (level.inThePast) {
@@ -393,18 +422,13 @@ public class Game extends AllocationGuard {
public boolean onTouchEvent(MotionEvent event) {
if (mRunning) {
- if (event.getAction() == MotionEvent.ACTION_UP) {
- BaseObject.sSystemRegistry.inputSystem.touchUp(event.getRawX() * (1.0f / mContextParameters.viewScaleX),
- event.getRawY() * (1.0f / mContextParameters.viewScaleY));
- } else {
- BaseObject.sSystemRegistry.inputSystem.touchDown(event.getRawX() * (1.0f / mContextParameters.viewScaleX),
- event.getRawY() * (1.0f / mContextParameters.viewScaleY));
- }
-
+ mTouchFilter.updateTouch(event);
}
return true;
}
+
+
public boolean onKeyDownEvent(int keyCode) {
boolean result = false;
if (mRunning) {
@@ -493,11 +517,14 @@ public class Game extends AllocationGuard {
BaseObject.sSystemRegistry.soundSystem.setSoundEnabled(soundEnabled);
}
- public void setControlOptions(boolean clickAttack, boolean tiltControls, int tiltSensitivity, int movementSensitivity) {
+ public void setControlOptions(boolean clickAttack,
+ boolean tiltControls, int tiltSensitivity, int movementSensitivity, boolean onScreenControls) {
BaseObject.sSystemRegistry.inputGameInterface.setUseClickForAttack(clickAttack);
BaseObject.sSystemRegistry.inputGameInterface.setUseOrientationForMovement(tiltControls);
BaseObject.sSystemRegistry.inputGameInterface.setOrientationMovementSensitivity((tiltSensitivity / 100.0f));
BaseObject.sSystemRegistry.inputGameInterface.setMovementSensitivity((movementSensitivity / 100.0f));
+ BaseObject.sSystemRegistry.inputGameInterface.setUseOnScreenControls(onScreenControls);
+ BaseObject.sSystemRegistry.hudSystem.setMovementSliderMode(onScreenControls);
}
public void setSafeMode(boolean safe) {
@@ -511,6 +538,14 @@ public class Game extends AllocationGuard {
public Vector2 getLastDeathPosition() {
return BaseObject.sSystemRegistry.eventRecorder.getLastDeathPosition();
}
+
+ public void setLastEnding(int ending) {
+ BaseObject.sSystemRegistry.eventRecorder.setLastEnding(ending);
+ }
+
+ public int getLastEnding() {
+ return BaseObject.sSystemRegistry.eventRecorder.getLastEnding();
+ }
public boolean isPaused() {
return (mRunning && mGameThread != null && mGameThread.getPaused());
@@ -521,4 +556,15 @@ public class Game extends AllocationGuard {
BaseObject.sSystemRegistry.inputGameInterface.setKeys(leftKey, rightKey, jumpKey, attackKey);
}
+ public int getRobotsDestroyed() {
+ return BaseObject.sSystemRegistry.eventRecorder.getRobotsDestroyed();
+ }
+
+ public int getPearlsCollected() {
+ return BaseObject.sSystemRegistry.eventRecorder.getPearlsCollected();
+ }
+
+ public int getPearlsTotal() {
+ return BaseObject.sSystemRegistry.eventRecorder.getPearlsTotal();
+ }
}
diff --git a/src/com/replica/replicaisland/GameObjectFactory.java b/src/com/replica/replicaisland/GameObjectFactory.java
index 3dc752b..8700e2e 100644
--- a/src/com/replica/replicaisland/GameObjectFactory.java
+++ b/src/com/replica/replicaisland/GameObjectFactory.java
@@ -23,6 +23,7 @@ import com.replica.replicaisland.CollisionParameters.HitType;
import com.replica.replicaisland.EnemyAnimationComponent.EnemyAnimations;
import com.replica.replicaisland.GameObject.ActionType;
import com.replica.replicaisland.GameObject.Team;
+import com.replica.replicaisland.GenericAnimationComponent.Animation;
/** A class for generating game objects at runtime.
* This should really be replaced with something that is data-driven, but it is hard to do data
@@ -99,6 +100,7 @@ public class GameObjectFactory extends BaseObject {
BROBOT_SPAWNER_LEFT (40),
BREAKABLE_BLOCK(41),
THE_SOURCE(42),
+ HINT_SIGN(43),
// Effects
DUST(48),
@@ -118,13 +120,7 @@ public class GameObjectFactory extends BaseObject {
FRAMERATE_WATCHER(57),
INFINITE_SPAWNER(58),
-
- SMOKE_BIG(59),
- SMOKE_SMALL(60),
-
- CRUSH_FLASH(61),
- FLASH(62),
-
+ CRUSHER_ANDOU(59),
// Projectiles
@@ -137,6 +133,12 @@ public class GameObjectFactory extends BaseObject {
WANDA_SHOT(70),
// Special Objects -- Not spawnable normally
+ SMOKE_BIG(-1),
+ SMOKE_SMALL(-1),
+
+ CRUSH_FLASH(-1),
+ FLASH(-1),
+
PLAYER_JETS(-1),
PLAYER_SPARKS(-1),
PLAYER_GLOW(-1),
@@ -215,6 +217,7 @@ public class GameObjectFactory extends BaseObject {
new ComponentClass(ButtonAnimationComponent.class, 32),
new ComponentClass(CameraBiasComponent.class, 8),
new ComponentClass(ChangeComponentsComponent.class, 256),
+ new ComponentClass(CrusherAndouComponent.class, 1),
new ComponentClass(DoorAnimationComponent.class, 256), //!
new ComponentClass(DynamicCollisionComponent.class, 256),
new ComponentClass(EnemyAnimationComponent.class, 256),
@@ -238,7 +241,7 @@ public class GameObjectFactory extends BaseObject {
new ComponentClass(PatrolComponent.class, 256),
new ComponentClass(PhysicsComponent.class, 8),
new ComponentClass(PlayerComponent.class, 1),
- new ComponentClass(PlaySingleSoundComponent.class, 32),
+ new ComponentClass(PlaySingleSoundComponent.class, 128),
new ComponentClass(PopOutComponent.class, 32),
new ComponentClass(RenderComponent.class, 384),
new ComponentClass(ScrollerComponent.class, 8),
@@ -249,7 +252,6 @@ public class GameObjectFactory extends BaseObject {
new ComponentClass(SolidSurfaceComponent.class, 16),
new ComponentClass(SpriteComponent.class, 384),
new ComponentClass(TheSourceComponent.class, 1),
-
};
@@ -489,6 +491,9 @@ public class GameObjectFactory extends BaseObject {
case THE_SOURCE:
newObject = spawnObjectTheSource(x, y);
break;
+ case HINT_SIGN:
+ newObject = spawnObjectSign(x, y);
+ break;
case DUST:
newObject = spawnDust(x, y, horzFlip);
break;
@@ -513,6 +518,9 @@ public class GameObjectFactory extends BaseObject {
case INFINITE_SPAWNER:
newObject = spawnObjectInfiniteSpawner(x, y);
break;
+ case CRUSHER_ANDOU:
+ newObject = spawnObjectCrusherAndou(x,y);
+ break;
case SMOKE_BIG:
newObject = spawnEffectSmokeBig(x, y);
break;
@@ -938,7 +946,7 @@ public class GameObjectFactory extends BaseObject {
invincibleSwap.setPingPongBehavior(true);
player.setInvincibleSwap(invincibleSwap);
- object.life = PlayerComponent.MAX_PLAYER_LIFE;
+ object.life = PlayerComponent.getDifficultyConstants().getMaxPlayerLife();
object.team = Team.PLAYER;
// Very very basic DDA. Make the game easier if we've died on this level too much.
@@ -1081,12 +1089,16 @@ public class GameObjectFactory extends BaseObject {
glowSprite.setCollisionComponent(glowCollision);
FadeDrawableComponent glowFade = (FadeDrawableComponent)allocateComponent(FadeDrawableComponent.class);
+ final float glowDuration = PlayerComponent.getDifficultyConstants().getGlowDuration();
glowFade.setupFade(1.0f, 0.0f, 0.15f,
FadeDrawableComponent.LOOP_TYPE_PING_PONG,
FadeDrawableComponent.FADE_EASE,
- PlayerComponent.GLOW_DURATION - 4.0f); // 4 seconds before the glow ends, start flashing
- glowFade.setPhaseDuration(PlayerComponent.GLOW_DURATION);
+ glowDuration - 4.0f); // 4 seconds before the glow ends, start flashing
+ glowFade.setPhaseDuration(glowDuration);
glowFade.setRenderComponent(glowRender);
+
+ // HACK
+ player.setInvincibleFader(glowFade);
invincibleSwap.addSwapInComponent(glowRender);
invincibleSwap.addSwapInComponent(glowSprite);
@@ -1244,6 +1256,7 @@ public class GameObjectFactory extends BaseObject {
LifetimeComponent lifetime = (LifetimeComponent)allocateComponent(LifetimeComponent.class);
lifetime.setObjectToSpawnOnDeath(GameObjectType.EXPLOSION_GIANT);
lifetime.setVulnerableToDeathTiles(true);
+ lifetime.setIncrementEventCounter(EventRecorder.COUNTER_ROBOTS_DESTROYED);
GhostComponent ghost = (GhostComponent)allocateComponent(GhostComponent.class);
ghost.setMovementSpeed(500.0f);
@@ -1489,8 +1502,10 @@ public class GameObjectFactory extends BaseObject {
staticData = new FixedSizeArray<BaseObject>(staticObjectCount);
PopOutComponent popOut = (PopOutComponent)allocateComponent(PopOutComponent.class);
- popOut.setAppearDistance(150);
- popOut.setHideDistance(190);
+ // edit: these guys turned out to be really annoying, so I'm changing the values
+ // here to force them to always be out.
+ popOut.setAppearDistance(2000);
+ popOut.setHideDistance(4000);
FixedSizeArray<CollisionVolume> basicVulnerabilityVolume = new FixedSizeArray<CollisionVolume>(1);
basicVulnerabilityVolume.add(new SphereCollisionVolume(16, 32, 32));
@@ -4375,7 +4390,8 @@ public class GameObjectFactory extends BaseObject {
//dynamicCollision.setHitReactionComponent(hitReact);
LifetimeComponent life = (LifetimeComponent)allocateComponent(LifetimeComponent.class);
-
+ life.setIncrementEventCounter(EventRecorder.COUNTER_PEARLS_COLLECTED);
+
object.life = 1;
object.add(render);
@@ -4387,6 +4403,9 @@ public class GameObjectFactory extends BaseObject {
addStaticData(GameObjectType.COIN, object, sprite);
sprite.playAnimation(0);
+
+ EventRecorder recorder = sSystemRegistry.eventRecorder;
+ recorder.incrementEventCounter(EventRecorder.COUNTER_PEARLS_TOTAL);
return object;
}
@@ -4982,7 +5001,7 @@ public class GameObjectFactory extends BaseObject {
FixedSizeArray<BaseObject> staticData = getStaticData(GameObjectType.BROBOT_SPAWNER);
if (staticData == null) {
- final int staticObjectCount = 3;
+ final int staticObjectCount = 2;
staticData = new FixedSizeArray<BaseObject>(staticObjectCount);
FixedSizeArray<CollisionVolume> basicVulnerabilityVolume =
@@ -5026,16 +5045,6 @@ public class GameObjectFactory extends BaseObject {
solidSurface.addSurface(surface2Start, surface2End, surface2Normal);
solidSurface.addSurface(surface3Start, surface3End, surface3Normal);
- GhostComponent ghost = (GhostComponent)allocateComponent(GhostComponent.class);
- ghost.setTargetAction(ActionType.IDLE);
- ghost.changeActionOnButton(ActionType.ATTACK);
-
- SoundSystem sound = BaseObject.sSystemRegistry.soundSystem;
- if (sound != null) {
- ghost.setAmbientSound(sound.load(R.raw.sound_possession));
- }
-
- staticData.add(ghost);
staticData.add(solidSurface);
staticData.add(idle);
@@ -5069,23 +5078,6 @@ public class GameObjectFactory extends BaseObject {
gun.setVelocityY(300.0f);
gun.enableProjectileTracking(1);
- LaunchProjectileComponent possessedGun
- = (LaunchProjectileComponent)allocateComponent(LaunchProjectileComponent.class);
- possessedGun.setRequiredAction(ActionType.ATTACK);
- possessedGun.setDelayBeforeFirstSet(0.0f);
- possessedGun.setObjectTypeToSpawn(GameObjectType.BROBOT_BULLET);
- possessedGun.setOffsetX(36);
- possessedGun.setOffsetY(50);
- possessedGun.setVelocityX(600.0f);
- possessedGun.setVelocityY(600.0f);
- possessedGun.setThetaError(0.3f);
-
- ChangeComponentsComponent componentSwap = (ChangeComponentsComponent)allocateComponent(ChangeComponentsComponent.class);
- componentSwap.addSwapOutComponent(gun);
- componentSwap.addSwapInComponent(possessedGun);
- componentSwap.setPingPongBehavior(true);
-
- hitReact.setPossessionComponent(componentSwap);
object.team = Team.ENEMY;
@@ -5100,19 +5092,13 @@ public class GameObjectFactory extends BaseObject {
object.add(gun);
object.add(collision);
object.add(hitReact);
- object.add(componentSwap);
addStaticData(GameObjectType.BROBOT_SPAWNER, object, sprite);
object.commitUpdates();
- GhostComponent possessedGhost = object.findByClass(GhostComponent.class);
- if (possessedGhost != null) {
- object.remove(possessedGhost); // Not supposed to be added yet.
- componentSwap.addSwapInComponent(possessedGhost);
- }
-
+
sprite.playAnimation(0);
return object;
@@ -5123,13 +5109,150 @@ public class GameObjectFactory extends BaseObject {
object.facingDirection.y = -1; //vertical flip
LaunchProjectileComponent gun = object.findByClass(LaunchProjectileComponent.class);
if (gun != null) {
- gun.enableProjectileTracking(68);
- gun.setDelayBetweenShots(0.5f);
+ gun.disableProjectileTracking();
+ gun.setDelayBetweenShots(0.15f);
+ gun.setSetsPerActivation(1);
+ gun.setShotsPerSet(60);
}
return object;
}
+ public GameObject spawnObjectCrusherAndou(float positionX, float positionY) {
+ TextureLibrary textureLibrary = sSystemRegistry.shortTermTextureLibrary;
+
+ GameObject object = mGameObjectPool.allocate();
+ object.getPosition().set(positionX, positionY);
+ object.activationRadius = mAlwaysActive;
+ object.width = 64;
+ object.height = 64;
+
+ FixedSizeArray<BaseObject> staticData = getStaticData(GameObjectType.CRUSHER_ANDOU);
+
+ if (staticData == null) {
+ final int staticObjectCount = 5;
+ staticData = new FixedSizeArray<BaseObject>(staticObjectCount);
+
+ GameComponent gravity = allocateComponent(GravityComponent.class);
+ GameComponent movement = allocateComponent(MovementComponent.class);
+ PhysicsComponent physics = (PhysicsComponent)allocateComponent(PhysicsComponent.class);
+
+ physics.setMass(9.1f); // ~90kg w/ earth gravity
+ physics.setDynamicFrictionCoeffecient(0.2f);
+ physics.setStaticFrictionCoeffecient(0.01f);
+
+ // Animation Data
+ FixedSizeArray<CollisionVolume> basicVulnerabilityVolume =
+ new FixedSizeArray<CollisionVolume>(1);
+ basicVulnerabilityVolume.add(new SphereCollisionVolume(16, 32, 32));
+
+ SpriteAnimation idle = new SpriteAnimation(Animation.IDLE, 1);
+ idle.addFrame(new AnimationFrame(textureLibrary.allocateTexture(R.drawable.andou_stand),
+ 1.0f, null, basicVulnerabilityVolume));
+
+
+ FixedSizeArray<CollisionVolume> stompAttackVolume =
+ new FixedSizeArray<CollisionVolume>(1);
+ stompAttackVolume.add(new AABoxCollisionVolume(16, -5.0f, 32, 37, HitType.HIT));
+
+
+ SpriteAnimation stomp = new SpriteAnimation(Animation.ATTACK, 4);
+ stomp.addFrame(
+ new AnimationFrame(textureLibrary.allocateTexture(R.drawable.andou_stomp01),
+ Utils.framesToTime(24, 1), stompAttackVolume, null));
+ stomp.addFrame(
+ new AnimationFrame(textureLibrary.allocateTexture(R.drawable.andou_stomp02),
+ Utils.framesToTime(24, 1), stompAttackVolume, null));
+ stomp.addFrame(
+ new AnimationFrame(textureLibrary.allocateTexture(R.drawable.andou_stomp03),
+ Utils.framesToTime(24, 1), stompAttackVolume, null));
+ stomp.addFrame(
+ new AnimationFrame(textureLibrary.allocateTexture(R.drawable.andou_stomp04),
+ Utils.framesToTime(24, 1), stompAttackVolume, null));
+
+
+
+ // Save static data
+ staticData.add(gravity);
+ staticData.add(movement);
+ staticData.add(physics);
+
+
+ staticData.add(idle);
+ staticData.add(stomp);
+
+
+ setStaticData(GameObjectType.CRUSHER_ANDOU, staticData);
+ }
+
+
+ RenderComponent render = (RenderComponent)allocateComponent(RenderComponent.class);
+ render.setPriority(SortConstants.PLAYER);
+ BackgroundCollisionComponent bgcollision
+ = (BackgroundCollisionComponent)allocateComponent(BackgroundCollisionComponent.class);
+ bgcollision.setSize(32, 48);
+ bgcollision.setOffset(16, 0);
+
+ GenericAnimationComponent animation = (GenericAnimationComponent)allocateComponent(GenericAnimationComponent.class);
+
+ SpriteComponent sprite = (SpriteComponent)allocateComponent(SpriteComponent.class);
+ sprite.setSize((int)object.width, (int)object.height);
+ sprite.setRenderComponent(render);
+ animation.setSprite(sprite);
+
+
+ DynamicCollisionComponent dynamicCollision
+ = (DynamicCollisionComponent)allocateComponent(DynamicCollisionComponent.class);
+ sprite.setCollisionComponent(dynamicCollision);
+
+ HitReactionComponent hitReact = (HitReactionComponent)allocateComponent(HitReactionComponent.class);
+ hitReact.setBounceOnHit(true);
+ hitReact.setPauseOnAttack(true);
+ hitReact.setInvincibleTime(3.0f);
+ hitReact.setSpawnOnDealHit(HitType.HIT, GameObjectType.CRUSH_FLASH, false, true);
+
+
+ dynamicCollision.setHitReactionComponent(hitReact);
+
+
+
+ object.life = 1;
+ object.team = Team.PLAYER;
+
+ object.add(animation);
+ object.add(bgcollision);
+ object.add(render);
+ object.add(sprite);
+ object.add(dynamicCollision);
+ object.add(hitReact);
+
+ addStaticData(GameObjectType.CRUSHER_ANDOU, object, sprite);
+
+ sprite.playAnimation(Animation.IDLE);
+
+ object.commitUpdates();
+
+ ChangeComponentsComponent swap = (ChangeComponentsComponent)allocateComponent(ChangeComponentsComponent.class);
+
+ final int count = object.getCount();
+ for (int x = 0; x < count; x++) {
+ swap.addSwapInComponent((GameComponent)object.get(x));
+ }
+
+ object.removeAll();
+
+ CrusherAndouComponent crusher = (CrusherAndouComponent)allocateComponent(CrusherAndouComponent.class);
+
+ crusher.setSwap(swap);
+
+ object.add(swap);
+ object.add(crusher);
+
+ object.commitUpdates();
+
+ return object;
+ }
+
public GameObject spawnObjectBreakableBlock(float positionX, float positionY) {
TextureLibrary textureLibrary = sSystemRegistry.shortTermTextureLibrary;
@@ -5328,6 +5451,66 @@ public class GameObjectFactory extends BaseObject {
return object;
}
+
+ public GameObject spawnObjectSign(float positionX, float positionY) {
+ TextureLibrary textureLibrary = sSystemRegistry.shortTermTextureLibrary;
+
+ GameObject object = mGameObjectPool.allocate();
+ object.getPosition().set(positionX, positionY);
+ object.activationRadius = mTightActivationRadius;
+ object.width = 32;
+ object.height = 32;
+
+ FixedSizeArray<BaseObject> staticData = getStaticData(GameObjectType.HINT_SIGN);
+ if (staticData == null) {
+ final int staticObjectCount = 1;
+ staticData = new FixedSizeArray<BaseObject>(staticObjectCount);
+
+ FixedSizeArray<CollisionVolume> basicVulnerabilityVolume =
+ new FixedSizeArray<CollisionVolume>(1);
+ basicVulnerabilityVolume.add(new AABoxCollisionVolume(8, 0, 24, 32, HitType.COLLECT));
+
+ SpriteAnimation idle = new SpriteAnimation(0, 1);
+ AnimationFrame frame1 = new AnimationFrame(textureLibrary.allocateTexture(R.drawable.object_sign),
+ Utils.framesToTime(24, 1), null, basicVulnerabilityVolume);
+
+ idle.addFrame(frame1);
+
+ idle.setLoop(true);
+
+ staticData.add(idle);
+
+ setStaticData(GameObjectType.HINT_SIGN, staticData);
+ }
+
+ RenderComponent render = (RenderComponent)allocateComponent(RenderComponent.class);
+ render.setPriority(SortConstants.GENERAL_OBJECT);
+
+ SpriteComponent sprite = (SpriteComponent)allocateComponent(SpriteComponent.class);
+ sprite.setSize((int)object.width, (int)object.height);
+ sprite.setRenderComponent(render);
+
+ DynamicCollisionComponent dynamicCollision = (DynamicCollisionComponent)allocateComponent(DynamicCollisionComponent.class);
+ sprite.setCollisionComponent(dynamicCollision);
+
+ HitReactionComponent hitReact = (HitReactionComponent)allocateComponent(HitReactionComponent.class);
+ dynamicCollision.setHitReactionComponent(hitReact);
+ hitReact.setSpawnGameEventOnHit(HitType.COLLECT, GameFlowEvent.EVENT_SHOW_DIALOG_CHARACTER2, 0);
+
+ SelectDialogComponent dialogSelect = (SelectDialogComponent)allocateComponent(SelectDialogComponent.class);
+ dialogSelect.setHitReact(hitReact);
+
+ object.add(dialogSelect);
+ object.add(render);
+ object.add(sprite);
+ object.add(dynamicCollision);
+ object.add(hitReact);
+
+ addStaticData(GameObjectType.HINT_SIGN, object, sprite);
+ sprite.playAnimation(0);
+
+ return object;
+ }
public GameObject spawnObjectTurret(float positionX, float positionY, boolean flipHorizontal) {
diff --git a/src/com/replica/replicaisland/GameOverActivity.java b/src/com/replica/replicaisland/GameOverActivity.java
new file mode 100644
index 0000000..9a09f0f
--- /dev/null
+++ b/src/com/replica/replicaisland/GameOverActivity.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.replica.replicaisland;
+
+import java.lang.reflect.InvocationTargetException;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.graphics.Canvas;
+import android.os.Bundle;
+import android.os.SystemClock;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+public class GameOverActivity extends Activity {
+ private float mPearlPercent = 100.0f;
+ private float mEnemiesDestroyedPercent = 100.0f;
+ private float mPlayTime = 0.0f;
+ private int mEnding = AnimationPlayerActivity.KABOCHA_ENDING;
+
+ private IncrementingTextView mPearlView;
+ private IncrementingTextView mEnemiesDestroyedView;
+ private IncrementingTextView mPlayTimeView;
+ private TextView mEndingView;
+
+ public static class IncrementingTextView extends TextView {
+ private static final int INCREMENT_DELAY_MS = 2 * 1000;
+ private static final int MODE_NONE = 0;
+ private static final int MODE_PERCENT = 1;
+ private static final int MODE_TIME = 2;
+
+ private float mTargetValue;
+ private float mIncrement = 1.0f;
+ private float mCurrentValue = 0.0f;
+ private long mLastTime = 0;
+ private int mMode = MODE_NONE;
+
+ public IncrementingTextView(Context context) {
+ super(context);
+ }
+
+ public IncrementingTextView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public IncrementingTextView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ public void setTargetValue(float target) {
+ mTargetValue = target;
+ postInvalidate();
+ }
+
+ public void setMode(int mode) {
+ mMode = mode;
+ }
+
+ public void setIncrement(float increment) {
+ mIncrement = increment;
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ final long time = SystemClock.uptimeMillis();
+ final long delta = time - mLastTime;
+ if (delta > INCREMENT_DELAY_MS) {
+ if (mCurrentValue < mTargetValue) {
+ mCurrentValue += mIncrement;
+ mCurrentValue = Math.min(mCurrentValue, mTargetValue);
+ String value;
+ if (mMode == MODE_PERCENT) {
+ value = mCurrentValue + "%";
+ } else if (mMode == MODE_TIME) {
+ float seconds = mCurrentValue;
+ float minutes = seconds / 60.0f;
+ float hours = minutes / 60.0f;
+
+ int totalHours = (int)Math.floor(hours);
+ float totalHourMinutes = totalHours * 60.0f;
+ int totalMinutes = (int)(minutes - totalHourMinutes);
+ float totalMinuteSeconds = totalMinutes * 60.0f;
+ float totalHourSeconds = totalHourMinutes * 60.0f;
+ int totalSeconds = (int)(seconds - (totalMinuteSeconds + totalHourSeconds));
+
+ value = totalHours + ":" + totalMinutes + ":" + totalSeconds;
+ } else {
+ value = mCurrentValue + "";
+ }
+ setText(value);
+ postInvalidateDelayed(INCREMENT_DELAY_MS);
+ }
+ }
+ super.onDraw(canvas);
+ }
+ }
+
+ private View.OnClickListener sOKClickListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ finish();
+ if (UIConstants.mOverridePendingTransition != null) {
+ try {
+ UIConstants.mOverridePendingTransition.invoke(GameOverActivity.this, R.anim.activity_fade_in, R.anim.activity_fade_out);
+ } catch (InvocationTargetException ite) {
+ DebugLog.d("Activity Transition", "Invocation Target Exception");
+ } catch (IllegalAccessException ie) {
+ DebugLog.d("Activity Transition", "Illegal Access Exception");
+ }
+ }
+ }
+ };
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.game_over);
+
+ mPearlView = (IncrementingTextView)findViewById(R.id.pearl_percent);
+ mEnemiesDestroyedView = (IncrementingTextView)findViewById(R.id.enemy_percent);
+ mPlayTimeView = (IncrementingTextView)findViewById(R.id.total_play_time);
+ mEndingView = (TextView)findViewById(R.id.ending);
+
+ SharedPreferences prefs = getSharedPreferences(PreferenceConstants.PREFERENCE_NAME, MODE_PRIVATE);
+ final float playTime = prefs.getFloat(PreferenceConstants.PREFERENCE_TOTAL_GAME_TIME, 0.0f);
+ final int ending = prefs.getInt(PreferenceConstants.PREFERENCE_LAST_ENDING, -1);
+ final int pearlsCollected = prefs.getInt(PreferenceConstants.PREFERENCE_PEARLS_COLLECTED, 0);
+ final int pearlsTotal = prefs.getInt(PreferenceConstants.PREFERENCE_PEARLS_TOTAL, 0);
+
+ final int enemies = prefs.getInt(PreferenceConstants.PREFERENCE_ROBOTS_DESTROYED, 0);
+
+ if (pearlsCollected > 0 && pearlsTotal > 0) {
+ mPearlView.setTargetValue((int)((pearlsCollected / (float)pearlsTotal) * 100.0f));
+ } else {
+ mPearlView.setText("--");
+ }
+ mPearlView.setMode(IncrementingTextView.MODE_PERCENT);
+ mEnemiesDestroyedView.setTargetValue(enemies);
+ mPlayTimeView.setTargetValue(playTime);
+ mPlayTimeView.setIncrement(90.0f);
+ mPlayTimeView.setMode(IncrementingTextView.MODE_TIME);
+
+ if (ending == AnimationPlayerActivity.KABOCHA_ENDING) {
+ mEndingView.setText(R.string.game_results_kabocha_ending);
+ } else if (ending == AnimationPlayerActivity.ROKUDOU_ENDING) {
+ mEndingView.setText(R.string.game_results_rokudou_ending);
+ } else {
+ mEndingView.setText(R.string.game_results_wanda_ending);
+ }
+
+ Button okButton = (Button)findViewById(R.id.ok);
+ okButton.setOnClickListener(sOKClickListener);
+
+ }
+
+
+}
diff --git a/src/com/replica/replicaisland/HudSystem.java b/src/com/replica/replicaisland/HudSystem.java
index b5ba663..4e0243b 100644
--- a/src/com/replica/replicaisland/HudSystem.java
+++ b/src/com/replica/replicaisland/HudSystem.java
@@ -32,6 +32,13 @@ public class HudSystem extends BaseObject {
private static final float STOMP_BUTTON_SCALE = 0.65f;
private static final int COLLECTABLE_EDGE_PADDING = 8;
private static final int MAX_DIGITS = 4;
+ private static final float MOVEMENT_SLIDER_BASE_X = 20.0f;
+ private static final float MOVEMENT_SLIDER_BASE_Y = 32.0f;
+ private static final float MOVEMENT_SLIDER_BUTTON_X = MOVEMENT_SLIDER_BASE_X + 32.0f;
+ private static final float MOVEMENT_SLIDER_BUTTON_Y = MOVEMENT_SLIDER_BASE_Y - 16.0f;
+ private static final float FLY_BUTTON_WIDTH = 128;
+ private static final float STOMP_BUTTON_WIDTH = FLY_BUTTON_WIDTH * STOMP_BUTTON_SCALE;
+ private static final float MOVEMENT_SLIDER_WIDTH = 128;
private DrawableBitmap mFuelDrawable;
private DrawableBitmap mFuelBackgroundDrawable;
@@ -53,6 +60,11 @@ public class HudSystem extends BaseObject {
private DrawableBitmap mStompButtonEnabledDrawable;
private DrawableBitmap mStompButtonDepressedDrawable;
+ private DrawableBitmap mMovementSliderBaseDrawable;
+ private DrawableBitmap mMovementSliderButtonDrawable;
+ private DrawableBitmap mMovementSliderButtonDepressedDrawable;
+
+
private Vector2 mFlyButtonLocation;
private boolean mFlyButtonActive;
private boolean mFlyButtonPressed;
@@ -60,6 +72,11 @@ public class HudSystem extends BaseObject {
private Vector2 mStompButtonLocation;
private boolean mStompButtonPressed;
+ private Vector2 mMovementSliderBaseLocation;
+ private Vector2 mMovementSliderButtonLocation;
+ private boolean mMovementSliderMode;
+ private boolean mMovementSliderButtonPressed;
+
private DrawableBitmap mRubyDrawable;
private DrawableBitmap mCoinDrawable;
@@ -93,6 +110,8 @@ public class HudSystem extends BaseObject {
mCoinDigits = new int[MAX_DIGITS];
mRubyDigits = new int[MAX_DIGITS];
mFPSDigits = new int[MAX_DIGITS];
+ mMovementSliderBaseLocation = new Vector2();
+ mMovementSliderButtonLocation = new Vector2();
reset();
}
@@ -133,6 +152,14 @@ public class HudSystem extends BaseObject {
mXDrawable = null;
mFadePendingEventType = GameFlowEvent.EVENT_INVALID;
mFadePendingEventIndex = 0;
+
+ mMovementSliderBaseDrawable = null;
+ mMovementSliderButtonDrawable = null;
+ mMovementSliderButtonDepressedDrawable = null;
+ mMovementSliderBaseLocation.set(MOVEMENT_SLIDER_BASE_X, MOVEMENT_SLIDER_BASE_Y);
+ mMovementSliderButtonLocation.set(MOVEMENT_SLIDER_BUTTON_X, MOVEMENT_SLIDER_BUTTON_Y);
+ mMovementSliderMode = false;
+ mMovementSliderButtonPressed = false;
}
public void setFuelPercent(float percent) {
@@ -148,13 +175,17 @@ public class HudSystem extends BaseObject {
mFadeTexture = texture;
}
- public void setButtonDrawables(DrawableBitmap disabled, DrawableBitmap enabled,
- DrawableBitmap depressed, DrawableBitmap stompEnabled, DrawableBitmap stompDepressed) {
+ public void setButtonDrawables(DrawableBitmap disabled, DrawableBitmap enabled, DrawableBitmap depressed,
+ DrawableBitmap stompEnabled, DrawableBitmap stompDepressed,
+ DrawableBitmap sliderBase, DrawableBitmap sliderButton, DrawableBitmap sliderDepressed) {
mFlyButtonDisabledDrawable = disabled;
mFlyButtonEnabledDrawable = enabled;
mFlyButtonDepressedDrawable = depressed;
mStompButtonEnabledDrawable = stompEnabled;
mStompButtonDepressedDrawable = stompDepressed;
+ mMovementSliderBaseDrawable = sliderBase;
+ mMovementSliderButtonDrawable = sliderButton;
+ mMovementSliderButtonDepressedDrawable = sliderDepressed;
}
public void setDigitDrawables(DrawableBitmap[] digits, DrawableBitmap xMark) {
@@ -169,9 +200,10 @@ public class HudSystem extends BaseObject {
mRubyDrawable = ruby;
}
- public void setButtonState(boolean pressed, boolean attackPressed) {
+ public void setButtonState(boolean pressed, boolean attackPressed, boolean sliderPressed) {
mFlyButtonPressed = pressed;
mStompButtonPressed = attackPressed;
+ mMovementSliderButtonPressed = sliderPressed;
}
public void startFade(boolean in, float duration) {
@@ -205,6 +237,21 @@ public class HudSystem extends BaseObject {
public void setShowFPS(boolean show) {
mShowFPS = show;
}
+
+ public void setMovementSliderMode(boolean sliderOn) {
+ mMovementSliderMode = sliderOn;
+ if (sliderOn) {
+ ContextParameters params = sSystemRegistry.contextParameters;
+ mFlyButtonLocation.set(params.gameWidth - FLY_BUTTON_WIDTH - FLY_BUTTON_X, FLY_BUTTON_Y);
+ mStompButtonLocation.set(params.gameWidth - STOMP_BUTTON_WIDTH - STOMP_BUTTON_X, STOMP_BUTTON_Y);
+ } else {
+ mFlyButtonLocation.set(FLY_BUTTON_X, FLY_BUTTON_Y);
+ mStompButtonLocation.set(STOMP_BUTTON_X, STOMP_BUTTON_Y);
+ }
+ }
+ public void setMovementSliderOffset(float offset) {
+ mMovementSliderButtonLocation.set(MOVEMENT_SLIDER_BUTTON_X + (offset * (MOVEMENT_SLIDER_WIDTH / 2.0f)), MOVEMENT_SLIDER_BUTTON_Y);
+ }
@Override
public void update(float timeDelta, BaseObject parent) {
@@ -280,6 +327,8 @@ public class HudSystem extends BaseObject {
render.scheduleForDraw(bitmap, mFlyButtonLocation, SortConstants.HUD, false);
}
+
+
if (mStompButtonEnabledDrawable != null && mStompButtonDepressedDrawable != null) {
DrawableBitmap bitmap = mStompButtonEnabledDrawable;
@@ -298,6 +347,39 @@ public class HudSystem extends BaseObject {
render.scheduleForDraw(bitmap, mStompButtonLocation, SortConstants.HUD, false);
}
+ if (mMovementSliderMode &&
+ mMovementSliderBaseDrawable != null && mMovementSliderButtonDrawable != null) {
+
+ if (mMovementSliderBaseDrawable.getWidth() == 0) {
+ // first time init
+ Texture tex = mMovementSliderBaseDrawable.getTexture();
+ mMovementSliderBaseDrawable.resize(tex.width, tex.height);
+ }
+
+ if (mMovementSliderButtonDrawable.getWidth() == 0) {
+ // first time init
+ Texture tex = mMovementSliderButtonDrawable.getTexture();
+ mMovementSliderButtonDrawable.resize(tex.width, tex.height);
+ }
+
+ if (mMovementSliderButtonDepressedDrawable.getWidth() == 0) {
+ // first time init
+ Texture tex = mMovementSliderButtonDepressedDrawable.getTexture();
+ mMovementSliderButtonDepressedDrawable.resize(tex.width, tex.height);
+ }
+
+ DrawableBitmap bitmap = mMovementSliderButtonDrawable;
+
+ if (mMovementSliderButtonPressed) {
+ bitmap = mMovementSliderButtonDepressedDrawable;
+ }
+
+ render.scheduleForDraw(mMovementSliderBaseDrawable, mMovementSliderBaseLocation, SortConstants.HUD, false);
+ render.scheduleForDraw(bitmap, mMovementSliderButtonLocation, SortConstants.HUD + 1, false);
+
+ }
+
+
if (mCoinDrawable != null) {
if (mCoinDrawable.getWidth() == 0) {
// first time init
@@ -342,7 +424,7 @@ public class HudSystem extends BaseObject {
if (mFPSDigitsChanged) {
int count = intToDigitArray(mFPS, mFPSDigits);
mFPSDigitsChanged = false;
- mFPSLocation.set(params.gameWidth - ((count + 1) * mDigitDrawables[0].getWidth()), 20.0f);
+ mFPSLocation.set(params.gameWidth - 10.0f - ((count + 1) * (mDigitDrawables[0].getWidth() / 2.0f)), 10.0f);
}
drawNumber(mFPSLocation, mFPSDigits, false);
@@ -452,8 +534,9 @@ public class HudSystem extends BaseObject {
if (count < digits.length) {
digits[count] = -1;
}
- return count;
+ return characterCount;
}
+
public void sendGameEventOnFadeComplete(int eventType, int eventIndex) {
mFadePendingEventType = eventType;
mFadePendingEventIndex = eventIndex;
diff --git a/src/com/replica/replicaisland/InputGameInterface.java b/src/com/replica/replicaisland/InputGameInterface.java
index 3625a49..80db673 100644
--- a/src/com/replica/replicaisland/InputGameInterface.java
+++ b/src/com/replica/replicaisland/InputGameInterface.java
@@ -32,6 +32,8 @@ public class InputGameInterface extends BaseObject {
private final static float ROLL_DECAY = 8.0f;
private final static float KEY_FILTER = 0.25f;
+ private final static float SLIDER_FILTER = 0.25f;
+
private InputButton mJumpButton = new InputButton();
private InputButton mAttackButton = new InputButton();
@@ -49,10 +51,10 @@ public class InputGameInterface extends BaseObject {
private float mOrientationSensitivity = 1.0f;
private float mOrientationSensitivityFactor = 1.0f;
private float mMovementSensitivity = 1.0f;
-
-
+
private boolean mUseClickButtonForAttack = true;
private boolean mUseOrientationForMovement = false;
+ private boolean mUseOnScreenControls = false;
private float mLastRollTime;
@@ -80,8 +82,32 @@ public class InputGameInterface extends BaseObject {
// tilt is easy
mTilt.clone(orientation);
+ final InputTouchScreen touch = input.getTouchScreen();
+ final float gameTime = sSystemRegistry.timeSystem.getGameTime();
+
+ float sliderOffset = 0;
+
// update movement inputs
- if (mUseOrientationForMovement) {
+ if (mUseOnScreenControls) {
+ final InputXY sliderTouch = touch.findPointerInRegion(
+ ButtonConstants.MOVEMENT_SLIDER_REGION_X,
+ ButtonConstants.MOVEMENT_SLIDER_REGION_Y,
+ ButtonConstants.MOVEMENT_SLIDER_REGION_WIDTH,
+ ButtonConstants.MOVEMENT_SLIDER_REGION_HEIGHT);
+
+ if (sliderTouch != null) {
+ final float halfWidth = ButtonConstants.MOVEMENT_SLIDER_BAR_WIDTH / 2.0f;
+ final float center = ButtonConstants.MOVEMENT_SLIDER_X + halfWidth;
+ final float offset = sliderTouch.getX() - center;
+ float magnitudeRamp = Math.abs(offset) > halfWidth ? 1.0f : (Math.abs(offset) / halfWidth);
+
+ final float magnitude = magnitudeRamp * Utils.sign(offset) * SLIDER_FILTER * mMovementSensitivity;
+ sliderOffset = magnitudeRamp * Utils.sign(offset);
+ mDirectionalPad.press(gameTime, magnitude, 0.0f);
+ } else {
+ mDirectionalPad.release();
+ }
+ } else if (mUseOrientationForMovement) {
mDirectionalPad.clone(orientation);
mDirectionalPad.setMagnitude(
filterOrientationForMovement(orientation.getX()),
@@ -94,7 +120,6 @@ public class InputGameInterface extends BaseObject {
final float leftPressedTime = left.getLastPressedTime();
final float rightPressedTime = right.getLastPressedTime();
- final float gameTime = sSystemRegistry.timeSystem.getGameTime();
if (trackball.getLastPressedTime() > Math.max(leftPressedTime, rightPressedTime)) {
// The trackball never goes "up", so force it to turn off if it wasn't triggered in the last frame.
@@ -170,19 +195,28 @@ public class InputGameInterface extends BaseObject {
// update other buttons
final InputButton jumpKey = keys[mJumpKeyCode];
- final InputXY touch = input.getTouchScreen();
+
+ // when on-screen movement controls are on, the fly and attack buttons are flipped.
+ float flyButtonRegionX = ButtonConstants.FLY_BUTTON_REGION_X;
+ float stompButtonRegionX = ButtonConstants.STOMP_BUTTON_REGION_X;
+
+ if (mUseOnScreenControls) {
+ ContextParameters params = sSystemRegistry.contextParameters;
+ flyButtonRegionX = params.gameWidth - ButtonConstants.FLY_BUTTON_REGION_WIDTH - ButtonConstants.FLY_BUTTON_REGION_X;
+ stompButtonRegionX = params.gameWidth - ButtonConstants.STOMP_BUTTON_REGION_WIDTH - ButtonConstants.STOMP_BUTTON_REGION_X;
+ }
+
+ final InputXY jumpTouch = touch.findPointerInRegion(
+ flyButtonRegionX,
+ ButtonConstants.FLY_BUTTON_REGION_Y,
+ ButtonConstants.FLY_BUTTON_REGION_WIDTH,
+ ButtonConstants.FLY_BUTTON_REGION_HEIGHT);
if (jumpKey.getPressed()) {
mJumpButton.press(jumpKey.getLastPressedTime(), jumpKey.getMagnitude());
- } else if (touch.getPressed() && getTouchedWithinRegion(
- touch.getX(),
- touch.getY(),
- ButtonConstants.FLY_BUTTON_REGION_X,
- ButtonConstants.FLY_BUTTON_REGION_Y,
- ButtonConstants.FLY_BUTTON_REGION_WIDTH,
- ButtonConstants.FLY_BUTTON_REGION_HEIGHT)) {
+ } else if (jumpTouch != null) {
if (!mJumpButton.getPressed()) {
- mJumpButton.press(touch.getLastPressedTime(), 1.0f);
+ mJumpButton.press(jumpTouch.getLastPressedTime(), 1.0f);
}
} else {
mJumpButton.release();
@@ -191,25 +225,34 @@ public class InputGameInterface extends BaseObject {
final InputButton attackKey = keys[mAttackKeyCode];
final InputButton clickButton = keys[KeyEvent.KEYCODE_DPAD_CENTER]; // special case
+ final InputXY stompTouch = touch.findPointerInRegion(
+ stompButtonRegionX,
+ ButtonConstants.STOMP_BUTTON_REGION_Y,
+ ButtonConstants.STOMP_BUTTON_REGION_WIDTH,
+ ButtonConstants.STOMP_BUTTON_REGION_HEIGHT);
+
if (mUseClickButtonForAttack && clickButton.getPressed()) {
mAttackButton.press(clickButton.getLastPressedTime(), clickButton.getMagnitude());
} else if (attackKey.getPressed()) {
mAttackButton.press(attackKey.getLastPressedTime(), attackKey.getMagnitude());
- } else if (touch.getPressed() && getTouchedWithinRegion(
- touch.getX(),
- touch.getY(),
- ButtonConstants.STOMP_BUTTON_REGION_X,
- ButtonConstants.STOMP_BUTTON_REGION_Y,
- ButtonConstants.STOMP_BUTTON_REGION_WIDTH,
- ButtonConstants.STOMP_BUTTON_REGION_HEIGHT)) {
+ } else if (stompTouch != null) {
// Since touch events come in constantly, we only want to press the attack button
// here if it's not already down. That makes it act like the other buttons (down once then up).
if (!mAttackButton.getPressed()) {
- mAttackButton.press(touch.getLastPressedTime(), 1.0f);
+ mAttackButton.press(stompTouch.getLastPressedTime(), 1.0f);
}
} else {
mAttackButton.release();
}
+
+ // This doesn't seem like exactly the right place to write to the HUD, but on the other hand,
+ // putting this code elsewhere causes dependencies between exact HUD content and physics, which
+ // we sometimes wish to avoid.
+ final HudSystem hud = sSystemRegistry.hudSystem;
+ if (hud != null) {
+ hud.setButtonState(mJumpButton.getPressed(), mAttackButton.getPressed(), mDirectionalPad.getPressed());
+ hud.setMovementSliderOffset(sliderOffset);
+ }
}
@@ -230,12 +273,6 @@ public class InputGameInterface extends BaseObject {
return smoothedMagnatude;
}
- private final boolean getTouchedWithinRegion(float x, float y, float regionX, float regionY, float regionWidth, float regionHeight) {
- return (x >= regionX &&
- y >= regionY &&
- x <= regionX + regionWidth &&
- y <= regionY + regionHeight);
- }
public final InputXY getDirectionalPad() {
return mDirectionalPad;
@@ -277,4 +314,8 @@ public class InputGameInterface extends BaseObject {
mMovementSensitivity = sensitivity;
}
+ public void setUseOnScreenControls(boolean onscreen) {
+ mUseOnScreenControls = onscreen;
+ }
+
}
diff --git a/src/com/replica/replicaisland/InputSystem.java b/src/com/replica/replicaisland/InputSystem.java
index 6bc4ed8..9dc1bff 100644
--- a/src/com/replica/replicaisland/InputSystem.java
+++ b/src/com/replica/replicaisland/InputSystem.java
@@ -21,11 +21,13 @@ package com.replica.replicaisland;
* an average direction over a short period of time.
*/
public class InputSystem extends BaseObject {
-
- private InputXY mTouchScreen = new InputXY(); // I guess for multitouch this could be an array.
+ private InputTouchScreen mTouchScreen = new InputTouchScreen();
private InputXY mOrientationSensor = new InputXY();
private InputXY mTrackball = new InputXY();
private InputKeyboard mKeyboard = new InputKeyboard();
+ private int mScreenRotation = 0;
+ private float mOrientationInput[] = new float[3];
+ private float mOrientationOutput[] = new float[3];
public InputSystem() {
super();
@@ -45,28 +47,39 @@ public class InputSystem extends BaseObject {
mTrackball.press(time.getGameTime(), mTrackball.getX() + x, mTrackball.getY() + y);
}
- public void touchDown(float x, float y) {
+ public void touchDown(int index, float x, float y) {
ContextParameters params = sSystemRegistry.contextParameters;
TimeSystem time = sSystemRegistry.timeSystem;
// Change the origin of the touch location from the top-left to the bottom-left to match
// OpenGL space.
// TODO: UNIFY THIS SHIT
- mTouchScreen.press(time.getGameTime(), x, params.gameHeight - y);
+ mTouchScreen.press(index, time.getGameTime(), x, params.gameHeight - y);
}
- public void touchUp(float x, float y) {
+ public void touchUp(int index, float x, float y) {
// TODO: record up location?
- mTouchScreen.release();
+ mTouchScreen.release(index);
}
- public void setOrientation(float azimuth, float pitch, float roll) {
- //DebugLog.d("Orientation", "Pitch: " + pitch + " Roll: " + roll);
- final float correctedPitch = -pitch / 180.0f;
- final float correctedRoll = -roll / 90.0f;
- //DebugLog.d("Orientation", "Pitch: " + correctedPitch + " Roll: " + correctedRoll);
-
+
+ public void setOrientation(float x, float y, float z) {
+ // The order of orientation axes changes depending on the rotation of the screen.
+ // Some devices call landscape "ROTAION_90" (e.g. phones), while others call it
+ // "ROTATION_0" (e.g. tablets). So we need to adjust the axes from canonical
+ // space into screen space depending on the rotation of the screen from
+ // whatever this device calls "default."
+ mOrientationInput[0] = x;
+ mOrientationInput[1] = y;
+ mOrientationInput[2] = z;
+
+ canonicalOrientationToScreenOrientation(mScreenRotation, mOrientationInput, mOrientationOutput);
+
+ // Now we have screen space rotations around xyz.
+ final float horizontalMotion = mOrientationOutput[1] / 90.0f;
+ final float verticalMotion = mOrientationOutput[0] / 90.0f;
+
TimeSystem time = sSystemRegistry.timeSystem;
- mOrientationSensor.press(time.getGameTime(), correctedPitch, correctedRoll);
+ mOrientationSensor.press(time.getGameTime(), horizontalMotion, verticalMotion);
}
@@ -83,12 +96,12 @@ public class InputSystem extends BaseObject {
public void releaseAllKeys() {
mTrackball.releaseX();
mTrackball.releaseY();
- mTouchScreen.release();
+ mTouchScreen.resetAll();
mKeyboard.releaseAll();
mOrientationSensor.release();
}
- public InputXY getTouchScreen() {
+ public InputTouchScreen getTouchScreen() {
return mTouchScreen;
}
@@ -103,7 +116,27 @@ public class InputSystem extends BaseObject {
public InputKeyboard getKeyboard() {
return mKeyboard;
}
+
+ public void setScreenRotation(int rotation) {
+ mScreenRotation = rotation;
+ }
+ // Thanks to NVIDIA for this useful canonical-to-screen orientation function.
+ // More here: http://developer.download.nvidia.com/tegra/docs/tegra_android_accelerometer_v5f.pdf
+ static void canonicalOrientationToScreenOrientation(
+ int displayRotation, float[] canVec, float[] screenVec) {
+ final int axisSwap[][] = {
+ { 1, -1, 0, 1 }, // ROTATION_0
+ {-1, -1, 1, 0 }, // ROTATION_90
+ {-1, 1, 0, 1 }, // ROTATION_180
+ { 1, 1, 1, 0 } }; // ROTATION_270
+
+ final int[] as = axisSwap[displayRotation];
+ screenVec[0] = (float)as[0] * canVec[ as[2] ];
+ screenVec[1] = (float)as[1] * canVec[ as[3] ];
+ screenVec[2] = canVec[2];
+ }
+
}
diff --git a/src/com/replica/replicaisland/InputTouchScreen.java b/src/com/replica/replicaisland/InputTouchScreen.java
new file mode 100644
index 0000000..1d8cd6b
--- /dev/null
+++ b/src/com/replica/replicaisland/InputTouchScreen.java
@@ -0,0 +1,115 @@
+package com.replica.replicaisland;
+
+public class InputTouchScreen extends BaseObject {
+
+ private int MAX_TOUCH_POINTS = 5;
+ private InputXY mTouchPoints[];
+
+ public InputTouchScreen() {
+ mTouchPoints = new InputXY[MAX_TOUCH_POINTS];
+ for (int x = 0; x < MAX_TOUCH_POINTS; x++) {
+ mTouchPoints[x] = new InputXY();
+ }
+ }
+
+ @Override
+ public void reset() {
+ for (int x = 0; x < MAX_TOUCH_POINTS; x++) {
+ mTouchPoints[x].reset();
+ }
+ }
+
+ public final void press(int index, float currentTime, float x, float y) {
+ assert (index >= 0 && index < MAX_TOUCH_POINTS);
+ if (index < MAX_TOUCH_POINTS) {
+ mTouchPoints[index].press(currentTime, x, y);
+ }
+ }
+
+ public final void release(int index) {
+ if (index < MAX_TOUCH_POINTS) {
+ mTouchPoints[index].release();
+ }
+ }
+
+ public void resetAll() {
+ for (int x = 0; x < MAX_TOUCH_POINTS; x++) {
+ mTouchPoints[x].reset();
+ }
+ }
+
+ public boolean getTriggered(int index, float time) {
+ boolean triggered = false;
+ if (index < MAX_TOUCH_POINTS) {
+ triggered = mTouchPoints[index].getTriggered(time);
+ }
+ return triggered;
+ }
+
+ public boolean getPressed(int index) {
+ boolean pressed = false;
+ if (index < MAX_TOUCH_POINTS) {
+ pressed = mTouchPoints[index].getPressed();
+ }
+ return pressed;
+ }
+
+ public final void setVector(int index, Vector2 vector) {
+ if (index < MAX_TOUCH_POINTS) {
+ mTouchPoints[index].setVector(vector);
+ }
+ }
+
+ public final float getX(int index) {
+ float magnitude = 0.0f;
+ if (index < MAX_TOUCH_POINTS) {
+ magnitude = mTouchPoints[index].getX();
+ }
+ return magnitude;
+ }
+
+ public final float getY(int index) {
+ float magnitude = 0.0f;
+ if (index < MAX_TOUCH_POINTS) {
+ magnitude = mTouchPoints[index].getY();
+ }
+ return magnitude;
+ }
+
+ public final float getLastPressedTime(int index) {
+ float time = 0.0f;
+ if (index < MAX_TOUCH_POINTS) {
+ time = mTouchPoints[index].getLastPressedTime();
+ }
+ return time;
+ }
+
+ public InputXY findPointerInRegion(float regionX, float regionY, float regionWidth, float regionHeight) {
+ InputXY touch = null;
+ for (int x = 0; x < MAX_TOUCH_POINTS; x++) {
+ final InputXY pointer = mTouchPoints[x];
+ if (pointer.getPressed() &&
+ getTouchedWithinRegion(pointer.getX(), pointer.getY(), regionX, regionY, regionWidth, regionHeight)) {
+ touch = pointer;
+ break;
+ }
+ }
+ return touch;
+ }
+
+ private final boolean getTouchedWithinRegion(float x, float y, float regionX, float regionY, float regionWidth, float regionHeight) {
+ return (x >= regionX &&
+ y >= regionY &&
+ x <= regionX + regionWidth &&
+ y <= regionY + regionHeight);
+ }
+
+ public boolean getTriggered(float gameTime) {
+ boolean triggered = false;
+ for (int x = 0; x < MAX_TOUCH_POINTS && !triggered; x++) {
+ triggered = mTouchPoints[x].getTriggered(gameTime);
+ }
+ return triggered;
+ }
+
+}
diff --git a/src/com/replica/replicaisland/KidsDifficultyConstants.java b/src/com/replica/replicaisland/KidsDifficultyConstants.java
new file mode 100644
index 0000000..37b5a2f
--- /dev/null
+++ b/src/com/replica/replicaisland/KidsDifficultyConstants.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.replica.replicaisland;
+
+public class KidsDifficultyConstants extends DifficultyConstants {
+
+ private static final float FUEL_AIR_REFILL_SPEED = 0.15f;
+ private static final float FUEL_GROUND_REFILL_SPEED = 2.0f;
+ public static final int MAX_PLAYER_LIFE = 3;
+ private static final int COINS_PER_POWERUP = 20;
+
+ public static final float GLOW_DURATION = 15.0f;
+
+ // DDA boosts
+ private static final int DDA_STAGE_1_ATTEMPTS = 3;
+ private static final int DDA_STAGE_2_ATTEMPTS = 8;
+ private static final int DDA_STAGE_1_LIFE_BOOST = 1;
+ private static final int DDA_STAGE_2_LIFE_BOOST = 2;
+ private static final float DDA_STAGE_1_FUEL_AIR_REFILL_SPEED = 0.22f;
+ private static final float DDA_STAGE_2_FUEL_AIR_REFILL_SPEED = 0.30f;
+
+ @Override
+ public float getFuelAirRefillSpeed() {
+ return FUEL_AIR_REFILL_SPEED;
+ }
+
+ @Override
+ public float getFuelGroundRefillSpeed() {
+ return FUEL_GROUND_REFILL_SPEED;
+ }
+
+ @Override
+ public int getMaxPlayerLife() {
+ return MAX_PLAYER_LIFE;
+ }
+
+ @Override
+ public int getCoinsPerPowerup() {
+ return COINS_PER_POWERUP;
+ }
+
+ @Override
+ public float getGlowDuration() {
+ return GLOW_DURATION;
+ }
+
+ @Override
+ public int getDDAStage1Attempts() {
+ return DDA_STAGE_1_ATTEMPTS;
+ }
+
+ @Override
+ public int getDDAStage2Attempts() {
+ return DDA_STAGE_2_ATTEMPTS;
+ }
+
+ @Override
+ public int getDDAStage1LifeBoost() {
+ return DDA_STAGE_1_LIFE_BOOST;
+ }
+
+ @Override
+ public int getDDAStage2LifeBoost() {
+ return DDA_STAGE_2_LIFE_BOOST;
+ }
+
+ @Override
+ public float getDDAStage1FuelAirRefillSpeed() {
+ return DDA_STAGE_1_FUEL_AIR_REFILL_SPEED;
+ }
+
+ @Override
+ public float getDDAStage2FuelAirRefillSpeed() {
+ return DDA_STAGE_2_FUEL_AIR_REFILL_SPEED;
+ }
+
+}
diff --git a/src/com/replica/replicaisland/LaunchProjectileComponent.java b/src/com/replica/replicaisland/LaunchProjectileComponent.java
index aa03bd8..f60f6b1 100644
--- a/src/com/replica/replicaisland/LaunchProjectileComponent.java
+++ b/src/com/replica/replicaisland/LaunchProjectileComponent.java
@@ -237,6 +237,11 @@ public class LaunchProjectileComponent extends GameComponent {
mTrackProjectiles = true;
}
+ public final void disableProjectileTracking() {
+ mMaxTrackedProjectiles = 0;
+ mTrackProjectiles = false;
+ }
+
public final void trackedProjectileDestroyed() {
assert mTrackProjectiles;
if (mTrackedProjectileCount == mMaxTrackedProjectiles) {
diff --git a/src/com/replica/replicaisland/LevelSelectActivity.java b/src/com/replica/replicaisland/LevelSelectActivity.java
index 72243e6..b9c49e7 100644
--- a/src/com/replica/replicaisland/LevelSelectActivity.java
+++ b/src/com/replica/replicaisland/LevelSelectActivity.java
@@ -33,6 +33,7 @@ import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@@ -170,7 +171,15 @@ public class LevelSelectActivity extends ListActivity {
setContentView(R.layout.level_select);
mLevelData = new ArrayList<LevelMetaData>();
- generateLevelList(true);
+ if (getIntent().getBooleanExtra("unlockAll", false)) {
+ generateLevelList(false);
+ for (LevelMetaData level : mLevelData) {
+ level.enabled = true;
+ }
+ } else {
+ generateLevelList(true);
+ }
+
DisableItemArrayAdapter<LevelMetaData> adapter = new DisableItemArrayAdapter<LevelMetaData>(
this, R.layout.level_select_row, R.layout.level_select_disabled_row, R.layout.level_select_completed_row,
@@ -246,6 +255,15 @@ public class LevelSelectActivity extends ListActivity {
} else {
setResult(RESULT_OK, intent);
finish();
+ if (UIConstants.mOverridePendingTransition != null) {
+ try {
+ UIConstants.mOverridePendingTransition.invoke(LevelSelectActivity.this, R.anim.activity_fade_in, R.anim.activity_fade_out);
+ } catch (InvocationTargetException ite) {
+ DebugLog.d("Activity Transition", "Invocation Target Exception");
+ } catch (IllegalAccessException ie) {
+ DebugLog.d("Activity Transition", "Illegal Access Exception");
+ }
+ }
}
}
}
diff --git a/src/com/replica/replicaisland/LevelTree.java b/src/com/replica/replicaisland/LevelTree.java
index 72844a8..6dfdd8c 100644
--- a/src/com/replica/replicaisland/LevelTree.java
+++ b/src/com/replica/replicaisland/LevelTree.java
@@ -63,17 +63,18 @@ public final class LevelTree {
}
public final static ArrayList<LevelGroup> levels = new ArrayList<LevelGroup>();
private static boolean mLoaded = false;
+ private static int mLoadedResource = 0;
public static final Level get(int row, int index) {
return levels.get(row).levels.get(index);
}
- public static final boolean isLoaded() {
- return mLoaded;
+ public static final boolean isLoaded(int resource) {
+ return mLoaded && mLoadedResource == resource;
}
public static final void loadLevelTree(int resource, Context context) {
- if (levels.size() > 0) {
+ if (levels.size() > 0 && mLoadedResource == resource) {
// already loaded
return;
}
@@ -189,6 +190,7 @@ public final class LevelTree {
parser.close();
}
mLoaded = true;
+ mLoadedResource = resource;
}
public final static void loadAllDialog(Context context) {
diff --git a/src/com/replica/replicaisland/LifetimeComponent.java b/src/com/replica/replicaisland/LifetimeComponent.java
index 09532e3..696d934 100644
--- a/src/com/replica/replicaisland/LifetimeComponent.java
+++ b/src/com/replica/replicaisland/LifetimeComponent.java
@@ -32,6 +32,8 @@ public class LifetimeComponent extends GameComponent {
private boolean mVulnerableToDeathTiles;
private boolean mDieOnHitBackground;
private Sound mDeathSound;
+ private boolean mIncrementEventCounter;
+ private int mEventCounter;
public LifetimeComponent() {
super();
@@ -51,6 +53,8 @@ public class LifetimeComponent extends GameComponent {
mVulnerableToDeathTiles = false;
mDieOnHitBackground = false;
mDeathSound = null;
+ mIncrementEventCounter = false;
+ mEventCounter = -1;
}
public void setDieWhenInvisible(boolean die) {
@@ -65,6 +69,11 @@ public class LifetimeComponent extends GameComponent {
mSpawnOnDeathType = type;
}
+ public void setIncrementEventCounter(int event) {
+ mIncrementEventCounter = true;
+ mEventCounter = event;
+ }
+
@Override
public void update(float timeDelta, BaseObject parent) {
GameObject parentObject = (GameObject)parent;
@@ -126,6 +135,11 @@ public class LifetimeComponent extends GameComponent {
ghost.releaseControl(parentObject);
}
}
+
+ if (mIncrementEventCounter) {
+ EventRecorder recorder = sSystemRegistry.eventRecorder;
+ recorder.incrementEventCounter(mEventCounter);
+ }
if (mSpawnOnDeathType != GameObjectFactory.GameObjectType.INVALID) {
GameObject object = factory.spawn(mSpawnOnDeathType, parentObject.getPosition().x,
@@ -141,6 +155,7 @@ public class LifetimeComponent extends GameComponent {
mTrackingSpawner.trackedProjectileDestroyed();
}
+
if (manager != null) {
manager.destroy(parentObject);
}
diff --git a/src/com/replica/replicaisland/MainMenuActivity.java b/src/com/replica/replicaisland/MainMenuActivity.java
index 87c8bed..e25051c 100644
--- a/src/com/replica/replicaisland/MainMenuActivity.java
+++ b/src/com/replica/replicaisland/MainMenuActivity.java
@@ -17,14 +17,20 @@
package com.replica.replicaisland;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
+import android.text.Html;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
@@ -34,25 +40,31 @@ public class MainMenuActivity extends Activity {
private boolean mPaused;
private View mStartButton;
private View mOptionsButton;
+ private View mExtrasButton;
private View mBackground;
private View mTicker;
private Animation mButtonFlickerAnimation;
private Animation mFadeOutAnimation;
private Animation mAlternateFadeOutAnimation;
private Animation mFadeInAnimation;
+ private boolean mJustCreated;
+ private String mSelectedControlsString;
- private final static int WHATS_NEW_DIALOG = 0;
+ private final static int WHATS_NEW_DIALOG = 0;
+ private final static int TILT_TO_SCREEN_CONTROLS_DIALOG = 1;
+ private final static int CONTROL_SETUP_DIALOG = 2;
+
// Create an anonymous implementation of OnClickListener
- private View.OnClickListener sStartButtonListener = new View.OnClickListener() {
+ private View.OnClickListener sContinueButtonListener = new View.OnClickListener() {
public void onClick(View v) {
if (!mPaused) {
Intent i = new Intent(getBaseContext(), AndouKun.class);
-
v.startAnimation(mButtonFlickerAnimation);
mFadeOutAnimation.setAnimationListener(new StartActivityAfterAnimation(i));
mBackground.startAnimation(mFadeOutAnimation);
mOptionsButton.startAnimation(mAlternateFadeOutAnimation);
+ mExtrasButton.startAnimation(mAlternateFadeOutAnimation);
mTicker.startAnimation(mAlternateFadeOutAnimation);
mPaused = true;
}
@@ -68,12 +80,40 @@ public class MainMenuActivity extends Activity {
mFadeOutAnimation.setAnimationListener(new StartActivityAfterAnimation(i));
mBackground.startAnimation(mFadeOutAnimation);
mStartButton.startAnimation(mAlternateFadeOutAnimation);
+ mExtrasButton.startAnimation(mAlternateFadeOutAnimation);
mTicker.startAnimation(mAlternateFadeOutAnimation);
mPaused = true;
}
}
};
+ private View.OnClickListener sExtrasButtonListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ if (!mPaused) {
+ Intent i = new Intent(getBaseContext(), ExtrasMenuActivity.class);
+
+ v.startAnimation(mButtonFlickerAnimation);
+ mButtonFlickerAnimation.setAnimationListener(new StartActivityAfterAnimation(i));
+ mPaused = true;
+
+ }
+ }
+ };
+
+ private View.OnClickListener sStartButtonListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ if (!mPaused) {
+ Intent i = new Intent(getBaseContext(), DifficultyMenuActivity.class);
+ i.putExtra("newGame", true);
+ v.startAnimation(mButtonFlickerAnimation);
+ mButtonFlickerAnimation.setAnimationListener(new StartActivityAfterAnimation(i));
+
+ mPaused = true;
+
+ }
+ }
+ };
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -84,22 +124,31 @@ public class MainMenuActivity extends Activity {
mOptionsButton = findViewById(R.id.optionButton);
mBackground = findViewById(R.id.mainMenuBackground);
- if (mStartButton != null) {
- mStartButton.setOnClickListener(sStartButtonListener);
- }
-
if (mOptionsButton != null) {
mOptionsButton.setOnClickListener(sOptionButtonListener);
}
+ mExtrasButton = findViewById(R.id.extrasButton);
+ mExtrasButton.setOnClickListener(sExtrasButtonListener);
mButtonFlickerAnimation = AnimationUtils.loadAnimation(this, R.anim.button_flicker);
mFadeOutAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
mAlternateFadeOutAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
mFadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_in);
- if (!LevelTree.isLoaded()) {
- LevelTree.loadLevelTree(R.xml.level_tree, this);
+ SharedPreferences prefs = getSharedPreferences(PreferenceConstants.PREFERENCE_NAME, MODE_PRIVATE);
+ final int row = prefs.getInt(PreferenceConstants.PREFERENCE_LEVEL_ROW, 0);
+ final int index = prefs.getInt(PreferenceConstants.PREFERENCE_LEVEL_INDEX, 0);
+ int levelTreeResource = R.xml.level_tree;
+ if (row != 0 || index != 0) {
+ final int linear = prefs.getInt(PreferenceConstants.PREFERENCE_LINEAR_MODE, 0);
+ if (linear != 0) {
+ levelTreeResource = R.xml.linear_level_tree;
+ }
+ }
+
+ if (!LevelTree.isLoaded(levelTreeResource)) {
+ LevelTree.loadLevelTree(levelTreeResource, this);
LevelTree.loadAllDialog(this);
}
@@ -110,12 +159,15 @@ public class MainMenuActivity extends Activity {
mTicker.setSelected(true);
}
+ mJustCreated = true;
+
// Keep the volume control type consistent across all activities.
setVolumeControlStream(AudioManager.STREAM_MUSIC);
//MediaPlayer mp = MediaPlayer.create(this, R.raw.bwv_115);
//mp.start();
+
}
@@ -130,23 +182,31 @@ public class MainMenuActivity extends Activity {
super.onResume();
mPaused = false;
+ mButtonFlickerAnimation.setAnimationListener(null);
if (mStartButton != null) {
- mStartButton.setVisibility(View.VISIBLE);
- mStartButton.clearAnimation();
- mStartButton.startAnimation(AnimationUtils.loadAnimation(this, R.anim.button_slide));
// Change "start" to "continue" if there's a saved game.
- SharedPreferences prefs = getSharedPreferences(AndouKun.PREFERENCE_NAME, MODE_PRIVATE);
- final int row = prefs.getInt(AndouKun.PREFERENCE_LEVEL_ROW, 0);
- final int index = prefs.getInt(AndouKun.PREFERENCE_LEVEL_INDEX, 0);
+ SharedPreferences prefs = getSharedPreferences(PreferenceConstants.PREFERENCE_NAME, MODE_PRIVATE);
+ final int row = prefs.getInt(PreferenceConstants.PREFERENCE_LEVEL_ROW, 0);
+ final int index = prefs.getInt(PreferenceConstants.PREFERENCE_LEVEL_INDEX, 0);
if (row != 0 || index != 0) {
((ImageView)mStartButton).setImageDrawable(getResources().getDrawable(R.drawable.ui_button_continue));
+ mStartButton.setOnClickListener(sContinueButtonListener);
} else {
((ImageView)mStartButton).setImageDrawable(getResources().getDrawable(R.drawable.ui_button_start));
+ mStartButton.setOnClickListener(sStartButtonListener);
}
- final int lastVersion = prefs.getInt(AndouKun.PREFERENCE_LAST_VERSION, 0);
+ TouchFilter touch;
+ final int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
+ if (sdkVersion < Build.VERSION_CODES.ECLAIR) {
+ touch = new SingleTouchFilter();
+ } else {
+ touch = new MultiTouchFilter();
+ }
+
+ final int lastVersion = prefs.getInt(PreferenceConstants.PREFERENCE_LAST_VERSION, 0);
if (lastVersion == 0) {
// This is the first time the game has been run.
// Pre-configure the control options to match the device.
@@ -154,24 +214,34 @@ public class MainMenuActivity extends Activity {
// TODO: is there a better way to do this? Seems like a kind of neat
// way to do custom device profiles.
final String navType = getString(R.string.nav_type);
+ mSelectedControlsString = getString(R.string.control_setup_dialog_trackball);
if (navType != null) {
if (navType.equalsIgnoreCase("DPad")) {
// Turn off the click-to-attack pref on devices that have a dpad.
SharedPreferences.Editor editor = prefs.edit();
- editor.putBoolean(AndouKun.PREFERENCE_CLICK_ATTACK, false);
+ editor.putBoolean(PreferenceConstants.PREFERENCE_CLICK_ATTACK, false);
editor.commit();
+ mSelectedControlsString = getString(R.string.control_setup_dialog_dpad);
} else if (navType.equalsIgnoreCase("None")) {
- // Turn on tilt controls if there's nothing else.
SharedPreferences.Editor editor = prefs.edit();
- editor.putBoolean(AndouKun.PREFERENCE_TILT_CONTROLS, true);
+
+ // This test relies on the PackageManager if api version >= 5.
+ if (touch.supportsMultitouch(this)) {
+ // Default to screen controls.
+ editor.putBoolean(PreferenceConstants.PREFERENCE_SCREEN_CONTROLS, true);
+ mSelectedControlsString = getString(R.string.control_setup_dialog_screen);
+ } else {
+ // Turn on tilt controls if there's nothing else.
+ editor.putBoolean(PreferenceConstants.PREFERENCE_TILT_CONTROLS, true);
+ mSelectedControlsString = getString(R.string.control_setup_dialog_tilt);
+ }
editor.commit();
+
}
}
}
-
-
-
+
if (Math.abs(lastVersion) < Math.abs(AndouKun.VERSION)) {
// This is a new install or an upgrade.
@@ -182,33 +252,47 @@ public class MainMenuActivity extends Activity {
Build.MODEL.contains("U8220") || // Huawei Pulse
Build.MODEL.contains("U8230") || // Huawei U8230
Build.MODEL.contains("MB300") || // Motorola Backflip
+ Build.MODEL.contains("MB501") || // Motorola Quench / Cliq XT
Build.MODEL.contains("Behold+II")) { // Samsung Behold II
// These are all models that users have complained about. They likely use
// the same buggy QTC graphics driver. Turn on Safe Mode by default
// for these devices.
SharedPreferences.Editor editor = prefs.edit();
- editor.putBoolean(AndouKun.PREFERENCE_SAFE_MODE, true);
+ editor.putBoolean(PreferenceConstants.PREFERENCE_SAFE_MODE, true);
editor.commit();
}
- // show what's new message
SharedPreferences.Editor editor = prefs.edit();
- editor.putInt(AndouKun.PREFERENCE_LAST_VERSION, AndouKun.VERSION);
+
+ if (lastVersion > 0 && lastVersion < 14) {
+ // if the user has beat the game once, go ahead and unlock stuff for them.
+ if (prefs.getInt(PreferenceConstants.PREFERENCE_LAST_ENDING, -1) != -1) {
+ editor.putBoolean(PreferenceConstants.PREFERENCE_EXTRAS_UNLOCKED, true);
+ }
+ }
+
+ // show what's new message
+ editor.putInt(PreferenceConstants.PREFERENCE_LAST_VERSION, AndouKun.VERSION);
editor.commit();
showDialog(WHATS_NEW_DIALOG);
+ // screen controls were added in version 14
+ if (lastVersion > 0 && lastVersion < 14 &&
+ prefs.getBoolean(PreferenceConstants.PREFERENCE_TILT_CONTROLS, false)) {
+ if (touch.supportsMultitouch(this)) {
+ // show message about switching from tilt to screen controls
+ showDialog(TILT_TO_SCREEN_CONTROLS_DIALOG);
+ }
+ } else if (lastVersion == 0) {
+ // show message about auto-selected control schemes.
+ showDialog(CONTROL_SETUP_DIALOG);
+ }
+
}
}
-
- if (mOptionsButton != null) {
- mOptionsButton.setVisibility(View.VISIBLE);
- mOptionsButton.clearAnimation();
- Animation anim = AnimationUtils.loadAnimation(this, R.anim.button_slide);
- anim.setStartOffset(200L);
- mOptionsButton.startAnimation(anim);
- }
+
if (mBackground != null) {
mBackground.clearAnimation();
@@ -219,6 +303,29 @@ public class MainMenuActivity extends Activity {
mTicker.setAnimation(mFadeInAnimation);
}
+ if (mJustCreated) {
+ if (mStartButton != null) {
+ mStartButton.startAnimation(AnimationUtils.loadAnimation(this, R.anim.button_slide));
+ }
+ if (mExtrasButton != null) {
+ Animation anim = AnimationUtils.loadAnimation(this, R.anim.button_slide);
+ anim.setStartOffset(500L);
+ mExtrasButton.startAnimation(anim);
+ }
+
+ if (mOptionsButton != null) {
+ Animation anim = AnimationUtils.loadAnimation(this, R.anim.button_slide);
+ anim.setStartOffset(1000L);
+ mOptionsButton.startAnimation(anim);
+ }
+ mJustCreated = false;
+
+ } else {
+ mStartButton.clearAnimation();
+ mOptionsButton.clearAnimation();
+ mExtrasButton.clearAnimation();
+ }
+
}
@@ -231,6 +338,36 @@ public class MainMenuActivity extends Activity {
.setPositiveButton(R.string.whats_new_dialog_ok, null)
.setMessage(R.string.whats_new_dialog_message)
.create();
+ } else if (id == TILT_TO_SCREEN_CONTROLS_DIALOG) {
+ dialog = new AlertDialog.Builder(this)
+ .setTitle(R.string.onscreen_tilt_dialog_title)
+ .setPositiveButton(R.string.onscreen_tilt_dialog_ok, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ SharedPreferences prefs = getSharedPreferences(PreferenceConstants.PREFERENCE_NAME, MODE_PRIVATE);
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putBoolean(PreferenceConstants.PREFERENCE_SCREEN_CONTROLS, true);
+ editor.commit();
+ }
+ })
+ .setNegativeButton(R.string.onscreen_tilt_dialog_cancel, null)
+ .setMessage(R.string.onscreen_tilt_dialog_message)
+ .create();
+ } else if (id == CONTROL_SETUP_DIALOG) {
+ String messageFormat = getResources().getString(R.string.control_setup_dialog_message);
+ String message = String.format(messageFormat, mSelectedControlsString);
+ CharSequence sytledMessage = Html.fromHtml(message); // lame.
+ dialog = new AlertDialog.Builder(this)
+ .setTitle(R.string.control_setup_dialog_title)
+ .setPositiveButton(R.string.control_setup_dialog_ok, null)
+ .setNegativeButton(R.string.control_setup_dialog_change, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ Intent i = new Intent(getBaseContext(), SetPreferencesActivity.class);
+ i.putExtra("controlConfig", true);
+ startActivity(i);
+ }
+ })
+ .setMessage(sytledMessage)
+ .create();
} else {
dialog = super.onCreateDialog(id);
}
@@ -246,11 +383,18 @@ public class MainMenuActivity extends Activity {
public void onAnimationEnd(Animation animation) {
- mStartButton.setVisibility(View.INVISIBLE);
- mStartButton.clearAnimation();
- mOptionsButton.setVisibility(View.INVISIBLE);
- mOptionsButton.clearAnimation();
- startActivity(mIntent);
+
+ startActivity(mIntent);
+
+ if (UIConstants.mOverridePendingTransition != null) {
+ try {
+ UIConstants.mOverridePendingTransition.invoke(MainMenuActivity.this, R.anim.activity_fade_in, R.anim.activity_fade_out);
+ } catch (InvocationTargetException ite) {
+ DebugLog.d("Activity Transition", "Invocation Target Exception");
+ } catch (IllegalAccessException ie) {
+ DebugLog.d("Activity Transition", "Illegal Access Exception");
+ }
+ }
}
public void onAnimationRepeat(Animation animation) {
diff --git a/src/com/replica/replicaisland/MultiTouchFilter.java b/src/com/replica/replicaisland/MultiTouchFilter.java
new file mode 100644
index 0000000..4df2030
--- /dev/null
+++ b/src/com/replica/replicaisland/MultiTouchFilter.java
@@ -0,0 +1,43 @@
+package com.replica.replicaisland;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.view.MotionEvent;
+
+public class MultiTouchFilter extends SingleTouchFilter {
+ private boolean mCheckedForMultitouch = false;
+ private boolean mSupportsMultitouch = false;
+
+ @Override
+ public void updateTouch(MotionEvent event) {
+ ContextParameters params = sSystemRegistry.contextParameters;
+ final int pointerCount = event.getPointerCount();
+ for (int x = 0; x < pointerCount; x++) {
+ final int action = event.getAction();
+ final int actualEvent = action & MotionEvent.ACTION_MASK;
+ final int id = event.getPointerId(x);
+ if (actualEvent == MotionEvent.ACTION_POINTER_UP ||
+ actualEvent == MotionEvent.ACTION_UP ||
+ actualEvent == MotionEvent.ACTION_CANCEL) {
+ BaseObject.sSystemRegistry.inputSystem.touchUp(id,
+ event.getX(x) * (1.0f / params.viewScaleX),
+ event.getY(x) * (1.0f / params.viewScaleY));
+ } else {
+ BaseObject.sSystemRegistry.inputSystem.touchDown(id,
+ event.getX(x) * (1.0f / params.viewScaleX),
+ event.getY(x) * (1.0f / params.viewScaleY));
+ }
+ }
+ }
+
+ @Override
+ public boolean supportsMultitouch(Context context) {
+ if (!mCheckedForMultitouch) {
+ PackageManager packageManager = context.getPackageManager();
+ mSupportsMultitouch = packageManager.hasSystemFeature("android.hardware.touchscreen.multitouch");
+ mCheckedForMultitouch = true;
+ }
+
+ return mSupportsMultitouch;
+ }
+}
diff --git a/src/com/replica/replicaisland/PlayerComponent.java b/src/com/replica/replicaisland/PlayerComponent.java
index de36bb8..adaa1af 100644
--- a/src/com/replica/replicaisland/PlayerComponent.java
+++ b/src/com/replica/replicaisland/PlayerComponent.java
@@ -31,8 +31,7 @@ public class PlayerComponent extends GameComponent {
private static final float MAX_UPWARD_SPEED = 250.0f;
private static final float VERTICAL_IMPULSE_TOLERANCE = 50.0f;
private static final float FUEL_AMOUNT = 1.0f;
- private static final float FUEL_AIR_REFILL_SPEED = 0.15f;
- private static final float FUEL_GROUND_REFILL_SPEED = 2.0f;
+
private static final float JUMP_TO_JETS_DELAY = 0.5f;
private static final float STOMP_VELOCITY = -1000.0f;
@@ -45,23 +44,12 @@ public class PlayerComponent extends GameComponent {
private static final float GHOST_REACTIVATION_DELAY = 0.3f;
private static final float GHOST_CHARGE_TIME = 0.75f;
- public static final int MAX_PLAYER_LIFE = 3;
private static final int MAX_GEMS_PER_LEVEL = 3;
- private static final int COINS_PER_POWERUP = 20;
private static final float NO_GEMS_GHOST_TIME = 3.0f;
private static final float ONE_GEM_GHOST_TIME = 8.0f;
private static final float TWO_GEMS_GHOST_TIME = 0.0f; // no limit.
- public static final float GLOW_DURATION = 15.0f;
-
- // DDA boosts
- private static final int DDA_STAGE_1_ATTEMPTS = 3;
- private static final int DDA_STAGE_2_ATTEMPTS = 8;
- private static final int DDA_STAGE_1_LIFE_BOOST = 1;
- private static final int DDA_STAGE_2_LIFE_BOOST = 2;
- private static final float FUEL_AIR_REFILL_SPEED_DDA1 = 0.22f;
- private static final float FUEL_AIR_REFILL_SPEED_DDA2 = 0.30f;
public enum State {
MOVE,
@@ -88,6 +76,13 @@ public class PlayerComponent extends GameComponent {
private float mInvincibleEndTime;
private HitReactionComponent mHitReaction;
private float mFuelAirRefillSpeed;
+ private DifficultyConstants mDifficultyConstants;
+ private final static DifficultyConstants sDifficultyArray[] = {
+ new BabyDifficultyConstants(),
+ new KidsDifficultyConstants(),
+ new AdultsDifficultyConstants()
+ };
+ private FadeDrawableComponent mInvincibleFader; // HACK!
// Variables recorded for animation decisions.
private boolean mRocketsOn;
@@ -115,7 +110,9 @@ public class PlayerComponent extends GameComponent {
mInvincibleSwap = null;
mInvincibleEndTime = 0.0f;
mHitReaction = null;
- mFuelAirRefillSpeed = FUEL_AIR_REFILL_SPEED;
+ mDifficultyConstants = getDifficultyConstants();
+ mFuelAirRefillSpeed = mDifficultyConstants.getFuelAirRefillSpeed();
+ mInvincibleFader = null;
}
protected void move(float time, float timeDelta, GameObject parentObject) {
@@ -126,7 +123,7 @@ public class PlayerComponent extends GameComponent {
if (mFuel < FUEL_AMOUNT) {
if (mTouchingGround) {
- mFuel += FUEL_GROUND_REFILL_SPEED * timeDelta;
+ mFuel += mDifficultyConstants.getFuelGroundRefillSpeed() * timeDelta;
} else {
mFuel += mFuelAirRefillSpeed * timeDelta;
}
@@ -230,16 +227,27 @@ public class PlayerComponent extends GameComponent {
if (mInventory != null && mState != State.WIN) {
InventoryComponent.UpdateRecord inventory = mInventory.getRecord();
- if (inventory.coinCount >= COINS_PER_POWERUP) {
+ if (inventory.coinCount >= mDifficultyConstants.getCoinsPerPowerup()) {
inventory.coinCount = 0;
mInventory.setChanged();
- parentObject.life = MAX_PLAYER_LIFE;
+ parentObject.life = mDifficultyConstants.getMaxPlayerLife();
if (mInvincibleEndTime < gameTime) {
mInvincibleSwap.activate(parentObject);
- mInvincibleEndTime = gameTime + GLOW_DURATION;
+ mInvincibleEndTime = gameTime + mDifficultyConstants.getGlowDuration();
if (mHitReaction != null) {
mHitReaction.setForceInvincible(true);
}
+ } else {
+ // invincibility is already active, extend it.
+ mInvincibleEndTime = gameTime + mDifficultyConstants.getGlowDuration();
+ // HACK HACK HACK. This really doesn't go here.
+ // To extend the invincible time we need to increment the value above (easy)
+ // and also tell the component managing the glow sprite to reset its
+ // timer (not easy). Next time, make a shared value system for this
+ // kind of case!!
+ if (mInvincibleFader != null) {
+ mInvincibleFader.resetPhase();
+ }
}
}
if (inventory.rubyCount >= MAX_GEMS_PER_LEVEL) {
@@ -247,7 +255,7 @@ public class PlayerComponent extends GameComponent {
}
}
- if (mInvincibleEndTime > 0.0f && mInvincibleEndTime < gameTime) {
+ if (mInvincibleEndTime > 0.0f && (mInvincibleEndTime < gameTime || mState == State.DEAD)) {
mInvincibleSwap.activate(parentObject);
mInvincibleEndTime = 0.0f;
if (mHitReaction != null) {
@@ -311,7 +319,6 @@ public class PlayerComponent extends GameComponent {
final InputGameInterface input = sSystemRegistry.inputGameInterface;
if (hud != null) {
hud.setFuelPercent(mFuel / FUEL_AMOUNT);
- hud.setButtonState(input.getJumpButton().getPressed(), input.getAttackButton().getPressed());
}
}
@@ -546,22 +553,31 @@ public class PlayerComponent extends GameComponent {
mHitReaction = hitReact;
}
+ public final void setInvincibleFader(FadeDrawableComponent fader) {
+ mInvincibleFader = fader;
+ }
+
public final void adjustDifficulty(GameObject parent, int levelAttemps ) {
// Super basic DDA.
// If we've tried this levels several times secretly increase our
// hit points so the level gets easier.
// Also make fuel refill faster in the air after we've died too many times.
- if (levelAttemps >= DDA_STAGE_1_ATTEMPTS) {
- if (levelAttemps >= DDA_STAGE_2_ATTEMPTS) {
- parent.life += DDA_STAGE_2_LIFE_BOOST;
- mFuelAirRefillSpeed = FUEL_AIR_REFILL_SPEED_DDA2;
+
+ if (levelAttemps >= mDifficultyConstants.getDDAStage1Attempts()) {
+ if (levelAttemps >= mDifficultyConstants.getDDAStage2Attempts()) {
+ parent.life += mDifficultyConstants.getDDAStage2LifeBoost();
+ mFuelAirRefillSpeed = mDifficultyConstants.getDDAStage2FuelAirRefillSpeed();
} else {
- parent.life += DDA_STAGE_1_LIFE_BOOST;
- mFuelAirRefillSpeed = FUEL_AIR_REFILL_SPEED_DDA1;
+ parent.life += mDifficultyConstants.getDDAStage1LifeBoost();
+ mFuelAirRefillSpeed = mDifficultyConstants.getDDAStage1FuelAirRefillSpeed();
}
}
}
+
+ public static DifficultyConstants getDifficultyConstants() {
+ return sDifficultyArray[sSystemRegistry.contextParameters.difficulty];
+ }
} \ No newline at end of file
diff --git a/src/com/replica/replicaisland/PreferenceConstants.java b/src/com/replica/replicaisland/PreferenceConstants.java
new file mode 100644
index 0000000..8164f2b
--- /dev/null
+++ b/src/com/replica/replicaisland/PreferenceConstants.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.replica.replicaisland;
+
+public class PreferenceConstants {
+ public static final String PREFERENCE_LEVEL_ROW = "levelRow";
+ public static final String PREFERENCE_LEVEL_INDEX = "levelIndex";
+ public static final String PREFERENCE_LEVEL_COMPLETED = "levelsCompleted";
+ public static final String PREFERENCE_SOUND_ENABLED = "enableSound";
+ public static final String PREFERENCE_SAFE_MODE = "safeMode";
+ public static final String PREFERENCE_SESSION_ID = "session";
+ public static final String PREFERENCE_LAST_VERSION = "lastVersion";
+ public static final String PREFERENCE_STATS_ENABLED = "enableStats";
+ public static final String PREFERENCE_CLICK_ATTACK = "enableClickAttack";
+ public static final String PREFERENCE_TILT_CONTROLS = "enableTiltControls";
+ public static final String PREFERENCE_TILT_SENSITIVITY = "tiltSensitivity";
+ public static final String PREFERENCE_MOVEMENT_SENSITIVITY = "movementSensitivity";
+ public static final String PREFERENCE_SCREEN_CONTROLS = "enableScreenControls";
+ public static final String PREFERENCE_ENABLE_DEBUG = "enableDebug";
+ public static final String PREFERENCE_TOTAL_GAME_TIME = "totalGameTime";
+ public static final String PREFERENCE_LAST_ENDING = "lastEnding";
+ public static final String PREFERENCE_ROBOTS_DESTROYED = "robotsDestroyed";
+ public static final String PREFERENCE_PEARLS_COLLECTED = "pearlsCollected";
+ public static final String PREFERENCE_PEARLS_TOTAL = "pearlsTotal";
+ public static final String PREFERENCE_LINEAR_MODE = "linearMode";
+ public static final String PREFERENCE_EXTRAS_UNLOCKED = "extrasUnlocked";
+ public static final String PREFERENCE_DIFFICULTY = "difficulty";
+
+ public static final String PREFERENCE_LEFT_KEY = "keyLeft";
+ public static final String PREFERENCE_RIGHT_KEY = "keyRight";
+ public static final String PREFERENCE_ATTACK_KEY = "keyAttack";
+ public static final String PREFERENCE_JUMP_KEY = "keyJump";
+
+ public static final String PREFERENCE_NAME = "ReplicaIslandPrefs";
+
+
+
+
+}
diff --git a/src/com/replica/replicaisland/RenderSystem.java b/src/com/replica/replicaisland/RenderSystem.java
index ffe3794..977eb1b 100644
--- a/src/com/replica/replicaisland/RenderSystem.java
+++ b/src/com/replica/replicaisland/RenderSystem.java
@@ -32,7 +32,7 @@ public class RenderSystem extends BaseObject {
private int mQueueIndex;
private final static int DRAW_QUEUE_COUNT = 2;
- private final static int MAX_RENDER_OBJECTS_PER_FRAME = 256;
+ private final static int MAX_RENDER_OBJECTS_PER_FRAME = 384;
private final static int MAX_RENDER_OBJECTS = MAX_RENDER_OBJECTS_PER_FRAME * DRAW_QUEUE_COUNT;
public RenderSystem() {
diff --git a/src/com/replica/replicaisland/SetPreferencesActivity.java b/src/com/replica/replicaisland/SetPreferencesActivity.java
index 6e9d2f6..4b190b8 100644
--- a/src/com/replica/replicaisland/SetPreferencesActivity.java
+++ b/src/com/replica/replicaisland/SetPreferencesActivity.java
@@ -20,6 +20,7 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
+import android.preference.PreferenceScreen;
import android.widget.Toast;
@@ -30,7 +31,7 @@ public class SetPreferencesActivity extends PreferenceActivity implements
super.onCreate(savedInstanceState);
getPreferenceManager().setSharedPreferencesMode(MODE_PRIVATE);
- getPreferenceManager().setSharedPreferencesName(AndouKun.PREFERENCE_NAME);
+ getPreferenceManager().setSharedPreferencesName(PreferenceConstants.PREFERENCE_NAME);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
@@ -44,18 +45,32 @@ public class SetPreferencesActivity extends PreferenceActivity implements
Preference configureKeyboardPref = getPreferenceManager().findPreference("keyconfig");
if (configureKeyboardPref != null) {
KeyboardConfigDialogPreference config = (KeyboardConfigDialogPreference)configureKeyboardPref;
- config.setPrefs(getSharedPreferences(AndouKun.PREFERENCE_NAME, MODE_PRIVATE));
+ config.setPrefs(getSharedPreferences(PreferenceConstants.PREFERENCE_NAME, MODE_PRIVATE));
config.setContext(this);
}
+
+ if (getIntent().getBooleanExtra("controlConfig", false)) {
+ PreferenceScreen controlConfig = (PreferenceScreen)getPreferenceManager().findPreference("controlConfigScreen");
+ if (controlConfig != null) {
+ setPreferenceScreen(controlConfig);
+ }
+ }
}
public void onDialogClosed(boolean positiveResult) {
if (positiveResult) {
- SharedPreferences prefs = getSharedPreferences(AndouKun.PREFERENCE_NAME, MODE_PRIVATE);
+ SharedPreferences prefs = getSharedPreferences(PreferenceConstants.PREFERENCE_NAME, MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
- editor.remove(AndouKun.PREFERENCE_LEVEL_ROW);
- editor.remove(AndouKun.PREFERENCE_LEVEL_INDEX);
- editor.remove(AndouKun.PREFERENCE_LEVEL_COMPLETED);
+ editor.remove(PreferenceConstants.PREFERENCE_LEVEL_ROW);
+ editor.remove(PreferenceConstants.PREFERENCE_LEVEL_INDEX);
+ editor.remove(PreferenceConstants.PREFERENCE_LEVEL_COMPLETED);
+ editor.remove(PreferenceConstants.PREFERENCE_LINEAR_MODE);
+ editor.remove(PreferenceConstants.PREFERENCE_TOTAL_GAME_TIME);
+ editor.remove(PreferenceConstants.PREFERENCE_PEARLS_COLLECTED);
+ editor.remove(PreferenceConstants.PREFERENCE_PEARLS_TOTAL);
+ editor.remove(PreferenceConstants.PREFERENCE_ROBOTS_DESTROYED);
+ editor.remove(PreferenceConstants.PREFERENCE_DIFFICULTY);
+
editor.commit();
Toast.makeText(this, R.string.saved_game_erased_notification,
Toast.LENGTH_SHORT).show();
diff --git a/src/com/replica/replicaisland/SingleTouchFilter.java b/src/com/replica/replicaisland/SingleTouchFilter.java
new file mode 100644
index 0000000..fac04bb
--- /dev/null
+++ b/src/com/replica/replicaisland/SingleTouchFilter.java
@@ -0,0 +1,21 @@
+package com.replica.replicaisland;
+
+import android.view.MotionEvent;
+
+public class SingleTouchFilter extends TouchFilter {
+
+ public void updateTouch(MotionEvent event) {
+ ContextParameters params = sSystemRegistry.contextParameters;
+ if (event.getAction() == MotionEvent.ACTION_UP) {
+ sSystemRegistry.inputSystem.touchUp(0, event.getRawX() * (1.0f / params.viewScaleX),
+ event.getRawY() * (1.0f / params.viewScaleY));
+ } else {
+ sSystemRegistry.inputSystem.touchDown(0, event.getRawX() * (1.0f / params.viewScaleX),
+ event.getRawY() * (1.0f / params.viewScaleY));
+ }
+ }
+ @Override
+ public void reset() {
+ }
+
+}
diff --git a/src/com/replica/replicaisland/SoundSystem.java b/src/com/replica/replicaisland/SoundSystem.java
index 84c2226..65854d0 100644
--- a/src/com/replica/replicaisland/SoundSystem.java
+++ b/src/com/replica/replicaisland/SoundSystem.java
@@ -116,6 +116,15 @@ public class SoundSystem extends BaseObject {
mSoundPool.resume(stream);
}
+ public final void stopAll() {
+ final int count = mLoopingStreams.length;
+ for (int x = count - 1; x >= 0; x--) {
+ if (mLoopingStreams[x] >= 0) {
+ stop(mLoopingStreams[x]);
+ }
+ }
+ }
+
// HACK: There's no way to pause an entire sound pool, but if we
// don't do something when our parent activity is paused, looping
// sounds will continue to play. Rather that reproduce all the bookkeeping
diff --git a/src/com/replica/replicaisland/TouchFilter.java b/src/com/replica/replicaisland/TouchFilter.java
new file mode 100644
index 0000000..b6172d2
--- /dev/null
+++ b/src/com/replica/replicaisland/TouchFilter.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.replica.replicaisland;
+
+import android.content.Context;
+import android.view.MotionEvent;
+
+public abstract class TouchFilter extends BaseObject {
+
+ public abstract void updateTouch(MotionEvent event);
+
+ public boolean supportsMultitouch(Context context) {
+ return false;
+ }
+
+ @Override
+ public void reset() {
+ }
+
+}
diff --git a/src/com/replica/replicaisland/UIConstants.java b/src/com/replica/replicaisland/UIConstants.java
new file mode 100644
index 0000000..3140a00
--- /dev/null
+++ b/src/com/replica/replicaisland/UIConstants.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package com.replica.replicaisland;
+
+import java.lang.reflect.Method;
+
+import android.app.Activity;
+
+public class UIConstants {
+
+ // Some versions of Android can support custom Activity transitions.
+ // If this method isn't null, we can use them.
+
+ public static Method mOverridePendingTransition;
+
+ static {
+ try {
+ mOverridePendingTransition = Activity.class.getMethod(
+ "overridePendingTransition", new Class[] { Integer.TYPE, Integer.TYPE } );
+ /* success, this is a newer device */
+ } catch (NoSuchMethodException nsme) {
+ /* failure, must be older device */
+ }
+ };
+}