package com.hyperling.apps.games;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;

/**
 * Created by ling on 12/17/16.
 */

public class GameActivity extends AppCompatActivity {

    BirdGameView birdGameView;
    ChickenGameView chickenGameView;

    private String gameType, birdGame, cowGame, pigGame, chickenGame, catGame;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

        gameType = GameActivity.this.getIntent().getAction();

        // Game types
        birdGame = getString(R.string.btnGameBird);
        cowGame = getString(R.string.btnGameCow);
        pigGame = getString(R.string.btnGamePig);
        chickenGame = getString(R.string.btnGameChicken);
        catGame = getString(R.string.btnGameCat);

        if (gameType.equals(birdGame)) {
            birdGameView = new BirdGameView(GameActivity.this);
            setContentView(birdGameView);
        }
        else if (gameType.equals(chickenGame)) {
            chickenGameView = new ChickenGameView(GameActivity.this);
            setContentView(chickenGameView);
        }
    }

    @Override
    protected void onPause() {

        if (gameType.equals(birdGame)) {
            birdGameView.pauseGame();
        }
        else if (gameType.equals(chickenGame)) {
            chickenGameView.pauseGame();
        }
        super.onPause();
    }
}
