public List <Vector3Int> FindPipeDirections() { var pipeDir = searchCenter.transform.Find("Pipe"); PipeRotater d = pipeDir.GetComponent <PipeRotater>(); var gate = d.pipeGates; directions.Clear(); if (gate[0] == '1') { directions.Add(Vector3Int.up); } if (gate[1] == '1') { directions.Add(Vector3Int.right); } if (gate[2] == '1') { directions.Add(Vector3Int.down); } if (gate[3] == '1') { directions.Add(Vector3Int.left); } return(directions); }
private static void RotateSelected() { var hey = Selection.activeTransform.gameObject; PipeRotater pipeRotater = hey.transform.Find("Pipe").GetComponent <PipeRotater>(); //var pipeDirection = pipeRotater.strDirection; if (pipeRotater.strDirection == "up") { pipeRotater.strDirection = "right"; } else if (pipeRotater.strDirection == "right") { pipeRotater.strDirection = "down"; } else if (pipeRotater.strDirection == "down") { pipeRotater.strDirection = "left"; } else if (pipeRotater.strDirection == "left") { pipeRotater.strDirection = "up"; } hey.transform.Find("Pipe").rotation *= Quaternion.Euler(0.0f, 0.0f, -90.0f); //Debug.Log(hey.name); }
void InstantiatePipe(string pipeType) { string path = $"Assets/Prefabs/{pipeType}.prefab"; GameObject gameObject = (GameObject)AssetDatabase.LoadAssetAtPath(path, typeof(GameObject)); GameObject pipe = Instantiate(gameObject); pipe.transform.parent = GameObject.Find("World").transform; pipe.transform.position = new Vector3(-6, 1, 0); index = Random.Range(0, zIndex.Length); Debug.Log(zIndex[index]); pipe.transform.Find("Pipe").rotation = Quaternion.Euler(0, 0, zIndex[index]); PipeRotater pipeRotater = pipe.transform.Find("Pipe").GetComponent <PipeRotater>(); pipeRotater.strDirection = directions[index]; }
public List <Vector3Int> FindPipeDirectionsBackwards() { directionsBack.Clear(); if (backSearch == endWaypoint) { directionsBack.Add(Vector3Int.up); directionsBack.Add(Vector3Int.right); directionsBack.Add(Vector3Int.down); directionsBack.Add(Vector3Int.left); } else { var pipeDir = backSearch.transform.Find("Pipe"); PipeRotater d = pipeDir.GetComponent <PipeRotater>(); var gate = d.pipeGates; if (gate[0] == '1') { directionsBack.Add(Vector3Int.up); } if (gate[1] == '1') { directionsBack.Add(Vector3Int.right); } if (gate[2] == '1') { directionsBack.Add(Vector3Int.down); } if (gate[3] == '1') { directionsBack.Add(Vector3Int.left); } } return(directionsBack); }