/// <summary> /// Main constructor for gridnodes /// Takes in the gridnodes location and gridnode prefab object /// </summary> public GridNode(Vector3 pos, GameObject gridNodePrefab, float spacing) { myGridController = GameObject.FindWithTag("gameControllers").GetComponent <gridController>(); position = pos; gridNodeObject = MonoBehaviour.Instantiate(gridNodePrefab, position, Quaternion.identity); gridNodeObject.transform.parent = myGridController.transform; Debug.Log("gridSpacing: " + spacing); gridNodeObject.transform.localScale = new Vector3(defaultGridSize * spacing, defaultGridSize * spacing, defaultGridSize * spacing); // change its local scale in x y z format frameHighlighter = gridNodeObject.GetComponent <highlighter>(); gridNodeObject.GetComponent <GridNodeBehavior>().setMyGridNode(this); }
/// <summary> /// Main constructor for defining a frame object /// Takes in the frames endpoints, the correct frame prefab for the section, the frame section, and the frames name /// </summary> public Frame(Vector3 start, Vector3 end, GameObject framePrefab, FrameSection section, string frameName) { sectionPropertyName = section.GetName(); frameObject = MonoBehaviour.Instantiate(framePrefab); trans = frameObject.transform; frameTrans = trans.Find("frame"); releaseStartTrans = trans.Find("startRelease"); releaseEndTrans = trans.Find("endRelease"); startPos = start; endPos = end; release = new FrameRelease(); setRelease(); frameObject.GetComponent <FrameBehavior>().setMyFrame(this); frameHighlighter = frameObject.GetComponent <highlighter>(); // scale the frame depending on the section type if (section.type == FrameSectionType.I) { frame_iBeamController controller = frameObject.GetComponent <frame_iBeamController>(); float[] arr = section.GetDimensions(); controller.SetDimensions(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]); } else if (section.type == FrameSectionType.Pipe) { frame_PipeController controller = frameObject.GetComponent <frame_PipeController>(); float[] arr = section.GetDimensions(); controller.SetDimensions(arr[0], arr[1]); } else if (section.type == FrameSectionType.Tube) { frame_TubeController controller = frameObject.GetComponent <frame_TubeController>(); float[] arr = section.GetDimensions(); controller.SetDimensions(arr[0], arr[1], arr[2], arr[3]); } else { Debug.LogError("Invalid frame section type passed to createFrame in Frame Class"); } setName(frameName); }