Weitere Anpassungen an ActionControl

This commit is contained in:
Ivan
2014-11-21 09:57:58 +01:00
parent 742b776ba8
commit f603e32a95
5 changed files with 97 additions and 35 deletions
@@ -260,6 +260,7 @@ public class GameLoopD extends JFrame implements Runnable {
if (!pause) {
ActionWatcher.tick();
ActionControl.tick();
if(ActionControl.getTickTimer())ActionControl.tickTimer();
HardwareResetTimers.tick();
player01.tick();
opponent01.tick();
@@ -26,7 +26,7 @@ public class HardwareResetTimers {
if (HardwareResetTickstamps.get(i).equals(tickCount)) {
Logger.write("Hardware "+i+" reset");
HardewareManipulate.resetHardware(i);
StatusPanelAdder.reduceMod();
//StatusPanelAdder.reduceMod();
}
}
}
@@ -41,6 +41,6 @@ public class HardwareResetTimers {
resetTimestamp = resetTimestamp % tickRoundMax;
}
HardwareResetTickstamps.put(c, resetTimestamp);
StatusPanelAdder.raiseMod();
//StatusPanelAdder.raiseMod();
}
}
+33 -8
View File
@@ -19,6 +19,7 @@ public class KeyBindings extends KeyAdapter {
private boolean up = false;
private boolean down = false;
private boolean esc = false;
private boolean key = false;
private Player player;
public KeyBindings(Player player) {
@@ -44,6 +45,18 @@ public class KeyBindings extends KeyAdapter {
case KeyEvent.VK_ESCAPE:
esc = false;
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;
case KeyEvent.VK_Q:
if(ActionWatcher.getAction()){
if(ActionWatcher.getAction()&&!key){
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()){
if(ActionControl.getSequence()[ActionControl.getCount()]=='Q'){
ActionControl.incCount();
@@ -85,12 +100,15 @@ public class KeyBindings extends KeyAdapter {
}
}
key=true;
}
break;
case KeyEvent.VK_W:
if(ActionWatcher.getAction()){
if(ActionWatcher.getAction()&&!key){
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()){
if(ActionControl.getSequence()[ActionControl.getCount()]=='W'){
ActionControl.incCount();
@@ -99,12 +117,15 @@ public class KeyBindings extends KeyAdapter {
ActionControl.setKeySequenceFail();
}
}
key=true;
}
break;
case KeyEvent.VK_E:
if(ActionWatcher.getAction()){
if(ActionWatcher.getAction()&&!key){
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()){
if(ActionControl.getSequence()[ActionControl.getCount()]=='E'){
ActionControl.incCount();
@@ -113,12 +134,15 @@ public class KeyBindings extends KeyAdapter {
ActionControl.setKeySequenceFail();
}
}
key=true;
}
break;
case KeyEvent.VK_R:
if(ActionWatcher.getAction()){
if(ActionWatcher.getAction()&&!key){
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()){
if(ActionControl.getSequence()[ActionControl.getCount()]=='R'){
ActionControl.incCount();
@@ -127,6 +151,7 @@ public class KeyBindings extends KeyAdapter {
ActionControl.setKeySequenceFail();
}
}
key=true;
}
break;
}
@@ -9,12 +9,14 @@ import javax.swing.border.LineBorder;
import de.heatup.mapengine.MapGrid;
import de.heatup.testing.GameLoopD;
import de.heatup.ui.StatusPanelAdder;
public class ActionControl{
private static int count = 0;
private static long beforTime = 0;
private static boolean time = true;
private static boolean keySequenceFail=false;
private static boolean tickTimer =false;
private static int option=0;
private static char chr;
private static char arr[];
@@ -22,6 +24,7 @@ public class ActionControl{
private static JProgressBar bar;
private static JLabel actionLabel;
private static JLabel bigActionLabel;
private static int tmpCount=0;
public static void setPanel(JPanel newPanel){
panel = newPanel;
@@ -50,11 +53,7 @@ public class ActionControl{
}else{
option=2;
setSequence(new Keysequence().getKeySequence());
String str="Bitte diese Tastenkombination \"";
for(int i=0;i<arr.length;i++){
str=str+getSequence()[i]+" ";
}
str=str + "\" "+"so schnell wie moeglich eingeben";
String str="Bitte diese Tastenkombination so schnell wie moeglich eingeben";
actionLabel.setText(str);
}
}
@@ -62,15 +61,15 @@ public class ActionControl{
if(ActionWatcher.getAction()){
//Smashing-Tick
if(option==1){
bar.setValue(0);
bar.setVisible(true);
if(count<50){
setTickTimer();
if(bar.getValue()<100){
if(time){
setProgressBar(0);
time = false;
beforTime=System.nanoTime();
}
bar.setValue((int)(count*2));
}else{
tmpCount=0;
bar.setVisible(false);
ActionWatcher.setAction(false);
if(System.nanoTime()-beforTime>8_000_000_000L){
@@ -82,25 +81,28 @@ public class ActionControl{
}
//KeySequence-Tick
}else{
if(!getTickTimer()){
setTickTimer();
setProgressBar(100);
}
if(!getKeySequenceFail()){
if(count<arr.length){
if(count<arr.length&&bar.getValue()>0){
bigActionLabel.setVisible(true);
if(time){
time = false;
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);
}
}else{
tmpCount=0;
resetTickTimer();
bigActionLabel.setVisible(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!!!");
}else{
actionLabel.setText("Manipulation erfolgreich!");
@@ -108,6 +110,8 @@ public class ActionControl{
}
}
}else{
resetTickTimer();
resetProgressBar();
bigActionLabel.setVisible(false);
ActionWatcher.setAction(false);
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(){
return option;
}
@@ -132,9 +156,13 @@ public class ActionControl{
}
public static void resetActionPanel(){
bigActionLabel.setText("");
bar.setValue(0);
bar.setVisible(false);
actionLabel.setText("");
resetProgressBar();
resetCount();
resetTime();
resetBeforTime();
resetKeySequenceFail();
resetTickTimer();
}
public static void resetTime(){
time=true;
@@ -149,6 +177,7 @@ public class ActionControl{
count++;
}
public static void resetCount(){
tmpCount=0;
count=0;
}
public static boolean getKeySequenceFail(){
@@ -166,4 +195,15 @@ public class ActionControl{
public static void setTextforManipulate(){
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
if(!MapGrid.getGridCell(GameLoopD.player01.getGridLocation().x, GameLoopD.player01.getGridLocation().y).isTrigger() && setAction){
ActionControl.resetActionPanel();
ActionControl.resetCount();
ActionControl.resetTime();
ActionControl.resetBeforTime();
ActionControl.resetKeySequenceFail();
infoText=false;
setAction=false;
action=false;