diff --git a/.gitignore b/.gitignore
index 6e8e9f3..e0eb3ce 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,8 @@
/.idea/workspace.xml
/.idea/vcs.xml
/.idea/libraries
+/.idea/caches/
+/.idea/codeStyles/
.DS_Store
/build
/captures
diff --git a/.idea/misc.xml b/.idea/misc.xml
index ba7052b..99202cc 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,11 +5,12 @@
@@ -24,7 +25,7 @@
-
+
diff --git a/app/src/main/java/com/simplecoil/simplecoil/FullscreenActivity.java b/app/src/main/java/com/simplecoil/simplecoil/FullscreenActivity.java
index 7c14219..1915f53 100644
--- a/app/src/main/java/com/simplecoil/simplecoil/FullscreenActivity.java
+++ b/app/src/main/java/com/simplecoil/simplecoil/FullscreenActivity.java
@@ -127,6 +127,7 @@ public class FullscreenActivity extends AppCompatActivity implements PopupMenu.O
private TextView mHealthLabelTV = null;
private TextView mPlayerNameTV = null;
private ProgressBar mHealthBar = null;
+ private ProgressBar mShieldBar = null;
private ProgressBar mReloadBar = null;
private ImageView mHitIV = null;
private ImageView mBatteryLevelIV = null;
@@ -149,6 +150,7 @@ public class FullscreenActivity extends AppCompatActivity implements PopupMenu.O
private CountDownTimer mSpawnTimer = null;
private CountDownTimer mReloadTimer = null;
+ private CountDownTimer mShieldTimer = null;
private CountDownTimer mGameCountdownTimer = null;
private CountDownTimer mConnectFailTimer = null;
private boolean mGameTimerRunning = false;
@@ -160,6 +162,9 @@ public class FullscreenActivity extends AppCompatActivity implements PopupMenu.O
private static final int MAX_EMPTY_TRIGGER_PULLS = 3; // automatically reloads if the trigger is pulled this many times while empty (for young players)
+ private float mShieldTickTime = 1.0f;
+ private int mShieldTickAmount = 1;
+
private boolean mScanning = false;
private volatile boolean mConnected = false;
private boolean mCommunicating = false; // Used to make sure that we start receiving telemetry data after initial connection
@@ -167,6 +172,7 @@ public class FullscreenActivity extends AppCompatActivity implements PopupMenu.O
private static byte mLastTeam = 0;
private int mHitsTaken = 0; // total hits taken regardless of lives
private static int mHealth = Globals.MAX_HEALTH;
+ private static int mShield = Globals.MAX_SHIELDS;
private byte mLastShotCount = 0;
private byte mLastTriggerCount = 0;
private byte mLastReloadButtonCount = 0;
@@ -531,9 +537,8 @@ public void onClick(View v) {
mShotModeTV = findViewById(R.id.shot_mode_tv);
mHealthLabelTV = findViewById(R.id.health_label_tv);
mHealthBar = findViewById(R.id.health_pb);
- mHealth = Globals.getInstance().mFullHealth;
- mHealthBar.setMax(mHealth);
- mHealthBar.setProgress(mHealth);
+ mShieldBar = findViewById(R.id.shield_pb);
+ resetVitalStatBars();
mReloadBar = findViewById(R.id.reload_pb);
mEliminatedTV = findViewById(R.id.eliminated_tv);
mEliminatedByTV = findViewById(R.id.eliminated_by_tv);
@@ -1114,6 +1119,16 @@ private void initBatteryQueue() {
mBatteryTotal = 16;
}
+ private void resetVitalStatBars() {
+ mHealth = Globals.getInstance().mFullHealth;
+ mHealthBar.setMax(mHealth);
+ mHealthBar.setProgress(mHealth);
+
+ mShield = Globals.getInstance().mFullShields;
+ mShieldBar.setMax(mShield);
+ mShieldBar.setProgress(mShield);
+ }
+
private void startGame() {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().getDecorView().setSystemUiVisibility(
@@ -1129,9 +1144,7 @@ private void startGame() {
else
mEliminationCount = 0;
mEliminationCountTV.setText("" + mEliminationCount);
- mHealth = Globals.getInstance().mFullHealth;
- mHealthBar.setMax(mHealth);
- mHealthBar.setProgress(mHealth);
+ resetVitalStatBars();
mEliminatedTV.setText(R.string.starting_game_label);
mStartGameButton.setVisibility(View.GONE);
mTeamMinusButton.setVisibility(View.INVISIBLE);
@@ -1209,6 +1222,8 @@ private void endGame() {
mGameTimerRunning = false;
if (mGameCountdownTimer != null)
mGameCountdownTimer.cancel();
+ if (mShieldTimer != null)
+ mShieldTimer.cancel();
mStartGameButton.setVisibility(View.VISIBLE);
mPlayerSettingsButton.setVisibility(View.VISIBLE);
mTeamMinusButton.setVisibility(View.VISIBLE);
@@ -1352,6 +1367,8 @@ private void setShotsRemaining(byte shotsRemaining) {
private void startSpawn(String eliminatedBy) {
if (mReloadTimer != null)
mReloadTimer.cancel();
+ if (mShieldTimer != null)
+ mShieldTimer.cancel();
Globals.getInstance().mGameState = Globals.GAME_STATE_ELIMINATED;
startReload(RELOADING_STATE_ELIMINATED);
mHitIV.setVisibility(View.GONE);
@@ -1373,8 +1390,7 @@ public void onFinish() {
mEliminatedTV.setText(R.string.eliminated_label);
mEliminatedByTV.setVisibility(View.INVISIBLE);
mSpawnInTV.setVisibility(View.GONE);
- mHealth = Globals.getInstance().mFullHealth;
- mHealthBar.setProgress(mHealth);
+ resetVitalStatBars();
Globals.getInstance().mGameState = Globals.GAME_STATE_RUNNING;
playSound(R.raw.spawn, getApplicationContext());
finishReload();
@@ -1392,6 +1408,27 @@ public void onFinish() {
}.start();
}
+ private void startShieldCountdown(float tickTime) {
+ if (mShieldTimer != null)
+ mShieldTimer.cancel();
+
+ mShieldTimer = new CountDownTimer((long)(tickTime * 1000), (long)(tickTime * 1000)) {
+ @Override
+ public void onTick(long millisUntilFinished) {
+ // Nothing
+ }
+
+ @Override
+ public void onFinish() {
+ mShield += mShieldTickAmount;
+ mShieldBar.setProgress(mShield);
+ if (mShield < Globals.getInstance().mFullShields) {
+ startShieldCountdown(mShieldTickTime);
+ }
+ }
+ }.start();
+ }
+
private void startGameCountdown() {
startGameCountdown(Globals.getInstance().mTimeLimit * 60);
}
@@ -1915,6 +1952,22 @@ public void onCompletion(MediaPlayer mp) {
mp.setLooping(false);
}
+ private boolean wouldDie(int damage) {
+ return (mShield + mHealth + damage) > 0;
+ }
+
+ private boolean takeDamage(int damage) {
+ if (mShield + damage < 0) {
+ damage += mShield;
+ mHealth += damage;
+ return true;
+ }
+ mShield += damage;
+
+ startShieldCountdown((long)(mShieldTickTime * 4));
+ return false;
+ }
+
/* Telemetry data is 20 bytes of raw data in the following format:
00 seems to be part of a continuous counter, first byte always 0 and second byte counts 0 to F, increments with each packet sent
01 player ID, 01, 02, 03, etc. 00 when not set
@@ -2194,8 +2247,9 @@ else if (averageBattery >= BATTERY_LEVEL_PISTOL_YELLOW)
}
if (healthRemoved != 0) {
if (Globals.getInstance().mGameState == Globals.GAME_STATE_RUNNING) {
- mHealth += healthRemoved;
+ takeDamage(healthRemoved);
mHealthBar.setProgress(mHealth);
+ mShieldBar.setProgress(mShield);
if (mHealth > 0) {
if (mHitIV != null && mHitAnimation == null) {
// Show the "you're being hit" animation
@@ -2287,12 +2341,12 @@ public void run() {
}
}
// Handy utility code if you want to see the raw data
- /*if (data != null && data.length > 0) {
+ if (data != null && data.length > 0) {
final StringBuilder stringBuilder = new StringBuilder(data.length);
for(byte byteChar : data)
stringBuilder.append(String.format("%02X ", byteChar));
Log.d(TAG, stringBuilder.toString());
- }*/
+ }
}
}
diff --git a/app/src/main/java/com/simplecoil/simplecoil/Globals.java b/app/src/main/java/com/simplecoil/simplecoil/Globals.java
index 2d9eff1..ea9b40c 100644
--- a/app/src/main/java/com/simplecoil/simplecoil/Globals.java
+++ b/app/src/main/java/com/simplecoil/simplecoil/Globals.java
@@ -41,6 +41,8 @@ public class Globals {
public volatile int mFullHealth = MAX_HEALTH;
public static final int DAMAGE_PER_HIT = -1;
public volatile int mDamage = DAMAGE_PER_HIT;
+ public static final int MAX_SHIELDS = 5;
+ public volatile int mFullShields = MAX_SHIELDS;
public volatile boolean mOverrideLives = false;
public volatile int mOverrideLivesVal = 0;
public volatile boolean mAllowPlayerSettings = true;
diff --git a/app/src/main/res/layout/activity_fullscreen.xml b/app/src/main/res/layout/activity_fullscreen.xml
index 127733c..fe96fd4 100644
--- a/app/src/main/res/layout/activity_fullscreen.xml
+++ b/app/src/main/res/layout/activity_fullscreen.xml
@@ -13,16 +13,16 @@
android:id="@+id/connect_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:visibility="gone"
- android:fitsSystemWindows="true">
+ android:fitsSystemWindows="true"
+ android:visibility="visible">
@@ -31,19 +31,19 @@
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"
- android:visibility="gone"
- android:text="@string/reconnect_weapon_button" />
+ android:layout_marginTop="20dp"
+ android:text="@string/reconnect_weapon_button"
+ android:visibility="gone" />
@@ -61,51 +61,51 @@
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="20dp"
- android:layout_centerHorizontal="true"
android:layout_below="@+id/connect_status_tv"
+ android:layout_centerHorizontal="true"
+ android:layout_marginTop="20dp"
android:text="@string/dedicated_server_button" />
+ android:layout_marginTop="16dp"
+ android:visibility="gone" />
+ android:fitsSystemWindows="true"
+ android:visibility="gone">
+ android:layout_centerHorizontal="true"
+ android:visibility="visible" />
@@ -114,18 +114,18 @@
android:id="@+id/player_count_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="5dp"
- android:layout_marginEnd="10dp"
android:layout_alignParentEnd="true"
+ android:layout_marginEnd="10dp"
+ android:layout_marginTop="5dp"
android:textAppearance="@android:style/TextAppearance.Material.Small.Inverse" />
@@ -143,8 +143,8 @@
android:id="@+id/team_label_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="15dp"
android:layout_centerHorizontal="true"
+ android:layout_marginTop="15dp"
android:text="@string/team_label"
android:textAppearance="@android:style/TextAppearance.Material.Small.Inverse" />
@@ -153,38 +153,38 @@
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="35dp"
android:layout_marginStart="15dp"
- android:visibility="invisible"
- android:text="-" />
+ android:layout_marginTop="35dp"
+ android:text="-"
+ android:visibility="invisible" />
+ android:layout_marginEnd="15dp"
+ android:layout_marginTop="35dp"
+ android:text="+"
+ android:visibility="invisible" />
+ android:layout_marginTop="35dp"
+ android:text="@string/scoreboard_button"
+ android:visibility="gone" />
@@ -193,8 +193,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/team_tv"
- android:layout_marginTop="10dp"
android:layout_marginStart="15dp"
+ android:layout_marginTop="10dp"
android:text="@string/shots_remaining_label"
android:textAppearance="@android:style/TextAppearance.Material.Small.Inverse" />
@@ -203,27 +203,27 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/shots_label_tv"
- android:layout_marginTop="0dp"
android:layout_marginStart="30dp"
+ android:layout_marginTop="0dp"
android:text="0"
android:textAppearance="@android:style/TextAppearance.Material.Large.Inverse" />
+ android:layout_marginStart="25dp"
+ android:layout_marginTop="0dp"
+ android:visibility="gone" />
@@ -231,9 +231,9 @@
android:id="@+id/recoil_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="0dp"
android:layout_below="@+id/recoil_label_tv"
android:layout_centerHorizontal="true"
+ android:layout_marginTop="0dp"
android:text="@string/recoil_enabled"
android:textAppearance="@android:style/TextAppearance.Material.Large.Inverse" />
@@ -241,10 +241,10 @@
android:id="@+id/shot_mode_label_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_alignParentEnd="true"
android:layout_below="@+id/team_tv"
- android:layout_marginTop="10dp"
android:layout_marginEnd="15dp"
- android:layout_alignParentEnd="true"
+ android:layout_marginTop="10dp"
android:text="@string/shot_mode_label"
android:textAppearance="@android:style/TextAppearance.Material.Small.Inverse" />
@@ -252,10 +252,10 @@
android:id="@+id/shot_mode_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_alignParentEnd="true"
android:layout_below="@+id/shot_mode_label_tv"
android:layout_marginEnd="15dp"
android:layout_marginTop="0dp"
- android:layout_alignParentEnd="true"
android:text="@string/shot_mode_single"
android:textAppearance="@android:style/TextAppearance.Material.Large.Inverse" />
@@ -263,11 +263,11 @@
android:id="@+id/hits_taken_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginEnd="30dp"
android:layout_alignParentEnd="true"
- android:visibility="gone"
+ android:layout_marginEnd="30dp"
android:text="0"
- android:textAppearance="@android:style/TextAppearance.Material.Large.Inverse" />
+ android:textAppearance="@android:style/TextAppearance.Material.Large.Inverse"
+ android:visibility="gone" />
+
+
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/shield_pb"
+ android:layout_marginEnd="30dp"
+ android:layout_marginStart="30dp"
+ android:layout_marginTop="5dp"
+ android:maxHeight="20dip"
+ android:minHeight="20dip"
+ android:progress="100" />
+ android:layout_centerVertical="true"
+ android:visibility="gone" />
+ android:textAppearance="@android:style/TextAppearance.Material.Large.Inverse"
+ android:visibility="invisible" />
+ android:textAppearance="@android:style/TextAppearance.Material.Large.Inverse"
+ android:visibility="invisible" />
+ android:textAppearance="@android:style/TextAppearance.Material.Large.Inverse"
+ android:visibility="gone" />
+ android:text="@string/end_game_button"
+ android:visibility="gone" />
@@ -418,8 +432,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
- android:layout_marginBottom="10dp"
android:layout_centerHorizontal="true"
+ android:layout_marginBottom="10dp"
android:text="@string/game_mode_2teams"
android:textAppearance="@android:style/TextAppearance.Material.Large.Inverse" />
@@ -428,9 +442,9 @@
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_above="@id/eliminations_count_label_tv"
android:layout_marginBottom="0dp"
android:layout_marginStart="15dp"
- android:layout_above="@id/eliminations_count_label_tv"
android:text="@string/game_limit_button" />
@@ -448,9 +462,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
- android:layout_marginEnd="15dp"
- android:layout_marginBottom="10dp"
android:layout_alignParentEnd="true"
+ android:layout_marginBottom="10dp"
+ android:layout_marginEnd="15dp"
android:text="0"
android:textAppearance="@android:style/TextAppearance.Material.Large.Inverse" />
@@ -459,97 +473,97 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/team_score_tv"
- android:layout_marginEnd="15dp"
android:layout_alignParentEnd="true"
+ android:layout_marginEnd="15dp"
android:text="@string/team_score_label"
- android:visibility="invisible"
- android:textAppearance="@android:style/TextAppearance.Material.Small.Inverse" />
+ android:textAppearance="@android:style/TextAppearance.Material.Small.Inverse"
+ android:visibility="invisible" />
+ android:textAppearance="@android:style/TextAppearance.Material.Large.Inverse"
+ android:visibility="invisible" />
+ android:text="@string/end_game_button"
+ android:visibility="gone" />
+ android:visibility="gone" />
+ android:textAppearance="@android:style/TextAppearance.Material.Small.Inverse"
+ android:visibility="gone" />
+ android:textAppearance="@android:style/TextAppearance.Material.Small.Inverse"
+ android:visibility="gone" />
+ android:layout_marginStart="15dp"
+ android:format="%s" />
+
+
-
-