Example #1
0
    public void setParent()
    {
        MapManager man = MapManager.manager;
        GameObject map = man.Map;

        //transform.parent = map.transform.GetChild(2);
        if (voxel == null)
        {
            voxel = man.voxels[layer][colID];
        }

        setTransform();

        if (voxel.mainAsset != null && voxel.mainAsset != this && (type.Equals(Type.MAIN) || type.Equals(Type.ALTAR)))
        {
            //Debug.Log("removing duplicate tree");
            NetworkServer.Destroy(gameObject);
            return;
        }
        if (type.Equals(Type.MAIN) || type.Equals(Type.ALTAR))
        {
            voxel.mainAsset = this;
        }
        //changeParent(voxel.gameObject.transform);
        changeParent(MapManager.manager.Map.transform.GetChild(3));

        if (voxel.Equals(MapManager.DeletedVoxel))
        {
            //Debug.Log("removing straggler tree");
            NetworkServer.Destroy(gameObject);
        }

        ready = true;

        if (type.Equals(Type.MAIN))
        {
            //Debug.Log("main asset final pos: " + transform.position );
        }
    }