package com.backfire.Animation;

import net.yeeyo.doudizhu.feiyu.R;
import android.graphics.Bitmap;
import android.graphics.Rect;

import com.backfire.doudizhu.common.BitmapManager;
import com.backfire.doudizhu.common.DdzApplication;
import com.backfire.graphics.PCanvas;
import com.backfire.room.data.ConfigCenter;
import com.backfire.utils.Log;

/**   
 * @Title: AnimationBurstLaizi.java
 * @Package com.backfire.Animation
 * @Description: 爆出癞子动画
 * @author Potter
 * @date 2013-11-27 下午8:40:47
 * @version V2.0   
 */
public class AnimationBurstLaizi extends Animation {

	private final int[] textures = {
			R.drawable.card_laizanim_1,
			R.drawable.card_laizanim_2,
			R.drawable.card_laizanim_3,
			R.drawable.card_laizanim_4,
			R.drawable.card_laizanim_5,
			R.drawable.card_laizanim_6,
			R.drawable.card_laizanim_7,
			R.drawable.card_laizanim_8,
			R.drawable.card_laizanim_9,
			R.drawable.card_laizanim_10
	};
	private int index=0;
	private final int windth = ConfigCenter.self_hand_card_W;
	private final int height = ConfigCenter.burst_Laizi_anim_H;
	
	float statetime=0.0f;
	private Rect srcRect;

	public AnimationBurstLaizi(int x,int y) {
		srcRect = new Rect();
		srcRect.set(x, y, x + windth, y + height);
	}

	@Override
	public void exec(PCanvas canvas,long sleep) {
		super.exec(canvas,sleep);
		statetime+=this.sleep;
		Log.i("休眠时间："+this.sleep);
		index=getCurrentBitmap(statetime, textures);
		BitmapManager bpool = DdzApplication.getApplication().getBmpPool();
		Bitmap texture = bpool.getBitmap(textures[index], 0, 0);
		if (null != texture) {
			canvas.drawBitmap(texture, null, srcRect, null);
		}
		if (index == textures.length-1) {
			index = 0;
			this.deleteFlag = true;
		}
	}

	@Override
	public void unload() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void overstatue() {
		this.deleteFlag = true;
	}
}
