mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 08:49:44 +02:00
Diverse Anpassungen
This commit is contained in:
@@ -259,7 +259,7 @@ public class GameLoopD extends JFrame implements Runnable {
|
||||
kb.checkKeyActivity();
|
||||
if (!pause) {
|
||||
ActionWatcher.tick();
|
||||
ActionControl.actionControl();
|
||||
ActionControl.tick();
|
||||
HardwareResetTimers.tick();
|
||||
player01.tick();
|
||||
opponent01.tick();
|
||||
|
||||
@@ -12,15 +12,12 @@ import de.heatup.testing.GameLoopD;
|
||||
|
||||
public class ActionControl{
|
||||
private static int count = 0;
|
||||
private static long afterTime = 0;
|
||||
private static long beforeTime = 0;
|
||||
private static long beforTime = 0;
|
||||
private static boolean time = true;
|
||||
private static boolean keySequenceFail=false;
|
||||
private static int option=0;
|
||||
private static char chr;
|
||||
private static char arr[];
|
||||
private static Smashing smashing;
|
||||
private static Keysequence keysequence;
|
||||
private static JPanel panel;
|
||||
private static JProgressBar bar;
|
||||
private static JLabel actionLabel;
|
||||
@@ -28,30 +25,31 @@ public class ActionControl{
|
||||
|
||||
public static void setPanel(JPanel newPanel){
|
||||
panel = newPanel;
|
||||
smashing = new Smashing();
|
||||
keysequence = new Keysequence();
|
||||
actionLabel = new JLabel();
|
||||
bigActionLabel = new JLabel();
|
||||
actionLabel.setFont(new Font("Arial", Font.CENTER_BASELINE, 16));
|
||||
bigActionLabel.setFont(new Font("Arial", Font.LAYOUT_RIGHT_TO_LEFT,40));
|
||||
bigActionLabel.setVisible(false);
|
||||
bar = new JProgressBar();
|
||||
actionLabel.setFont(new Font("Arial", Font.CENTER_BASELINE, 16));
|
||||
actionLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||
bigActionLabel.setFont(new Font("Arial", Font.LAYOUT_RIGHT_TO_LEFT,40));
|
||||
bigActionLabel.setForeground(Color.RED);
|
||||
bigActionLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||
bigActionLabel.setVisible(false);
|
||||
bar.setVisible(false);
|
||||
panel.setLayout(new BorderLayout());
|
||||
panel.add(actionLabel, BorderLayout.NORTH);
|
||||
panel.add(bar,BorderLayout.SOUTH);
|
||||
panel.add(bigActionLabel,BorderLayout.CENTER);
|
||||
wishPanel();
|
||||
resetActionPanel();
|
||||
}
|
||||
public static void setAction(int rd){
|
||||
if(rd==1){
|
||||
option=1;
|
||||
setSmash(smashing.getKey());
|
||||
setSmash(new Smashing().getKey());
|
||||
String str= "Bitte die Taste "+getSmash()+" so schnell wie moeglich druecken";
|
||||
actionLabel.setText(str);
|
||||
}else{
|
||||
option=2;
|
||||
setSequence(keysequence.getKeySequence());
|
||||
setSequence(new Keysequence().getKeySequence());
|
||||
String str="Bitte diese Tastenkombination \"";
|
||||
for(int i=0;i<arr.length;i++){
|
||||
str=str+getSequence()[i]+" ";
|
||||
@@ -60,7 +58,7 @@ public class ActionControl{
|
||||
actionLabel.setText(str);
|
||||
}
|
||||
}
|
||||
public static void actionControl(){
|
||||
public static void tick(){
|
||||
if(ActionWatcher.getAction()){
|
||||
//Smashing-Tick
|
||||
if(option==1){
|
||||
@@ -68,21 +66,17 @@ public class ActionControl{
|
||||
bar.setVisible(true);
|
||||
if(count<50){
|
||||
if(time){
|
||||
time = !time;
|
||||
beforeTime=System.nanoTime();
|
||||
time = false;
|
||||
beforTime=System.nanoTime();
|
||||
}
|
||||
bar.setValue((int)(count*2));;
|
||||
bar.setValue((int)(count*2));
|
||||
}else{
|
||||
bar.setVisible(false);
|
||||
afterTime=System.nanoTime()-beforeTime;
|
||||
if(afterTime>8_000_000_000L){
|
||||
ActionWatcher.setAction(false);
|
||||
ActionWatcher.setAction(false);
|
||||
if(System.nanoTime()-beforTime>8_000_000_000L){
|
||||
actionLabel.setText("Zu langsam! Fehlgeschlagen!!!");
|
||||
}else{
|
||||
ActionWatcher.setAction(false);
|
||||
actionLabel.setText("Manipulation erfolgreich!");
|
||||
count=0;
|
||||
time=!time;
|
||||
HardewareManipulate.setHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger());
|
||||
}
|
||||
}
|
||||
@@ -92,11 +86,11 @@ public class ActionControl{
|
||||
if(count<arr.length){
|
||||
bigActionLabel.setVisible(true);
|
||||
if(time){
|
||||
time = !time;
|
||||
beforeTime=System.nanoTime();
|
||||
time = false;
|
||||
beforTime=System.nanoTime();
|
||||
}else if(count!=0){
|
||||
actionLabel.setText("");
|
||||
String str=" ";
|
||||
String str="";
|
||||
for(int i=count;i<arr.length;i++){
|
||||
str=str+getSequence()[i]+" ";
|
||||
}
|
||||
@@ -104,15 +98,12 @@ public class ActionControl{
|
||||
}
|
||||
}else{
|
||||
bigActionLabel.setVisible(false);
|
||||
afterTime=System.nanoTime()-beforeTime;
|
||||
if(afterTime>7_000_000_000L){
|
||||
ActionWatcher.setAction(false);
|
||||
ActionWatcher.setAction(false);
|
||||
if(System.nanoTime()-beforTime>7_000_000_000L){
|
||||
|
||||
actionLabel.setText("Zu langsam! Fehlgeschlagen!!!");
|
||||
}else{
|
||||
ActionWatcher.setAction(false);
|
||||
actionLabel.setText("Manipulation erfolgreich!");
|
||||
count=0;
|
||||
time=!time;
|
||||
HardewareManipulate.setHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger());
|
||||
}
|
||||
}
|
||||
@@ -139,7 +130,7 @@ public class ActionControl{
|
||||
public static char[] getSequence(){
|
||||
return arr;
|
||||
}
|
||||
public static void wishPanel(){
|
||||
public static void resetActionPanel(){
|
||||
bigActionLabel.setText("");
|
||||
bar.setValue(0);
|
||||
bar.setVisible(false);
|
||||
@@ -148,8 +139,8 @@ public class ActionControl{
|
||||
public static void resetTime(){
|
||||
time=true;
|
||||
}
|
||||
public static void resetBeforeTime(){
|
||||
beforeTime=0;
|
||||
public static void resetBeforTime(){
|
||||
beforTime=0;
|
||||
}
|
||||
public static int getCount(){
|
||||
return count;
|
||||
|
||||
@@ -14,9 +14,8 @@ import de.heatup.testing.GameLoopD;
|
||||
|
||||
public class ActionWatcher{
|
||||
private static boolean action = false;
|
||||
private static boolean setaction = false;
|
||||
private static boolean setAction = false;
|
||||
private static boolean infoText =false;
|
||||
private static Random rdm = new Random();
|
||||
|
||||
public static void setAction(boolean b){
|
||||
action = b;
|
||||
@@ -25,35 +24,35 @@ public class ActionWatcher{
|
||||
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){
|
||||
//Infotext, wenn man in der nähe von einem Hardwareteil steht
|
||||
if(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && !action && !setAction){
|
||||
infoText=true;
|
||||
if(!HardewareManipulate.getHardware(MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).getCorrespondingHardwareToTrigger())){
|
||||
ActionControl.setTextforA();;
|
||||
ActionControl.setTextforA();
|
||||
}else{
|
||||
ActionControl.setTextforManipulate();
|
||||
}
|
||||
}
|
||||
//Entfernt "Taste A drücken"
|
||||
//Entfernt InfoText
|
||||
if(!MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && infoText){
|
||||
ActionControl.wishPanel();
|
||||
ActionControl.resetActionPanel();
|
||||
infoText=false;
|
||||
}
|
||||
//Nach dem man A gedrueckt hat kommt entweder Smashing oder Keysequence Text.
|
||||
if(action&&!setaction){
|
||||
setaction=true;
|
||||
ActionControl.wishPanel();
|
||||
ActionControl.setAction(rdm.nextInt(2)+1);
|
||||
//Leitet das Manipulieren ein, nachdem man das "A" gedrückt hat. Es kommt entweder Smashing oder Keysequence Text.
|
||||
if(action&&!setAction){
|
||||
setAction=true;
|
||||
ActionControl.resetActionPanel();
|
||||
ActionControl.setAction(new Random().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();
|
||||
//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){
|
||||
ActionControl.resetActionPanel();
|
||||
ActionControl.resetCount();
|
||||
ActionControl.resetTime();
|
||||
ActionControl.resetBeforeTime();
|
||||
ActionControl.resetBeforTime();
|
||||
ActionControl.resetKeySequenceFail();
|
||||
infoText=false;
|
||||
setaction=false;
|
||||
setAction=false;
|
||||
action=false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user