package com.backfire.Animation;

import com.backfire.graphics.PCanvas;

/**
 * @author wf
 *
 */
public abstract class Animation implements Comparable<Animation>{
	public abstract void unload();
	public abstract void overstatue();
	
	public boolean deleteFlag = false;
	public long sleep;
	public float frameDuration=30f;
	public int drawLevel = 0;
	public int tag = -1;
	public AnimationManager.IAnimationSequence sequenceCallback;
	
	public void exec(PCanvas canvas,long sleep){
		this.sleep=sleep;
		if (this.sleep < 15) {
			this.sleep = 15;
		}
	}
	
	public int compareTo(Animation o) {
		int dl = o.drawLevel;
		if (dl < this.drawLevel) {
			return 1;
		}
		
		if (dl > this.drawLevel) {
			return -1;
		}
		
		return 0;
	}
	
	public int getCurrentBitmap(float statetime,int [] textures) {
		int frameNumber = (int) (statetime / this.frameDuration);
		frameNumber = Math.min(textures.length - 1, frameNumber);
		return frameNumber;
	}
}