mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 11:29: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();
|
kb.checkKeyActivity();
|
||||||
ActionWatcher.tick();
|
ActionWatcher.tick();
|
||||||
|
ActionControl.actionControl();
|
||||||
player01.tick();
|
player01.tick();
|
||||||
opponent01.tick();
|
opponent01.tick();
|
||||||
opponent02.tick();
|
opponent02.tick();
|
||||||
|
|||||||
@@ -5,9 +5,12 @@ import java.awt.event.KeyEvent;
|
|||||||
|
|
||||||
import sun.awt.resources.awt;
|
import sun.awt.resources.awt;
|
||||||
import de.heatup.mapengine.CollisionHandler;
|
import de.heatup.mapengine.CollisionHandler;
|
||||||
|
import de.heatup.mapengine.MapGrid;
|
||||||
import de.heatup.testing.GameLoopD;
|
import de.heatup.testing.GameLoopD;
|
||||||
import de.heatup.testing.Player;
|
import de.heatup.testing.Player;
|
||||||
|
import de.heatup.ui.actionPanel.ActionControl;
|
||||||
import de.heatup.ui.actionPanel.ActionWatcher;
|
import de.heatup.ui.actionPanel.ActionWatcher;
|
||||||
|
import de.heatup.ui.actionPanel.HardewareManipulate;
|
||||||
|
|
||||||
public class KeyBindings extends KeyAdapter {
|
public class KeyBindings extends KeyAdapter {
|
||||||
|
|
||||||
@@ -64,7 +67,50 @@ public class KeyBindings extends KeyAdapter {
|
|||||||
esc = true;
|
esc = true;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_A:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,29 @@
|
|||||||
package de.heatup.ui.actionPanel;
|
package de.heatup.ui.actionPanel;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.event.KeyAdapter;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.LineBorder;
|
import javax.swing.border.LineBorder;
|
||||||
|
|
||||||
import de.heatup.testing.Player;
|
import de.heatup.mapengine.MapGrid;
|
||||||
|
import de.heatup.testing.GameLoopD;
|
||||||
|
|
||||||
public class ActionControl{
|
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 Smashing smashing;
|
||||||
private static Keysequence keysequence;
|
private static Keysequence keysequence;
|
||||||
private static JPanel panel;
|
private static JPanel panel;
|
||||||
private static boolean smash=false;
|
|
||||||
private static char chr;
|
|
||||||
private static int count=0;
|
|
||||||
protected static JLabel actionLabel;
|
protected static JLabel actionLabel;
|
||||||
|
|
||||||
public static void setPanel(JPanel newPanel){
|
public static void setPanel(JPanel newPanel){
|
||||||
@@ -32,22 +38,75 @@ public class ActionControl{
|
|||||||
wishPanel();
|
wishPanel();
|
||||||
}
|
}
|
||||||
public static void setAction(int rd){
|
public static void setAction(int rd){
|
||||||
if(rd==1){
|
if(true){
|
||||||
|
option=true;
|
||||||
setSmash(smashing.getKey());
|
setSmash(smashing.getKey());
|
||||||
String str= "Bitte die Taste "+getSmash()+" so schnell wie moeglich druecken";
|
String str= "Bitte die Taste "+getSmash()+" so schnell wie moeglich druecken";
|
||||||
actionLabel.setText(str);
|
actionLabel.setText(str);
|
||||||
}else{
|
/*}else{
|
||||||
char []tmp = keysequence.getKeySequence();
|
option=false;
|
||||||
String str="Bitte diese Tastenkombination \""+tmp[0]+" "+tmp[1]+" "+tmp[2]+" "+tmp[3]+"\" "+"so schnell wie moeglich eingeben";
|
setSequence(keysequence.getKeySequence());
|
||||||
actionLabel.setText(str);
|
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){
|
private static void setSmash(char c){
|
||||||
chr=c;
|
chr=c;
|
||||||
}
|
}
|
||||||
private static char getSmash(){
|
private static void setSequence(char c[]){
|
||||||
|
arr=c;
|
||||||
|
}
|
||||||
|
public static char getSmash(){
|
||||||
return chr;
|
return chr;
|
||||||
}
|
}
|
||||||
|
private static char[] getSequence(){
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
public static void wishPanel(){
|
public static void wishPanel(){
|
||||||
actionLabel.setText("");
|
actionLabel.setText("");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,24 +13,38 @@ import de.heatup.mapengine.MapGridCell;
|
|||||||
import de.heatup.testing.GameLoopD;
|
import de.heatup.testing.GameLoopD;
|
||||||
|
|
||||||
public class ActionWatcher{
|
public class ActionWatcher{
|
||||||
public static boolean action =false;
|
private static boolean action = false;
|
||||||
public static boolean setaction =false;
|
private static boolean setaction = false;
|
||||||
private static Random rdm =new Random();
|
private static Random rdm = new Random();
|
||||||
|
|
||||||
public static void tick(){
|
public static void setAction(boolean b){
|
||||||
if(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && !action){
|
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");
|
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){
|
if(!MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && !action && !setaction){
|
||||||
ActionControl.wishPanel();
|
ActionControl.wishPanel();
|
||||||
}
|
}
|
||||||
|
//Nach dem man A gedrueckt hat kommt entweder Smashing oder Keysequence Text.
|
||||||
if(action&&!setaction){
|
if(action&&!setaction){
|
||||||
setaction = !setaction;
|
setaction = !setaction;
|
||||||
ActionControl.actionLabel.setText("");
|
ActionControl.actionLabel.setText("");
|
||||||
ActionControl.setAction(rdm.nextInt(2)+1);
|
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){
|
if(!MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && setaction){
|
||||||
ActionControl.wishPanel();
|
ActionControl.wishPanel();
|
||||||
|
ActionControl.count=0;
|
||||||
|
ActionControl.time=true;
|
||||||
|
ActionControl.beforeTime=0;
|
||||||
setaction = !setaction;
|
setaction = !setaction;
|
||||||
action = !action;
|
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;
|
import java.util.Random;
|
||||||
|
|
||||||
public class Keysequence {
|
public class Keysequence {
|
||||||
char[] key_sq;
|
private int length =8;
|
||||||
Random rdm;
|
private char[] key_sq;
|
||||||
|
private Random rdm;
|
||||||
public Keysequence(){
|
public Keysequence(){
|
||||||
rdm = new Random();
|
rdm = new Random();
|
||||||
key_sq=new char[4];
|
key_sq=new char[length];
|
||||||
}
|
}
|
||||||
|
public int getLength(){
|
||||||
public char[] getKeySequence(){
|
return length;
|
||||||
for(int i=0;i<4;i++){
|
}
|
||||||
|
protected char[] getKeySequence(){
|
||||||
|
for(int i=0;i<length;i++){
|
||||||
switch(rdm.nextInt(4)+1){
|
switch(rdm.nextInt(4)+1){
|
||||||
case 1:
|
case 1:
|
||||||
key_sq[i]='Q';
|
key_sq[i]='Q';
|
||||||
|
|||||||
Reference in New Issue
Block a user