public class CompleteAnimation implements Runnable{
	private Field field;
	private SpiderSolitia st;
	private FieldCard [] fc;
	private int[] dx;
	private int[] dy;
	private int x;
	public CompleteAnimation(SpiderSolitia st,Field field,FieldCard [] fc,int x){
		this.field = field;
		this.st = st;
		this.fc = fc;
		this.x = x;
		dx = new int[13];
		dy = new int[13];
	}
	public void run(){
		int cnt = 0;
		int dcnt = 1;
		for(int i = 0;i < 13;i++){
			dx[i] = (15 + 15 * field.getCs().getCompleteCount()) - fc[i].getIndex_x();  
			dy[i] = 485 - fc[i].getIndex_y();
		}
		while(cnt <= 12){
			try{
				Thread.sleep(10);
				int set_x = fc[cnt].getIndex_x() + dx[cnt] * dcnt / 20;
				int set_y = fc[cnt].getIndex_y() + dy[cnt] * dcnt / 20;
				fc[cnt].setFrontstate(true);
				fc[cnt].setIndex_x(set_x);
				fc[cnt].setIndex_y(set_y);
				dcnt = dcnt + 1;
				if(dcnt > 20){
					field.getCardRow(x).removeCard();
					if(cnt != 12){
						st.musicPlay();
					}
					cnt = cnt + 1;
					dcnt = 1;
				}
				st.repaint();
			}catch(InterruptedException e){
			}
		}
		field.frontCheck(field.getCardRow(x));
		st.completeThreadStop();
		st.repaint();
	}
}
