public static GameObject generateObject(string objectName, string spriteName, TypeTerrain tTerrain = null, componentMapObject parent = null, Dictionary<string, List<NotifyBehaviorMapObject>> notifyBehaviors = null, Notifier notify = null)
    {
        GameObject playerObject = new GameObject(objectName);

        attachNewComponent(playerObject, spriteName, tTerrain, parent, notifyBehaviors, notify);

        return playerObject;
    }
    public static GameObject generateObject(string objectName, string spriteName = null, TypeTerrain tTerrain = null, componentMapObject parent = null, Dictionary<string, List<NotifyBehaviorMapObject>> notifyBehaviors = null, Notifier notify = null)
    {
        GameObject tileObject = new GameObject(objectName);

        componentMapObject cTile = tileObject.AddComponent<componentTile>();
        initializeComponent(cTile, spriteName, tTerrain, parent, notifyBehaviors, notify);

        return tileObject;
    }
    /// <summary>
    /// Creates a new unit's GameObject and attaches appropriate components.
    /// </summary>
    /// <param name="unitName">The Unit's name (Not the game object's name). If this is null it will get it from the stat template</param>
    /// <param name="stats">The stat template</param>
    /// <param name="owner">This will need to change, it is unused at the current moment.</param>
    /// <param name="objectName">The GameObject's name</param>
    /// <param name="spriteName">The sprite's name</param>
    /// <param name="tTerrain">The typeTerrain of the unit (Typically this should be unpassable... because it's a unit)</param>
    /// <param name="mapObjectParent">The map object's parent object</param>
    /// <returns>The newly created GameObject with attached components</returns>
    public static GameObject createUnit(string unitName, IUnitStatTemplate stats, int owner, string objectName, string spriteName, TypeTerrain tTerrain = null, componentMapObject mapObjectParent = null)
    {
        //TODO: Change owner to a pointer to a player or controller data structure. not enitrely sure how I want to handle that yet.
        GameObject objUnit = new GameObject(objectName);

        componentUnitMapObject.attachNewComponent(objUnit, spriteName, tTerrain, mapObjectParent);
        componentUnit.attachNewComponent(objUnit, unitName, stats, owner);

        return objUnit;
    }
    //Final stop for addMapObject
    public componentMapObject addMapObject(int x, int y, componentMapObject cMapObject)
    {
        //Debug.Log(x + "," + y);
        _objects.Add(cMapObject);
        _objectMap[x, y].Add(cMapObject);
        _objectLocations[cMapObject] = new Vector2();

        if (cMapObject.gameObject != null)
        {
            cMapObject.gameObject.transform.parent = gameObject.transform;
            setGameObjectLocation(x, y, cMapObject.gameObject);
        }

        return cMapObject;
    }
 private static void initializeComponent(componentMapObject cTile, string spriteName, TypeTerrain tTerrain = null, componentMapObject parent = null, Dictionary<string, List<NotifyBehaviorMapObject>> notifyBehaviors = null, Notifier notify = null)
 {
     cTile.setParent(parent);
     cTile.setSprite(spriteName);
     cTile.setTypeTerrain(tTerrain);
     cTile.setRenderSortingLayer(RENDER_SORTING_LAYER);
     cTile.init();
     if(notifyBehaviors != null)
     {
         foreach(string key in notifyBehaviors.Keys)
         {
             foreach(NotifyBehaviorMapObject behavior in notifyBehaviors[key])
             {
                 cTile.addNotifyBehavior(key, new NotifyBehaviorMapObject(behavior));
             }
         }
     }
     cTile.setNotifier(notify);
 }
    public static GameObject attachNewComponent(GameObject attachingTo, string spriteName, TypeTerrain tTerrain = null, componentMapObject parent = null, Dictionary<string, List<NotifyBehaviorMapObject>> notifyBehaviors = null, Notifier notify = null)
    {
        componentMapObject cMapObject = attachingTo.AddComponent<componentUnitMapObject>();
        cMapObject.setParent(parent);
        cMapObject.setSprite(spriteName);
        cMapObject.setTypeTerrain(tTerrain);
        cMapObject.setRenderSortingLayer("gamePieces");
        cMapObject.init();
        if (notifyBehaviors != null)
        {
            foreach (string key in notifyBehaviors.Keys)
            {
                foreach (NotifyBehaviorMapObject behavior in notifyBehaviors[key])
                {
                    cMapObject.addNotifyBehavior(key, new NotifyBehaviorMapObject(behavior));
                }
            }
        }
        cMapObject.setNotifier(notify);

        return attachingTo;
    }
    public static GameObject generateObject(string objectName, string spriteName, TypeTerrain tTerrain = null, componentMapObject parent = null, Dictionary<string, List<NotifyBehaviorMapObject>> notifyBehaviors = null, Notifier notify = null)
    {
        GameObject tileObject = new GameObject(objectName);

        componentMapObject cMapObject = tileObject.AddComponent<componentTestObject>();
        cMapObject.setParent(parent);
        cMapObject.setSprite(spriteName);
        cMapObject.setTypeTerrain(tTerrain);
        cMapObject.setRenderSortingLayer("gameAbovePieces");
        cMapObject.init();
        if (notifyBehaviors != null)
        {
            foreach (string key in notifyBehaviors.Keys)
            {
                foreach (NotifyBehaviorMapObject behavior in notifyBehaviors[key])
                {
                    cMapObject.addNotifyBehavior(key, new NotifyBehaviorMapObject(behavior));
                }
            }
        }
        cMapObject.setNotifier(notify);

        return tileObject;
    }
    /**
     * A dedicated function to create the game object and tile component from it's parts.
     * Note: There isn't a way to externally create components.
     * @param x refers to the grid location
     * @param y refers to the grid location
     * @param spriteName refers to the sprite name
     * @param tTerrain refers to the type of terrain
     * @param parent refers to who the parent of the tile is
     */
    public GameObject addTile(int x, int y, string spriteName, TypeTerrain tTerrain, componentMapObject parent = null)
    {
        GameObject tileObject = componentTile.generateObject(TILE_OBJECT_NAME + " (" + x + "," + y + ")", spriteName, tTerrain, parent);

        addMapObject(x, y, tileObject);

        return tileObject;
    }
    private void setGameObjectLocation(int x, int y, componentMapObject cMapObject)
    {
        if(cMapObject.gameObject == null)
        {
            Debug.Log("You cannot set the location of an object that has no game object.");
            return;
        }

        setGameObjectLocation(x, y, cMapObject.gameObject);
    }
    public void moveMapObject(int x, int y, componentMapObject cMapObject, bool instant = true)
    {
        if(_objects.Contains(cMapObject) == false)
        {
            Debug.Log("The map object you are trying to move was not properly added to the map.");
            return;
        }

        int oldX = (int)_objectLocations[cMapObject].x;
        int oldY = (int)_objectLocations[cMapObject].y;
        _objectMap[oldX, oldY].Remove(cMapObject);

        if (instant == true)
        {
            setGameObjectLocation(x, y, cMapObject);
            reorderLocation(oldX, oldY);
        }
        else
        {
            //TODO: This animation section.
            //ANIMATING STUFF GOES HERE, how to determine layer sorting order gets significantly more tricky.
        }
    }
 public Vector2 getObjectLocation(componentMapObject mapObject)
 {
     return _objectLocations[mapObject];
 }
 public void execute(componentMapObject actor, TriggeredEvent tEvent)
 {
     Debug.Log("Executing Triggered Behavior!!!");
 }
 public void setParent(componentMapObject value)
 {
     _parent = value;
 }
 public void execute(componentMapObject actor, Notification note)
 {
     Debug.Log("Executing Notify Behavior!!!");
 }