mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 10:19:46 +02:00
Noch mehr Anpassungen, Smashing so gut wie durch
This commit is contained in:
@@ -256,6 +256,7 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
}
|
||||
kb.checkKeyActivity();
|
||||
ActionWatcher.tick();
|
||||
ActionControl.actionControl();
|
||||
player01.tick();
|
||||
opponent01.tick();
|
||||
opponent02.tick();
|
||||
|
||||
@@ -5,9 +5,12 @@ 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 {
|
||||
|
||||
@@ -64,7 +67,50 @@ public class KeyBindings extends KeyAdapter {
|
||||
esc = true;
|
||||
break;
|
||||
case KeyEvent.VK_A:
|
||||
ActionWatcher.action = true;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,29 @@
|
||||
package de.heatup.ui.actionPanel;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import de.heatup.testing.Player;
|
||||
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;
|
||||
private static boolean smash=false;
|
||||
private static char chr;
|
||||
private static int count=0;
|
||||
protected static JLabel actionLabel;
|
||||
|
||||
public static void setPanel(JPanel newPanel){
|
||||
@@ -32,22 +38,75 @@ public class ActionControl{
|
||||
wishPanel();
|
||||
}
|
||||
public static void setAction(int rd){
|
||||
if(rd==1){
|
||||
if(true){
|
||||
option=true;
|
||||
setSmash(smashing.getKey());
|
||||
String str= "Bitte die Taste "+getSmash()+" so schnell wie moeglich druecken";
|
||||
actionLabel.setText(str);
|
||||
}else{
|
||||
char []tmp = keysequence.getKeySequence();
|
||||
String str="Bitte diese Tastenkombination \""+tmp[0]+" "+tmp[1]+" "+tmp[2]+" "+tmp[3]+"\" "+"so schnell wie moeglich eingeben";
|
||||
actionLabel.setText(str);
|
||||
/*}else{
|
||||
option=false;
|
||||
setSequence(keysequence.getKeySequence());
|
||||
String str="Bitte diese Tastenkombination \"";
|
||||
for(int i=0;i<keysequence.getLength();i++){
|
||||
str=str+getSequence()[i]+" ";
|
||||
}
|
||||
str=str + "\" "+"so schnell wie moeglich eingeben";
|
||||
actionLabel.setText(str);*/
|
||||
}
|
||||
}
|
||||
public static void actionControl(){
|
||||
if(ActionWatcher.getAction()){
|
||||
if(option){
|
||||
if(count<30){
|
||||
if(time){
|
||||
time = !time;
|
||||
beforeTime=System.nanoTime();
|
||||
}
|
||||
}else{
|
||||
afterTime=System.nanoTime()-beforeTime;
|
||||
count=0;
|
||||
time=!time;
|
||||
ActionWatcher.setAction(false);
|
||||
if(afterTime>8_000_000_000L){
|
||||
actionLabel.setText("Fehlgeschlagen");
|
||||
}else{
|
||||
actionLabel.setText("Manipulation erfolgreich!");
|
||||
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 char getSmash(){
|
||||
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("");
|
||||
}
|
||||
|
||||
@@ -13,24 +13,38 @@ import de.heatup.mapengine.MapGridCell;
|
||||
import de.heatup.testing.GameLoopD;
|
||||
|
||||
public class ActionWatcher{
|
||||
public static boolean action =false;
|
||||
public static boolean setaction =false;
|
||||
private static Random rdm =new Random();
|
||||
private static boolean action = false;
|
||||
private static boolean setaction = false;
|
||||
private static Random rdm = new Random();
|
||||
|
||||
public static void tick(){
|
||||
if(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && !action){
|
||||
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
|
||||
&& !HardewareManipulate.getHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger())){
|
||||
ActionControl.actionLabel.setText("Taste A druecken");
|
||||
}
|
||||
//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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package de.heatup.ui.actionPanel;
|
||||
|
||||
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;
|
||||
break;
|
||||
case '1':
|
||||
h01=true;
|
||||
break;
|
||||
case '2':
|
||||
h02=true;
|
||||
break;
|
||||
case '3':
|
||||
h03=true;
|
||||
break;
|
||||
case '4':
|
||||
h04=true;
|
||||
break;
|
||||
case '5':
|
||||
h05=true;
|
||||
break;
|
||||
case '6':
|
||||
h06=true;
|
||||
break;
|
||||
case '7':
|
||||
h07=true;
|
||||
break;
|
||||
case '8':
|
||||
h08=true;
|
||||
break;
|
||||
case '9':
|
||||
h09=true;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,18 @@ package de.heatup.ui.actionPanel;
|
||||
import java.util.Random;
|
||||
|
||||
public class Keysequence {
|
||||
char[] key_sq;
|
||||
Random rdm;
|
||||
private int length =8;
|
||||
private char[] key_sq;
|
||||
private Random rdm;
|
||||
public Keysequence(){
|
||||
rdm = new Random();
|
||||
key_sq=new char[4];
|
||||
key_sq=new char[length];
|
||||
}
|
||||
|
||||
public char[] getKeySequence(){
|
||||
for(int i=0;i<4;i++){
|
||||
public int getLength(){
|
||||
return length;
|
||||
}
|
||||
protected char[] getKeySequence(){
|
||||
for(int i=0;i<length;i++){
|
||||
switch(rdm.nextInt(4)+1){
|
||||
case 1:
|
||||
key_sq[i]='Q';
|
||||
|
||||
Reference in New Issue
Block a user