Merge pull request #85 from HGE-IT-Course-2016/SpielerBegrenzung

Spielerbegrenzung
master
Felix Stupp 8 years ago committed by GitHub
commit a0449e89da

@ -17,8 +17,8 @@ public class Colours extends World implements ButtonEvent
Button lila = new Button ("Lila", 16, this); Button lila = new Button ("Lila", 16, this);
Button gelb = new Button ("Gelb", 16, this); Button gelb = new Button ("Gelb", 16, this);
Button weiter = new Button ("Weiter", 16, this); Button weiter = new Button ("Weiter", 16, this);
int[] color = new int [6]; int[] color = new int [5];
String[] pn = new String [6]; String[] pn = new String [5];
int x = 0; int x = 0;
boolean possw = true; // schwarz boolean possw = true; // schwarz
boolean posbl = true; // blau boolean posbl = true; // blau
@ -40,7 +40,6 @@ public class Colours extends World implements ButtonEvent
Label pl3 = new Label("",16); Label pl3 = new Label("",16);
Label pl4 = new Label("",16); Label pl4 = new Label("",16);
Label pl5 = new Label("",16); Label pl5 = new Label("",16);
Label pl6 = new Label("",16);
/** /**
* Constructor for objects of class Colors. * Constructor for objects of class Colors.
@ -52,7 +51,7 @@ public class Colours extends World implements ButtonEvent
setBackground(Start_Load.backgroundImage); setBackground(Start_Load.backgroundImage);
Button[] bList = new Button[] {schwarz,gelb,blau,grün,rot,lila,weiter,remove}; Button[] bList = new Button[] {schwarz,gelb,blau,grün,rot,lila,weiter,remove};
Label[] lList = new Label[] {header,pl1,pl2,pl3,pl4,pl5,pl6}; Label[] lList = new Label[] {header,pl1,pl2,pl3,pl4,pl5};
addObject(header,200,15); addObject(header,200,15);
@ -70,7 +69,6 @@ public class Colours extends World implements ButtonEvent
addObject(pl3,355,200); addObject(pl3,355,200);
addObject(pl4,355,220); addObject(pl4,355,220);
addObject(pl5,355,240); addObject(pl5,355,240);
addObject(pl6,355,260);
schwarz.setForeColor(Color.black); schwarz.setForeColor(Color.black);
gelb.setForeColor(Color.yellow); gelb.setForeColor(Color.yellow);
@ -98,58 +96,49 @@ public class Colours extends World implements ButtonEvent
//der per Konstruktor die Daten der Colorklasse übertragen werden, dannach wird die Map die aktive Welt //der per Konstruktor die Daten der Colorklasse übertragen werden, dannach wird die Map die aktive Welt
public void buttonClicked (Button b) public void buttonClicked (Button b)
{ {
if ( b == schwarz && possw == true) if (x < 5) {
{ if (b == schwarz && possw == true) {
color[x] = sw; color[x] = sw;
pn[x]=getName(x,"Schwarz"); pn[x]=getName(x,"Schwarz");
if(pn[x].length() > 0) { if(pn[x].length() > 0) {
x+=1; x+=1;
possw = false; possw = false;
} }
} } else if (b == blau && posbl == true) {
if (b == blau && posbl == true) color[x] = bl;
{ pn[x]=getName(x,"Blau");
color[x] = bl; if(pn[x].length() > 0) {
pn[x]=getName(x,"Blau"); x+=1;
if(pn[x].length() > 0) { posbl = false;
x+=1; }
posbl = false; } else if (b == grün && posgr == true ) {
} color[x] = gr;
} pn[x]=getName(x,"Grün");
if (b == grün && posgr == true ) if(pn[x].length() > 0) {
{ x+=1;
color[x] = gr; posgr = false;
pn[x]=getName(x,"Grün"); }
if(pn[x].length() > 0) { } else if (b == rot && posrt == true) {
x+=1; color[x] = rt;
posgr = false; pn[x]=getName(x,"Rot");
} if(pn[x].length() > 0) {
} x+=1;
if ( b == rot && posrt == true) posrt = false;
{ }
color[x] = rt; } else if (b == gelb && posgb == true) {
pn[x]=getName(x,"Rot"); color [x] = gb;
if(pn[x].length() > 0) { pn[x]=getName(x,"Gelb");
x+=1; if(pn[x].length() > 0) {
posrt = false; x+=1;
} posgb = false;
} }
if ( b == gelb && posgb == true) } else if (b == lila && posli == true) {
{ color [x] = li;
color [x] = gb; pn[x]=getName(x,"Lila");
pn[x]=getName(x,"Gelb"); if(pn[x].length() > 0) {
if(pn[x].length() > 0) { x+=1;
x+=1; posli = false;
posgb = false; }
}
}
if ( b == lila && posli == true)
{
color [x] = li;
pn[x]=getName(x,"Lila");
if(pn[x].length() > 0) {
x+=1;
posli = false;
} }
} }
if(b == remove && x > 0) { if(b == remove && x > 0) {
@ -179,6 +168,9 @@ public class Colours extends World implements ButtonEvent
} }
private Color getC(boolean pos) { private Color getC(boolean pos) {
if(x >= 5) {
return Color.gray;
}
return (pos) ? Color.lightGray : Color.gray; return (pos) ? Color.lightGray : Color.gray;
} }
@ -193,15 +185,13 @@ public class Colours extends World implements ButtonEvent
lila.setBackColor(getC(posli)); lila.setBackColor(getC(posli));
gelb.setBackColor(getC(posgb)); gelb.setBackColor(getC(posgb));
remove.setBackColor((x > 0) ? Color.black : Color.gray); remove.setBackColor((x > 0) ? Color.black : Color.gray);
weiter.setBackColor((x > 2) ? Color.black : Color.gray);
pl1.setText(""); pl1.setText("");
pl2.setText(""); pl2.setText("");
pl3.setText(""); pl3.setText("");
pl4.setText(""); pl4.setText("");
pl5.setText(""); pl5.setText("");
pl6.setText("");
switch(x) { switch(x) {
case 6:
pl6.setText(pn[5]);
case 5: case 5:
pl5.setText(pn[4]); pl5.setText(pn[4]);
case 4: case 4:

@ -1,8 +0,0 @@
public class Debug6 extends Map_World {
public Debug6() {
super(
new String[] {"Spieler Nr. 1", "Player No. 2", "Spieler Nr. 3", "Player No. 4", "Spieler Nr. 5", "Player No. 6"},
new int[] {1,2,3,4,5,6}
);
}
}
Loading…
Cancel
Save