Newer
Older
HelloAndroid / RiverCrossingAI / src / sample / game / model / OppositeIcon.java
package sample.game.model;

import library.core.model.CoreModel;
import library.core.system.CoreImageData;
import sample.game.model.CharaModel.TARGET_TYPE;

public class OppositeIcon extends CoreModel{


	public CoreImageData emptyIcon;
	public CoreImageData charaIcon;
	public CoreModel[] numberIcons;

	public boolean isEmpty;

	public TARGET_TYPE type;

	/**
	 *
	 * @param numbers	 X2とX3の2つしか来ないので大きさは2
	 * @param emptyIcon
	 * @param charaIcon
	 * @param menberNum
	 * @param centerX
	 * @param centerY
	 * @param width
	 * @param height
	 */
	public OppositeIcon(TARGET_TYPE type,CoreModel[] numbers,CoreImageData emptyIcon,CoreImageData charaIcon,int menberNum, float centerX, float centerY,
			float width, float height) {
		super(emptyIcon, centerX, centerY, width, height);

		this.numberIcons=numbers;
		this.emptyIcon=emptyIcon;
		this.charaIcon=charaIcon;

		this.type=type;

		this.setIcon(menberNum);

	}

	public void setIcon(int menberNum){
		if(menberNum==0){
			setEmpty(true);

			numberIcons[0].setShowView(false);
			numberIcons[1].setShowView(false);
		}else if(menberNum>=1){
			setEmpty(false);
			//数字の設定

			if(menberNum==2){
				numberIcons[0].setShowView(true);
				numberIcons[1].setShowView(false);
			}else if(menberNum==3){
				numberIcons[0].setShowView(false);
				numberIcons[1].setShowView(true);
			}else{
				numberIcons[0].setShowView(false);
				numberIcons[1].setShowView(false);
			}
		}
	}

	/**
	 * アイコンの切り替え
	 * @param b
	 */
	private void setEmpty(boolean b){
		if(b){
			this.setImageData(emptyIcon);
		}else{
			this.setImageData(charaIcon);
		}

		isEmpty=b;
	}

	public TARGET_TYPE getType() {
		return type;
	}


	@Override
	public void setShowView(boolean b){
		super.setShowView(b);

		if(!b){
			numberIcons[0].setShowView(false);
			numberIcons[1].setShowView(false);
		}

	}


}