public void createB1p3() { if (!partCreated[2]) { clearPartsCreated(); Vector3 pos = offscreenCreateLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(0, 90, 270); GameObject newB1p3 = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[2], pos, fuseToRotation))); StartCoroutine(moveToStartingPosition(newB1p3)); // this creates the zooming up from the ground effect Transform b1p3 = newB1p3.transform.Find("b1p3"); Transform b1p3_bb1_a1 = newB1p3.transform.Find("b1p3_bb1_a1"); b1p3.GetComponent <Tooltip>().enabled = true; b1p3_bb1_a1.GetComponent <Tooltip>().enabled = true; FuseAttributes fuseAtts = b1p3Fuses(); b1p3_bb1_a1.gameObject.AddComponent <FuseBehavior>(); b1p3_bb1_a1.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); b1p3_bb1_a1.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("B1p3")); b1p3_bb1_a1.gameObject.AddComponent <FaceSelector>(); b1p3_bb1_a1.gameObject.GetComponent <FaceSelector>().setSelectPartScript(GameObject.Find("EventSystem").GetComponent <SelectPart>()); b1p3_bb1_a1.gameObject.GetComponent <FaceSelector>().setFuseButton(GameObject.Find("FuseButton").GetComponent <Button>()); b1p3_bb1_a1.gameObject.GetComponent <FaceSelector>().selectedNormal = Vector3.down; instantiated[2] = newB1p3; partCreated[2] = true; partButtons[2].interactable = false; selectionManager.newPartCreated("b1p3Prefab(Clone)"); } }
public void createConnector() { if (!partCreated[1]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = new Quaternion(); GameObject newConnector = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[1], pos, fuseToRotation))); Transform backLeftCoverAttach = newConnector.transform.FindChild("connector_corner_attach"); Transform backRightCoverAttach = newConnector.transform.FindChild("connector_diagonal_side_attach"); Transform backBridgeAttach = newConnector.transform.FindChild("connector_diagonal_top_attach"); FuseAttributes fuseAtts = connectorFuses(); backLeftCoverAttach.gameObject.AddComponent <FuseBehavior>(); backLeftCoverAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); backLeftCoverAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Connector")); backRightCoverAttach.gameObject.AddComponent <FuseBehavior>(); backRightCoverAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); backRightCoverAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Connector")); backBridgeAttach.gameObject.AddComponent <FuseBehavior>(); backBridgeAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); backBridgeAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Connector")); instantiated[1] = newConnector; partCreated[1] = true; selectionManager.newPartCreated("connectorPrefab(Clone)"); enableManipulationButtons(newConnector); } }
public void createDiagonal() { if (!partCreated[4]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = new Quaternion(); GameObject newDiagonal = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[4], pos, fuseToRotation))); Transform diagonalConnectorSideAttach = newDiagonal.transform.FindChild("diagonal_connector_side_attach"); Transform diagonalConnectorTopAttach = newDiagonal.transform.FindChild("diagonal_connector_top_attach"); FuseAttributes fuseAtts = diagonalFuses(); diagonalConnectorSideAttach.gameObject.AddComponent <FuseBehavior>(); diagonalConnectorSideAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); diagonalConnectorSideAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Diagonal")); diagonalConnectorTopAttach.gameObject.AddComponent <FuseBehavior>(); diagonalConnectorTopAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); diagonalConnectorTopAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Diagonal")); instantiated[4] = newDiagonal; partCreated[4] = true; selectionManager.newPartCreated("diagonalPrefab(Clone)"); enableManipulationButtons(newDiagonal); } }
public void createSpike() { if (!partCreated[6]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(0, 90, 270); GameObject newSpike = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[6], pos, fuseToRotation))); Transform spikeShaftAttach = newSpike.transform.Find("spike_shaft_attach"); FuseAttributes fuseAtts = spikeFuses(); spikeShaftAttach.gameObject.AddComponent <FuseBehavior>(); spikeShaftAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); spikeShaftAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Spike")); instantiated[6] = newSpike; partCreated[6] = true; partButtons[6].interactable = false; selectionManager.newPartCreated("spikePrefab(Clone)"); enableManipulationButtons(newSpike); } }
public void createTopPointRight() { if (!partCreated[9]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(90, 90, 0); GameObject newTopPointRight = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[9], pos, fuseToRotation))); Transform topPointRightHeadAttach = newTopPointRight.transform.Find("top_point_right_head_attach"); Transform topPointRightLeftAttach = newTopPointRight.transform.Find("top_point_right_left_attach"); FuseAttributes fuseAtts = topPointRightFuses(); topPointRightHeadAttach.gameObject.AddComponent <FuseBehavior>(); topPointRightHeadAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); topPointRightHeadAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("TopPointRight")); topPointRightLeftAttach.gameObject.AddComponent <FuseBehavior>(); topPointRightLeftAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); topPointRightLeftAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("TopPointRight")); instantiated[9] = newTopPointRight; partCreated[9] = true; partButtons[9].interactable = false; selectionManager.newPartCreated("top_point_rightPrefab(Clone)"); enableManipulationButtons(newTopPointRight); } }
public void createCone() { if (!partCreated[2]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(0, 90, 90); GameObject newCone = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[2], pos, fuseToRotation))); Transform coneBoxAttach = newCone.transform.Find("cone_box_attach"); FuseAttributes fuseAtts = coneFuses(); coneBoxAttach.gameObject.AddComponent <FuseBehavior>(); coneBoxAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); coneBoxAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Cone")); instantiated[2] = newCone; partCreated[2] = true; selectionManager.newPartCreated("tutorial1_conePrefab(Clone)"); enableManipulationButtons(newCone); } }
public void createBottomPoint() { if (!partCreated[3]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = new Quaternion(); GameObject newBottomPoint = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[3], pos, fuseToRotation))); Transform bottomPointHeadAttach = newBottomPoint.transform.Find("bottom_point_head_attach"); //fixes off center problem //generatorStrutLeftAttach.transform.localPosition = new Vector3(0, 0, 0); //generatorStrutRightAttach.transform.localPosition = new Vector3(0, 0, 0); //generatorStrutTopAttach.transform.localPosition = new Vector3(0, 0, 0); FuseAttributes fuseAtts = bottomPointFuses(); bottomPointHeadAttach.gameObject.AddComponent <FuseBehavior>(); bottomPointHeadAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); bottomPointHeadAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("BottomPoint")); instantiated[3] = newBottomPoint; partCreated[3] = true; selectionManager.newPartCreated("bottom_pointPrefab(Clone)"); enableManipulationButtons(newBottomPoint); } }
public void createBody() { if (!partCreated[0]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = new Quaternion(); GameObject newBody = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[0], pos, fuseToRotation))); Transform bodyTopAttach = newBody.transform.Find("Body_Top_Attach"); Transform bodySideAttach = newBody.transform.Find("Body_Side_Attach"); Transform bodyBottomAttach = newBody.transform.Find("Body_Bottom_Attach"); FuseAttributes fuseAtts = bodyFuses(); bodyTopAttach.gameObject.AddComponent <FuseBehavior>(); bodyTopAttach.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); bodyTopAttach.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Body")); bodySideAttach.gameObject.AddComponent <FuseBehavior>(); bodySideAttach.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); bodySideAttach.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Body")); bodyBottomAttach.gameObject.AddComponent <FuseBehavior>(); bodyBottomAttach.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); bodyBottomAttach.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Body")); instantiated[0] = newBody; partCreated[0] = true; selectionManager.newPartCreated("BodyPrefab(Clone)"); enableManipulationButtons(newBody); } }
public void createCalf() { if (!partCreated[1]) { clearPartsCreated(); Vector3 pos = new Vector3(-30, 25, 140); // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(0, 0, 90); GameObject newCalf = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[1], pos, fuseToRotation))); Transform calfTopAttach = newCalf.transform.Find("Calf_Top_Attach"); Transform calfBottomAttach = newCalf.transform.Find("Calf_Bottom_Attach"); FuseAttributes fuseAtts = calfFuses(); calfTopAttach.gameObject.AddComponent <FuseBehavior>(); calfTopAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); calfTopAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Calf")); calfBottomAttach.gameObject.AddComponent <FuseBehavior>(); calfBottomAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); calfBottomAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Calf")); instantiated[1] = newCalf; partCreated[1] = true; selectionManager.newPartCreated("calfPrefab(Clone)"); enableManipulationButtons(newCalf); } }
public void createBack() { if (!partCreated[1]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(0, 180, 0); GameObject newBack = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[1], pos, fuseToRotation))); Transform backLeftCoverAttach = newBack.transform.Find("back_left_cover_attach"); Transform backRightCoverAttach = newBack.transform.Find("back_right_cover_attach"); Transform backBridgeAttach = newBack.transform.Find("back_bridge_attach"); FuseAttributes fuseAtts = backFuses(); backLeftCoverAttach.gameObject.AddComponent <FuseBehavior>(); backLeftCoverAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); backLeftCoverAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Back")); backRightCoverAttach.gameObject.AddComponent <FuseBehavior>(); backRightCoverAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); backRightCoverAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Back")); backBridgeAttach.gameObject.AddComponent <FuseBehavior>(); backBridgeAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); backBridgeAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Back")); instantiated[1] = newBack; partCreated[1] = true; selectionManager.newPartCreated("backPrefab(Clone)"); enableManipulationButtons(newBack); } }
public void createRightCover() { if (!partCreated[4]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(0, 0, 90); GameObject newRightCover = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[4], pos, fuseToRotation))); Transform rightCoverBackAttach = newRightCover.transform.Find("right_cover_back_attach"); Transform rightCoverBackSlopeAttach = newRightCover.transform.Find("right_cover_back_slope_attach"); FuseAttributes fuseAtts = rightCoverFuses(); rightCoverBackAttach.gameObject.AddComponent <FuseBehavior>(); rightCoverBackAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); rightCoverBackAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("RightCover")); rightCoverBackSlopeAttach.gameObject.AddComponent <FuseBehavior>(); rightCoverBackSlopeAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); rightCoverBackSlopeAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("RightCover")); instantiated[4] = newRightCover; partCreated[4] = true; selectionManager.newPartCreated("right_coverPrefab(Clone)"); enableManipulationButtons(newRightCover); } }
public void SpawnGhost() { // Transforms. instance = new GameObject(); instance.transform.position = transform.position; instance.transform.localScale = /*10 */ transform.parent.localScale.x * transform.localScale; instance.transform.rotation = transform.rotation; //instance.transform.parent = transform.parent; LoadUtils.InstantiateParenter(instance); instance.layer = 2; // Add mesh filter and renderer MeshFilter meshf = instance.AddComponent <MeshFilter>(); meshf.mesh = GetComponent <MeshFilter>().mesh; MeshRenderer meshr = instance.AddComponent <MeshRenderer>(); meshr.material = Resources.Load("Opacity") as Material; // Add ghost script. SelectedGhost ghost = instance.AddComponent <SelectedGhost>(); ghost.hitInfo = hitInfo; }
public void createLeftSupport() { if (!partCreated[5]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(0, 0, 90); GameObject newLeftSupport = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[5], pos, fuseToRotation))); Transform leftSupportAxleAttach = newLeftSupport.transform.FindChild("left_support_axle_attach"); Transform leftSupportPlatformAttach = newLeftSupport.transform.FindChild("left_support_platform_attach"); FuseAttributes fuseAtts = leftSupportFuses(); leftSupportAxleAttach.gameObject.AddComponent <FuseBehavior>(); leftSupportAxleAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); leftSupportAxleAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("LeftSupport")); leftSupportPlatformAttach.gameObject.AddComponent <FuseBehavior>(); leftSupportPlatformAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); leftSupportPlatformAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("LeftSupport")); instantiated[5] = newLeftSupport; partCreated[5] = true; selectionManager.newPartCreated("left_support_completePrefab(Clone)"); enableManipulationButtons(newLeftSupport); } }
public void createThrowingArm() { if (!partCreated[1]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(0, 270, 0); GameObject newThrowingArm = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[1], pos, fuseToRotation))); Transform throwingArmAxleLeftAttach = newThrowingArm.transform.FindChild("throwing_arm_axle_left_attach"); Transform throwingArmAxleRightAttach = newThrowingArm.transform.FindChild("throwing_arm_axle_right_attach"); Transform throwingArmAxleBottomAttach = newThrowingArm.transform.FindChild("throwing_arm_axle_bottom_attach"); FuseAttributes fuseAtts = throwingArmFuses(); throwingArmAxleLeftAttach.gameObject.AddComponent <FuseBehavior>(); throwingArmAxleLeftAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); throwingArmAxleLeftAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("ThrowingArm")); throwingArmAxleRightAttach.gameObject.AddComponent <FuseBehavior>(); throwingArmAxleRightAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); throwingArmAxleRightAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("ThrowingArm")); throwingArmAxleBottomAttach.gameObject.AddComponent <FuseBehavior>(); throwingArmAxleBottomAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); throwingArmAxleBottomAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("ThrowingArm")); instantiated[1] = newThrowingArm; partCreated[1] = true; selectionManager.newPartCreated("throwing_arm_completePrefab(Clone)"); enableManipulationButtons(newThrowingArm); } }
public void createLeftVestOval() { if (!partCreated[2]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(0, 270, 0); GameObject newBackSlope = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[2], pos, fuseToRotation))); Transform leftVestOvalVestDiamondAttach = newBackSlope.transform.FindChild("left_vest_oval_vest_diamond_attach"); //fixes off center rotation problem //strutTopBodyAttach.transform.localPosition = new Vector3(0, 0, 0); //strutTopGeneratorAttach.transform.localPosition = new Vector3(0.08f, 0, -0.72f); //strutTopPointyAttach.transform.localPosition = new Vector3(0, 0, 0); FuseAttributes fuseAtts = leftVestOvalFuses(); leftVestOvalVestDiamondAttach.gameObject.AddComponent <FuseBehavior>(); leftVestOvalVestDiamondAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); leftVestOvalVestDiamondAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("LeftOval")); instantiated[2] = newBackSlope; partCreated[2] = true; selectionManager.newPartCreated("left_vest_ovalPrefab(Clone)"); enableManipulationButtons(newBackSlope); } }
public void createToeSole() { if (!partCreated[6]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = new Quaternion(); GameObject newToeSole = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[6], pos, fuseToRotation))); Transform toeSoleTopAttach = newToeSole.transform.Find("Sole_Toe_Top_Attach"); Transform toeSoleSideAttach = newToeSole.transform.Find("Sole_Toe_Side_Attach"); FuseAttributes fuseAtts = toeSoleFuses(); toeSoleTopAttach.gameObject.AddComponent <FuseBehavior>(); toeSoleTopAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); toeSoleTopAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("ToeSole")); toeSoleSideAttach.gameObject.AddComponent <FuseBehavior>(); toeSoleSideAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); toeSoleSideAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("ToeSole")); instantiated[6] = newToeSole; partCreated[6] = true; selectionManager.newPartCreated("ToeSolePrefab(Clone)"); enableManipulationButtons(newToeSole); } }
public void createVestOval() { if (!partCreated[3]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(180, 0, 0); GameObject newRightCover = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[3], pos, fuseToRotation))); Transform vestOvalVestDiamondAttach = newRightCover.transform.FindChild("vest_oval_vest_diamond_attach"); FuseAttributes fuseAtts = vestOvalFuses(); vestOvalVestDiamondAttach.gameObject.AddComponent <FuseBehavior>(); vestOvalVestDiamondAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); vestOvalVestDiamondAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Oval")); instantiated[3] = newRightCover; partCreated[3] = true; selectionManager.newPartCreated("vest_ovalPrefab(Clone)"); enableManipulationButtons(newRightCover); } }
public void createTrim() { if (!partCreated[4]) { clearPartsCreated(); Vector3 pos = offscreenCreateLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(270, 270, 0); GameObject newTrim = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[4], pos, fuseToRotation))); StartCoroutine(moveToStartingPosition(newTrim)); // this creates the zooming up from the ground effect Transform trimCalfAttach = newTrim.transform.Find("trim_calf_attach"); FuseAttributes fuseAtts = trimFuses(); // trim_calf_attach trimCalfAttach.gameObject.AddComponent <FuseBehavior>(); trimCalfAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); trimCalfAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Trim")); trimCalfAttach.gameObject.AddComponent <FaceSelector>(); trimCalfAttach.gameObject.GetComponent <FaceSelector>().selectedNormal = Vector3.left; trimCalfAttach.gameObject.GetComponent <FaceSelector>().setSelectPartScript(GameObject.Find("EventSystem").GetComponent <SelectPart>()); trimCalfAttach.gameObject.GetComponent <FaceSelector>().setFuseButton(GameObject.Find("FuseButton").GetComponent <Button>()); instantiated[4] = newTrim; partCreated[4] = true; partButtons[4].interactable = false; selectionManager.newPartCreated("trim_harderPrefab(Clone)"); } }
public void createHead() { if (!partCreated[1]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = new Quaternion(); GameObject newHead = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[1], pos, fuseToRotation))); Transform headTrapezoidAttach = newHead.transform.Find("head_trapezoid_attach"); Transform headBottomPointAttach = newHead.transform.Find("head_bottom_point_attach"); Transform headTopPointAttach = newHead.transform.Find("head_top_point_attach"); FuseAttributes fuseAtts = headFuses(); headTrapezoidAttach.gameObject.AddComponent <FuseBehavior>(); headTrapezoidAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); headTrapezoidAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Head")); headBottomPointAttach.gameObject.AddComponent <FuseBehavior>(); headBottomPointAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); headBottomPointAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Head")); headTopPointAttach.gameObject.AddComponent <FuseBehavior>(); headTopPointAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); headTopPointAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Head")); instantiated[1] = newHead; partCreated[1] = true; selectionManager.newPartCreated("headPrefab(Clone)"); enableManipulationButtons(newHead); } }
public void SpawnGhost() { // Transforms. // will adding the name parameter help unity distinguish fuseTo ghosts from AC ghosts? We'll see! instance = new GameObject(this.name + "_ghost"); instance.transform.position = transform.position; instance.transform.localScale = /*10 */ transform.parent.localScale.x * transform.localScale; instance.transform.rotation = transform.rotation; LoadUtils.InstantiateParenter(instance); instance.layer = 2; // Add mesh filter and renderer MeshFilter meshf = instance.AddComponent <MeshFilter>(); meshf.mesh = GetComponent <MeshFilter>().mesh; MeshRenderer meshr = instance.AddComponent <MeshRenderer>(); meshr.material = Resources.Load("Opacity") as Material; // Add ghost script. SelectedGhost ghost = instance.AddComponent <SelectedGhost>(); //Vector3[] normals = GetComponent<MeshFilter>().mesh.normals; //ghost.setNormal(normals[0]); //ghost.setNormal(hitUpdate.normal); ghost.setNormal(gameObject.GetComponent <FaceSelector>().selectedNormal); }
//CHANGE these next 5 methods so that they refer to the 5 prefabs you made. This requires you to // change most of the variables and strings in each method. public void createBottomPointLeft() { if (!partCreated[0]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(0, 90, 0); GameObject newBottomPointLeft = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[0], pos, fuseToRotation))); GameObject bottomPointLeftHeadAttach = GameObject.Find("bottom_point_left_head_attach"); GameObject bottomPointLeftRightAttach = GameObject.Find("bottom_point_left_right_attach"); FuseAttributes fuseAtts = bottomPointLeftFuses(); bottomPointLeftHeadAttach.AddComponent <FuseBehavior>(); bottomPointLeftHeadAttach.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); bottomPointLeftHeadAttach.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("BottomPointLeft")); bottomPointLeftRightAttach.AddComponent <FuseBehavior>(); bottomPointLeftRightAttach.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); bottomPointLeftRightAttach.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("BottomPointLeft")); instantiated[0] = newBottomPointLeft; partCreated[0] = true; partButtons[0].interactable = false; selectionManager.newPartCreated("bottom_point_leftPrefab(Clone)"); enableManipulationButtons(newBottomPointLeft); } }
void BreakFX(GameObject toMimic) { // Get the Renderer for the object we're breaking so we can mimic its material. MeshRenderer meshr = toMimic.GetComponent <MeshRenderer>(); if (meshr == null) { Debug.Log("Didn't find a mesh on top level of object attempting to be broken."); return; } GameObject spawned = Resources.Load <GameObject>("Prefabs/DebrisBase"); for (int i = 0; i < 20; i++) { GameObject instance = LoadUtils.InstantiateParenter(Instantiate(spawned)); Rigidbody rb = instance.GetComponent <Rigidbody>(); MeshRenderer mr = instance.GetComponent <MeshRenderer>(); mr.material = meshr.material; Vector3 newPos = transform.position; newPos.y += 1f; instance.transform.position = newPos; instance.transform.localScale = new Vector3(Random.Range(0.5f, 4f), Random.Range(0.5f, 4f), Random.Range(0.5f, 4f)); rb.AddTorque(Random.Range(-10f, 10f), Random.Range(0f, 15f), Random.Range(-10f, 10f), ForceMode.Impulse); rb.AddForce(Random.Range(-10f, 10f), Random.Range(0f, 15f), Random.Range(-10f, 10f), ForceMode.Impulse); } }
public void createTip() { if (!partCreated[7]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(0, 180, 0); GameObject newTip = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[7], pos, fuseToRotation))); Transform tipHeadAttach = newTip.transform.Find("tip_head_attach"); FuseAttributes fuseAtts = tipFuses(); tipHeadAttach.gameObject.AddComponent <FuseBehavior>(); tipHeadAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); tipHeadAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Tip")); instantiated[7] = newTip; partCreated[7] = true; partButtons[7].interactable = false; selectionManager.newPartCreated("tipPrefab(Clone)"); enableManipulationButtons(newTip); } }
public void createUprightT() { if (!partCreated[1]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = new Quaternion(); GameObject newUprightT = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[1], pos, fuseToRotation))); Transform uprightTdanglyTAttach = newUprightT.transform.FindChild("upright_T_dangly_T_attach"); //fixes off center rotation problem //uprightTdanglyTAttach.transform.localPosition = new Vector3(0, 0, 0); FuseAttributes fuseAtts = uprightTFuses(); uprightTdanglyTAttach.gameObject.AddComponent <FuseBehavior>(); uprightTdanglyTAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); uprightTdanglyTAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("UprightT")); instantiated[1] = newUprightT; partCreated[1] = true; selectionManager.newPartCreated("uprightTPrefab(Clone)"); enableManipulationButtons(newUprightT); } }
public void createTrapezoid() { if (!partCreated[10]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(0, 90, 270); GameObject newTrapezoid = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[10], pos, fuseToRotation))); Transform trapezoidShaftAttach = newTrapezoid.transform.Find("trapezoid_shaft_attach"); Transform trapezoidHeadAttach = newTrapezoid.transform.Find("trapezoid_head_attach"); FuseAttributes fuseAtts = trapezoidFuses(); trapezoidShaftAttach.gameObject.AddComponent <FuseBehavior>(); trapezoidShaftAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); trapezoidShaftAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Trapezoid")); trapezoidHeadAttach.gameObject.AddComponent <FuseBehavior>(); trapezoidHeadAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); trapezoidHeadAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Trapezoid")); instantiated[10] = newTrapezoid; partCreated[10] = true; partButtons[10].interactable = false; selectionManager.newPartCreated("trapezoid_harderPrefab(Clone)"); enableManipulationButtons(newTrapezoid); } }
public void createUprightRect() { if (!partCreated[4]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = new Quaternion(); GameObject newUprightRect = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[4], pos, fuseToRotation))); Transform uprightRectWalkingPantsAttach = newUprightRect.transform.FindChild("upright_rect_walking_pants_attach"); //fixes off center rotation problem //bodyChild.transform.localPosition = new Vector3(0, 0, 0); //pointyStrutTopAttach.transform.localPosition = new Vector3(0, -1.35f, 0); //dec1.transform.localPosition = new Vector3(0.05f, 0, -1.52f); //dec2.transform.localPosition = new Vector3(0.7f, 0, -1.85f); FuseAttributes fuseAtts = uprightRectFuses(); uprightRectWalkingPantsAttach.gameObject.AddComponent <FuseBehavior>(); uprightRectWalkingPantsAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); uprightRectWalkingPantsAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("UprightRect")); instantiated[4] = newUprightRect; partCreated[4] = true; selectionManager.newPartCreated("upright_rectPrefab(Clone)"); enableManipulationButtons(newUprightRect); } }
public void createBigCorner() { if (!partCreated[2]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = new Quaternion(); GameObject newBigCorner = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[2], pos, fuseToRotation))); Transform bigCornerLongLAttach = newBigCorner.transform.FindChild("big_corner_long_l_attach"); //fixes off center rotation problem //strutTopBodyAttach.transform.localPosition = new Vector3(0, 0, 0); //strutTopGeneratorAttach.transform.localPosition = new Vector3(0.08f, 0, -0.72f); //strutTopPointyAttach.transform.localPosition = new Vector3(0, 0, 0); FuseAttributes fuseAtts = bigCornerFuses(); bigCornerLongLAttach.gameObject.AddComponent <FuseBehavior>(); bigCornerLongLAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); bigCornerLongLAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("BigCorner")); instantiated[2] = newBigCorner; partCreated[2] = true; selectionManager.newPartCreated("big_cornerPrefab(Clone)"); enableManipulationButtons(newBigCorner); } }
public void createBackStrap() { if (!partCreated[0]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(0, 270, 90); GameObject newBack = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[0], pos, fuseToRotation))); Transform backStrapShortBackStrapLongAttach = newBack.transform.FindChild("back_strap_short_back_strap_long_attach"); Transform backStrapRightStrapAttach = newBack.transform.FindChild("back_strap_right_strap_attach"); FuseAttributes fuseAtts = backStrapFuses(); backStrapShortBackStrapLongAttach.gameObject.AddComponent <FuseBehavior>(); backStrapShortBackStrapLongAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); backStrapShortBackStrapLongAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("BackStrap")); backStrapRightStrapAttach.gameObject.AddComponent <FuseBehavior>(); backStrapRightStrapAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); backStrapRightStrapAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("BackStrap")); instantiated[0] = newBack; partCreated[0] = true; selectionManager.newPartCreated("back_strapPrefab(Clone)"); enableManipulationButtons(newBack); } }
public void createHandle() { if (!partCreated[4]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(0, 90, 0); GameObject newHandle = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[4], pos, fuseToRotation))); Transform handleCenterBoxTopAttach = newHandle.transform.FindChild("handle_center_box_top_attach"); Transform handleCenterBoxBottomAttach = newHandle.transform.FindChild("handle_center_box_bottom_attach"); FuseAttributes fuseAtts = ffaHandleFuses(); handleCenterBoxTopAttach.gameObject.AddComponent <FuseBehavior>(); handleCenterBoxTopAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); handleCenterBoxTopAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Handle")); handleCenterBoxBottomAttach.gameObject.AddComponent <FuseBehavior>(); handleCenterBoxBottomAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); handleCenterBoxBottomAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Handle")); instantiated[4] = newHandle; partCreated[4] = true; selectionManager.newPartCreated("ffa_handlePrefab(Clone)"); enableManipulationButtons(newHandle); } }
public void createBigbox() { if (!partCreated[3]) { clearPartsCreated(); Vector3 pos = createLoc; // this is where the object will appear when it's instantiated Quaternion fuseToRotation = Quaternion.Euler(90, 0, 0); GameObject newBigbox = rotateGizmo.Enable(LoadUtils.InstantiateParenter((GameObject)Instantiate(parts[3], pos, fuseToRotation))); Transform bigboxLongboxAttach = newBigbox.transform.FindChild("bigbox_longbox_attach"); Transform bigboxSmallboxBlueAttach = newBigbox.transform.FindChild("bigbox_smallbox_blue_attach"); FuseAttributes fuseAtts = bigboxFuses(); bigboxLongboxAttach.gameObject.AddComponent <FuseBehavior>(); bigboxLongboxAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); bigboxLongboxAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Bigbox")); bigboxSmallboxBlueAttach.gameObject.AddComponent <FuseBehavior>(); bigboxSmallboxBlueAttach.gameObject.GetComponent <FuseBehavior>().setFuseTo(fuseAtts); bigboxSmallboxBlueAttach.gameObject.GetComponent <FuseBehavior>().setButtonTo(GameObject.Find("Bigbox")); instantiated[3] = newBigbox; partCreated[3] = true; selectionManager.newPartCreated("tutorial2_bigboxPrefab(Clone)"); enableManipulationButtons(newBigbox); } }