package objects;

import java.util.ResourceBundle;

import util.reflection.Reflection;
import util.reflection.ReflectionException;
import jboxGlue.PhysicalObject;
import jgame.JGColor;

public abstract class GameObject extends PhysicalObject{
    public static final String DEFAULT_RESOURCE_PACKAGE = "engineResources/";
    public static final String DEFAULT_BEHAVIOR = "";
    
	protected ResourceBundle myDieWays;
	protected ResourceBundle myMoveWays;
	protected String myDieString;

	protected GameObject(String name, int collisionId, JGColor color) {
		super(name, collisionId, color);
	}
	
	protected void initObject(){
		myDieWays = ResourceBundle.getBundle(DEFAULT_RESOURCE_PACKAGE + DEFAULT_BEHAVIOR);
	}
	
	protected GameObject(String name, int collisionId, String gfxname){
		super(name, collisionId, gfxname);
	}
	
	public void setDieBehavior(String s){
		myDieString = s;
	}
	
	public void die(){
		try{
			Object dieBehavior = Reflection.createInstance(myDieWays.getString(myDieString), this);
			Reflection.callMethod(dieBehavior, "remove");	
		} catch (Exception e){
			e.printStackTrace();
		}
	}
}

@@ -84,52 +84,8 @@
 on;%0A
-import util.reflection.ReflectionException;%0A
 impo
@@ -357,22 +357,24 @@
 undle my
-DieWay
+Behavior
 s;%0A%09prot
@@ -383,33 +383,26 @@
 ted 
-ResourceBundle myMoveWays
+String myDieString
 ;%0A%09p
@@ -411,34 +411,35 @@
 tected String my
-Di
+Mov
 eString;%0A%0A%09prote
@@ -575,22 +575,24 @@
 ()%7B%0A%09%09my
-DieWay
+Behavior
 s = Reso
@@ -833,24 +833,89 @@
 g = s;%0A%09%7D%0A%09%0A
+%09public void setMoveBehavior(String s)%7B%0A%09%09myMoveString = s;%0A%09%7D%0A%09%0A
 %09public void
@@ -985,14 +985,16 @@
 e(my
-DieWay
+Behavior
 s.ge
@@ -1128,10 +1128,251 @@
 %0A%09%09%7D%0A%09%7D%0A
+%09%0A%09@Override%0A%09public void move()%7B%0A%09%09try%7B%0A%09%09%09Object moveBehavior = Reflection.createInstance(myBehaviors.getString(myMoveString), this);%0A%09%09%09Reflection.callMethod(moveBehavior, %22move%22);%09%0A%09%09%7D catch (Exception e)%7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%7D%0A
 %7D%0A

use Reflection for Move