Ejemplo n.º 1
0
    /// <summary>
    /// Called from LevelController by each hex, instantiates an object at corresponding position
    /// </summary>
    /// <param name="cell"></param>
    public void addCellToUIMap(UICell cell)
    {
        //Create a new GameObject to represent a location in the world
        GameObject newHologramCell = (GameObject)Instantiate(uiGridPrefab, cell.centerPos, transform.rotation);

        cell.setGameObject(newHologramCell);
        newHologramCell.GetComponent <UICellObj>().parent = cell;
        newHologramCell.GetComponent <UICellObj>().q      = cell.q;
        newHologramCell.GetComponent <UICellObj>().r      = cell.r;
        newHologramCell.GetComponent <UICellObj>().h      = cell.h;
        //Put the cell into the UIGrid
        uiGrid[cell.q, cell.r, cell.h] = cell;
        //Set the game object's parent transform for scaling/rotation purposes.
        newHologramCell.transform.SetParent(gameObject.transform);
    }