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