package com.game.objects;

import java.util.ArrayList;

import org.anddev.andengine.engine.handler.physics.PhysicsHandler;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.scene.Scene.IOnSceneTouchListener;
import org.anddev.andengine.entity.shape.Shape;
import org.anddev.andengine.entity.sprite.AnimatedSprite;
import org.anddev.andengine.entity.sprite.AnimatedSprite.IAnimationListener;
import org.anddev.andengine.input.touch.TouchEvent;
import org.anddev.andengine.opengl.texture.region.TiledTextureRegion;

import android.content.Context;

import com.commons.game_commons;
import com.game.commons.cTools;
import com.game.commons.cGame_Commons.ACTION_PLAYER;
import com.game.interfaces.IGame_CommonItem;
import com.qwerjk.andengine.entity.sprite.PixelPerfectAnimatedSprite;
import com.qwerjk.andengine.opengl.texture.region.PixelPerfectTiledTextureRegion;

public class cGame_Object_Enemy extends PixelPerfectAnimatedSprite implements IGame_CommonItem , IOnSceneTouchListener {
	
	private int go_id;
	public String go_name;
	private String go_barcode;
	
	public Shape go_Shape;
	
	public PhysicsHandler go_PhysicsHandler;
	// Coleccion de Partes del Objeto
	public ArrayList<cGame_Object_Part> go_Parts = new ArrayList<cGame_Object_Part>();
	private PixelPerfectTiledTextureRegion go_TiledTextureRegion;
	
	public cGame_Object_Enemy(float pX, float pY, float pTileWidth,float pTileHeight, PixelPerfectTiledTextureRegion pTiledTextureRegion,String tname,String tBARCODE,int tzindex) {
		super(pX, pY,pTiledTextureRegion);
		this.go_id=cTools.generic_id();
		this.go_name=tname;
		this.go_barcode=tBARCODE;
		this.setZIndex(tzindex);
		//**************** VELOCITAT INICIAL ***********************
		go_PhysicsHandler = new PhysicsHandler(this);
	    this.registerUpdateHandler(go_PhysicsHandler);
	    this.go_PhysicsHandler.setVelocity(0, 0);
	    this.go_TiledTextureRegion=pTiledTextureRegion;
	    
	    this.go_Shape=this;
	}
	
	@Override
	public void getInfo(Context tActivity)
	{
	}

	public void addPart(cGame_Object_Part tPart)
	{
		go_Parts.add(tPart);
	}
	
	@Override
	public void addScene(Scene ts)
	{
		this.setScale(3.0f);
		// Add main object
		ts.attachChild(this);
		// Add all parts of the object
		for (cGame_Object_Part c_Part : go_Parts )
		{
			c_Part.setScale(3.0f);
			ts.attachChild(c_Part);
			
		}
		ts.sortChildren();
		
	}
	
	public void move(float ctot) 
	{

	}
	

	@Override
	public void anima(long ms,ACTION_PLAYER action) 
	{

	}

	@Override
    protected void onManagedUpdate(final float pSecondsElapsed) 
	{

			
            super.onManagedUpdate(pSecondsElapsed);
    }
	
	
	
	
	@Override
	public void move() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
		// TODO Auto-generated method stub
		return false;
	}
	
}
