package sample.game.main; import java.util.ArrayList; import library.core.mainAI.CoreActivity; import library.core.mainAI.RiverCrossingAI; import library.core.music.CoreSeData; import sample.game.ai.Memory; import sample.game.builder.GameBuilder; import sample.game.controller.GameController; import sample.game.manager.EndIsland; import sample.game.manager.StartIsland; import sample.game.model.BoatModel; import sample.game.system.define; import android.content.Intent; import android.os.Bundle; import android.view.MotionEvent; public class MainActivity extends CoreActivity{ private GameController gameController; private boolean isUseAi=true; private int boatSize=2; private int ministerNum=1; private int wolfNum=1; private int cabbageNum=1; private int cattleNum=1; private int shortest=1; public enum gameSeType{ AI_MISS, ATTENTION, CLEAR, CROSS, FAILUER, PARFECT, RETURN, RIDE, NEXT, SELECT, } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); screen.setScreenSize(1280, 720); Intent intent=getIntent(); ministerNum=intent.getIntExtra("minister",1); wolfNum=intent.getIntExtra("wolf",1); cabbageNum=intent.getIntExtra("cabbage",1); cattleNum=intent.getIntExtra("cattle", 1); boatSize=intent.getIntExtra("boat", 2); shortest=intent.getIntExtra("short", 1); isUseAi=intent.getBooleanExtra("isUseAi",true); } @Override protected void update(float deltaTime) { if(gameController!=null) gameController.update(deltaTime); } @Override protected void touch(MotionEvent event) { if(gameController!=null) gameController.onTouch(event, screen.castX(event.getX()), screen.castY(event.getY())); } @Override protected void screenLoadEnd() { createGame(); } /** * ゲームの再スタート */ public void restartGame(){ Intent intent = new Intent(MainActivity.this,MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("minister",ministerNum); intent.putExtra("wolf",wolfNum); intent.putExtra("cabbage",cabbageNum); intent.putExtra("cattle",cattleNum); intent.putExtra("boat",boatSize); intent.putExtra("isUseAi",isUseAi); intent.putExtra("short",shortest); intent.putExtra("isNormalGameMode",true); RiverCrossingAI.changeActivity(); startActivity(intent); } public void resumeStartGame(StartIsland s,EndIsland e,BoatModel b){ Memory m=gameController.getMoveData(); objectFactory.deleteAll(); textObjectFactory.deleteAll(); gameController=null; GameBuilder bulBuilder=new GameBuilder(this, objectFactory, s, e, b); gameController=bulBuilder.reBuild(isUseAi, m); } public void createGame(){ GameBuilder builder=new GameBuilder(this,objectFactory, boatSize); gameController=builder.build(isUseAi, ministerNum, wolfNum, cabbageNum, cattleNum); } public void moveTitle(){ Intent intent=null; if(define.GAME_MODE_AI){ intent = new Intent(MainActivity.this,AiGameTitle.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("minister",ministerNum); intent.putExtra("wolf",wolfNum); intent.putExtra("cabbage",cabbageNum); intent.putExtra("cattle",cattleNum); intent.putExtra("boat",boatSize); }else{ intent = new Intent(MainActivity.this,UserGameTitle.class); } RiverCrossingAI.changeActivity(); startActivity(intent); } public int getShortest() { return shortest; } @Override protected void loadSe() { ArrayList<CoreSeData> ses = new ArrayList<CoreSeData>(); ses.add(new CoreSeData("se/ai_miss.ogg",gameSeType.AI_MISS.ordinal(),1,1,0,false,1)); ses.add(new CoreSeData("se/attention.ogg",gameSeType.ATTENTION.ordinal(),1,1,2,false,1)); ses.add(new CoreSeData("se/clear.ogg",gameSeType.CLEAR.ordinal(),1,1,0,false,1)); ses.add(new CoreSeData("se/cross.ogg",gameSeType.CROSS.ordinal(),1,1,0,false,1)); ses.add(new CoreSeData("se/failure.ogg",gameSeType.FAILUER.ordinal(),1,1,0,false,1)); ses.add(new CoreSeData("se/parfect.ogg",gameSeType.PARFECT.ordinal(),1,1,0,false,1)); ses.add(new CoreSeData("se/return.ogg",gameSeType.RETURN.ordinal(),1,1,0,true,1)); ses.add(new CoreSeData("se/ride.ogg",gameSeType.RIDE.ordinal(),1,1,2,false,1f)); ses.add(new CoreSeData("se/next.ogg",gameSeType.NEXT.ordinal(),1,1,1,false,1f)); ses.add(new CoreSeData("se/select2.ogg",gameSeType.SELECT.ordinal(),0.7f,0.7f,1,false,1f)); RiverCrossingAI.getSePlayer().load(ses); } }