diff --git a/HeatUp/src/de/heatup/audio/Main.java b/HeatUp/src/de/heatup/audio/Main.java index 69ceb73..2282518 100644 --- a/HeatUp/src/de/heatup/audio/Main.java +++ b/HeatUp/src/de/heatup/audio/Main.java @@ -3,6 +3,7 @@ package de.heatup.audio; public class Main { public static void main(String[] args) { - new WavePlayer("").start(); + + Sound.BOMB.play(); } } diff --git a/HeatUp/src/de/heatup/audio/Sound.java b/HeatUp/src/de/heatup/audio/Sound.java new file mode 100644 index 0000000..4beda07 --- /dev/null +++ b/HeatUp/src/de/heatup/audio/Sound.java @@ -0,0 +1,58 @@ +package de.heatup.audio; + +import java.io.File; +import java.io.IOException; + +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; +import javax.sound.sampled.Line; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.UnsupportedAudioFileException; + +public enum Sound { + BOMB("src/de/heatup/resources/audio/" + "bomb.wav"); + + private Clip clip; + + Sound(String soundFileName) { + + File f = new File(soundFileName); + if(!f.exists()) { + System.err.println("File not found : " + f.getAbsolutePath()); + return; + } + + try { + + Line.Info linfo = new Line.Info(Clip.class); + Line line = AudioSystem.getLine(linfo); + + clip = (Clip) line; + AudioInputStream inputStream = AudioSystem.getAudioInputStream(f); + + clip.open(inputStream); + + } catch(UnsupportedAudioFileException e) { + e.printStackTrace(); + } catch(IOException e) { + e.printStackTrace(); + } catch(LineUnavailableException e) { + e.printStackTrace(); + } catch(Exception e) { + e.printStackTrace(); + } + } + + public void play() { + try { + new Thread() { + public void run() { + clip.start(); + } + }.start(); + } catch(Throwable e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/HeatUp/src/de/heatup/audio/WavePlayer.java b/HeatUp/src/de/heatup/audio/WavePlayer.java deleted file mode 100644 index 3835596..0000000 --- a/HeatUp/src/de/heatup/audio/WavePlayer.java +++ /dev/null @@ -1,99 +0,0 @@ -package de.heatup.audio; - -import java.io.File; -import java.io.IOException; -import javax.sound.sampled.AudioFormat; -import javax.sound.sampled.AudioInputStream; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.DataLine; -import javax.sound.sampled.FloatControl; -import javax.sound.sampled.LineUnavailableException; -import javax.sound.sampled.SourceDataLine; -import javax.sound.sampled.UnsupportedAudioFileException; - -public class WavePlayer extends Thread { - - private String filename; - - private Position curPosition; - - private final int EXTERNAL_BUFFER_SIZE = 524288; // 128Kb - - enum Position { - LEFT, RIGHT, NORMAL - }; - - public WavePlayer(String wavfile) { - filename = wavfile; - curPosition = Position.NORMAL; - } - - public WavePlayer(String wavfile, Position p) { - filename = wavfile; - curPosition = p; - } - - public void run() { - - File soundFile = new File(filename); - if (!soundFile.exists()) { - System.err.println("Wave file not found: " + filename); - return; - } - - AudioInputStream audioInputStream = null; - try { - audioInputStream = AudioSystem.getAudioInputStream(soundFile); - } catch (UnsupportedAudioFileException e1) { - e1.printStackTrace(); - return; - } catch (IOException e1) { - e1.printStackTrace(); - return; - } - - AudioFormat format = audioInputStream.getFormat(); - SourceDataLine auline = null; - DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); - - try { - auline = (SourceDataLine) AudioSystem.getLine(info); - auline.open(format); - } catch (LineUnavailableException e) { - e.printStackTrace(); - return; - } catch (Exception e) { - e.printStackTrace(); - return; - } - - if (auline.isControlSupported(FloatControl.Type.PAN)) { - FloatControl pan = (FloatControl) auline - .getControl(FloatControl.Type.PAN); - if (curPosition == Position.RIGHT) - pan.setValue(1.0f); - else if (curPosition == Position.LEFT) - pan.setValue(-1.0f); - } - - auline.start(); - int nBytesRead = 0; - byte[] abData = new byte[EXTERNAL_BUFFER_SIZE]; - - try { - while (nBytesRead != -1) { - nBytesRead = audioInputStream.read(abData, 0, abData.length); - if (nBytesRead >= 0) - auline.write(abData, 0, nBytesRead); - } - } catch (IOException e) { - e.printStackTrace(); - return; - } finally { - auline.drain(); - auline.close(); - } - - } -} - \ No newline at end of file diff --git a/HeatUp/src/de/heatup/cfg/Config.java b/HeatUp/src/de/heatup/cfg/Config.java index 439c9f5..7f888c8 100644 --- a/HeatUp/src/de/heatup/cfg/Config.java +++ b/HeatUp/src/de/heatup/cfg/Config.java @@ -4,6 +4,11 @@ package de.heatup.cfg; * Bitte hier eure Magicnumbers eintragen */ public class Config { + /* + * Attribute + * de.heatup.ui.GameLoop + */ + public static int currentTickNr = 0; /* * Attribute * de.heatup.mapengine.* diff --git a/HeatUp/src/de/heatup/mapengine/CollisionHandler.java b/HeatUp/src/de/heatup/mapengine/CollisionHandler.java index 32a4e98..b8ecfd6 100644 --- a/HeatUp/src/de/heatup/mapengine/CollisionHandler.java +++ b/HeatUp/src/de/heatup/mapengine/CollisionHandler.java @@ -1,9 +1,13 @@ package de.heatup.mapengine; +import java.util.ArrayList; + import de.heatup.logging.Logger; +import de.heatup.testing.Opponent; import de.heatup.testing.Player; public class CollisionHandler { + private static ArrayList movingObjects = new ArrayList(); /** * Prüfe ob eine Kollision vorliegt * @param movingObject Kann alles sein, dass sich bewegt. Spieler oder KI. @@ -11,29 +15,101 @@ public class CollisionHandler { * @return */ public static boolean checkCollision(Player movingObject, char d) { + if (movingObject == (movingObjects.get(0))) { +// return normalCheck(movingObject, d); +// if (movingObject.equals(movingObjects.get(0))) { +// enemyCollision(movingObject, d); + hardwareCollision(movingObject, d); + return normalCheck(movingObject, d); + } else { +// playerCollision(movingObject, d); + return normalCheck(movingObject, d); + } +// switch (d) { +// case 'l': +// if (MapGrid.getGridCell(movingObject.getGridLocation().x-1, movingObject.getGridLocation().y).isPath() && MapGrid.getGridCell(movingObject.getGridLocation().x-1, movingObject.getGridLocation().y).isTrigger()) { +// Logger.write("Collision with trigger of hardware ID: " + MapGrid.getGridCell(movingObject.getGridLocation().x-1, movingObject.getGridLocation().y).getCorrespondingHardwareToTrigger()); +// } +// return MapGrid.getGridCell(movingObject.getGridLocation().x-1, movingObject.getGridLocation().y).isPath(); +// case 'r': +// if (MapGrid.getGridCell(movingObject.getGridLocation().x+1, movingObject.getGridLocation().y).isPath() && MapGrid.getGridCell(movingObject.getGridLocation().x+1, movingObject.getGridLocation().y).isTrigger()) { +// Logger.write("Collision with trigger of hardware ID: " + MapGrid.getGridCell(movingObject.getGridLocation().x+1, movingObject.getGridLocation().y).getCorrespondingHardwareToTrigger()); +// } +// return MapGrid.getGridCell(movingObject.getGridLocation().x+1, movingObject.getGridLocation().y).isPath(); +// case 'd': +// if (MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y+1).isPath() && MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y+1).isTrigger()) { +// Logger.write("Collision with trigger of hardware ID: " + MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y+1).getCorrespondingHardwareToTrigger()); +// } +// return MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y+1).isPath(); +// case 'u': +// if (MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y-1).isPath() && MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y-1).isTrigger()) { +// Logger.write("Collision with trigger of hardware ID: " + MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y-1).getCorrespondingHardwareToTrigger()); +// } +// return MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y-1).isPath(); +// default: +// return true; +// } + } + private static void playerCollision(Player movingObject, char d) { +// if (movingObject.getGridLocation().x== movingObjects.get(0).getGridLocation().x && movingObject.getGridLocation().y == movingObjects.get(0).getGridLocation().y) { +//// System.exit(-1); +// } + } + private static void enemyCollision(Player movingObject, char d ) { +// for (int i=1; i= 1) { - tick(); + if (!pause) { + tick(); + } updates++; delta--; } @@ -209,12 +250,23 @@ public class GameLoopD extends JFrame implements Runnable { } // alles was geupdatet werden muss hier rein private void tick() { + if (Config.currentTickNr >= 60) { + Config.currentTickNr = 0; + } else { + Config.currentTickNr++; + } kb.checkKeyActivity(); + ActionWatcher.tick(); + ActionControl.actionControl(); + HardwareResetTimers.tick(); player01.tick(); opponent01.tick(); opponent02.tick(); opponent03.tick(); - + opponent04.tick(); + opponent05.tick(); + opponent06.tick(); + CollisionHandler.tick(); } // alles was animiert wird hier rein (paints) private void render() { diff --git a/HeatUp/src/de/heatup/testing/Opponent.java b/HeatUp/src/de/heatup/testing/Opponent.java index 4e5498b..b2c3a03 100644 --- a/HeatUp/src/de/heatup/testing/Opponent.java +++ b/HeatUp/src/de/heatup/testing/Opponent.java @@ -8,13 +8,12 @@ import javax.imageio.ImageIO; import de.heatup.cfg.Config; import de.heatup.logging.Logger; +import de.heatup.mapengine.CollisionHandler; import de.heatup.mapengine.MapGrid; +import de.heatup.mapengine.MapGridCell; public class Opponent extends Player { - /** - * - */ private static final long serialVersionUID = 1L; private boolean redecide = true; // Nötig sobald der Schritt in die gewollte Richtung erfolgt ist private Random rand = new Random(); @@ -26,7 +25,13 @@ public class Opponent extends Player { private int prevX; private int prevY; private boolean blocked = false; + private boolean move = false; private int blockedCounter = 0; + private char charDir; + + public Opponent() { + CollisionHandler.addMovingObject(this); + } @Override protected void loadBufferedImage() { try { @@ -37,17 +42,9 @@ public class Opponent extends Player { } @Override public void tick() { - if ( redecide ) { while ( true ) { - this.d = (rand.nextInt(10) <= 4) ? 'x' : 'y'; - this.i = (rand.nextInt(10) <= 4) ? 1 : -1; - - // Sicher stellen das man nicht in die Richtung geht aus der man gekommen ist. - if ( redecide && this.d == this.prevd && this.i != this.previ ) { - this.i *= -1; - } // Blockade Erkennung if ( this.prevX == this.getGridLocation().x & this.prevY == this.getGridLocation().y ) { this.blockedCounter++; @@ -58,12 +55,47 @@ public class Opponent extends Player { this.prevX = this.getGridLocation().x; this.prevY = this.getGridLocation().y; - //TODO: Bei Kreuzung umentscheiden + if ( d == 'x' ) { + if ( CollisionHandler.checkCollision(this, 'd') ) { + this.move = false; + } + if ( CollisionHandler.checkCollision(this, 'u') ) { + this.move = false; + } + } + if ( d == 'y' ) { + if ( CollisionHandler.checkCollision(this, 'l') ) { + this.move = false; + } + if ( CollisionHandler.checkCollision(this, 'r') ) { + this.move = false; + } + } + + + + // Umentscheiden oder weiter in die vorgegeben Richtung + if ( ! this.move ) { + //Logger.write("Redeciding..."); + this.d = (rand.nextInt(10) <= 4) ? 'x' : 'y'; + this.i = (rand.nextInt(10) <= 4) ? 1 : -1; + // Sicher stellen das man nicht in die Richtung geht aus der man gekommen ist. + if ( redecide && this.d == this.prevd && this.i != this.previ ) { + this.i *= -1; + } + + } else { + //Logger.write("Moving..."); + } + + this.move = true; + // Blockade auflösen, gehe doch in die Richtung aus man gekommen ist if ( this.blocked ) { - Logger.write("Warning: Block detected!"); + //Logger.write("Warning: Block detected!"); this.i *= -1; + this.move = false; this.blocked = false; this.blockedCounter = 0; } @@ -77,16 +109,24 @@ public class Opponent extends Player { testX=this.getGridLocation().x; } - // Testen ob die gewählte Richtung begehbar ist - if (MapGrid.getGridCell(testX,testY).isPath()) { + if ( d == 'x' && i == -1 ) { + charDir = 'l'; + } else if ( d == 'x' && i == 1 ) { + charDir = 'r'; + } else if ( d == 'y' && i == -1 ) { + charDir = 'u'; + } else if ( d == 'y' && i == 1 ) { + charDir = 'd'; + } + + if (CollisionHandler.checkCollision(this, charDir)) { this.setGridLocation(testX, testY); this.prevd = d; this.previ = i; redecide = false; animate = true; break; - } - + } } } @@ -94,7 +134,8 @@ public class Opponent extends Player { int newx = this.getX(); int newy = this.getY(); - for (int s = 0; s < this.speedMultiplicator; s++) { // speed multiplikator + // Speed Multiplikator + for (int s = 0; s < this.speedMultiplicator; s++) { if (d == 'x' && i == -1) { newx = newx - 1; } else if (d == 'x' && i == 1) { @@ -104,20 +145,22 @@ public class Opponent extends Player { } else if (d == 'y' && i == 1) { newy = newy + 1; } - + this.setAutoBounds(newx, newy); stepCounter--; if ( stepCounter <= 0 ) { animate = false; break; } + } if (stepCounter <= 0) { stepCounter = 25; redecide = true; + animate = false; + } else { + animate = true; } - - } + } } - } diff --git a/HeatUp/src/de/heatup/testing/Player.java b/HeatUp/src/de/heatup/testing/Player.java index 27667bf..8981400 100644 --- a/HeatUp/src/de/heatup/testing/Player.java +++ b/HeatUp/src/de/heatup/testing/Player.java @@ -14,6 +14,7 @@ import javax.swing.JComponent; import de.heatup.cfg.Config; import de.heatup.logging.Logger; +import de.heatup.mapengine.CollisionHandler; public class Player extends JComponent { private static final long serialVersionUID = 1L; @@ -33,6 +34,10 @@ public class Player extends JComponent { int stepCounter = 25; private Point currentGridPosition; + public Player() { + CollisionHandler.addMovingObject(this); + } + public void setSpeedMultiplicator(int factor) { this.speedMultiplicator *= factor; } diff --git a/HeatUp/src/de/heatup/timers/HardwareResetTimers.java b/HeatUp/src/de/heatup/timers/HardwareResetTimers.java new file mode 100644 index 0000000..6605dd6 --- /dev/null +++ b/HeatUp/src/de/heatup/timers/HardwareResetTimers.java @@ -0,0 +1,36 @@ +package de.heatup.timers; + +import java.util.HashMap; +import java.util.Map; + +import de.heatup.cfg.Config; +import de.heatup.logging.Logger; +import de.heatup.ui.actionPanel.HardewareManipulate; + +public class HardwareResetTimers { + private static int tickCount = 0; + private static int tickRoundMax = 10000; + private static int nrOfTicksUntilReset = 900; // entspricht 15 sekunden ingame zeit (nicht unbedingt echtzeit!); berechnet durch 15*targetTickRate im Gameloop. + private static Map HardwareResetTickstamps = new HashMap(); + public static void tick() { + tickCount++; + if (tickCount>=tickRoundMax) { + tickCount = 0; + } + for (char i = Config.firstHardwareChar; i<=Config.lastHardwareChar; i++) { + if (HardwareResetTickstamps.containsKey(i)) { + if (HardwareResetTickstamps.get(i).equals(tickCount)) { + Logger.write("Hardware "+i+" reset"); + HardewareManipulate.resetHardware(i); + } + } + } + } + public static void setManipulated(char c) { + int resetTimestamp = tickCount+nrOfTicksUntilReset; + if (resetTimestamp > tickRoundMax) { + resetTimestamp = resetTimestamp % tickRoundMax; + } + HardwareResetTickstamps.put(c, resetTimestamp); + } +} diff --git a/HeatUp/src/de/heatup/ui/KeyBindings.java b/HeatUp/src/de/heatup/ui/KeyBindings.java index edd1692..3288c41 100644 --- a/HeatUp/src/de/heatup/ui/KeyBindings.java +++ b/HeatUp/src/de/heatup/ui/KeyBindings.java @@ -3,8 +3,14 @@ package de.heatup.ui; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; +import sun.awt.resources.awt; import de.heatup.mapengine.CollisionHandler; +import de.heatup.mapengine.MapGrid; +import de.heatup.testing.GameLoopD; import de.heatup.testing.Player; +import de.heatup.ui.actionPanel.ActionControl; +import de.heatup.ui.actionPanel.ActionWatcher; +import de.heatup.ui.actionPanel.HardewareManipulate; public class KeyBindings extends KeyAdapter { @@ -12,6 +18,7 @@ public class KeyBindings extends KeyAdapter { private boolean right = false; private boolean up = false; private boolean down = false; + private boolean esc = false; private Player player; public KeyBindings(Player player) { @@ -34,6 +41,9 @@ public class KeyBindings extends KeyAdapter { case KeyEvent.VK_DOWN: down = false; break; + case KeyEvent.VK_ESCAPE: + esc = false; + break; } } @@ -53,6 +63,55 @@ public class KeyBindings extends KeyAdapter { case KeyEvent.VK_DOWN: down = true; break; + case KeyEvent.VK_ESCAPE: + esc = true; + break; + case KeyEvent.VK_A: + if(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() + && !HardewareManipulate.getHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger())){ + ActionWatcher.setAction(true); + } + break; + case KeyEvent.VK_Q: + if(ActionWatcher.getAction()&&ActionControl.getSmash()=='Q'){ + if(ActionControl.getOption()){ + ActionControl.count++; + }else{ + //ActionControl.setQ(); + //ActionControl.count++; + } + } + break; + case KeyEvent.VK_W: + if(ActionWatcher.getAction()&&ActionControl.getSmash()=='W'){ + if(ActionControl.getOption()){ + ActionControl.count++; + }else{ + //ActionControl.setW(); + //ActionControl.count++; + } + } + break; + case KeyEvent.VK_E: + if(ActionWatcher.getAction()&&ActionControl.getSmash()=='E'){ + if(ActionControl.getOption()){ + ActionControl.count++; + }else{ + //ActionControl.setE(); + //ActionControl.count++; + } + } + break; + case KeyEvent.VK_R: + if(ActionWatcher.getAction()&&ActionControl.getSmash()=='R'){ + if(ActionControl.getOption()){ + ActionControl.count++; + }else{ + //ActionControl.setR(); + //ActionControl.count++; + } + } + break; } } @@ -90,6 +149,10 @@ public class KeyBindings extends KeyAdapter { } player.animate = true; } + if (isESC()) { + System.out.println("ESC pressed."); + GameLoopD.pause(); + } } public boolean isLeft() { @@ -107,4 +170,7 @@ public class KeyBindings extends KeyAdapter { public boolean isDown() { return down; } + public boolean isESC() { + return esc; + } } \ No newline at end of file diff --git a/HeatUp/src/de/heatup/ui/actionPanel/ActionControl.java b/HeatUp/src/de/heatup/ui/actionPanel/ActionControl.java new file mode 100644 index 0000000..2493d0c --- /dev/null +++ b/HeatUp/src/de/heatup/ui/actionPanel/ActionControl.java @@ -0,0 +1,113 @@ +package de.heatup.ui.actionPanel; + +import java.awt.Color; +import java.awt.Font; + +import javax.swing.*; +import javax.swing.border.LineBorder; + +import de.heatup.mapengine.MapGrid; +import de.heatup.testing.GameLoopD; + +public class ActionControl{ + public static int count =0; + private static long afterTime=0; + static long beforeTime =0; + static boolean time =true; + private static boolean Q=false; + private static boolean W=false; + private static boolean E=false; + private static boolean R=false; + private static boolean option; + private static char chr='0'; + private static char arr[]; + private static Smashing smashing; + private static Keysequence keysequence; + private static JPanel panel; + protected static JLabel actionLabel; + + public static void setPanel(JPanel newPanel){ + panel = newPanel; + smashing = new Smashing(); + keysequence = new Keysequence(); + actionLabel = new JLabel(); + actionLabel.setFont(new Font("Arial", Font.CENTER_BASELINE, 16)); + actionLabel.setBorder(new LineBorder(Color.BLACK, 1)); + actionLabel.setSize(100,10); + panel.add(actionLabel); + wishPanel(); + } + public static void setAction(int rd){ + if(true){ + option=true; + setSmash(smashing.getKey()); + String str= "Bitte die Taste "+getSmash()+" so schnell wie moeglich druecken"; + actionLabel.setText(str); + /*}else{ + option=false; + setSequence(keysequence.getKeySequence()); + String str="Bitte diese Tastenkombination \""; + for(int i=0;i8_000_000_000L){ + actionLabel.setText("Fehlgeschlagen"); + }else{ + actionLabel.setText("Manipulation erfolgreich!"); + count=0; + time=!time; + ActionWatcher.setAction(false); + HardewareManipulate.setHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger()); + } + } + }else{ + // + } + } + } + public static void setQ(){ + Q=true; + } + public static void setW(){ + W=true; + } + public static void setE(){ + E=true; + } + public static void setR(){ + R=true; + } + + public static boolean getOption(){ + return option; + } + private static void setSmash(char c){ + chr=c; + } + private static void setSequence(char c[]){ + arr=c; + } + public static char getSmash(){ + return chr; + } + private static char[] getSequence(){ + return arr; + } + public static void wishPanel(){ + actionLabel.setText(""); + } +} diff --git a/HeatUp/src/de/heatup/ui/actionPanel/ActionWatcher.java b/HeatUp/src/de/heatup/ui/actionPanel/ActionWatcher.java new file mode 100644 index 0000000..8a5826c --- /dev/null +++ b/HeatUp/src/de/heatup/ui/actionPanel/ActionWatcher.java @@ -0,0 +1,55 @@ +package de.heatup.ui.actionPanel; + +import java.awt.Component; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.util.Random; + +import javax.swing.JLabel; + +import de.heatup.mapengine.MapEngine; +import de.heatup.mapengine.MapGrid; +import de.heatup.mapengine.MapGridCell; +import de.heatup.testing.GameLoopD; + +public class ActionWatcher{ + private static boolean action = false; + private static boolean setaction = false; + private static Random rdm = new Random(); + + public static void setAction(boolean b){ + action = b; + } + public static boolean getAction(){ + 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){ + if(!HardewareManipulate.getHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger())){ + ActionControl.actionLabel.setText("Taste A druecken"); + }else{ + ActionControl.actionLabel.setText("Bereits Manipuliert"); + } + } + //Entfernt jeglichen Text wenn man sich von dem Hardwarestück entfernt und noch nicht A gedrückt hat + if(!MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && !action && !setaction){ + ActionControl.wishPanel(); + } + //Nach dem man A gedrueckt hat kommt entweder Smashing oder Keysequence Text. + if(action&&!setaction){ + setaction = !setaction; + ActionControl.actionLabel.setText(""); + ActionControl.setAction(rdm.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(); + ActionControl.count=0; + ActionControl.time=true; + ActionControl.beforeTime=0; + setaction = !setaction; + action = !action; + } + } +} diff --git a/HeatUp/src/de/heatup/ui/actionPanel/HardewareManipulate.java b/HeatUp/src/de/heatup/ui/actionPanel/HardewareManipulate.java new file mode 100644 index 0000000..616fa32 --- /dev/null +++ b/HeatUp/src/de/heatup/ui/actionPanel/HardewareManipulate.java @@ -0,0 +1,132 @@ +package de.heatup.ui.actionPanel; + +import de.heatup.timers.HardwareResetTimers; + +public class HardewareManipulate { + private static boolean h00=false; + private static boolean h01=false; + private static boolean h02=false; + private static boolean h03=false; + private static boolean h04=false; + private static boolean h05=false; + private static boolean h06=false; + private static boolean h07=false; + private static boolean h08=false; + private static boolean h09=false; + public static void setHardware(char c){ + switch(c){ + case '0': + h00=true; + HardwareResetTimers.setManipulated(c); + break; + case '1': + h01=true; + HardwareResetTimers.setManipulated(c); + break; + case '2': + h02=true; + HardwareResetTimers.setManipulated(c); + break; + case '3': + h03=true; + HardwareResetTimers.setManipulated(c); + break; + case '4': + h04=true; + HardwareResetTimers.setManipulated(c); + break; + case '5': + h05=true; + HardwareResetTimers.setManipulated(c); + break; + case '6': + h06=true; + HardwareResetTimers.setManipulated(c); + break; + case '7': + h07=true; + HardwareResetTimers.setManipulated(c); + break; + case '8': + h08=true; + HardwareResetTimers.setManipulated(c); + break; + case '9': + h09=true; + HardwareResetTimers.setManipulated(c); + break; + } + } + public static void resetHardware(char c){ + switch(c){ + case '0': + h00=false; + break; + case '1': + h01=false; + break; + case '2': + h02=false; + break; + case '3': + h03=false; + break; + case '4': + h04=false; + break; + case '5': + h05=false; + break; + case '6': + h06=false; + break; + case '7': + h07=false; + break; + case '8': + h08=false; + break; + case '9': + h09=false; + break; + } + } + public static boolean getHardware(char c){ + switch(c){ + case '0': + return h00; + case '1': + return h01; + case '2': + return h02; + case '3': + return h03; + case '4': + return h04; + case '5': + return h05; + case '6': + return h06; + case '7': + return h07; + case '8': + return h08; + case '9': + return h09; + default: + return false; + } + } + public static void reinitialisieren(){ + h00=false; + h01=false; + h02=false; + h03=false; + h04=false; + h05=false; + h06=false; + h07=false; + h08=false; + h09=false; + } +} diff --git a/HeatUp/src/de/heatup/ui/actionPanel/Keysequence.java b/HeatUp/src/de/heatup/ui/actionPanel/Keysequence.java new file mode 100644 index 0000000..c6b890b --- /dev/null +++ b/HeatUp/src/de/heatup/ui/actionPanel/Keysequence.java @@ -0,0 +1,35 @@ +package de.heatup.ui.actionPanel; + +import java.util.Random; + +public class Keysequence { + private int length =8; + private char[] key_sq; + private Random rdm; + public Keysequence(){ + rdm = new Random(); + key_sq=new char[length]; + } + public int getLength(){ + return length; + } + protected char[] getKeySequence(){ + for(int i=0;i