// Bandit Manchot, by Seb Luca, UNamur, June 2018

package com.projet.sluca.banditmanchot;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity implements View.OnClickListener
{
    private static int REQUEST_CODE = 1;
    private Button buttonPlay;  // bouton "Start the Game"
    private Button buttonRules; // bouton "Read The Rules"

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        boutons(); // Appel de la gestion des boutons (deux pour une activity, donc plus complexe).
    }

    public void boutons() // Gestion des deux boutons de cette activity.
    {
        // -- Gestion bouton "Rejouer".

        buttonPlay = (Button)findViewById(R.id.btnStart);
        final Intent intent2 = new Intent();
        intent2.setClass(MainActivity.this, GameActivity.class); // pointe vers GameActivity.

        buttonPlay.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {

                // Bruitage.
                MediaPlayer sound = MediaPlayer.create(MainActivity.this,R.raw.buttonstart);
                sound.start();

                startActivity(intent2); // Si clic : changement d'activity.
            }
        });

        // -- Gestion bouton "Menu Principal".

        buttonRules = (Button)findViewById(R.id.btnRules);
        final Intent intent1 = new Intent();
        intent1.setClass(MainActivity.this, RulesActivity.class); // pointe vers RulesActivity.

        buttonRules.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                // Bruitage.
                MediaPlayer sound = MediaPlayer.create(MainActivity.this,R.raw.buttonstart);
                sound.start();

                startActivity(intent1); // Si clic : changement d'activity.
            }
        });
    }

    @Override
    public void onClick(View v) { /**/ } // Doit être là pour la forme.
}