void CreateWallInNode(int posX, int posZ, Level_WallObj.WallDirection direction) { Node getNode = gridBase.grid[posX, posZ]; Vector3 wallPosition = getNode.vis.transform.position; if (getNode.wallObj == null) { GameObject actualObjPlaced = Instantiate(wallPrefab, wallPosition, Quaternion.identity) as GameObject; Level_Object placedObjProperties = actualObjPlaced.GetComponent <Level_Object>(); Level_WallObj placedWallProperties = actualObjPlaced.GetComponent <Level_WallObj>(); placedObjProperties.gridPosX = posX; placedObjProperties.gridPosZ = posZ; manager.inSceneWalls.Add(actualObjPlaced); getNode.wallObj = placedWallProperties; UpdateWallNode(getNode, direction); } else { UpdateWallNode(getNode, direction); } UpdateWallCorners(getNode, false, false, false); }
void PlaceObject() { if (hasObj) { UpdateMousePosition(); Node curNode = gridBase.NodeFromWorldPosition(mousePosition); worldPosition = curNode.vis.transform.position; if (cloneObj == null) { cloneObj = Instantiate(objToPlace, worldPosition, Quaternion.identity) as GameObject; objProperties = cloneObj.GetComponent <Level_Object>(); } else { cloneObj.transform.position = worldPosition; if (Input.GetMouseButton(0) && !ui.mouseOverUIElement) { if (curNode.placeObj != null) { manager.inSceneGameObjects.Remove(curNode.placeObj.gameObject); Destroy(curNode.placeObj.gameObject); curNode.placeObj = null; } GameObject actualObjPlaced = Instantiate(objToPlace, worldPosition, cloneObj.transform.rotation) as GameObject; actualObjPlaced.transform.parent = GameObject.Find("room").transform; Level_Object placedObjProperties = actualObjPlaced.GetComponent <Level_Object>(); curNode.placeObj = placedObjProperties; placedObjProperties.gridPosX = curNode.nodePosX; placedObjProperties.gridPosY = curNode.nodePosY; manager.inSceneGameObjects.Add(actualObjPlaced); } if (Input.GetMouseButton(1)) { objProperties.ChangeRotation(); } } } else { if (cloneObj != null) { Destroy(cloneObj); } } }
void PlaceStackObj() { if (placeStackObj) { UpdateMousePosition(); Node curNode = gridBase.NodeFromWorldPosition(mousePosition); worldPosition = curNode.vis.transform.position; if (stackCloneObj == null) { stackCloneObj = Instantiate(stackObjToPlace, worldPosition, Quaternion.identity) as GameObject; stackObjProperties = stackCloneObj.GetComponent <Level_Object>(); } else { stackCloneObj.transform.position = worldPosition; if (Input.GetMouseButtonUp(0) && !ui.mouseOverUIElement) { GameObject actualObjPlaced = Instantiate(stackObjToPlace, worldPosition, stackCloneObj.transform.rotation) as GameObject; Level_Object placedObjProperties = actualObjPlaced.GetComponent <Level_Object>(); placedObjProperties.gridPosX = curNode.nodePosX; placedObjProperties.gridPosY = curNode.nodePosY; curNode.stackedObjs.Add(placedObjProperties); manager.inSceneStackObjects.Add(actualObjPlaced); } if (Input.GetMouseButtonUp(1)) { stackObjProperties.ChangeRotation(); } } } else { if (stackCloneObj != null) { Destroy(stackCloneObj); } } }