//Check if left Mouse-Button was pressed and handle it void CheckMouseButtons() { if (Input.GetMouseButtonDown(0)) { if (lastCollidedObject != null && lastCollidedObject.GetComponentInChildren <Connectable>() != null) { lastCollidedObject.GetComponentInChildren <Connectable>().addConnectedPart(this.movingObject.GetComponentInChildren <Rotatable>()); } if (lastCollidedObject != null && lastCollidedObject.GetComponentInChildren <Interlockable>() != null) { lastCollidedObject.GetComponentInChildren <Interlockable>().addInterlockingPart(this.movingObject.GetComponentInChildren <Interlockable>()); } string tagLayerName = "Cogwheel"; movingObject.gameObject.layer = LayerMask.NameToLayer(tagLayerName); //Set Layer for all children foreach (Transform t in movingObject.GetComponentsInChildren <Transform>()) { t.gameObject.layer = LayerMask.NameToLayer(tagLayerName); } movingObject.gameObject.tag = tagLayerName; //Create new CogwheelFact and add to global FactList int cogId = GameState.Facts.Count; float radius = movingObject.GetComponentInChildren <Cogwheel>().getRadius(); float insideRadius = movingObject.GetComponentInChildren <Cogwheel>().getInsideRadius(); float outsideRadius = movingObject.GetComponentInChildren <Cogwheel>().getOutsideRadius(); CogwheelFact newFact = new CogwheelFact(cogId, movingObject.transform.position, movingObject.transform.up, radius, insideRadius, outsideRadius); newFact.Representation = movingObject; GameState.Facts.Insert(cogId, newFact); UnityEngine.Debug.Log("Successfully added new CogwheelFact with backendUri: " + newFact.backendURI); Stop(); } }
public override bool Equals(System.Object obj) { //Check for null and compare run-time types. if ((obj == null) || !this.GetType().Equals(obj.GetType())) { return(false); } else { CogwheelFact p = (CogwheelFact)obj; return(this.Point.Equals(p.Point) && this.Normal.Equals(p.Normal) && this.Radius.Equals(p.Radius)); } }
public static void loadConeCogwheelObject(SceneObject obj) { if (obj.GetType().Equals(typeof(ConeCogwheelObject))) { ConeCogwheelObject ccObject = (ConeCogwheelObject)obj; GameObject cogwheel = Instantiate(prefabDictionary[obj.GetType()]); cogwheel.GetComponentInChildren <Cogwheel>().generateMesh(ccObject.height, ccObject.cogCount, ccObject.radius); cogwheel.transform.position = new Vector3(ccObject.position.x, ccObject.position.y, ccObject.position.z); cogwheel.transform.eulerAngles = new Vector3(ccObject.rotation.x, ccObject.rotation.y, ccObject.rotation.z); foreach (int id in ccObject.interlockingObjects) { Tuple <SceneObject, GameObject> tuple = addedSceneObjects.Find(tp => tp.Item1.id.Equals(id)); if (tuple != null) { cogwheel.GetComponentInChildren <Interlockable>().addInterlockingPart(tuple.Item2.GetComponentInChildren <Interlockable>()); } } //Set Layer for gameobject and all its children string tagLayerName = "Cogwheel"; SetLayerRecursively(cogwheel, LayerMask.NameToLayer(tagLayerName)); cogwheel.gameObject.tag = tagLayerName; //Create new CogwheelFact and add to global FactList int cogId = GameState.Facts.Count; float radius = cogwheel.GetComponentInChildren <Cogwheel>().getRadius(); float insideRadius = cogwheel.GetComponentInChildren <Cogwheel>().getInsideRadius(); float outsideRadius = cogwheel.GetComponentInChildren <Cogwheel>().getOutsideRadius(); CogwheelFact newFact = new CogwheelFact(cogId, cogwheel.transform.position, cogwheel.transform.up, radius, insideRadius, outsideRadius); newFact.Representation = cogwheel; GameState.Facts.Insert(cogId, newFact); UnityEngine.Debug.Log("Successfully added new CogwheelFact with backendUri: " + newFact.backendURI); addedSceneObjects.Add(new Tuple <SceneObject, GameObject>(obj, cogwheel)); } }