Newer
Older
HelloAndroid / RiverCrossingAI / src / sample / game / builder / TitleUserBuilder.java
package sample.game.builder;

import java.util.ArrayList;

import library.core.model.CoreAnimation;
import library.core.model.CoreModel;
import library.core.object.CoreObjectFactory;
import library.core.system.CoreImageData;
import library.core.view.CoreView;
import sample.game.controller.TitleController;
import sample.game.controller.TitleController.Level;
import sample.game.main.UserGameTitle;
import sample.game.model.title.HowToPlayButton;
import sample.game.model.title.LevelButton;
import sample.game.model.title.SoundButton;
import sample.game.model.title.TitleAnimationModel;

public class TitleUserBuilder {

	private CoreObjectFactory objectFactory;

	private ArrayList<LevelButton> levelButtons;

	public TitleUserBuilder(CoreObjectFactory coreObjectFactory){
		this.objectFactory=coreObjectFactory;

		this.levelButtons=new ArrayList<LevelButton>();

	}


	public TitleController build(UserGameTitle palent){

		TitleController controller=new TitleController(palent);

		/*CoreModel back=new CoreModel(new CoreImageData("image/title/title.jpg"),
				640, 369, 1280, 720);*/
		CoreModel back=new CoreModel(new CoreImageData("image/back/title.png"),
				640, 369, 1280, 720);
		objectFactory.create(back, new CoreView(back, 0));
		controller.setBackScreen(back);


		back=new CoreModel(new CoreImageData("image/back/title.png"),
				-640, 369, 1280, 720);
		objectFactory.create(back, new CoreView(back, 0));
		controller.setBackScreen2(back);


		//ロゴの表示
		CoreModel logo=new CoreModel(new CoreImageData("image/title/titlelogo.png"),
				640, 96, 1024, 144);
		objectFactory.create(logo, new CoreView(logo, 0));
		controller.setLogo(logo);


		//音ボタンの表示
		ArrayList<CoreImageData> soundImages=new ArrayList<CoreImageData>();
		soundImages.add(new CoreImageData("image/title/user/ui/mute_on.png"));
		soundImages.add(new CoreImageData("image/title/user/ui/mute_off.png"));
		SoundButton soundButton=new SoundButton(soundImages, 1153, 230, 96, 96);
		objectFactory.create(soundButton, new CoreView(soundButton, 1));
		controller.setSoundButton(soundButton);

		//遊び方ボタン
		HowToPlayButton howToPlayButton=new HowToPlayButton(controller,
				new CoreImageData("image/title/user/ui/howtoplay.png"),1006 , 230, 96, 96);
		objectFactory.create(howToPlayButton, new CoreView(howToPlayButton, 1));
		controller.setHowToPlayButton(howToPlayButton);


		//レベル選択ボタン
		LevelButton button=new LevelButton(Level.easy,controller,new CoreImageData("image/title/user/ui/easy.png"),
				250, 630, 352, 96);
		levelButtons.add(button);
		objectFactory.create(button, new CoreView(button, 1));

		button=new LevelButton(Level.normal,controller,new CoreImageData("image/title/user/ui/normal.png"),
				640, 630, 352, 96);
		levelButtons.add(button);
		objectFactory.create(button, new CoreView(button, 1));

		button=new LevelButton(Level.hard,controller,new CoreImageData("image/title/user/ui/hard.png"),
				1030, 630, 352, 96);
		levelButtons.add(button);
		objectFactory.create(button, new CoreView(button, 1));

		controller.setLevelButtons(levelButtons);


		//タイトルのキャラ
		//ミナミ
		ArrayList<CoreImageData> animDatas=new ArrayList<CoreImageData>();
		animDatas.add(new CoreImageData("image/title/user/anim/minamiTitle.png",0,0,324,324));
		animDatas.add(new CoreImageData("image/title/user/anim/minamiTitle.png",1,0,324,324));
		animDatas.add(new CoreImageData("image/title/user/anim/minamiTitle.png",2,0,324,324));

		ArrayList<Integer> animIndexs=new ArrayList<Integer>();
		animIndexs.add(1);
		animIndexs.add(0);
		animIndexs.add(1);
		animIndexs.add(2);

		ArrayList<CoreAnimation> anims=new ArrayList<CoreAnimation>();

		//ループ絵の設定
		anims.add(new CoreAnimation("easyLoop", animDatas,animIndexs,0.3f, true));


		animDatas=new ArrayList<CoreImageData>();
		animDatas.add(new CoreImageData("image/title/user/minami_title4.png"));
		animIndexs=new ArrayList<Integer>();
		animIndexs.add(0);

		//停止絵の設定
		anims.add(new CoreAnimation("easyEnd", animDatas, animIndexs, 1f, false));


		TitleAnimationModel animationModel=new TitleAnimationModel(anims, 0, 250, 384, 324, 324);
		objectFactory.create(animationModel, new CoreView(animationModel, 1));
		controller.setEasyCharaAnim(animationModel);


		//なんぼう
		animDatas=new ArrayList<CoreImageData>();
		animDatas.add(new CoreImageData("image/title/user/anim/nanbouTitle.png",0,0,324,324));
		animDatas.add(new CoreImageData("image/title/user/anim/nanbouTitle.png",1,0,324,324));
		animDatas.add(new CoreImageData("image/title/user/anim/nanbouTitle.png",2,0,324,324));

		animIndexs=new ArrayList<Integer>();
		animIndexs.add(1);
		animIndexs.add(0);
		animIndexs.add(1);
		animIndexs.add(2);

		anims=new ArrayList<CoreAnimation>();

		//ループ絵の設定
		anims.add(new CoreAnimation("normalLoop", animDatas,animIndexs,0.3f, true));


		animDatas=new ArrayList<CoreImageData>();
		animDatas.add(new CoreImageData("image/title/user/nanbou_title4.png"));
		animIndexs=new ArrayList<Integer>();
		animIndexs.add(0);

		//停止絵の設定
		anims.add(new CoreAnimation("normalEnd", animDatas, animIndexs, 1f, false));


		animationModel=new TitleAnimationModel(anims, 0, 640, 384, 324, 324);
		objectFactory.create(animationModel, new CoreView(animationModel, 1));
		controller.setNormalCharaAnim(animationModel);


		//へび
		animDatas=new ArrayList<CoreImageData>();
		animDatas.add(new CoreImageData("image/title/user/anim/snakeTitle.png",0,0,324,324));
		animDatas.add(new CoreImageData("image/title/user/anim/snakeTitle.png",1,0,324,324));

		animIndexs=new ArrayList<Integer>();
		animIndexs.add(0);
		animIndexs.add(1);

		anims=new ArrayList<CoreAnimation>();

		//ループ絵の設定
		anims.add(new CoreAnimation("hardLoop", animDatas,animIndexs,0.3f, true));


		animDatas=new ArrayList<CoreImageData>();
		animDatas.add(new CoreImageData("image/title/user/snake_title3.png"));
		animIndexs=new ArrayList<Integer>();
		animIndexs.add(0);

		//停止絵の設定
		anims.add(new CoreAnimation("hardEnd", animDatas, animIndexs, 1f, false));


		animationModel=new TitleAnimationModel(anims, 0, 1030, 384, 324, 324);
		objectFactory.create(animationModel, new CoreView(animationModel, 1));
		controller.setHardCharaAnim(animationModel);


		//フェイド用のマスク
		CoreModel fadeMask=new CoreModel(new CoreImageData("image/game/screen/fadeMask.png"),
				640, 360, 1280, 720);
		fadeMask.setShowView(false);
		fadeMask.setAlpha(0);
		objectFactory.create(fadeMask, new CoreView(fadeMask, 20));
		controller.setFadeMask(fadeMask);

		controller.checkInitProduction();

		return controller;

	}


}