From ac852f1d405eef44f65cda1bb2b91392d209db37 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 18 Nov 2014 22:47:46 +0100 Subject: [PATCH] Diverse Anpassungen --- HeatUp/src/de/heatup/testing/GameLoopD.java | 2 +- .../heatup/ui/actionPanel/ActionControl.java | 59 ++++++++----------- .../heatup/ui/actionPanel/ActionWatcher.java | 33 +++++------ 3 files changed, 42 insertions(+), 52 deletions(-) diff --git a/HeatUp/src/de/heatup/testing/GameLoopD.java b/HeatUp/src/de/heatup/testing/GameLoopD.java index 5c0a337..396f558 100644 --- a/HeatUp/src/de/heatup/testing/GameLoopD.java +++ b/HeatUp/src/de/heatup/testing/GameLoopD.java @@ -259,7 +259,7 @@ public class GameLoopD extends JFrame implements Runnable { kb.checkKeyActivity(); if (!pause) { ActionWatcher.tick(); - ActionControl.actionControl(); + ActionControl.tick(); HardwareResetTimers.tick(); player01.tick(); opponent01.tick(); diff --git a/HeatUp/src/de/heatup/ui/actionPanel/ActionControl.java b/HeatUp/src/de/heatup/ui/actionPanel/ActionControl.java index 9fde52d..383b1a2 100644 --- a/HeatUp/src/de/heatup/ui/actionPanel/ActionControl.java +++ b/HeatUp/src/de/heatup/ui/actionPanel/ActionControl.java @@ -12,15 +12,12 @@ import de.heatup.testing.GameLoopD; public class ActionControl{ private static int count = 0; - private static long afterTime = 0; - private static long beforeTime = 0; + private static long beforTime = 0; private static boolean time = true; private static boolean keySequenceFail=false; private static int option=0; private static char chr; private static char arr[]; - private static Smashing smashing; - private static Keysequence keysequence; private static JPanel panel; private static JProgressBar bar; private static JLabel actionLabel; @@ -28,30 +25,31 @@ public class ActionControl{ public static void setPanel(JPanel newPanel){ panel = newPanel; - smashing = new Smashing(); - keysequence = new Keysequence(); actionLabel = new JLabel(); bigActionLabel = new JLabel(); - actionLabel.setFont(new Font("Arial", Font.CENTER_BASELINE, 16)); - bigActionLabel.setFont(new Font("Arial", Font.LAYOUT_RIGHT_TO_LEFT,40)); - bigActionLabel.setVisible(false); bar = new JProgressBar(); + actionLabel.setFont(new Font("Arial", Font.CENTER_BASELINE, 16)); + actionLabel.setHorizontalAlignment(JLabel.CENTER); + bigActionLabel.setFont(new Font("Arial", Font.LAYOUT_RIGHT_TO_LEFT,40)); + bigActionLabel.setForeground(Color.RED); + bigActionLabel.setHorizontalAlignment(JLabel.CENTER); + bigActionLabel.setVisible(false); bar.setVisible(false); panel.setLayout(new BorderLayout()); panel.add(actionLabel, BorderLayout.NORTH); panel.add(bar,BorderLayout.SOUTH); panel.add(bigActionLabel,BorderLayout.CENTER); - wishPanel(); + resetActionPanel(); } public static void setAction(int rd){ if(rd==1){ option=1; - setSmash(smashing.getKey()); + setSmash(new Smashing().getKey()); String str= "Bitte die Taste "+getSmash()+" so schnell wie moeglich druecken"; actionLabel.setText(str); }else{ option=2; - setSequence(keysequence.getKeySequence()); + setSequence(new Keysequence().getKeySequence()); String str="Bitte diese Tastenkombination \""; for(int i=0;i8_000_000_000L){ - ActionWatcher.setAction(false); + ActionWatcher.setAction(false); + if(System.nanoTime()-beforTime>8_000_000_000L){ actionLabel.setText("Zu langsam! Fehlgeschlagen!!!"); }else{ - ActionWatcher.setAction(false); actionLabel.setText("Manipulation erfolgreich!"); - count=0; - time=!time; HardewareManipulate.setHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger()); } } @@ -92,11 +86,11 @@ public class ActionControl{ if(count7_000_000_000L){ - ActionWatcher.setAction(false); + ActionWatcher.setAction(false); + if(System.nanoTime()-beforTime>7_000_000_000L){ + actionLabel.setText("Zu langsam! Fehlgeschlagen!!!"); }else{ - ActionWatcher.setAction(false); actionLabel.setText("Manipulation erfolgreich!"); - count=0; - time=!time; HardewareManipulate.setHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger()); } } @@ -139,7 +130,7 @@ public class ActionControl{ public static char[] getSequence(){ return arr; } - public static void wishPanel(){ + public static void resetActionPanel(){ bigActionLabel.setText(""); bar.setValue(0); bar.setVisible(false); @@ -148,8 +139,8 @@ public class ActionControl{ public static void resetTime(){ time=true; } - public static void resetBeforeTime(){ - beforeTime=0; + public static void resetBeforTime(){ + beforTime=0; } public static int getCount(){ return count; diff --git a/HeatUp/src/de/heatup/ui/actionPanel/ActionWatcher.java b/HeatUp/src/de/heatup/ui/actionPanel/ActionWatcher.java index 2a5e6ea..8045251 100644 --- a/HeatUp/src/de/heatup/ui/actionPanel/ActionWatcher.java +++ b/HeatUp/src/de/heatup/ui/actionPanel/ActionWatcher.java @@ -14,9 +14,8 @@ import de.heatup.testing.GameLoopD; public class ActionWatcher{ private static boolean action = false; - private static boolean setaction = false; + private static boolean setAction = false; private static boolean infoText =false; - private static Random rdm = new Random(); public static void setAction(boolean b){ action = b; @@ -25,35 +24,35 @@ public class ActionWatcher{ return action; } public static void tick(){ - //Taucht auf, falls man in der Näche von einem Hardwareteil steht - if(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && !action && !setaction){ + //Infotext, wenn man in der nähe von einem Hardwareteil steht + if(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && !action && !setAction){ infoText=true; if(!HardewareManipulate.getHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger())){ - ActionControl.setTextforA();; + ActionControl.setTextforA(); }else{ ActionControl.setTextforManipulate(); } } - //Entfernt "Taste A drücken" + //Entfernt InfoText if(!MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && infoText){ - ActionControl.wishPanel(); + ActionControl.resetActionPanel(); infoText=false; } - //Nach dem man A gedrueckt hat kommt entweder Smashing oder Keysequence Text. - if(action&&!setaction){ - setaction=true; - ActionControl.wishPanel(); - ActionControl.setAction(rdm.nextInt(2)+1); + //Leitet das Manipulieren ein, nachdem man das "A" gedrückt hat. Es kommt entweder Smashing oder Keysequence Text. + if(action&&!setAction){ + setAction=true; + ActionControl.resetActionPanel(); + ActionControl.setAction(new Random().nextInt(2)+1); } - //Entfernt jeglichen Text wenn man sich von dem Hardwarestück entfernt und setzt Booleans wieder auf ausganssituation - if(!MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && setaction){ - ActionControl.wishPanel(); + //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.resetBeforeTime(); + ActionControl.resetBeforTime(); ActionControl.resetKeySequenceFail(); infoText=false; - setaction=false; + setAction=false; action=false; } }