mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 09:59:45 +02:00
Noch mehr Anpassungen
This commit is contained in:
@@ -13,7 +13,7 @@ import de.heatup.ui.actionPanel.ActionWatcher;
|
|||||||
import de.heatup.ui.actionPanel.HardewareManipulate;
|
import de.heatup.ui.actionPanel.HardewareManipulate;
|
||||||
|
|
||||||
public class KeyBindings extends KeyAdapter {
|
public class KeyBindings extends KeyAdapter {
|
||||||
|
final private static int progressBarTimer = 7;
|
||||||
private boolean left = false;
|
private boolean left = false;
|
||||||
private boolean right = false;
|
private boolean right = false;
|
||||||
private boolean up = false;
|
private boolean up = false;
|
||||||
@@ -45,6 +45,9 @@ public class KeyBindings extends KeyAdapter {
|
|||||||
case KeyEvent.VK_ESCAPE:
|
case KeyEvent.VK_ESCAPE:
|
||||||
esc = false;
|
esc = false;
|
||||||
break;
|
break;
|
||||||
|
case KeyEvent.VK_A:
|
||||||
|
key = false;
|
||||||
|
break;
|
||||||
case KeyEvent.VK_Q:
|
case KeyEvent.VK_Q:
|
||||||
key = false;
|
key = false;
|
||||||
break;
|
break;
|
||||||
@@ -80,22 +83,22 @@ public class KeyBindings extends KeyAdapter {
|
|||||||
esc = true;
|
esc = true;
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_A:
|
case KeyEvent.VK_A:
|
||||||
if(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger()
|
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())){
|
&& !HardewareManipulate.getHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger()))&&!key)&&ActionControl.getKeyA()){
|
||||||
ActionWatcher.setAction(true);
|
ActionWatcher.setAction(true);
|
||||||
|
key=true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_Q:
|
case KeyEvent.VK_Q:
|
||||||
if(ActionWatcher.getAction()&&!key){
|
if(ActionWatcher.getAction()&&!key){
|
||||||
if(ActionControl.getOption()==1){
|
if(ActionControl.getOption()==1){
|
||||||
if(ActionControl.getSmash()=='Q'){
|
if(ActionControl.getSmash()=='Q'){
|
||||||
ActionControl.getBar().setValue(ActionControl.getBar().getValue()+7);
|
ActionControl.setProgressBarTimer(progressBarTimer);
|
||||||
}
|
}
|
||||||
}else if(!ActionControl.getKeySequenceFail()){
|
}else if(!ActionControl.getKeySequenceFail()){
|
||||||
if(ActionControl.getSequence()[ActionControl.getCount()]=='Q'){
|
if(ActionControl.getSequence()[ActionControl.getCount()]=='Q'){
|
||||||
ActionControl.incCount();
|
ActionControl.incCount();
|
||||||
}else{
|
}else{
|
||||||
ActionControl.resetCount();
|
|
||||||
ActionControl.setKeySequenceFail();
|
ActionControl.setKeySequenceFail();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,13 +110,12 @@ public class KeyBindings extends KeyAdapter {
|
|||||||
if(ActionWatcher.getAction()&&!key){
|
if(ActionWatcher.getAction()&&!key){
|
||||||
if(ActionControl.getOption()==1){
|
if(ActionControl.getOption()==1){
|
||||||
if(ActionControl.getSmash()=='W'){;
|
if(ActionControl.getSmash()=='W'){;
|
||||||
ActionControl.getBar().setValue(ActionControl.getBar().getValue()+7);
|
ActionControl.setProgressBarTimer(progressBarTimer);
|
||||||
}
|
}
|
||||||
}else if(!ActionControl.getKeySequenceFail()){
|
}else if(!ActionControl.getKeySequenceFail()){
|
||||||
if(ActionControl.getSequence()[ActionControl.getCount()]=='W'){
|
if(ActionControl.getSequence()[ActionControl.getCount()]=='W'){
|
||||||
ActionControl.incCount();
|
ActionControl.incCount();
|
||||||
}else{
|
}else{
|
||||||
ActionControl.resetCount();
|
|
||||||
ActionControl.setKeySequenceFail();
|
ActionControl.setKeySequenceFail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,13 +126,12 @@ public class KeyBindings extends KeyAdapter {
|
|||||||
if(ActionWatcher.getAction()&&!key){
|
if(ActionWatcher.getAction()&&!key){
|
||||||
if(ActionControl.getOption()==1){
|
if(ActionControl.getOption()==1){
|
||||||
if(ActionControl.getSmash()=='E'){
|
if(ActionControl.getSmash()=='E'){
|
||||||
ActionControl.getBar().setValue(ActionControl.getBar().getValue()+7);
|
ActionControl.setProgressBarTimer(progressBarTimer);
|
||||||
}
|
}
|
||||||
}else if(!ActionControl.getKeySequenceFail()){
|
}else if(!ActionControl.getKeySequenceFail()){
|
||||||
if(ActionControl.getSequence()[ActionControl.getCount()]=='E'){
|
if(ActionControl.getSequence()[ActionControl.getCount()]=='E'){
|
||||||
ActionControl.incCount();
|
ActionControl.incCount();
|
||||||
}else{
|
}else{
|
||||||
ActionControl.resetCount();
|
|
||||||
ActionControl.setKeySequenceFail();
|
ActionControl.setKeySequenceFail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,13 +142,12 @@ public class KeyBindings extends KeyAdapter {
|
|||||||
if(ActionWatcher.getAction()&&!key){
|
if(ActionWatcher.getAction()&&!key){
|
||||||
if(ActionControl.getOption()==1){
|
if(ActionControl.getOption()==1){
|
||||||
if(ActionControl.getSmash()=='R'){
|
if(ActionControl.getSmash()=='R'){
|
||||||
ActionControl.getBar().setValue(ActionControl.getBar().getValue()+7);
|
ActionControl.setProgressBarTimer(progressBarTimer);
|
||||||
}
|
}
|
||||||
}else if(!ActionControl.getKeySequenceFail()){
|
}else if(!ActionControl.getKeySequenceFail()){
|
||||||
if(ActionControl.getSequence()[ActionControl.getCount()]=='R'){
|
if(ActionControl.getSequence()[ActionControl.getCount()]=='R'){
|
||||||
ActionControl.incCount();
|
ActionControl.incCount();
|
||||||
}else{
|
}else{
|
||||||
ActionControl.resetCount();
|
|
||||||
ActionControl.setKeySequenceFail();
|
ActionControl.setKeySequenceFail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,18 +5,14 @@ import java.awt.Color;
|
|||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.LineBorder;
|
|
||||||
|
|
||||||
import de.heatup.mapengine.MapGrid;
|
import de.heatup.mapengine.MapGrid;
|
||||||
import de.heatup.testing.GameLoopD;
|
import de.heatup.testing.GameLoopD;
|
||||||
import de.heatup.ui.StatusPanelAdder;
|
|
||||||
|
|
||||||
public class ActionControl{
|
public class ActionControl{
|
||||||
private static int count = 0;
|
private static int count = 0;
|
||||||
private static long beforTime = 0;
|
private static long beforTime = 0;
|
||||||
private static boolean time = true;
|
|
||||||
private static boolean keySequenceFail=false;
|
private static boolean keySequenceFail=false;
|
||||||
private static boolean tickTimer =false;
|
|
||||||
private static int option=0;
|
private static int option=0;
|
||||||
private static char chr;
|
private static char chr;
|
||||||
private static char arr[];
|
private static char arr[];
|
||||||
@@ -25,6 +21,7 @@ public class ActionControl{
|
|||||||
private static JLabel actionLabel;
|
private static JLabel actionLabel;
|
||||||
private static JLabel bigActionLabel;
|
private static JLabel bigActionLabel;
|
||||||
private static int tmpCount=0;
|
private static int tmpCount=0;
|
||||||
|
private static boolean keyA=true;
|
||||||
|
|
||||||
public static void setPanel(JPanel newPanel){
|
public static void setPanel(JPanel newPanel){
|
||||||
panel = newPanel;
|
panel = newPanel;
|
||||||
@@ -45,81 +42,57 @@ public class ActionControl{
|
|||||||
resetActionPanel();
|
resetActionPanel();
|
||||||
}
|
}
|
||||||
public static void setAction(int rd){
|
public static void setAction(int rd){
|
||||||
|
setKeyA();
|
||||||
if(rd==1){
|
if(rd==1){
|
||||||
option=1;
|
option=1;
|
||||||
setSmash(new Smashing().getKey());
|
setSmash(new 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);
|
||||||
|
setProgressBar(0);
|
||||||
|
beforTime=System.nanoTime();
|
||||||
}else{
|
}else{
|
||||||
option=2;
|
option=2;
|
||||||
setSequence(new Keysequence().getKeySequence());
|
setSequence(new Keysequence().getKeySequence());
|
||||||
String str="Bitte diese Tastenkombination so schnell wie moeglich eingeben";
|
String str="Bitte diese Tastenkombination so schnell wie moeglich eingeben";
|
||||||
actionLabel.setText(str);
|
actionLabel.setText(str);
|
||||||
|
setProgressBar(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void tick(){
|
public static void tick(){
|
||||||
if(ActionWatcher.getAction()){
|
if(ActionWatcher.getAction()){
|
||||||
//Smashing-Tick
|
if(option==1){ //Smashing-Tick
|
||||||
if(option==1){
|
if(bar.getValue()>=100){
|
||||||
setTickTimer();
|
setAchiv(8_000_000_000L, System.nanoTime()-beforTime);
|
||||||
if(bar.getValue()<100){
|
|
||||||
if(time){
|
|
||||||
setProgressBar(0);
|
|
||||||
time = false;
|
|
||||||
beforTime=System.nanoTime();
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
tmpCount=0;
|
|
||||||
bar.setVisible(false);
|
|
||||||
ActionWatcher.setAction(false);
|
|
||||||
if(System.nanoTime()-beforTime>8_000_000_000L){
|
|
||||||
actionLabel.setText("Zu langsam! Fehlgeschlagen!!!");
|
|
||||||
}else{
|
|
||||||
actionLabel.setText("Manipulation erfolgreich!");
|
|
||||||
HardewareManipulate.setHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//KeySequence-Tick
|
|
||||||
}else{
|
|
||||||
if(!getTickTimer()){
|
|
||||||
setTickTimer();
|
|
||||||
setProgressBar(100);
|
|
||||||
}
|
}
|
||||||
|
}else{ //KeySequence-Tick
|
||||||
if(!getKeySequenceFail()){
|
if(!getKeySequenceFail()){
|
||||||
if(count<arr.length&&bar.getValue()>0){
|
if(count<arr.length&&bar.getValue()>0){
|
||||||
bigActionLabel.setVisible(true);
|
bigActionLabel.setVisible(true);
|
||||||
if(time){
|
|
||||||
time = false;
|
|
||||||
beforTime=System.nanoTime();
|
|
||||||
}
|
|
||||||
String str="";
|
String str="";
|
||||||
for(int i=count;i<arr.length;i++){
|
for(int i=count;i<arr.length;i++){
|
||||||
str=str+getSequence()[i]+" ";
|
str=str+getSequence()[i]+" ";
|
||||||
}
|
}
|
||||||
bigActionLabel.setText(str);
|
bigActionLabel.setText(str);
|
||||||
}else{
|
}else{
|
||||||
tmpCount=0;
|
setAchiv(bar.getValue(),0);
|
||||||
resetTickTimer();
|
|
||||||
bigActionLabel.setVisible(false);
|
|
||||||
ActionWatcher.setAction(false);
|
|
||||||
if(System.nanoTime()-beforTime>7_000_000_000L || bar.getValue()<=0){
|
|
||||||
actionLabel.setText("Zu langsam! Fehlgeschlagen!!!");
|
|
||||||
}else{
|
|
||||||
actionLabel.setText("Manipulation erfolgreich!");
|
|
||||||
HardewareManipulate.setHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
resetTickTimer();
|
setAchiv();
|
||||||
resetProgressBar();
|
|
||||||
bigActionLabel.setVisible(false);
|
|
||||||
ActionWatcher.setAction(false);
|
|
||||||
actionLabel.setText("Falsche Taste! Fehlgeschlagen!!!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tickProgressBar(); //ProgressBar-Tick
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void tickTimer(){
|
public static boolean getKeyA(){
|
||||||
|
return keyA;
|
||||||
|
}
|
||||||
|
private static void setKeyA(){
|
||||||
|
keyA=false;
|
||||||
|
}
|
||||||
|
public static void resetKeyA(){
|
||||||
|
keyA=true;
|
||||||
|
}
|
||||||
|
private static void tickProgressBar(){
|
||||||
tmpCount++;
|
tmpCount++;
|
||||||
if(option==1){
|
if(option==1){
|
||||||
if(bar.getValue()>1){
|
if(bar.getValue()>1){
|
||||||
@@ -130,14 +103,21 @@ public class ActionControl{
|
|||||||
if(tmpCount%3==0)bar.setValue(bar.getValue()-1);
|
if(tmpCount%3==0)bar.setValue(bar.getValue()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static boolean getTickTimer(){
|
private static void setAchiv(double value1, double value2){
|
||||||
return tickTimer;
|
ActionWatcher.setAction(false);
|
||||||
|
if(value1<=value2){
|
||||||
|
resetActionPanel();
|
||||||
|
actionLabel.setText("Zu langsam! Fehlgeschlagen!!!");
|
||||||
|
}else{
|
||||||
|
resetActionPanel();
|
||||||
|
actionLabel.setText("Manipulation erfolgreich!");
|
||||||
|
HardewareManipulate.setHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public static void resetTickTimer(){
|
private static void setAchiv(){
|
||||||
tickTimer=false;
|
ActionWatcher.setAction(false);
|
||||||
}
|
resetActionPanel();
|
||||||
private static void setTickTimer(){
|
actionLabel.setText("Falsche Taste! Fehlgeschlagen!!!");
|
||||||
tickTimer=true;
|
|
||||||
}
|
}
|
||||||
public static int getOption(){
|
public static int getOption(){
|
||||||
return option;
|
return option;
|
||||||
@@ -155,19 +135,20 @@ public class ActionControl{
|
|||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
public static void resetActionPanel(){
|
public static void resetActionPanel(){
|
||||||
bigActionLabel.setText("");
|
resetBigActionLabel();
|
||||||
actionLabel.setText("");
|
resetActionLabel();
|
||||||
resetProgressBar();
|
resetProgressBar();
|
||||||
resetCount();
|
resetCount();
|
||||||
resetTime();
|
|
||||||
resetBeforTime();
|
resetBeforTime();
|
||||||
resetKeySequenceFail();
|
resetKeySequenceFail();
|
||||||
resetTickTimer();
|
|
||||||
}
|
}
|
||||||
public static void resetTime(){
|
private static void resetActionLabel(){
|
||||||
time=true;
|
actionLabel.setText("");
|
||||||
}
|
}
|
||||||
public static void resetBeforTime(){
|
private static void resetBigActionLabel(){
|
||||||
|
bigActionLabel.setText("");
|
||||||
|
}
|
||||||
|
private static void resetBeforTime(){
|
||||||
beforTime=0;
|
beforTime=0;
|
||||||
}
|
}
|
||||||
public static int getCount(){
|
public static int getCount(){
|
||||||
@@ -176,7 +157,7 @@ public class ActionControl{
|
|||||||
public static void incCount(){
|
public static void incCount(){
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
public static void resetCount(){
|
private static void resetCount(){
|
||||||
tmpCount=0;
|
tmpCount=0;
|
||||||
count=0;
|
count=0;
|
||||||
}
|
}
|
||||||
@@ -186,7 +167,7 @@ public class ActionControl{
|
|||||||
public static void setKeySequenceFail(){
|
public static void setKeySequenceFail(){
|
||||||
keySequenceFail=true;
|
keySequenceFail=true;
|
||||||
}
|
}
|
||||||
public static void resetKeySequenceFail(){
|
private static void resetKeySequenceFail(){
|
||||||
keySequenceFail=false;
|
keySequenceFail=false;
|
||||||
}
|
}
|
||||||
public static void setTextforA(){
|
public static void setTextforA(){
|
||||||
@@ -203,7 +184,7 @@ public class ActionControl{
|
|||||||
bar.setValue(0);
|
bar.setValue(0);
|
||||||
bar.setVisible(false);
|
bar.setVisible(false);
|
||||||
}
|
}
|
||||||
public static JProgressBar getBar(){
|
public static void setProgressBarTimer(int value){
|
||||||
return bar;
|
bar.setValue(bar.getValue()+value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,8 @@
|
|||||||
package de.heatup.ui.actionPanel;
|
package de.heatup.ui.actionPanel;
|
||||||
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.event.KeyAdapter;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import de.heatup.mapengine.MapEngine;
|
|
||||||
import de.heatup.mapengine.MapGrid;
|
import de.heatup.mapengine.MapGrid;
|
||||||
import de.heatup.mapengine.MapGridCell;
|
|
||||||
import de.heatup.testing.GameLoopD;
|
import de.heatup.testing.GameLoopD;
|
||||||
|
|
||||||
public class ActionWatcher{
|
public class ActionWatcher{
|
||||||
@@ -47,6 +40,7 @@ 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
|
//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){
|
if(!MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && setAction){
|
||||||
ActionControl.resetActionPanel();
|
ActionControl.resetActionPanel();
|
||||||
|
ActionControl.resetKeyA();
|
||||||
infoText=false;
|
infoText=false;
|
||||||
setAction=false;
|
setAction=false;
|
||||||
action=false;
|
action=false;
|
||||||
|
|||||||
Reference in New Issue
Block a user