Exemplo n.º 1
0
 public void DeleteCellObject(Vector2Int objKey)
 {
     if (this.gridObjects.ContainsKey(objKey))
     {
         AbstractCellObject go = this.gridObjects[objKey];
         this.gridObjects.Remove(objKey);
         go.DeleteSelf(this);
     }
 }
Exemplo n.º 2
0
    public AbstractCellObject CreateCellObject(Vector2Int objCoords, AbstractCellObject prefab)
    {
        Vector2 objPos = gSpace.CoordsToGPos(objCoords);

        if (!gridObjects.ContainsKey(objCoords))
        {
            AbstractCellObject obj = Object.Instantiate(prefab.gameObject, objPos, Quaternion.identity, this.transform).GetComponent <AbstractCellObject>();
            gridObjects.Add(objCoords, obj);
            return(obj);
        }
        else
        {
            Debug.Log("WARNING (CreateCellObject): Object already exists at grid coordinates: " + objCoords);
            return(null);
        }
    }
Exemplo n.º 3
0
    /**
     * Makes a copy of prefab on the grid at the screen pos. Should only be called if no object exists at screenPos.
     */
    public AbstractCellObject CreateCellObject(Vector3 screenPos, AbstractCellObject prefab)
    {
        Vector2Int objCoords = gSpace.SSToCoords(screenPos);

        return(CreateCellObject(objCoords, prefab));
    }