Skip to content
Snippets Groups Projects
Commit b4b7c539 authored by SCHILLING Juliette's avatar SCHILLING Juliette
Browse files

indication pour aller a une piece ok + quelues debugs

parent 50291cd2
Branches
No related tags found
No related merge requests found
......@@ -76,7 +76,7 @@ public class ModeConceptionActivity extends AppCompatActivity {
Bitmap photoBitmap = (Bitmap) extras.get("data");
//On vérifie que la photo a bien été prise
Log.i("testPhotoBitmap", "hauteur de l'image : " + photoBitmap.getHeight());
//Log.i("testPhotoBitmap", "hauteur de l'image : " + photoBitmap.getHeight());
Mur murAssocie = gestionnaire.getMur(photoEnCours);
if(murAssocie != null){
......@@ -97,8 +97,14 @@ public class ModeConceptionActivity extends AppCompatActivity {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");
String date = simpleDateFormat.format(calendar.getTime());
murAssocie.setDate(date);
Toast.makeText(getBaseContext(), murAssocie.getDate(), Toast.LENGTH_SHORT).show();
Log.i("testDateJSON", habitat.toJSON().toString());
for(Piece piece :habitat.getPieces()){
for(Mur mur : piece.getMurs()){
if(mur.equals(murAssocie)){
mur.setDate(date);
}
}
}
majHabitat();
}
affichePieces();
}
......
......@@ -41,6 +41,7 @@ public class ModeImmersionActivity extends AppCompatActivity implements SensorEv
private Piece goToPiece;
private Rect goToRect;
private GrapheHabitat grapheHabitat;
private ImageView imageViewFleche;
/**
* onCreate de ModeImmersionActivity
......@@ -66,6 +67,8 @@ public class ModeImmersionActivity extends AppCompatActivity implements SensorEv
setContentView(R.layout.activity_mode_immersion);
grapheHabitat = new GrapheHabitat(habitat);
imageViewFleche = findViewById(R.id.imageViewFleche);
imageViewFleche.setVisibility(View.INVISIBLE);
rectangles = new ArrayList<Rect>();
pieceArriveeRect = new HashMap<Rect, Piece>();
......@@ -255,7 +258,7 @@ public class ModeImmersionActivity extends AppCompatActivity implements SensorEv
public void onSensorChanged(SensorEvent event) {
// On récupère l'angle
float angle = -(Math.round(event.values[0]))-60;
float angle = -(Math.round(event.values[0]));
//On créé l'animation de rotation
RotateAnimation rotateAnimation = new RotateAnimation(debut, angle, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
......@@ -368,20 +371,97 @@ public class ModeImmersionActivity extends AppCompatActivity implements SensorEv
//On recupere la prochaine piece et le mur à partir duquel on y accede
Piece pieceEnsuite = chemin.get(1);
//On recuperera la direction pour la fleche
Orientation orientation = null;
for (Ouverture ouverture : habitat.getOuvertures()) {
Piece pieceDepart = ouverture.getMurDepart().getPiece();
Piece pieceArrivee = ouverture.getMurArrivee().getPiece();
Log.i("testGraphe", "pieceDepart = " + pieceDepart.getNom() + " pieceArrivee = " + pieceArrivee.getNom() + " pieceEnCours = " + pieceEnCours.getNom() + " pieceEnsuite = " + pieceEnsuite.getNom());
if (pieceDepart.equals(pieceEnCours) && pieceArrivee.equals(pieceEnsuite)) {
goToRect = ouverture.getRectDepart();
orientation = ouverture.getMurDepart().getOrientation();
} else if (pieceArrivee.equals(pieceEnCours) && pieceDepart.equals(pieceEnsuite)) {
goToRect = ouverture.getRectArrivee();
orientation = ouverture.getMurArrivee().getOrientation();
}
}
afficheOuvertures();
//Log.i("testFleche", orientation.toString());
imageViewFleche.setVisibility(View.VISIBLE);
imageViewFleche.animate().cancel();
switch (orientation){
case EST:
switch(murEnCours.getOrientation()){
case OUEST:
imageViewFleche.animate().rotation(180);
break;
case SUD:
imageViewFleche.animate().rotation(-90);
break;
case NORD:
imageViewFleche.animate().rotation(90);
break;
default:
imageViewFleche.animate().rotation(0);
break;
}
break;
case OUEST:
switch(murEnCours.getOrientation()){
case EST:
imageViewFleche.animate().rotation(180);
break;
case SUD:
imageViewFleche.animate().rotation(90);
break;
case NORD:
imageViewFleche.animate().rotation(-90);
break;
default:
imageViewFleche.animate().rotation(0);
break;
}
break;
case SUD:
switch(murEnCours.getOrientation()){
case EST:
imageViewFleche.animate().rotation(90);
break;
case OUEST:
imageViewFleche.animate().rotation(-90);
break;
case NORD:
imageViewFleche.animate().rotation(180);
break;
default:
imageViewFleche.animate().rotation(0);
break;
}
break;
case NORD:
switch(murEnCours.getOrientation()){
case EST:
imageViewFleche.animate().rotation(-90);
break;
case OUEST:
imageViewFleche.animate().rotation(90);
break;
case SUD:
imageViewFleche.animate().rotation(180);
break;
default:
imageViewFleche.animate().rotation(0);
break;
}
break;
}
}else{
goToRect = null;
goToPiece = null;
imageViewFleche.setVisibility(View.INVISIBLE);
Toast.makeText(getBaseContext(), "Vous êtes arrivé !", Toast.LENGTH_SHORT).show();
}
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package habitat;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
......
......@@ -205,16 +205,12 @@ public class Mur implements Parcelable {
return jsonObject;
}
/**
* Fonction equals du mur
* @param o
* @return true si egaux, false sinon
*/
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
return id == ((Mur) o).getId() && Objects.equals(piece, ((Mur) o).getPiece()) && orientation == ((Mur) o).getOrientation();
Mur mur = (Mur) o;
return id == mur.id;
}
/**
......
......@@ -29,7 +29,9 @@
android:layout_marginTop="52dp"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginBottom="117dp"
app:layout_constraintBottom_toTopOf="@+id/imageViewMur"/>
app:layout_constraintBottom_toTopOf="@+id/imageViewMur"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintVertical_bias="0.617"/>
<SurfaceView
android:layout_width="414dp"
......@@ -75,4 +77,14 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<ImageView
android:layout_width="59dp"
android:layout_height="51dp"
app:srcCompat="@android:drawable/arrow_up_float"
android:id="@+id/imageViewFleche"
app:layout_constraintTop_toTopOf="@+id/imageViewMur"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="12dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment