From f603e32a953f6ee15b18f367e724f1786fd1153a Mon Sep 17 00:00:00 2001 From: Ivan Date: Fri, 21 Nov 2014 09:57:58 +0100 Subject: [PATCH] Weitere Anpassungen an ActionControl --- HeatUp/src/de/heatup/testing/GameLoopD.java | 1 + .../de/heatup/timers/HardwareResetTimers.java | 4 +- HeatUp/src/de/heatup/ui/KeyBindings.java | 41 ++++++++-- .../heatup/ui/actionPanel/ActionControl.java | 82 ++++++++++++++----- .../heatup/ui/actionPanel/ActionWatcher.java | 4 - 5 files changed, 97 insertions(+), 35 deletions(-) diff --git a/HeatUp/src/de/heatup/testing/GameLoopD.java b/HeatUp/src/de/heatup/testing/GameLoopD.java index 396f558..4c50c33 100644 --- a/HeatUp/src/de/heatup/testing/GameLoopD.java +++ b/HeatUp/src/de/heatup/testing/GameLoopD.java @@ -260,6 +260,7 @@ public class GameLoopD extends JFrame implements Runnable { if (!pause) { ActionWatcher.tick(); ActionControl.tick(); + if(ActionControl.getTickTimer())ActionControl.tickTimer(); HardwareResetTimers.tick(); player01.tick(); opponent01.tick(); diff --git a/HeatUp/src/de/heatup/timers/HardwareResetTimers.java b/HeatUp/src/de/heatup/timers/HardwareResetTimers.java index dba72cb..e8603c4 100644 --- a/HeatUp/src/de/heatup/timers/HardwareResetTimers.java +++ b/HeatUp/src/de/heatup/timers/HardwareResetTimers.java @@ -26,7 +26,7 @@ public class HardwareResetTimers { if (HardwareResetTickstamps.get(i).equals(tickCount)) { Logger.write("Hardware "+i+" reset"); HardewareManipulate.resetHardware(i); - StatusPanelAdder.reduceMod(); + //StatusPanelAdder.reduceMod(); } } } @@ -41,6 +41,6 @@ public class HardwareResetTimers { resetTimestamp = resetTimestamp % tickRoundMax; } HardwareResetTickstamps.put(c, resetTimestamp); - StatusPanelAdder.raiseMod(); + //StatusPanelAdder.raiseMod(); } } diff --git a/HeatUp/src/de/heatup/ui/KeyBindings.java b/HeatUp/src/de/heatup/ui/KeyBindings.java index 3da9e8f..4a0b687 100644 --- a/HeatUp/src/de/heatup/ui/KeyBindings.java +++ b/HeatUp/src/de/heatup/ui/KeyBindings.java @@ -19,6 +19,7 @@ public class KeyBindings extends KeyAdapter { private boolean up = false; private boolean down = false; private boolean esc = false; + private boolean key = false; private Player player; public KeyBindings(Player player) { @@ -44,6 +45,18 @@ public class KeyBindings extends KeyAdapter { case KeyEvent.VK_ESCAPE: esc = false; break; + case KeyEvent.VK_Q: + key = false; + break; + case KeyEvent.VK_W: + key = false; + break; + case KeyEvent.VK_E: + key = false; + break; + case KeyEvent.VK_R: + key = false; + break; } } @@ -73,9 +86,11 @@ public class KeyBindings extends KeyAdapter { } break; case KeyEvent.VK_Q: - if(ActionWatcher.getAction()){ + if(ActionWatcher.getAction()&&!key){ if(ActionControl.getOption()==1){ - if(ActionControl.getSmash()=='Q')ActionControl.incCount(); + if(ActionControl.getSmash()=='Q'){ + ActionControl.getBar().setValue(ActionControl.getBar().getValue()+7); + } }else if(!ActionControl.getKeySequenceFail()){ if(ActionControl.getSequence()[ActionControl.getCount()]=='Q'){ ActionControl.incCount(); @@ -85,12 +100,15 @@ public class KeyBindings extends KeyAdapter { } } + key=true; } break; case KeyEvent.VK_W: - if(ActionWatcher.getAction()){ + if(ActionWatcher.getAction()&&!key){ if(ActionControl.getOption()==1){ - if(ActionControl.getSmash()=='W')ActionControl.incCount(); + if(ActionControl.getSmash()=='W'){; + ActionControl.getBar().setValue(ActionControl.getBar().getValue()+7); + } }else if(!ActionControl.getKeySequenceFail()){ if(ActionControl.getSequence()[ActionControl.getCount()]=='W'){ ActionControl.incCount(); @@ -99,12 +117,15 @@ public class KeyBindings extends KeyAdapter { ActionControl.setKeySequenceFail(); } } + key=true; } break; case KeyEvent.VK_E: - if(ActionWatcher.getAction()){ + if(ActionWatcher.getAction()&&!key){ if(ActionControl.getOption()==1){ - if(ActionControl.getSmash()=='E')ActionControl.incCount(); + if(ActionControl.getSmash()=='E'){ + ActionControl.getBar().setValue(ActionControl.getBar().getValue()+7); + } }else if(!ActionControl.getKeySequenceFail()){ if(ActionControl.getSequence()[ActionControl.getCount()]=='E'){ ActionControl.incCount(); @@ -113,12 +134,15 @@ public class KeyBindings extends KeyAdapter { ActionControl.setKeySequenceFail(); } } + key=true; } break; case KeyEvent.VK_R: - if(ActionWatcher.getAction()){ + if(ActionWatcher.getAction()&&!key){ if(ActionControl.getOption()==1){ - if(ActionControl.getSmash()=='R')ActionControl.incCount(); + if(ActionControl.getSmash()=='R'){ + ActionControl.getBar().setValue(ActionControl.getBar().getValue()+7); + } }else if(!ActionControl.getKeySequenceFail()){ if(ActionControl.getSequence()[ActionControl.getCount()]=='R'){ ActionControl.incCount(); @@ -127,6 +151,7 @@ public class KeyBindings extends KeyAdapter { ActionControl.setKeySequenceFail(); } } + key=true; } break; } diff --git a/HeatUp/src/de/heatup/ui/actionPanel/ActionControl.java b/HeatUp/src/de/heatup/ui/actionPanel/ActionControl.java index 383b1a2..52fc91d 100644 --- a/HeatUp/src/de/heatup/ui/actionPanel/ActionControl.java +++ b/HeatUp/src/de/heatup/ui/actionPanel/ActionControl.java @@ -9,12 +9,14 @@ import javax.swing.border.LineBorder; import de.heatup.mapengine.MapGrid; import de.heatup.testing.GameLoopD; +import de.heatup.ui.StatusPanelAdder; public class ActionControl{ private static int count = 0; private static long beforTime = 0; private static boolean time = true; private static boolean keySequenceFail=false; + private static boolean tickTimer =false; private static int option=0; private static char chr; private static char arr[]; @@ -22,6 +24,7 @@ public class ActionControl{ private static JProgressBar bar; private static JLabel actionLabel; private static JLabel bigActionLabel; + private static int tmpCount=0; public static void setPanel(JPanel newPanel){ panel = newPanel; @@ -50,11 +53,7 @@ public class ActionControl{ }else{ option=2; setSequence(new Keysequence().getKeySequence()); - String str="Bitte diese Tastenkombination \""; - for(int i=0;i8_000_000_000L){ @@ -82,25 +81,28 @@ public class ActionControl{ } //KeySequence-Tick }else{ + if(!getTickTimer()){ + setTickTimer(); + setProgressBar(100); + } if(!getKeySequenceFail()){ - if(count0){ bigActionLabel.setVisible(true); if(time){ time = false; beforTime=System.nanoTime(); - }else if(count!=0){ - actionLabel.setText(""); - String str=""; - for(int i=count;i7_000_000_000L){ - + if(System.nanoTime()-beforTime>7_000_000_000L || bar.getValue()<=0){ actionLabel.setText("Zu langsam! Fehlgeschlagen!!!"); }else{ actionLabel.setText("Manipulation erfolgreich!"); @@ -108,6 +110,8 @@ public class ActionControl{ } } }else{ + resetTickTimer(); + resetProgressBar(); bigActionLabel.setVisible(false); ActionWatcher.setAction(false); actionLabel.setText("Falsche Taste! Fehlgeschlagen!!!"); @@ -115,6 +119,26 @@ public class ActionControl{ } } } + public static void tickTimer(){ + tmpCount++; + if(option==1){ + if(bar.getValue()>1){ + if(tmpCount%2==0)bar.setValue(bar.getValue()-1); + if(bar.getValue()<3)bar.setValue(0); + } + }else{ + if(tmpCount%3==0)bar.setValue(bar.getValue()-1); + } + } + public static boolean getTickTimer(){ + return tickTimer; + } + public static void resetTickTimer(){ + tickTimer=false; + } + private static void setTickTimer(){ + tickTimer=true; + } public static int getOption(){ return option; } @@ -132,9 +156,13 @@ public class ActionControl{ } public static void resetActionPanel(){ bigActionLabel.setText(""); - bar.setValue(0); - bar.setVisible(false); actionLabel.setText(""); + resetProgressBar(); + resetCount(); + resetTime(); + resetBeforTime(); + resetKeySequenceFail(); + resetTickTimer(); } public static void resetTime(){ time=true; @@ -149,6 +177,7 @@ public class ActionControl{ count++; } public static void resetCount(){ + tmpCount=0; count=0; } public static boolean getKeySequenceFail(){ @@ -166,4 +195,15 @@ public class ActionControl{ public static void setTextforManipulate(){ actionLabel.setText("Bereits Manipuliert"); } + private static void setProgressBar(int value){ + bar.setValue(value); + bar.setVisible(true); + } + public static void resetProgressBar(){ + bar.setValue(0); + bar.setVisible(false); + } + public static JProgressBar getBar(){ + return bar; + } } diff --git a/HeatUp/src/de/heatup/ui/actionPanel/ActionWatcher.java b/HeatUp/src/de/heatup/ui/actionPanel/ActionWatcher.java index 8045251..c115e10 100644 --- a/HeatUp/src/de/heatup/ui/actionPanel/ActionWatcher.java +++ b/HeatUp/src/de/heatup/ui/actionPanel/ActionWatcher.java @@ -47,10 +47,6 @@ public class ActionWatcher{ //Entfernt jeglichen Text wenn man sich von dem Hardwarestück entfernt, nachdem Aktion bereits eingeleitet wurde, und setzt Booleans/Counter wieder auf die Ausgangssituation if(!MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && setAction){ ActionControl.resetActionPanel(); - ActionControl.resetCount(); - ActionControl.resetTime(); - ActionControl.resetBeforTime(); - ActionControl.resetKeySequenceFail(); infoText=false; setAction=false; action=false;