package sample.game.model.title;

import java.util.ArrayList;

import library.core.listener.OnCoreTouchDownListener;
import library.core.mainAI.RiverCrossingAI;
import library.core.model.CoreModel;
import library.core.system.CoreImageData;

public class SoundButton extends CoreModel implements OnCoreTouchDownListener{


	public ArrayList<CoreImageData> images;	//ONとOFFの２つの画像

	private boolean canUse;
	private boolean isSoundOn;	//音が鳴っているかどうか

	public SoundButton(ArrayList<CoreImageData> images, float centerX, float centerY,
			float width, float height) {
		super(images.get(0), centerX, centerY, width, height);

		this.images=images;

		this.canUse=true;
		this.isSoundOn=true;
	}

/*
	@Override
	public void onTouchUp() {
		if(!canUse) return;

		if(isSoundOn){	//音が鳴る
			this.setImageData(images.get(0));
		}else{	//ミュート
			this.setImageData(images.get(1));
		}

		isSoundOn=!isSoundOn;
	}
*/

	public void setCanUse(boolean canUse) {
		this.canUse = canUse;
	}


	@Override
	public void onTouchDown() {
		if(!canUse) return;

		isSoundOn=!isSoundOn;


		RiverCrossingAI.getSePlayer().play(2);
		if(isSoundOn){	//音が鳴る
			RiverCrossingAI.getBgmPlayer().setMute(false);
			RiverCrossingAI.getSePlayer().setMute(false);
			RiverCrossingAI.getBgmPlayer().play("bgm/title.ogg", 1);
			this.setImageData(images.get(0));
		}else{	//ミュート
			RiverCrossingAI.getBgmPlayer().setMute(true);
			RiverCrossingAI.getSePlayer().setMute(true);
			this.setImageData(images.get(1));
		}


	}



}
