mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 11:39:45 +02:00
Weitere Anpassungen an ActionControl
This commit is contained in:
@@ -260,6 +260,7 @@ public class GameLoopD extends JFrame implements Runnable {
|
|||||||
if (!pause) {
|
if (!pause) {
|
||||||
ActionWatcher.tick();
|
ActionWatcher.tick();
|
||||||
ActionControl.tick();
|
ActionControl.tick();
|
||||||
|
if(ActionControl.getTickTimer())ActionControl.tickTimer();
|
||||||
HardwareResetTimers.tick();
|
HardwareResetTimers.tick();
|
||||||
player01.tick();
|
player01.tick();
|
||||||
opponent01.tick();
|
opponent01.tick();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class HardwareResetTimers {
|
|||||||
if (HardwareResetTickstamps.get(i).equals(tickCount)) {
|
if (HardwareResetTickstamps.get(i).equals(tickCount)) {
|
||||||
Logger.write("Hardware "+i+" reset");
|
Logger.write("Hardware "+i+" reset");
|
||||||
HardewareManipulate.resetHardware(i);
|
HardewareManipulate.resetHardware(i);
|
||||||
StatusPanelAdder.reduceMod();
|
//StatusPanelAdder.reduceMod();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,6 +41,6 @@ public class HardwareResetTimers {
|
|||||||
resetTimestamp = resetTimestamp % tickRoundMax;
|
resetTimestamp = resetTimestamp % tickRoundMax;
|
||||||
}
|
}
|
||||||
HardwareResetTickstamps.put(c, resetTimestamp);
|
HardwareResetTickstamps.put(c, resetTimestamp);
|
||||||
StatusPanelAdder.raiseMod();
|
//StatusPanelAdder.raiseMod();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class KeyBindings extends KeyAdapter {
|
|||||||
private boolean up = false;
|
private boolean up = false;
|
||||||
private boolean down = false;
|
private boolean down = false;
|
||||||
private boolean esc = false;
|
private boolean esc = false;
|
||||||
|
private boolean key = false;
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
||||||
public KeyBindings(Player player) {
|
public KeyBindings(Player player) {
|
||||||
@@ -44,6 +45,18 @@ public class KeyBindings extends KeyAdapter {
|
|||||||
case KeyEvent.VK_ESCAPE:
|
case KeyEvent.VK_ESCAPE:
|
||||||
esc = false;
|
esc = false;
|
||||||
break;
|
break;
|
||||||
|
case KeyEvent.VK_Q:
|
||||||
|
key = false;
|
||||||
|
break;
|
||||||
|
case KeyEvent.VK_W:
|
||||||
|
key = false;
|
||||||
|
break;
|
||||||
|
case KeyEvent.VK_E:
|
||||||
|
key = false;
|
||||||
|
break;
|
||||||
|
case KeyEvent.VK_R:
|
||||||
|
key = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,9 +86,11 @@ public class KeyBindings extends KeyAdapter {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_Q:
|
case KeyEvent.VK_Q:
|
||||||
if(ActionWatcher.getAction()){
|
if(ActionWatcher.getAction()&&!key){
|
||||||
if(ActionControl.getOption()==1){
|
if(ActionControl.getOption()==1){
|
||||||
if(ActionControl.getSmash()=='Q')ActionControl.incCount();
|
if(ActionControl.getSmash()=='Q'){
|
||||||
|
ActionControl.getBar().setValue(ActionControl.getBar().getValue()+7);
|
||||||
|
}
|
||||||
}else if(!ActionControl.getKeySequenceFail()){
|
}else if(!ActionControl.getKeySequenceFail()){
|
||||||
if(ActionControl.getSequence()[ActionControl.getCount()]=='Q'){
|
if(ActionControl.getSequence()[ActionControl.getCount()]=='Q'){
|
||||||
ActionControl.incCount();
|
ActionControl.incCount();
|
||||||
@@ -85,12 +100,15 @@ public class KeyBindings extends KeyAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
key=true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_W:
|
case KeyEvent.VK_W:
|
||||||
if(ActionWatcher.getAction()){
|
if(ActionWatcher.getAction()&&!key){
|
||||||
if(ActionControl.getOption()==1){
|
if(ActionControl.getOption()==1){
|
||||||
if(ActionControl.getSmash()=='W')ActionControl.incCount();
|
if(ActionControl.getSmash()=='W'){;
|
||||||
|
ActionControl.getBar().setValue(ActionControl.getBar().getValue()+7);
|
||||||
|
}
|
||||||
}else if(!ActionControl.getKeySequenceFail()){
|
}else if(!ActionControl.getKeySequenceFail()){
|
||||||
if(ActionControl.getSequence()[ActionControl.getCount()]=='W'){
|
if(ActionControl.getSequence()[ActionControl.getCount()]=='W'){
|
||||||
ActionControl.incCount();
|
ActionControl.incCount();
|
||||||
@@ -99,12 +117,15 @@ public class KeyBindings extends KeyAdapter {
|
|||||||
ActionControl.setKeySequenceFail();
|
ActionControl.setKeySequenceFail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
key=true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_E:
|
case KeyEvent.VK_E:
|
||||||
if(ActionWatcher.getAction()){
|
if(ActionWatcher.getAction()&&!key){
|
||||||
if(ActionControl.getOption()==1){
|
if(ActionControl.getOption()==1){
|
||||||
if(ActionControl.getSmash()=='E')ActionControl.incCount();
|
if(ActionControl.getSmash()=='E'){
|
||||||
|
ActionControl.getBar().setValue(ActionControl.getBar().getValue()+7);
|
||||||
|
}
|
||||||
}else if(!ActionControl.getKeySequenceFail()){
|
}else if(!ActionControl.getKeySequenceFail()){
|
||||||
if(ActionControl.getSequence()[ActionControl.getCount()]=='E'){
|
if(ActionControl.getSequence()[ActionControl.getCount()]=='E'){
|
||||||
ActionControl.incCount();
|
ActionControl.incCount();
|
||||||
@@ -113,12 +134,15 @@ public class KeyBindings extends KeyAdapter {
|
|||||||
ActionControl.setKeySequenceFail();
|
ActionControl.setKeySequenceFail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
key=true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_R:
|
case KeyEvent.VK_R:
|
||||||
if(ActionWatcher.getAction()){
|
if(ActionWatcher.getAction()&&!key){
|
||||||
if(ActionControl.getOption()==1){
|
if(ActionControl.getOption()==1){
|
||||||
if(ActionControl.getSmash()=='R')ActionControl.incCount();
|
if(ActionControl.getSmash()=='R'){
|
||||||
|
ActionControl.getBar().setValue(ActionControl.getBar().getValue()+7);
|
||||||
|
}
|
||||||
}else if(!ActionControl.getKeySequenceFail()){
|
}else if(!ActionControl.getKeySequenceFail()){
|
||||||
if(ActionControl.getSequence()[ActionControl.getCount()]=='R'){
|
if(ActionControl.getSequence()[ActionControl.getCount()]=='R'){
|
||||||
ActionControl.incCount();
|
ActionControl.incCount();
|
||||||
@@ -127,6 +151,7 @@ public class KeyBindings extends KeyAdapter {
|
|||||||
ActionControl.setKeySequenceFail();
|
ActionControl.setKeySequenceFail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
key=true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,14 @@ 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 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[];
|
||||||
@@ -22,6 +24,7 @@ public class ActionControl{
|
|||||||
private static JProgressBar bar;
|
private static JProgressBar bar;
|
||||||
private static JLabel actionLabel;
|
private static JLabel actionLabel;
|
||||||
private static JLabel bigActionLabel;
|
private static JLabel bigActionLabel;
|
||||||
|
private static int tmpCount=0;
|
||||||
|
|
||||||
public static void setPanel(JPanel newPanel){
|
public static void setPanel(JPanel newPanel){
|
||||||
panel = newPanel;
|
panel = newPanel;
|
||||||
@@ -50,11 +53,7 @@ public class ActionControl{
|
|||||||
}else{
|
}else{
|
||||||
option=2;
|
option=2;
|
||||||
setSequence(new Keysequence().getKeySequence());
|
setSequence(new Keysequence().getKeySequence());
|
||||||
String str="Bitte diese Tastenkombination \"";
|
String str="Bitte diese Tastenkombination so schnell wie moeglich eingeben";
|
||||||
for(int i=0;i<arr.length;i++){
|
|
||||||
str=str+getSequence()[i]+" ";
|
|
||||||
}
|
|
||||||
str=str + "\" "+"so schnell wie moeglich eingeben";
|
|
||||||
actionLabel.setText(str);
|
actionLabel.setText(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,15 +61,15 @@ public class ActionControl{
|
|||||||
if(ActionWatcher.getAction()){
|
if(ActionWatcher.getAction()){
|
||||||
//Smashing-Tick
|
//Smashing-Tick
|
||||||
if(option==1){
|
if(option==1){
|
||||||
bar.setValue(0);
|
setTickTimer();
|
||||||
bar.setVisible(true);
|
if(bar.getValue()<100){
|
||||||
if(count<50){
|
|
||||||
if(time){
|
if(time){
|
||||||
|
setProgressBar(0);
|
||||||
time = false;
|
time = false;
|
||||||
beforTime=System.nanoTime();
|
beforTime=System.nanoTime();
|
||||||
}
|
}
|
||||||
bar.setValue((int)(count*2));
|
|
||||||
}else{
|
}else{
|
||||||
|
tmpCount=0;
|
||||||
bar.setVisible(false);
|
bar.setVisible(false);
|
||||||
ActionWatcher.setAction(false);
|
ActionWatcher.setAction(false);
|
||||||
if(System.nanoTime()-beforTime>8_000_000_000L){
|
if(System.nanoTime()-beforTime>8_000_000_000L){
|
||||||
@@ -82,25 +81,28 @@ public class ActionControl{
|
|||||||
}
|
}
|
||||||
//KeySequence-Tick
|
//KeySequence-Tick
|
||||||
}else{
|
}else{
|
||||||
|
if(!getTickTimer()){
|
||||||
|
setTickTimer();
|
||||||
|
setProgressBar(100);
|
||||||
|
}
|
||||||
if(!getKeySequenceFail()){
|
if(!getKeySequenceFail()){
|
||||||
if(count<arr.length){
|
if(count<arr.length&&bar.getValue()>0){
|
||||||
bigActionLabel.setVisible(true);
|
bigActionLabel.setVisible(true);
|
||||||
if(time){
|
if(time){
|
||||||
time = false;
|
time = false;
|
||||||
beforTime=System.nanoTime();
|
beforTime=System.nanoTime();
|
||||||
}else if(count!=0){
|
|
||||||
actionLabel.setText("");
|
|
||||||
String str="";
|
|
||||||
for(int i=count;i<arr.length;i++){
|
|
||||||
str=str+getSequence()[i]+" ";
|
|
||||||
}
|
|
||||||
bigActionLabel.setText(str);
|
|
||||||
}
|
}
|
||||||
|
String str="";
|
||||||
|
for(int i=count;i<arr.length;i++){
|
||||||
|
str=str+getSequence()[i]+" ";
|
||||||
|
}
|
||||||
|
bigActionLabel.setText(str);
|
||||||
}else{
|
}else{
|
||||||
|
tmpCount=0;
|
||||||
|
resetTickTimer();
|
||||||
bigActionLabel.setVisible(false);
|
bigActionLabel.setVisible(false);
|
||||||
ActionWatcher.setAction(false);
|
ActionWatcher.setAction(false);
|
||||||
if(System.nanoTime()-beforTime>7_000_000_000L){
|
if(System.nanoTime()-beforTime>7_000_000_000L || bar.getValue()<=0){
|
||||||
|
|
||||||
actionLabel.setText("Zu langsam! Fehlgeschlagen!!!");
|
actionLabel.setText("Zu langsam! Fehlgeschlagen!!!");
|
||||||
}else{
|
}else{
|
||||||
actionLabel.setText("Manipulation erfolgreich!");
|
actionLabel.setText("Manipulation erfolgreich!");
|
||||||
@@ -108,6 +110,8 @@ public class ActionControl{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
resetTickTimer();
|
||||||
|
resetProgressBar();
|
||||||
bigActionLabel.setVisible(false);
|
bigActionLabel.setVisible(false);
|
||||||
ActionWatcher.setAction(false);
|
ActionWatcher.setAction(false);
|
||||||
actionLabel.setText("Falsche Taste! Fehlgeschlagen!!!");
|
actionLabel.setText("Falsche Taste! Fehlgeschlagen!!!");
|
||||||
@@ -115,6 +119,26 @@ public class ActionControl{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void tickTimer(){
|
||||||
|
tmpCount++;
|
||||||
|
if(option==1){
|
||||||
|
if(bar.getValue()>1){
|
||||||
|
if(tmpCount%2==0)bar.setValue(bar.getValue()-1);
|
||||||
|
if(bar.getValue()<3)bar.setValue(0);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(tmpCount%3==0)bar.setValue(bar.getValue()-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static boolean getTickTimer(){
|
||||||
|
return tickTimer;
|
||||||
|
}
|
||||||
|
public static void resetTickTimer(){
|
||||||
|
tickTimer=false;
|
||||||
|
}
|
||||||
|
private static void setTickTimer(){
|
||||||
|
tickTimer=true;
|
||||||
|
}
|
||||||
public static int getOption(){
|
public static int getOption(){
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
@@ -132,9 +156,13 @@ public class ActionControl{
|
|||||||
}
|
}
|
||||||
public static void resetActionPanel(){
|
public static void resetActionPanel(){
|
||||||
bigActionLabel.setText("");
|
bigActionLabel.setText("");
|
||||||
bar.setValue(0);
|
|
||||||
bar.setVisible(false);
|
|
||||||
actionLabel.setText("");
|
actionLabel.setText("");
|
||||||
|
resetProgressBar();
|
||||||
|
resetCount();
|
||||||
|
resetTime();
|
||||||
|
resetBeforTime();
|
||||||
|
resetKeySequenceFail();
|
||||||
|
resetTickTimer();
|
||||||
}
|
}
|
||||||
public static void resetTime(){
|
public static void resetTime(){
|
||||||
time=true;
|
time=true;
|
||||||
@@ -149,6 +177,7 @@ public class ActionControl{
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
public static void resetCount(){
|
public static void resetCount(){
|
||||||
|
tmpCount=0;
|
||||||
count=0;
|
count=0;
|
||||||
}
|
}
|
||||||
public static boolean getKeySequenceFail(){
|
public static boolean getKeySequenceFail(){
|
||||||
@@ -166,4 +195,15 @@ public class ActionControl{
|
|||||||
public static void setTextforManipulate(){
|
public static void setTextforManipulate(){
|
||||||
actionLabel.setText("Bereits Manipuliert");
|
actionLabel.setText("Bereits Manipuliert");
|
||||||
}
|
}
|
||||||
|
private static void setProgressBar(int value){
|
||||||
|
bar.setValue(value);
|
||||||
|
bar.setVisible(true);
|
||||||
|
}
|
||||||
|
public static void resetProgressBar(){
|
||||||
|
bar.setValue(0);
|
||||||
|
bar.setVisible(false);
|
||||||
|
}
|
||||||
|
public static JProgressBar getBar(){
|
||||||
|
return bar;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,10 +47,6 @@ 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.resetCount();
|
|
||||||
ActionControl.resetTime();
|
|
||||||
ActionControl.resetBeforTime();
|
|
||||||
ActionControl.resetKeySequenceFail();
|
|
||||||
infoText=false;
|
infoText=false;
|
||||||
setAction=false;
|
setAction=false;
|
||||||
action=false;
|
action=false;
|
||||||
|
|||||||
Reference in New Issue
Block a user