Visuel partie avec pion vide
This commit is contained in:
parent
e2b69773c7
commit
bfb83c514e
@ -14,12 +14,18 @@ public class ChoiceCombi extends Activity implements SaisieActivity {
|
||||
private Saisie saisie;
|
||||
private Integer[] combiGagnante;
|
||||
private Integer[] pions;
|
||||
private boolean emptyPion;
|
||||
private View view;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
int[] tab = getIntent().getIntArrayExtra("pions");
|
||||
this.emptyPion = getIntent().getBooleanExtra("emptyPion", false);
|
||||
if(emptyPion) {
|
||||
this.pions=new Integer[7];
|
||||
} else {
|
||||
this.pions=new Integer[6];
|
||||
}
|
||||
for (int i=0;i<tab.length;i++) {
|
||||
this.pions[i] = tab[i];
|
||||
}
|
||||
@ -36,7 +42,12 @@ public class ChoiceCombi extends Activity implements SaisieActivity {
|
||||
public void changeState(){
|
||||
if(this.saisie.getSizeSelection()==4) {
|
||||
Intent returnIntent = new Intent();
|
||||
int[] tabpions=new int[6];
|
||||
int[] tabpions;
|
||||
if(emptyPion) {
|
||||
tabpions=new int[7];
|
||||
} else {
|
||||
tabpions=new int[6];
|
||||
}
|
||||
for (int i=0;i<this.saisie.getSizeSelection();i++) {
|
||||
tabpions[i] = this.saisie.getSelection()[i];
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ public class GameActivity extends Activity implements SaisieActivity {
|
||||
private Grille grille;
|
||||
private boolean bot;
|
||||
private Bot theBot;
|
||||
private boolean emptyPion;
|
||||
private boolean state;
|
||||
private View view;
|
||||
private LinearLayout rootView;
|
||||
@ -36,6 +37,7 @@ public class GameActivity extends Activity implements SaisieActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.bot = getIntent().getBooleanExtra("bot", false);
|
||||
this.emptyPion = getIntent().getBooleanExtra("pionVide", false);
|
||||
this.state=true;
|
||||
this.saisie=new Saisie();
|
||||
this.grille=new Grille();
|
||||
@ -45,10 +47,16 @@ public class GameActivity extends Activity implements SaisieActivity {
|
||||
this.combiGagnante=this.theBot.getCollectionWin();
|
||||
} else if(!this.bot){
|
||||
Intent choiceCombi = new Intent(this, ChoiceCombi.class);
|
||||
int[] tabpions=new int[6];
|
||||
int[] tabpions;
|
||||
if(emptyPion) {
|
||||
tabpions=new int[7];
|
||||
} else {
|
||||
tabpions=new int[6];
|
||||
}
|
||||
for (int i=0;i<this.pionsAttaquant.length;i++) {
|
||||
tabpions[i] = this.pionsAttaquant[i];
|
||||
}
|
||||
choiceCombi.putExtra("emptyPion", emptyPion);
|
||||
choiceCombi.putExtra("pions", tabpions);
|
||||
startActivityForResult(choiceCombi, 1);
|
||||
}
|
||||
@ -67,7 +75,11 @@ public class GameActivity extends Activity implements SaisieActivity {
|
||||
if (requestCode == 1) {
|
||||
if(resultCode == Activity.RESULT_OK){
|
||||
int[] tab = data.getIntArrayExtra("choix");
|
||||
if(emptyPion) {
|
||||
this.combiGagnante=new Integer[7];
|
||||
} else {
|
||||
this.combiGagnante=new Integer[6];
|
||||
}
|
||||
for (int i=0;i<tab.length;i++) {
|
||||
this.combiGagnante[i] = tab[i];
|
||||
}
|
||||
@ -176,13 +188,20 @@ public class GameActivity extends Activity implements SaisieActivity {
|
||||
this.pionsDefenseur[1]=this.getResources().getColor(R.color.black);
|
||||
|
||||
//L'attaquant a des pions de couleurs
|
||||
if(emptyPion) {
|
||||
this.pionsAttaquant = new Integer[7];
|
||||
} else {
|
||||
this.pionsAttaquant = new Integer[6];
|
||||
}
|
||||
this.pionsAttaquant[0]=this.getResources().getColor(R.color.pink);
|
||||
this.pionsAttaquant[1]=this.getResources().getColor(R.color.purple);
|
||||
this.pionsAttaquant[2]=this.getResources().getColor(R.color.blue);
|
||||
this.pionsAttaquant[3]=this.getResources().getColor(R.color.green);
|
||||
this.pionsAttaquant[4]=this.getResources().getColor(R.color.yellow);
|
||||
this.pionsAttaquant[5]=this.getResources().getColor(R.color.white);
|
||||
if(emptyPion) {
|
||||
this.pionsAttaquant[6]=this.getResources().getColor(R.color.pionVide);
|
||||
}
|
||||
|
||||
// on inisialise la saisie
|
||||
this.saisie.setChoix(this.pionsAttaquant);
|
||||
|
@ -26,9 +26,7 @@ public class MainActivity extends Activity {
|
||||
public void onClick(View v) {
|
||||
Intent HotSeat = new Intent(MainActivity.this, GameActivity.class);
|
||||
HotSeat.putExtra("bot", false);
|
||||
if(pionV) {
|
||||
HotSeat.putExtra("pionVide", true);
|
||||
}
|
||||
HotSeat.putExtra("pionVide", pionV);
|
||||
startActivity(HotSeat);
|
||||
}
|
||||
});
|
||||
@ -37,9 +35,7 @@ public class MainActivity extends Activity {
|
||||
public void onClick(View v) {
|
||||
Intent ordi = new Intent(MainActivity.this, GameActivity.class);
|
||||
ordi.putExtra("bot", true);
|
||||
if(pionV) {
|
||||
ordi.putExtra("pionVide", true);
|
||||
}
|
||||
ordi.putExtra("pionVide", pionV);
|
||||
startActivity(ordi);
|
||||
}
|
||||
});
|
||||
@ -47,7 +43,7 @@ public class MainActivity extends Activity {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent settings = new Intent(MainActivity.this, SettingsActivity.class);
|
||||
startActivityForResult(settings, 1);
|
||||
startActivityForResult(settings, 2);
|
||||
}
|
||||
});
|
||||
mRules.setOnClickListener(new View.OnClickListener() {
|
||||
@ -63,7 +59,7 @@ public class MainActivity extends Activity {
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if(requestCode == 1) {
|
||||
if(requestCode == 2) {
|
||||
pionV = data.getBooleanExtra("pionV", false);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class SettingsActivity extends Activity {
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("pionV", pionV);
|
||||
setResult(1, intent);
|
||||
setResult(2, intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
@ -74,9 +74,16 @@ public class GameView extends View {
|
||||
//copie des couleurs dispos
|
||||
LinkedList<Integer> couleurs = new LinkedList<Integer>();
|
||||
couleurs.addAll(this.saisie.getChoix());
|
||||
for (int i=0;i<this.saisie.getChoix().size();i++){
|
||||
if(this.saisie.getChoix().size() == 6 || this.saisie.getChoix().size() == 2) {
|
||||
for (int i = 0; i < this.saisie.getChoix().size(); i++) {
|
||||
this.circle.setColor(couleurs.pop());
|
||||
canvas.drawCircle((i*this.getWidth()*2/13+this.getWidth()/8),this.getHeight()-this.getHeight()/7, this.getWidth()/16, this.circle);
|
||||
canvas.drawCircle((i * this.getWidth() * 2 / 13 + this.getWidth() / 8), this.getHeight() - this.getHeight() / 7, this.getWidth() / 16, this.circle);
|
||||
}
|
||||
} else if(this.saisie.getChoix().size() == 7) {
|
||||
for (int i = 0; i < this.saisie.getChoix().size(); i++) {
|
||||
this.circle.setColor(couleurs.pop());
|
||||
canvas.drawCircle((i * this.getWidth() * 2 / 14 + this.getWidth() / 14), this.getHeight() - this.getHeight() / 7, this.getWidth() / 19, this.circle);
|
||||
}
|
||||
}
|
||||
|
||||
// bouton valider
|
||||
|
Loading…
Reference in New Issue
Block a user