package sample.game.main;

import java.util.ArrayList;

import library.core.debug.CoreLog;
import library.core.mainAI.CoreActivity;
import library.core.mainAI.RiverCrossingAI;
import library.core.music.CoreSeData;
import sample.game.builder.TitleUserBuilder;
import sample.game.controller.TitleController;
import sample.game.controller.TitleController.Level;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;

public class UserGameTitle extends CoreActivity{

	private TitleUserBuilder builder;
	private TitleController controller;

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

			CoreLog.debug("create Title");

			screen.setScreenSize(1280, 720);

			builder=new TitleUserBuilder(objectFactory);
	}

	@Override
	protected void update(float deltaTime) {
		if(controller!=null) controller.update(deltaTime);

	}

	@Override
	protected void touch(MotionEvent event) {
		// TODO 自動生成されたメソッド・スタブ

		if(event.getAction()==MotionEvent.ACTION_DOWN){
			CoreLog.debug(""+screen.castX(event.getX())+"/"+ screen.castY(event.getY()));
		}

	}

	@Override
	protected void screenLoadEnd() {
		controller= builder.build(this);
	}


	/**
	 * ゲーム画面への遷移
	 */
	public void loadGameScreen(Level level){

		Intent intent = new Intent(UserGameTitle.this,MainActivity.class);

		switch (level) {
		case easy:
			intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			intent.putExtra("minister",1);
			intent.putExtra("wolf",1);
			intent.putExtra("cabbage",1);
			intent.putExtra("cattle",1);
			intent.putExtra("boat",2);
			intent.putExtra("short",7);
			intent.putExtra("isUseAi",false);
			intent.putExtra("isNormalGameMode",true);
			break;
		case normal:
			intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			intent.putExtra("minister",1);
			intent.putExtra("wolf",1);
			intent.putExtra("cabbage",1);
			intent.putExtra("cattle",3);
			intent.putExtra("boat",3);
			intent.putExtra("short",7);
			intent.putExtra("isUseAi",false);
			intent.putExtra("isNormalGameMode",true);
			break;
		case hard:
			intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			intent.putExtra("minister",1);
			intent.putExtra("wolf",1);
			intent.putExtra("cabbage",3);
			intent.putExtra("cattle",2);
			intent.putExtra("boat",3);
			intent.putExtra("short",7);
			intent.putExtra("isUseAi",false);
			intent.putExtra("isNormalGameMode",true);
			break;
		}


		startActivity(intent);
		RiverCrossingAI.changeActivity();
	}

	public void loadHowToPlay(){
		Intent intent = new Intent(UserGameTitle.this,HowToPlay.class);
		startActivity(intent);
		RiverCrossingAI.changeActivity();
	}

	@Override
	protected void loadSe() {
		ArrayList<CoreSeData> ses = new ArrayList<CoreSeData>();

		ses.add(new CoreSeData("se/next.ogg",1,1,1,0,false,1));
		ses.add(new CoreSeData("se/select.ogg",2,1,1,2,false,1));

		RiverCrossingAI.getSePlayer().load(ses);
	}


}
