diff --git a/.gitignore b/.gitignore index e146ae7..cc89475 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ tags bin/ gen/R.java.d main.*.de.phbouillon.android.games.alite.obb +/local.properties diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 3dc0f6c..cb08980 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,7 +1,7 @@ /Android/obb/de.phbouillon.android.games.alite/main.2180.de.phbouillon.android.games.alite.obb". +the directory "/Android/obb/de.phbouillon.android.games.alite/main.2192.de.phbouillon.android.games.alite.obb". Now you have two options: @@ -131,9 +139,9 @@ a command prompt or shell in that directory and type: java -jar jobb.jar -d Resources -o main..de.phbouillon.android.games.alite.obb -pn de.phbouillon.android.games.alite -pv and make sure that _exactly!_ matches the version number you -specified in the AliteStartManager, see EXTENSION_FILE_VERSION. +specified in the AliteConfig, see EXTENSION_FILE_VERSION. -Once built set EXTENSION_FILE_LENGTH in AliteStartManager to the size of your +Once built set EXTENSION_FILE_LENGTH in AliteConfig to the size of your new obb file in bytes and rebuild & install Alite. Why is that so complicated?! I wish I knew :). The thing is that the jobb tool @@ -153,17 +161,16 @@ article here: http://developer.android.com/google/play/expansion-files.html If you only want to enhance Alite and test it on your device, or you don't want to bother handling OBBs, set the "HAS_EXTENSION_APK" flag to false in -the AliteStartManager class. +the AliteConfig class. This tells Alite that all files have to be loaded from the assets directory. So, if you set the flag to "false", copy all files from the Resources/assets -directory to the assets/directory. +directory to the assets/ directory. Next, copy the files from the Resources/intro directory to the res/raw directory ("raw" has to be created). Now, one more thing to do: -In "AliteIntro", you'll find the method "determineIntroId(int quality)" and -several commented lines below it: uncomment those and comment the final return. -In line 179, replace the "introId = -1;" with -"introId = R.raw.alite_intro_b1920;". +In "AliteConfig", you'll find the constants ALITE_INTRO_XXX. Replace their +-1 value with the "R.raw.alite_intro_xxx" value you'll find in the comments +of the AliteConfig file. Done. When you now deploy Alite, you don't have to keep an OBB file on your phone and you'll instantly see changes to resources you made. But deployment diff --git a/build.xml b/build.xml index c5269a3..6b05acb 100644 --- a/build.xml +++ b/build.xml @@ -86,7 +86,26 @@ In all cases you must update the value of version-tag below to read 'custom' instead of an integer, in order to avoid having your file be overridden by tools such as "android update project" --> - + + + + + + + + + + + + + + + + + + diff --git a/libs/android-support-v4.jar b/libs/android-support-v4.jar deleted file mode 100644 index e74b0d7..0000000 Binary files a/libs/android-support-v4.jar and /dev/null differ diff --git a/project.properties b/project.properties index a3ee5ab..4ab1256 100644 --- a/project.properties +++ b/project.properties @@ -11,4 +11,4 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-17 +target=android-19 diff --git a/src/de/phbouillon/android/framework/impl/AccelerometerHandler.java b/src/de/phbouillon/android/framework/impl/AccelerometerHandler.java index ffab4a7..8c4f53d 100644 --- a/src/de/phbouillon/android/framework/impl/AccelerometerHandler.java +++ b/src/de/phbouillon/android/framework/impl/AccelerometerHandler.java @@ -26,11 +26,22 @@ import android.hardware.SensorManager; import android.view.OrientationEventListener; import android.view.WindowManager; +import de.phbouillon.android.framework.math.Vector3f; import de.phbouillon.android.games.alite.Settings; public class AccelerometerHandler implements SensorEventListener { + public static boolean needsCalibration = true; + private float [] accelValues = new float[3]; private float [] adjustedValues = new float[3]; + private Vector3f accelerationVector = new Vector3f(0, 0, 0); + private Vector3f accelerationMean = new Vector3f(0, 0, 0); + private Vector3f accelerationCalibration = new Vector3f(0, 0, 0); + private Vector3f rollVector = new Vector3f(0, 0, 0); + private Vector3f pitchVector = new Vector3f(0, 0, 0); + private Vector3f upVector = new Vector3f(0, 1, 0); + private Vector3f tempVector = new Vector3f(0, 0, 0); + private final AndroidGame game; private int defaultOrientation; private boolean reversedLandscape = false; @@ -124,20 +135,23 @@ public void adjustAccelOrientation(float [] eventValues) { @Override public void onSensorChanged(SensorEvent event) { - switch (event.sensor.getType()) { - case Sensor.TYPE_ACCELEROMETER: - for (int i = 0; i < 3; i++) { - accelValues[i] = event.values[i]; - } - break; + accelerationVector.x = event.values[0]; + accelerationVector.y = event.values[1]; + accelerationVector.z = event.values[2]; + accelerationVector.normalize(); + + accelerationVector.copy(accelerationMean); + if (needsCalibration) { + needsCalibration = false; + accelerationVector.copy(accelerationCalibration); + upVector.copy(rollVector); + upVector.cross(accelerationCalibration, pitchVector); } - - float roll = (float) Math.atan2(accelValues[0], accelValues[2]); - float pitch = (float) Math.atan2(accelValues[1], accelValues[2]); - - accelValues[2] = -roll; - accelValues[1] = -pitch; - accelValues[0] = 0; + + accelerationMean.sub(accelerationCalibration, tempVector); + accelValues[0] = 0; // Yaw + accelValues[1] = tempVector.dot(rollVector); // Roll + accelValues[2] = tempVector.dot(pitchVector); // Pitch adjustAccelOrientation(accelValues); } diff --git a/src/de/phbouillon/android/framework/impl/AndroidAudio.java b/src/de/phbouillon/android/framework/impl/AndroidAudio.java index 710c586..7d6ec11 100644 --- a/src/de/phbouillon/android/framework/impl/AndroidAudio.java +++ b/src/de/phbouillon/android/framework/impl/AndroidAudio.java @@ -28,8 +28,8 @@ import de.phbouillon.android.framework.Audio; import de.phbouillon.android.framework.Music; import de.phbouillon.android.framework.Sound; +import de.phbouillon.android.games.alite.AliteConfig; import de.phbouillon.android.games.alite.AliteLog; -import de.phbouillon.android.games.alite.AliteStartManager; public class AndroidAudio implements Audio { public static final int MAXIMUM_NUMBER_OF_CONCURRENT_SAMPLES = 20; @@ -47,7 +47,7 @@ public AndroidAudio(Activity activity, AndroidFileIO fileIO) { @Override public Music newMusic(String fileName, Sound.SoundType soundType) { - if (AliteStartManager.HAS_EXTENSION_APK) { + if (AliteConfig.HAS_EXTENSION_APK) { try { return new AndroidMusic(fileIO, fileName, soundType); } catch (IOException e) { @@ -70,7 +70,7 @@ public Music newMusic(String fileName, Sound.SoundType soundType) { @Override public Sound newSound(String fileName, Sound.SoundType soundType) { try { - int soundId = AliteStartManager.HAS_EXTENSION_APK ? + int soundId = AliteConfig.HAS_EXTENSION_APK ? soundPool.load(fileIO.getPrivatePath(fileName), 0) : soundPool.load(fileIO.getFileDescriptor(fileName), 0); return new AndroidSound(soundPool, soundId, soundType); diff --git a/src/de/phbouillon/android/framework/impl/AndroidFileIO.java b/src/de/phbouillon/android/framework/impl/AndroidFileIO.java index 0dfc09a..4f09858 100644 --- a/src/de/phbouillon/android/framework/impl/AndroidFileIO.java +++ b/src/de/phbouillon/android/framework/impl/AndroidFileIO.java @@ -37,7 +37,7 @@ import android.content.res.AssetManager; import android.os.Environment; import de.phbouillon.android.framework.FileIO; -import de.phbouillon.android.games.alite.AliteStartManager; +import de.phbouillon.android.games.alite.AliteConfig; import de.phbouillon.android.games.alite.io.ObbExpansionsManager; public class AndroidFileIO implements FileIO { @@ -318,7 +318,7 @@ public void unzip(File zipFile, File targetDirectory) throws IOException { @Override public boolean existsPrivateFile(String fileName) throws IOException { - if (AliteStartManager.HAS_EXTENSION_APK) { + if (AliteConfig.HAS_EXTENSION_APK) { return new File(ObbExpansionsManager.getInstance().getMainRoot() + "assets/" + fileName).exists(); } try { @@ -332,14 +332,14 @@ public boolean existsPrivateFile(String fileName) throws IOException { @Override public InputStream readPrivateFile(String fileName) throws IOException { - if (AliteStartManager.HAS_EXTENSION_APK) { + if (AliteConfig.HAS_EXTENSION_APK) { return new FileInputStream(getPrivatePath(fileName)); } return assets.open(fileName); } public AssetFileDescriptor getFileDescriptor(String fileName) throws IOException { - if (AliteStartManager.HAS_EXTENSION_APK) { + if (AliteConfig.HAS_EXTENSION_APK) { throw new IOException("Cannot access extension assets via AssetDescriptor. Use private path instead."); } return assets.openFd(fileName); @@ -347,7 +347,7 @@ public AssetFileDescriptor getFileDescriptor(String fileName) throws IOException @Override public String getPrivatePath(String fileName) throws IOException { - if (AliteStartManager.HAS_EXTENSION_APK) { + if (AliteConfig.HAS_EXTENSION_APK) { String path; if (ObbExpansionsManager.getInstance() == null) { throw new IOException("Obb not loaded. Please try all-in-one solution from http://alite.mobi."); diff --git a/src/de/phbouillon/android/framework/impl/VideoView.java b/src/de/phbouillon/android/framework/impl/VideoView.java index 009a523..32222bc 100644 --- a/src/de/phbouillon/android/framework/impl/VideoView.java +++ b/src/de/phbouillon/android/framework/impl/VideoView.java @@ -619,4 +619,9 @@ public boolean canSeekBackward() { public boolean canSeekForward() { return mCanSeekForward; } + + @Override + public int getAudioSessionId() { + return 1; + } } diff --git a/src/de/phbouillon/android/games/alite/Alite.java b/src/de/phbouillon/android/games/alite/Alite.java index 0ff59b3..9d1cbc2 100644 --- a/src/de/phbouillon/android/games/alite/Alite.java +++ b/src/de/phbouillon/android/games/alite/Alite.java @@ -70,7 +70,7 @@ import de.phbouillon.android.games.alite.screens.opengl.sprites.AliteFont; public class Alite extends AndroidGame { - public static final String VERSION_STRING = "1.4.4 " + (AliteStartManager.HAS_EXTENSION_APK ? "OBB" : "SFI"); + public static final String VERSION_STRING = AliteConfig.VERSION_STRING + " " + (AliteConfig.HAS_EXTENSION_APK ? "OBB" : "SFI"); public static final String LOG_IS_INITIALIZED = "logIsInitialized"; private Player player; @@ -448,8 +448,9 @@ public void afterSurfaceCreated() { Assets.italicFont = new GLText(); Assets.boldItalicFont = new GLText(); Assets.titleFont = new GLText(); - Assets.smallFont = new GLText(); - if (AliteStartManager.HAS_EXTENSION_APK) { + Assets.smallFont = new GLText(); + + if (AliteConfig.HAS_EXTENSION_APK) { Assets.regularFont.load(ObbExpansionsManager.getInstance().getMainRoot() + "assets/robotor.ttf", (int) (40.0f * scaleFactor), 40, 2, 2); Assets.boldFont.load(ObbExpansionsManager.getInstance().getMainRoot() + "assets/robotob.ttf", (int) (40.0f * scaleFactor), 40, 2, 2); Assets.italicFont.load(ObbExpansionsManager.getInstance().getMainRoot() + "assets/robotoi.ttf", (int) (40.0f * scaleFactor), 40, 2, 2); diff --git a/src/de/phbouillon/android/games/alite/AliteConfig.java b/src/de/phbouillon/android/games/alite/AliteConfig.java new file mode 100644 index 0000000..a50b2b2 --- /dev/null +++ b/src/de/phbouillon/android/games/alite/AliteConfig.java @@ -0,0 +1,14 @@ +package de.phbouillon.android.games.alite; + +public class AliteConfig { + public static final boolean HAS_EXTENSION_APK = false; + public static final int EXTENSION_FILE_VERSION = 2192; + public static final long EXTENSION_FILE_LENGTH = 427312705l; + public static final String VERSION_STRING = "1.4.6"; + public static final int ALITE_INTRO_B1920 = -1; //R.raw.alite_intro_b1920; + public static final int ALITE_INTRO_B1280 = -1; //R.raw.alite_intro_b1280; + public static final int ALITE_INTRO_B640 = -1; //R.raw.alite_intro_b640; + public static final int ALITE_INTRO_B320 = -1; //R.raw.alite_intro_b320; + public static final int ALITE_INTRO_288 = -1; //R.raw.alite_intro_288; + public static final int ALITE_INTRO_B240 = -1; //R.raw.alite_intro_b240; +} diff --git a/src/de/phbouillon/android/games/alite/AliteIntro.java b/src/de/phbouillon/android/games/alite/AliteIntro.java index 6356777..524ab2b 100644 --- a/src/de/phbouillon/android/games/alite/AliteIntro.java +++ b/src/de/phbouillon/android/games/alite/AliteIntro.java @@ -84,23 +84,22 @@ private FileDescriptor getFileDescriptor(String file) throws IOException { } private int determineIntroId(int quality) { -// switch (quality) { -// case 0: AliteLog.d("Video Playback", "Using video resolution 1920x1080"); -// return R.raw.alite_intro_b1920; -// case 1: AliteLog.d("Video Playback", "Using video resolution 1280x720"); -// return R.raw.alite_intro_b1280; -// case 2: AliteLog.d("Video Playback", "Using video resolution 640x360"); -// return R.raw.alite_intro_b640; -// case 3: AliteLog.d("Video Playback", "Using video resolution 320x180"); -// return R.raw.alite_intro_b320; -// case 4: AliteLog.d("Video Playback", "Failsafe mode 1: 288"); -// return R.raw.alite_intro_288; -// case 5: AliteLog.d("Video Playback", "Failsafe mode 2: 240"); -// return R.raw.alite_intro_b240; -// default: AliteLog.d("Video Playback", "No mode found. Giving up :(."); -// return -1; -// } - return -1; + switch (quality) { + case 0: AliteLog.d("Video Playback", "Using video resolution 1920x1080"); + return AliteConfig.ALITE_INTRO_B1920; + case 1: AliteLog.d("Video Playback", "Using video resolution 1280x720"); + return AliteConfig.ALITE_INTRO_B1280; + case 2: AliteLog.d("Video Playback", "Using video resolution 640x360"); + return AliteConfig.ALITE_INTRO_B640; + case 3: AliteLog.d("Video Playback", "Using video resolution 320x180"); + return AliteConfig.ALITE_INTRO_B320; + case 4: AliteLog.d("Video Playback", "Failsafe mode 1: 288"); + return AliteConfig.ALITE_INTRO_288; + case 5: AliteLog.d("Video Playback", "Failsafe mode 2: 240"); + return AliteConfig.ALITE_INTRO_B240; + default: AliteLog.d("Video Playback", "No mode found. Giving up :(."); + return -1; + } } private String determineIntroFilename(int quality) { @@ -164,7 +163,7 @@ public void uncaughtException(Thread paramThread, Throwable paramThrowable) { if (videoView == null) { initializeVideoView(); } - if (AliteStartManager.HAS_EXTENSION_APK) { + if (AliteConfig.HAS_EXTENSION_APK) { playVideoFromOBB(); } else { playVideoFromRawFolder(); @@ -178,7 +177,7 @@ private void playVideoFromRawFolder() { if (Settings.introVideoQuality == 255) { cyclingThroughVideoQualities = 0; AliteLog.d("Video Playback", "Using video resolution 1920x1080"); - introId = -1; //R.raw.alite_intro_b1920; + introId = AliteConfig.ALITE_INTRO_B1920; } else { introId = determineIntroId(Settings.introVideoQuality); } @@ -260,7 +259,7 @@ public void onCompletion(final MediaPlayer mp) { @Override public boolean onError(MediaPlayer mp, int what, int extra) { AliteLog.d("cyclingThroughVideoQualities [1]", "cyclingThroughVideoQualities = " + cyclingThroughVideoQualities); - if (AliteStartManager.HAS_EXTENSION_APK) { + if (AliteConfig.HAS_EXTENSION_APK) { if (errorHandlerObb(mp)) { return true; } @@ -340,7 +339,7 @@ private boolean errorHandlerObb(final MediaPlayer mp) { // Ignore } } - if (AliteStartManager.HAS_EXTENSION_APK) { + if (AliteConfig.HAS_EXTENSION_APK) { videoViewFileInputStream = new FileInputStream(getAbsolutePath(introFilename)); AliteLog.d("Intro path", "Intro path: " + getAbsolutePath(introFilename)); videoView.setVideoFD(videoViewFileInputStream.getFD()); diff --git a/src/de/phbouillon/android/games/alite/AliteStartManager.java b/src/de/phbouillon/android/games/alite/AliteStartManager.java index 29e4307..0b5a9ad 100644 --- a/src/de/phbouillon/android/games/alite/AliteStartManager.java +++ b/src/de/phbouillon/android/games/alite/AliteStartManager.java @@ -46,9 +46,6 @@ import de.phbouillon.android.games.alite.screens.canvas.tutorial.IMethodHook; public class AliteStartManager extends Activity implements IDownloaderClient { - public static final boolean HAS_EXTENSION_APK = true; - public static final int EXTENSION_FILE_VERSION = 2192; - private static final long EXTENSION_FILE_LENGTH = 427312705l; public static final int ALITE_RESULT_CLOSE_ALL = 78615265; public static final String ALITE_STATE_FILE = "current_state.dat"; @@ -81,10 +78,10 @@ private boolean expansionFilesDelivered() { if (oldObb.exists()) { oldObb.delete(); } - String fileName = Helpers.getExpansionAPKFileName(this, true, EXTENSION_FILE_VERSION); + String fileName = Helpers.getExpansionAPKFileName(this, true, AliteConfig.EXTENSION_FILE_VERSION); File fileForNewFile = new File(Helpers.generateSaveFileName(this, fileName)); AliteLog.e("Check for OBB", "OBB exists? " + fileForNewFile.getAbsolutePath()); - return Helpers.doesFileExist(this, fileName, EXTENSION_FILE_LENGTH, false); + return Helpers.doesFileExist(this, fileName, AliteConfig.EXTENSION_FILE_LENGTH, false); } private void setStatus(String status) { @@ -151,7 +148,7 @@ public void uncaughtException(Thread paramThread, Throwable paramThrowable) { AliteLog.d("Alite Start Manager", "Alite Start Manager has been created."); Settings.load(fileIO); - if (HAS_EXTENSION_APK) { + if (AliteConfig.HAS_EXTENSION_APK) { checkDownload(); } else { startGame(); @@ -254,7 +251,7 @@ public void onDownloadStateChanged(int newState) { setStatus(getString(Helpers.getDownloaderStringResourceIDFromState(newState))); if (newState == IDownloaderClient.STATE_COMPLETED) { ((TextView) findViewById(R.id.downloadProgressPercentTextView)).setText("100%"); - ((ProgressBar) findViewById(R.id.downloadProgressBar)).setProgress((int) EXTENSION_FILE_LENGTH); + ((ProgressBar) findViewById(R.id.downloadProgressBar)).setProgress((int) AliteConfig.EXTENSION_FILE_LENGTH); ((TextView) findViewById(R.id.downloadTextView)).setText("Download complete."); AliteFiles.performMount(this, new IMethodHook() { private static final long serialVersionUID = -5369313962579796580L; diff --git a/src/de/phbouillon/android/games/alite/io/ObbExpansionsManager.java b/src/de/phbouillon/android/games/alite/io/ObbExpansionsManager.java index 8c315c1..71bd7c5 100644 --- a/src/de/phbouillon/android/games/alite/io/ObbExpansionsManager.java +++ b/src/de/phbouillon/android/games/alite/io/ObbExpansionsManager.java @@ -26,8 +26,8 @@ import android.os.Environment; import android.os.storage.OnObbStateChangeListener; import android.os.storage.StorageManager; +import de.phbouillon.android.games.alite.AliteConfig; import de.phbouillon.android.games.alite.AliteLog; -import de.phbouillon.android.games.alite.AliteStartManager; /** * For more info about APK Expansion files see http://developer.android.com/google/play/expansion-files.html @@ -56,7 +56,7 @@ private ObbExpansionsManager(Context context, final ObbListener listener) { packageName = context.getPackageName(); AliteLog.d(TAG, "Package name = " + packageName); - packageVersion = AliteStartManager.EXTENSION_FILE_VERSION; + packageVersion = AliteConfig.EXTENSION_FILE_VERSION; AliteLog.d(TAG, "Package version = " + packageVersion); this.listener = listener; sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); @@ -121,7 +121,7 @@ public void onObbStateChange(String path, int state) { public static boolean isMainFileExists(Context context) { String packageName = context.getPackageName(); AliteLog.d(TAG, "Package name = " + packageName); - int packageVersion = AliteStartManager.EXTENSION_FILE_VERSION; + int packageVersion = AliteConfig.EXTENSION_FILE_VERSION; AliteLog.d(TAG, "Package version = " + packageVersion); File main = new File(Environment.getExternalStorageDirectory() + "/Android/obb/" + packageName + "/" + "main." + packageVersion + "." + packageName + ".obb"); diff --git a/src/de/phbouillon/android/games/alite/screens/canvas/missions/MissionLine.java b/src/de/phbouillon/android/games/alite/screens/canvas/missions/MissionLine.java index 2173c6a..077f1b1 100644 --- a/src/de/phbouillon/android/games/alite/screens/canvas/missions/MissionLine.java +++ b/src/de/phbouillon/android/games/alite/screens/canvas/missions/MissionLine.java @@ -24,8 +24,8 @@ import android.media.MediaPlayer; import android.media.MediaPlayer.OnCompletionListener; import de.phbouillon.android.framework.impl.AndroidFileIO; +import de.phbouillon.android.games.alite.AliteConfig; import de.phbouillon.android.games.alite.AliteLog; -import de.phbouillon.android.games.alite.AliteStartManager; class MissionLine implements OnCompletionListener { private final String text; @@ -34,7 +34,7 @@ class MissionLine implements OnCompletionListener { MissionLine(AndroidFileIO fio, String speechPath, String text) throws IOException { if (speechPath != null) { - if (AliteStartManager.HAS_EXTENSION_APK) { + if (AliteConfig.HAS_EXTENSION_APK) { speechObject = fio.getPrivatePath(speechPath); } else { speechObject = fio.getFileDescriptor(speechPath); @@ -52,7 +52,7 @@ void play(MediaPlayer mp) { try { isPlaying = true; mp.reset(); - if (AliteStartManager.HAS_EXTENSION_APK) { + if (AliteConfig.HAS_EXTENSION_APK) { mp.setDataSource((String) speechObject); } else { AssetFileDescriptor afd = ((AssetFileDescriptor) speechObject); diff --git a/src/de/phbouillon/android/games/alite/screens/canvas/tutorial/TutorialScreen.java b/src/de/phbouillon/android/games/alite/screens/canvas/tutorial/TutorialScreen.java index 0a9090c..4474e07 100644 --- a/src/de/phbouillon/android/games/alite/screens/canvas/tutorial/TutorialScreen.java +++ b/src/de/phbouillon/android/games/alite/screens/canvas/tutorial/TutorialScreen.java @@ -33,8 +33,8 @@ import de.phbouillon.android.framework.impl.AndroidGraphics; import de.phbouillon.android.framework.impl.PulsingHighlighter; import de.phbouillon.android.games.alite.Alite; +import de.phbouillon.android.games.alite.AliteConfig; import de.phbouillon.android.games.alite.AliteLog; -import de.phbouillon.android.games.alite.AliteStartManager; import de.phbouillon.android.games.alite.Assets; import de.phbouillon.android.games.alite.Button; import de.phbouillon.android.games.alite.SoundManager; @@ -138,7 +138,7 @@ protected void initLines(int tutorialIndex, String... texts) { AndroidFileIO afi = (AndroidFileIO) alite.getFileIO(); String audioName = path + (index < 10 ? "0" + index : index) + ".mp3"; for (String t: texts) { - lines.add(new TutorialLine(AliteStartManager.HAS_EXTENSION_APK ? afi.getPrivatePath(audioName) : + lines.add(new TutorialLine(AliteConfig.HAS_EXTENSION_APK ? afi.getPrivatePath(audioName) : afi.getFileDescriptor(audioName), t)); index++; } @@ -153,7 +153,7 @@ protected TutorialLine addLine(int tutorialIndex, String line) { int index = lines.size() + 1; AndroidFileIO afi = (AndroidFileIO) alite.getFileIO(); String audioName = path + (index < 10 ? "0" + index : index) + ".mp3"; - TutorialLine result = new TutorialLine(AliteStartManager.HAS_EXTENSION_APK ? afi.getPrivatePath(audioName) : + TutorialLine result = new TutorialLine(AliteConfig.HAS_EXTENSION_APK ? afi.getPrivatePath(audioName) : afi.getFileDescriptor(audioName), line); lines.add(result); return result; @@ -169,9 +169,9 @@ protected TutorialLine addLine(int tutorialIndex, String line, String option) { AndroidFileIO afi = (AndroidFileIO) alite.getFileIO(); String audioName = path + (index < 10 ? "0" + index : index); try { - TutorialLine result = new TutorialLine(AliteStartManager.HAS_EXTENSION_APK ? afi.getPrivatePath(audioName + ".mp3") : + TutorialLine result = new TutorialLine(AliteConfig.HAS_EXTENSION_APK ? afi.getPrivatePath(audioName + ".mp3") : afi.getFileDescriptor(audioName + ".mp3"), line); - result.addSpeech(AliteStartManager.HAS_EXTENSION_APK ? afi.getPrivatePath(audioName + option + ".mp3") : + result.addSpeech(AliteConfig.HAS_EXTENSION_APK ? afi.getPrivatePath(audioName + option + ".mp3") : afi.getFileDescriptor(audioName + option + ".mp3")); lines.add(result); return result; diff --git a/src/de/phbouillon/android/games/alite/screens/opengl/ingame/GameOverUpdater.java b/src/de/phbouillon/android/games/alite/screens/opengl/ingame/GameOverUpdater.java index e6f1275..50e4202 100644 --- a/src/de/phbouillon/android/games/alite/screens/opengl/ingame/GameOverUpdater.java +++ b/src/de/phbouillon/android/games/alite/screens/opengl/ingame/GameOverUpdater.java @@ -20,8 +20,6 @@ import java.io.IOException; import java.io.ObjectInputStream; -import java.util.ArrayList; -import java.util.List; import de.phbouillon.android.framework.Updater; import de.phbouillon.android.framework.impl.gl.GraphicObject; @@ -29,7 +27,6 @@ import de.phbouillon.android.games.alite.Alite; import de.phbouillon.android.games.alite.AliteLog; import de.phbouillon.android.games.alite.model.statistics.WeaponType; -import de.phbouillon.android.games.alite.screens.opengl.objects.AliteObject; import de.phbouillon.android.games.alite.screens.opengl.objects.space.ships.CobraMkIII; class GameOverUpdater implements Updater { @@ -84,6 +81,7 @@ public void onUpdate(float deltaTime) { private final void spawnShip() { ship.computeMatrix(); cobra = new CobraMkIII(alite); + cobra.setIdentified(); cobra.setUpVector(ship.getUpVector()); cobra.setRightVector(ship.getRightVector()); cobra.setForwardVector(ship.getForwardVector()); @@ -112,12 +110,8 @@ private final void moveShip() { private final void destroyShip() { if (needsDestruction) { - List objectsToBeAdded = new ArrayList(); cobra.setHullStrength(0); inGame.explode(cobra, true, WeaponType.BeamLaser); - for (AliteObject o: objectsToBeAdded) { - inGame.addObject(o); - } needsDestruction = false; } if ((System.nanoTime() - startTime) > 10000000000l) { diff --git a/src/de/phbouillon/android/games/alite/screens/opengl/ingame/InGameManager.java b/src/de/phbouillon/android/games/alite/screens/opengl/ingame/InGameManager.java index 9fbed05..d3678af 100644 --- a/src/de/phbouillon/android/games/alite/screens/opengl/ingame/InGameManager.java +++ b/src/de/phbouillon/android/games/alite/screens/opengl/ingame/InGameManager.java @@ -32,6 +32,7 @@ import de.phbouillon.android.framework.Geometry; import de.phbouillon.android.framework.Input.TouchEvent; import de.phbouillon.android.framework.Screen; +import de.phbouillon.android.framework.impl.AccelerometerHandler; import de.phbouillon.android.framework.impl.AndroidGraphics; import de.phbouillon.android.framework.impl.gl.GlUtils; import de.phbouillon.android.framework.math.Vector3f; @@ -89,8 +90,6 @@ public class InGameManager implements Serializable { private transient String feeText = null; private transient Alite alite; - private final Vector3f zero = new Vector3f(0, 0, 0); - private final Vector3f deltaOrientation = new Vector3f(0, 0, 0); private final Vector3f deltaYawRollPitch = new Vector3f(0, 0, 0); private final Vector3f tempVector = new Vector3f(0, 0, -1); private final Vector3f systemStationPosition = new Vector3f(0, 0, 0); @@ -186,6 +185,7 @@ public InGameManager(final Alite alite, AliteHud hud, String skyMap, float [] li spawnManager.startSimulation(alite.getPlayer().getCurrentSystem()); alite.getCobra().setMissileLocked(false); objectPicker = new ObjectPicker(this, visibleArea); + AccelerometerHandler.needsCalibration = true; } public LaserManager getLaserManager() { @@ -415,7 +415,8 @@ void addTimedEvent(final TimedEvent event) { } private final float clamp(float val, float min, float max) { - return val < min ? min : val > max ? max : val; + float result = val < min ? min : val > max ? max : val; + return result; } public CobraMkIII getShip() { @@ -425,36 +426,32 @@ public CobraMkIII getShip() { public void calibrate() { // Ensures that a re-calibration occurs on the next frame. calibrated = false; + AccelerometerHandler.needsCalibration = true; } - + private void getAccelerometerData() { if (!calibrated) { - zero.x = alite.getInput().getAccelX(); - zero.y = alite.getInput().getAccelY(); - zero.z = alite.getInput().getAccelZ(); calibrated = true; - } else { - deltaOrientation.x = -clamp(((int) ((alite.getInput().getAccelX() - zero.x) * 10.0f)) / 4.0f, -2.0f, 2.0f); - deltaOrientation.y = clamp(((int) ((alite.getInput().getAccelY() - zero.y) * 50.0f)) / 10.0f, -2.0f, 2.0f); - deltaOrientation.z = -clamp(((int) ((alite.getInput().getAccelZ() - zero.z) * 50.0f)) / 10.0f, -2.0f, 2.0f); - - deltaYawRollPitch.z = (float) (30.0f * Math.PI / 180.0f) * deltaOrientation.z; - if (Settings.reversePitch) { - deltaYawRollPitch.z = -deltaYawRollPitch.z; - } - deltaYawRollPitch.y = (float) (30.0f * Math.PI / 180.0f) * deltaOrientation.y; - } + } + float accelY = alite.getInput().getAccelY(); + float accelZ = alite.getInput().getAccelZ(); + + deltaYawRollPitch.x = 0; + deltaYawRollPitch.y = -clamp((int) (accelY * 50.0f) / 10.0f, -2.0f, 2.0f); + deltaYawRollPitch.z = clamp((int) (accelZ * 30.0f) / 10.0f, -2.0f, 2.0f); + + if (Settings.reversePitch) { + deltaYawRollPitch.z = -deltaYawRollPitch.z; + } } private void getHudControlData() { if (hud != null) { - deltaOrientation.z = hud.getZ(); - deltaOrientation.y = hud.getY(); - deltaYawRollPitch.z = (float) (30.0f * Math.PI / 180.0f) * deltaOrientation.z; + deltaYawRollPitch.z = hud.getZ(); if (Settings.reversePitch) { deltaYawRollPitch.z = -deltaYawRollPitch.z; } - deltaYawRollPitch.y = (float) (30.0f * Math.PI / 180.0f) * deltaOrientation.y; + deltaYawRollPitch.y = hud.getY(); } } @@ -963,7 +960,7 @@ private void renderHud() { GLES11.glMatrixMode(GLES11.GL_MODELVIEW); GLES11.glLoadIdentity(); if (playerControl) { - alite.getCobra().setRotation(deltaOrientation.z, deltaOrientation.y); + alite.getCobra().setRotation(deltaYawRollPitch.z, deltaYawRollPitch.y); } alite.getCobra().setSpeed(ship.getSpeed()); hud.render(); @@ -1164,7 +1161,7 @@ private void renderAllObjects(final float deltaTime, final List ob missileLock = (SpaceObject) go; SoundManager.play(Assets.missileLocked); targetMissile = false; - } else if (Settings.autoId) { + } else if (Settings.autoId && isPlayerAlive()) { SoundManager.play(Assets.identify); setMessage(go.getName()); } diff --git a/src/de/phbouillon/android/games/alite/screens/opengl/ingame/LaserManager.java b/src/de/phbouillon/android/games/alite/screens/opengl/ingame/LaserManager.java index 240b033..6aaa38d 100644 --- a/src/de/phbouillon/android/games/alite/screens/opengl/ingame/LaserManager.java +++ b/src/de/phbouillon/android/games/alite/screens/opengl/ingame/LaserManager.java @@ -224,7 +224,7 @@ private final void spawnCargoCanisters(final SpaceObject so, int forceCount, Wea } if (so.getCargoType() == null || !so.spawnsCargoCanisters()) { // Legacy: The cargo type is still declared at a ship, but not longer used... - // However, if it was defined that a ship has no carho type, we still + // However, if it was defined that a ship has no cargo type, we still // exit here... return; } diff --git a/src/de/phbouillon/android/games/alite/screens/opengl/objects/space/ships/CargoCanister.java b/src/de/phbouillon/android/games/alite/screens/opengl/objects/space/ships/CargoCanister.java index 029f427..50287e4 100644 --- a/src/de/phbouillon/android/games/alite/screens/opengl/objects/space/ships/CargoCanister.java +++ b/src/de/phbouillon/android/games/alite/screens/opengl/objects/space/ships/CargoCanister.java @@ -36,7 +36,7 @@ public class CargoCanister extends SpaceObject { private static final long serialVersionUID = -7940435691937589868L; - public static final Vector3f HUD_COLOR = new Vector3f(0.94f, 0.0f, 0.94f); + public static final Vector3f HUD_COLOR = new Vector3f(0.54f, 0.0f, 0.94f); private TradeGood content; private Weight weight;