public void HydrateData() { if (Current.User.IsInAnyRole("Admin,ReleaseOfficial,GenericReleaseUser")) { foreach (var data in MainObject.GetCounts(ViewTime.Value)) { switch (data.StatusEnum) { case StatusEnum.Cancelled: Cancelled += data.NumItems; break; case StatusEnum.Completed: case StatusEnum.ReviewNotRequired: Completed += data.NumItems; break; case StatusEnum.Rejected: Rejected += data.NumItems; break; case StatusEnum.InPeerReview: case StatusEnum.InReview: UnderReview += data.NumItems; break; default: InProcess += data.NumItems; break; } } } Reviews = MainObject.GetReviewsForUser(Current.User.EmployeeId); if (GetMainCount() <= 200) { IsSmall = true; Mains = GetMainData(ViewMode, ViewTime, OrgMode, OrgOption); } }
private static string ConstructBody(MainObject main, ReviewObject review, string comment, EmailTemplateObject template) { if (template != null) { return(template.Body .Replace("{STI_Number}", main.StiNumber ?? string.Empty) .Replace("{Title}", main.Title ?? string.Empty) .Replace("{Authors}", string.Join(", ", main.Authors.Select(n => n.Name)) ?? string.Empty) //.Replace("{DueDate}", $"{main.DueDate:d}") .Replace("{ReviewStatus}", main.ReviewStatus ?? string.Empty) .Replace("{ReviewProgress}", $"{main.ReviewProgress:P}" ?? string.Empty) .Replace("{ReviewerName}", review?.ReviewerName ?? string.Empty) .Replace("{Comment}", comment ?? string.Empty) .Replace("{ReviewType}", review?.ReviewerTypeDisplayName ?? string.Empty) .Replace("{Url}", $"<a href=\"{Config.SiteUrl.TrailingSlash()}Artifact/Index/{main.MainId}\">LRS Artifact</a>") .Replace("{OUO-FOIA}", main.OuoEmailText ?? string.Empty) .Replace("{FundingOrg}", string.Join(", ", main?.Funding?.Where(m => !string.IsNullOrWhiteSpace(m.FundingOrgName)).Select(n => n.FundingOrgName)) ?? string.Empty)); } return(string.Empty); }
//void rcOptions(int offset) //{ // float heightC = (_menuBtnHeight + _spacing * 2) * Data.rollerCoasters.Count; // _scrollPos = GUI.BeginScrollView(new Rect((_menuBtnWidth + _spacing), (_menuBtnHeight + _spacing) * offset + _spacing, widthS, heightS), _scrollPos, new Rect(0, 0, _menuBtnWidth, heightC)); // for (int i = 0, index = 0; i < Data.objects.Count; i++) // { // RollerCoaster train = Data.objects[i].GetComponent<RollerCoaster>(); // if (Data.objects[i].tag == "train") // { // if (GUI.Button(new Rect(0, (_menuBtnHeight + _spacing) * index, _menuBtnWidth, _menuBtnHeight), train.name)) { Data.activeObj = i;setCamera(); closeObjectMenu(); } // index++; // } // } // GUI.EndScrollView(); //} void animalOptions(int offset) { float heightC = (_menuBtnHeight + _spacing * 2) * Data.objects.Count; _scrollPos = GUI.BeginScrollView(new Rect((_menuBtnWidth + _spacing), (_menuBtnHeight + _spacing) * offset + _spacing, _menuOptionWidth + 20, heightS), _scrollPos, new Rect(0, 0, _menuOptionWidth, heightC)); for (int i = 0, index = 0; i < Data.objects.Count; i++) { bool flag = false; MainObject obj = Data.objects[i].GetComponent <MainObject>(); if (displayOPtion == obj.type || displayOPtion == ObjectType.DEFAULT) { if (GUI.Button(new Rect(0, (_menuBtnHeight + _spacing) * index, _menuOptionWidth, _menuBtnHeight), obj.nameO)) { Data.activeObj = i; setCamera(); menu = Menu.NONE; } index++; } } GUI.EndScrollView(); }
private void CreateWheel() { BRigidBody rigidBody = MainObject.GetComponent <BRigidBody>(); rigidBody.friction = WHEEL_FRICTION; WheelDriverMeta wheel = this.GetDriverMeta <WheelDriverMeta>(); BSphereShape sphereShape = MainObject.AddComponent <BSphereShape>(); sphereShape.Radius = wheel.radius * 0.01f; // Old cylinder method... collision not as smoth. ////BCylinderShapeZ cylinderShape = MainObject.AddComponent<BCylinderShapeZ>(); //BCylinderShapeX cylinderShape = MainObject.AddComponent<BCylinderShapeX>(); //cylinderShape.HalfExtent = new Vector3(wheel.radius * 1.5f, wheel.width, wheel.width) * 0.01f; //cylinderShape.GetCollisionShape().Margin = wheel.radius * 0.005f; // hopefully change later? // ... and continuous collision detection rigidBody.GetCollisionObject().CcdMotionThreshold = CCD_MOTION_THRESHOLD; rigidBody.GetCollisionObject().CcdSweptSphereRadius = CCD_SWEPT_SPHERE_RADIUS; }
public void setPosition(string[] ins) { string name = ins[1].Replace("\"", ""); GameObject go = null; for (int i = 0; i < Data.objects.Count; i++) { MainObject mo = Data.objects[i].GetComponent <MainObject>(); if (mo.nameO == name) { go = Data.objects[i]; break; } } if (go != null) { float x = float.Parse(ins[1]); float y = float.Parse(ins[2]); float z = float.Parse(ins[3]); go.transform.position = new Vector3(x, y, z); } }
IEnumerator AttackNearestWithBolt() { while (true) // TODO: 시간으로 바꿀까 { if (friendMover.state == FriendMover.eState.Moving) { MainObject nearestMeteo = newMeteo.FindNearestMeteo(transform.position, AttackRange); if (nearestMeteo != null) { // Create a (pooled) bolt to nearest meteo for (int i = 0; i < NumberOfBoltLine; i++) { CreatePooledBolt(transform.position, nearestMeteo.stone.transform.position, Color.white, Thickness); } audio.Play(); nearestMeteo.stone.GetComponent <CrushMeteo>().Crush(); yield return(new WaitForSeconds(AttackDelayTime)); } } yield return(null); } }
public void gotShot() { Debug.Log(gameObject.name + " shooting handler working."); MainObject mo = gameObject.GetComponent <MainObject>(); if (gameObject.tag == "animal") { gameObject.GetComponent <AnimalAnimation>().gotShot(); } if (mo.type == ObjectType.BIRD) { gameObject.GetComponent <BirdAnim>().gotShot(); } if (mo.type == ObjectType.PLANT) { gameObject.GetComponent <MovementLib>().gotShot(); } if (mo.type == ObjectType.BALLOON) { gameObject.GetComponent <MovementLib>().gotShot(); } }
/// <summary> /// Creates node_0 of a manipulator for QuickSwap mode. Node_0 is used to attach the manipulator to the robot. /// </summary> public void CreateManipulatorJoint() { //Ignore physics/collisions between the manipulator and the robot. Currently not working. foreach (BRigidBody rb in GameObject.Find("Robot").GetComponentsInChildren <BRigidBody>()) { MainObject.GetComponent <BRigidBody>().GetCollisionObject().SetIgnoreCollisionCheck(rb.GetCollisionObject(), true); } if (joint != null || GetSkeletalJoint() == null) { RotationalJoint_Base rNode = new RotationalJoint_Base(); B6DOFConstraint hc = MainObject.AddComponent <B6DOFConstraint>(); hc.thisRigidBody = MainObject.GetComponent <BRigidBody>(); hc.otherRigidBody = GameObject.Find("Robot").GetComponentInChildren <BRigidBody>(); hc.localConstraintPoint = ComOffset; //Put this after everything else hc.constraintType = BTypedConstraint.ConstraintType.constrainToAnotherBody; } }
public static AttachmentObject AddAttachment(int mainId, string fileName, string description, int?size, int?numberPages, bool adminOnly = false, string employeeId = null) { string sizeStr = string.Empty; if (size.HasValue) { double num = (double)size.Value / 1024.0; if (num > 999999.99) //GigaBytes { sizeStr = $"{(num / 1000000.0):F3} GB"; } else if (num > 999.99) //MegaBytes { sizeStr = $"{(num / 1000.0):F2} MB"; } else //KiloBytes { sizeStr = $"{num:F2} KB"; } } var sao = new AttachmentObject() { MainId = mainId, FileName = fileName, Note = description, IsDeleted = false, Size = sizeStr, NumberPages = numberPages, UploadEmployeeId = employeeId, AdminOnly = adminOnly }; sao.Save(); MainObject.UpdateActivityDateToNow(mainId); return(sao); }
public static List <MainObject> GetMainData(ViewModeOptionEnum viewMode, int?viewTime, int?orgMode, string orgOption) { var data = new List <MainObject>(); viewTime = viewTime ?? 12; if (viewTime <= 0) { viewTime = 12; } if (viewTime > 360) { viewTime = 360; } orgMode = orgMode ?? 0; if (Current.User.IsInAnyRole("Admin,ReleaseOfficial,GenericReleaseUser")) { data = MainObject.GetAllMains(viewMode, viewTime.Value); } else if (Current.User.IsInAnyRole("OrgManager")) { if (((OrgOptionEnum)orgMode) == OrgOptionEnum.OrgArtifacts) { data = MainObject.GetAllForOrg(viewMode, viewTime.Value, Current.User.EmployeeId, orgOption); } else { data = MainObject.GetAllForUser(viewMode, viewTime.Value, Current.User.EmployeeId); } } else { data = MainObject.GetAllForUser(viewMode, viewTime.Value, Current.User.EmployeeId); } return(data); }
IEnumerator Flying() { // position이 부모로부터 계층적??이기 때문에 잠깐 빼놓고 이동시키기 위해 부모를 저장해둔다. Transform parent = transform.parent; transform.parent = null; Vector3 littleRigth = new Vector3(0.1f, 1f); while (!kaboom) { MainObject nearestMeteo = newMeteo.FindNearestMeteo(transform.position); if (nearestMeteo == null) { targetPos = transform.position + transform.rotation * littleRigth; } else { targetPos = nearestMeteo.ballPos; } aim = targetPos - transform.position; // Rotate Toward Quaternion toAim = Quaternion.FromToRotation(Vector3.up, aim); transform.rotation = Quaternion.RotateTowards(transform.rotation, toAim, MaxDegreeDelta * Time.deltaTime); // Move Forward transform.position += (transform.rotation * Vector3.up) * Speed * Time.deltaTime; yield return(null); } transform.parent = parent; gameObject.SetActive(false); }
public static bool SendEmail(MainObject main, ReviewObject review, EmailTypeEnum emailType, string comment, ref string errorMsg) { try { var template = EmailTemplateObject.GetEmailTemplate(emailType); if (template != null) { string subject = template.Header.Replace("{STI_Number}", main.StiNumber ?? string.Empty).Replace("{Title}", main.Title ?? string.Empty); string body = ConstructBody(main, review, comment, template); switch (emailType) { case EmailTypeEnum.ReleaseOfficerComplete: return(SendReleaseOfficerEmail(subject, body, ref errorMsg)); case EmailTypeEnum.ClassReviewer: case EmailTypeEnum.ExportReviewer: case EmailTypeEnum.ManagerReviewer: case EmailTypeEnum.PeerReviewer: case EmailTypeEnum.TechReviewer: case EmailTypeEnum.ReviewReminder: return(review != null?SendReviewerEmail(review, subject, body, ref errorMsg) : SendReviewersEmail(main, subject, body, emailType, ref errorMsg)); default: return(SendOwnerEmail(main, subject, body, template.IncludeAuthors, template.IncludeContacts, ref errorMsg)); } } errorMsg = $"Unable to find the Template for Email Type: {emailType}"; } catch (Exception ex) { errorMsg = $"Exception Caught while attempting to send an email: {ex.Message}"; } return(false); }
void inspector() { if (Data.objects.Count == 0) { return; } if (_activeObj != Data.activeObj) { obj = Data.objects[Data.activeObj].GetComponent <MainObject>(); } if (obj == null) { return; } //GUILayout.BeginArea(new Rect(new Vector2(Screen.width - 1.5f * Data._inspectorWidth, 30), new Vector2(Screen.width - Data._inspectorWidth, Screen.height - 90)), inspectorStyle); GUILayout.BeginArea(new Rect(new Vector2(Screen.width - 1.3f * Data._inspectorWidth, 30), new Vector2(Screen.width - Data._inspectorWidth, Screen.height - Screen.height * 4 / 5)), inspectorStyle); rotateButtons(); GUILayout.EndArea(); GUILayout.BeginArea(new Rect(new Vector2(Screen.width - 1.3f * Data._inspectorWidth, Screen.height - 200), new Vector2(Screen.width - Data._inspectorWidth, Screen.height - 90)), inspectorStyle); scaleButtons(); GUILayout.EndArea(); //GUILayout.EndArea(); }
public void getAngleY(string[] ins) { string name = ins[1].Replace("\"", ""); GameObject go = null; for (int i = 0; i < Data.objects.Count; i++) { MainObject mo = Data.objects[i].GetComponent <MainObject>(); if (mo.nameO == name) { go = Data.objects[i]; break; } } if (go != null) { float ang = go.transform.rotation.eulerAngles.y; ang %= 360; if (ang < 0) { ang += 360; } _ip.setValue(ins[2], ang); } }
public void DeserialzeTest() { MainObject mo = new MainObject() { Name = "name", Age = 33, Region = Region.Bbb, Child = new MainObject() { Name = "child", Age = 11, Region = Region.CcC }, }; mo.Boy.Name = "boy"; XmlTransformer trans = new XmlTransformer(); XDocument doc = new XDocument(); XElement root = new XElement("test"); doc.Add(root); trans.Serialize(mo, root); Debug.WriteLine(">>> Serializing..."); Debug.WriteLine(doc.ToString()); mo = new MainObject(); mo = (MainObject)trans.Deserialize(root, mo); Assert.AreEqual(mo.Name, "name"); Assert.AreEqual(mo.Region, Region.Bbb); Assert.AreEqual(mo.Age, 33); Assert.AreEqual(mo.Child.Name, "child"); Assert.AreEqual(mo.Boy.Name, "boy"); Assert.AreEqual(mo.Boy.Region, Region.AAA); Type t = typeof(MainObject); mo = (MainObject)trans.Deserialize(root, t); Assert.AreEqual(mo.Name, "name"); Assert.AreEqual(mo.Region, Region.Bbb); Assert.AreEqual(mo.Age, 33); Assert.AreEqual(mo.Child.Name, "child"); Assert.AreEqual(mo.Boy.Name, "boy"); Assert.AreEqual(mo.Boy.Region, Region.AAA); }
IEnumerator _Ignite(Vector3 velocity, float explosionTimer) { Transform parent = transform.parent; transform.position = parent.position; transform.parent = null; while (0 < explosionTimer) { explosionTimer -= Time.deltaTime; transform.position += velocity * Time.deltaTime; yield return(null); } //BOOM! //animator.SetTrigger("Boom"); // animator.GetCurrentStateInfo(0)[0] 에 State Update가 안되냐 animator.Play("SpikeBomb_Explode"); yield return(null); float distanceSqr = .0f; //foreach (MainObject meteo in newMeteo.meteoList) for (int i = newMeteo.meteoList.Count - 1; 0 <= i; --i) { MainObject meteo = newMeteo.meteoList[i]; distanceSqr = (meteo.ballPos - transform.position).sqrMagnitude; if (distanceSqr <= ExplosionRadius * ExplosionRadius) { meteo.stone.GetComponent <CrushMeteo>().Crush(4); } } yield return(waitExplosionDuration); transform.parent = parent; gameObject.SetActive(false); }
public void AddAnimation(MainObject obj, ObjectAnimation animation) { obj.SetAnimation(animation); }
public void CreateJoint(RobotBase robotBase, float wheelFriction = 1f, float lateralFriction = 1f) { if (joint != null || GetSkeletalJoint() == null) { return; } switch (GetSkeletalJoint().GetJointType()) { case SkeletalJointType.ROTATIONAL: if (this.HasDriverMeta <WheelDriverMeta>() && this.GetDriverMeta <WheelDriverMeta>().type != WheelType.NOT_A_WHEEL) { RigidNode parent = (RigidNode)GetParent(); if (parent.MainObject.GetComponent <BRaycastRobot>() == null) { parent.MainObject.AddComponent <BRaycastRobot>().RootNode = RootNode; } WheelType wheelType = this.GetDriverMeta <WheelDriverMeta>().type; BRaycastWheel wheel = MainObject.AddComponent <BRaycastWheel>(); wheel.CreateWheel(this); if (robotBase is MaMRobot) { wheel.Friction = wheelFriction; wheel.SlidingFriction = lateralFriction; } MainObject.transform.parent = parent.MainObject.transform; } else { RotationalJoint_Base rNode = (RotationalJoint_Base)GetSkeletalJoint(); BHingedConstraintEx hc = (BHingedConstraintEx)(joint = ConfigJoint <BHingedConstraintEx>(rNode.basePoint.AsV3() - ComOffset, rNode.axis.AsV3(), AxisType.X)); Vector3 rAxis = rNode.axis.AsV3().normalized; hc.axisInA = rAxis; hc.axisInB = rAxis; if (hc.setLimit = rNode.hasAngularLimit) { hc.lowLimitAngleRadians = rNode.currentAngularPosition - rNode.angularLimitHigh; hc.highLimitAngleRadians = rNode.currentAngularPosition - rNode.angularLimitLow; } hc.constraintType = BTypedConstraint.ConstraintType.constrainToAnotherBody; } break; case SkeletalJointType.CYLINDRICAL: CylindricalJoint_Base cNode = (CylindricalJoint_Base)GetSkeletalJoint(); Vector3 cAxis = cNode.axis.AsV3().normalized; B6DOFConstraint bc = (B6DOFConstraint)(joint = ConfigJoint <B6DOFConstraint>(cNode.basePoint.AsV3() - ComOffset, cAxis, AxisType.X)); bc.localConstraintAxisX = cAxis; bc.localConstraintAxisY = new Vector3(cAxis.y, cAxis.z, cAxis.x); bc.linearLimitLower = new Vector3((cNode.linearLimitStart - cNode.currentLinearPosition) * 0.01f, 0f, 0f); bc.linearLimitUpper = new Vector3((cNode.linearLimitEnd - cNode.currentLinearPosition) * 0.01f, 0f, 0f); // TODO: Implement angular cylinder limits bc.constraintType = BTypedConstraint.ConstraintType.constrainToAnotherBody; break; case SkeletalJointType.LINEAR: LinearJoint_Base lNode = (LinearJoint_Base)GetSkeletalJoint(); Vector3 lAxis = lNode.axis.AsV3().normalized; BSliderConstraint sc = (BSliderConstraint)(joint = ConfigJoint <BSliderConstraint>(lNode.basePoint.AsV3() - ComOffset, lAxis, AxisType.X)); sc.localConstraintAxisX = lAxis; sc.localConstraintAxisY = new Vector3(lAxis.y, lAxis.z, lAxis.x); sc.lowerLinearLimit = (lNode.linearLimitLow - lNode.currentLinearPosition) * 0.01f; sc.upperLinearLimit = (lNode.linearLimitHigh - lNode.currentLinearPosition) * 0.01f; sc.lowerAngularLimitRadians = 0f; sc.upperAngularLimitRadians = 0f; sc.constraintType = BTypedConstraint.ConstraintType.constrainToAnotherBody; bool b = this.HasDriverMeta <ElevatorDriverMeta>(); if (GetSkeletalJoint().cDriver != null) { if (GetSkeletalJoint().cDriver.GetDriveType().IsElevator()) { MainObject.GetComponent <BRigidBody>().mass *= 2f; } } break; } }
// Use this for initialization void Start() { mainObject = GameObject.Find("MainObject"); playerScript = mainObject.GetComponent<MainObject>(); Player1.isObjectExists = true; }
public InputField(string name) { Main = new MainObject(GameObject.Find(name)); Placeholder = new FieldChild(Main.GameObject, "Placeholder"); Text = new FieldChild(Main.GameObject, "Text"); }
public void Save() { repo.SaveFunding(this); MainObject.UpdateActivityDateToNow(MainId); }
public RepairCardViewModel(MainObject mainObject) { Repair = new RepairClass(); MainObject = mainObject; }
public bool CreateMesh(string filePath) { Debug.Log(filePath); BXDAMesh mesh = new BXDAMesh(); mesh.ReadFromFile(filePath); //if (!mesh.GUID.Equals(GUID)) //{ // Debug.Log("Returning false"); // return false; //} List <GameObject> meshObjects = new List <GameObject>(); AuxFunctions.ReadMeshSet(mesh.meshes, delegate(int id, BXDAMesh.BXDASubMesh sub, Mesh meshu) { GameObject meshObject = new GameObject(MainObject.name + "_mesh"); meshObjects.Add(meshObject); meshObject.AddComponent <MeshFilter>().mesh = meshu; meshObject.AddComponent <MeshRenderer>(); Material[] materials = new Material[meshu.subMeshCount]; for (int i = 0; i < materials.Length; i++) { materials[i] = sub.surfaces[i].AsMaterial(true); } meshObject.GetComponent <MeshRenderer>().materials = materials; meshObject.transform.position = root.position; meshObject.transform.rotation = root.rotation; Debug.Log("Mesh Objects count " + meshObjects.Count); }, true); Vector3 com = mesh.physics.centerOfMass.AsV3(); com.x *= -1; ComOffset = com; Mesh[] colliders = new Mesh[mesh.colliders.Count]; AuxFunctions.ReadMeshSet(mesh.colliders, delegate(int id, BXDAMesh.BXDASubMesh sub, Mesh meshu) { colliders[id] = meshu; }, true); MainObject.transform.position = root.position + ComOffset; MainObject.transform.rotation = root.rotation; foreach (GameObject meshObject in meshObjects) { meshObject.transform.parent = MainObject.transform; } if (!this.HasDriverMeta <WheelDriverMeta>() || this.GetDriverMeta <WheelDriverMeta>().type == WheelType.NOT_A_WHEEL) { BMultiHullShape hullShape = MainObject.AddComponent <BMultiHullShape>(); foreach (Mesh collider in colliders) { ConvexHullShape hull = new ConvexHullShape(Array.ConvertAll(collider.vertices, x => x.ToBullet()), collider.vertices.Length); hull.Margin = 0f; hullShape.AddHullShape(hull, BulletSharp.Math.Matrix.Translation(-ComOffset.ToBullet())); } MainObject.AddComponent <MeshRenderer>(); PhysicalProperties = mesh.physics; Debug.Log(PhysicalProperties.centerOfMass); BRigidBody rigidBody = MainObject.AddComponent <BRigidBody>(); rigidBody.mass = mesh.physics.mass; rigidBody.friction = 0.25f; rigidBody.RemoveOnCollisionCallbackEventHandler(); ((RigidBody)rigidBody.GetCollisionObject()).ActivationState = ActivationState.DisableDeactivation; foreach (BRigidBody rb in MainObject.transform.parent.GetComponentsInChildren <BRigidBody>()) { rigidBody.GetCollisionObject().SetIgnoreCollisionCheck(rb.GetCollisionObject(), true); } MainObject.AddComponent <BMultiCallbacks>().AddCallback((StateMachine.Instance.CurrentState as MainState).CollisionTracker); } if (this.HasDriverMeta <WheelDriverMeta>() && this.GetDriverMeta <WheelDriverMeta>().type != WheelType.NOT_A_WHEEL && GetParent() == null) { BRigidBody rigidBody = MainObject.GetComponent <BRigidBody>(); if (MixAndMatchMode.isMixAndMatchMode) { rigidBody.mass += PlayerPrefs.GetFloat("wheelMass", 1f); } rigidBody.GetCollisionObject().CollisionShape.CalculateLocalInertia(rigidBody.mass); } #region Free mesh foreach (var list in new List <BXDAMesh.BXDASubMesh>[] { mesh.meshes, mesh.colliders }) { foreach (BXDAMesh.BXDASubMesh sub in list) { sub.verts = null; sub.norms = null; foreach (BXDAMesh.BXDASurface surf in sub.surfaces) { surf.indicies = null; } } for (int i = 0; i < list.Count; i++) { list[i] = null; } } mesh = null; GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); #endregion return(true); }
public void Serialization1() { MainObject mainObj = new MainObject(); MainObjectRepoSerMgr mainObjSerMgr = MainObjectRepoSerMgr.Singleton; RepositorySerializationContext serCtx = new RepositorySerializationContext(); RepositorySerializationContext serCtx2 = new RepositorySerializationContext(); String serialization = null; TextWriter tw = new StringWriter(); if (typeof(IMainObject).GetTypeGuid().ToString() == "e94473ee-f53f-4b7b-95d6-36d78d327e86") { System.Diagnostics.Debug.WriteLine("Guid verificato"); } mainObj.DateTimeField = DateTime.Now; mainObj.Field3 = new SubObject(); mainObj.Field1 = "String Field \", \"aaa\" : \"bbb\", Insidioso"; mainObj.Field2 = "Mario"; mainObj.Field3.SubObjField1 = "Sub 1"; mainObj.Field3.SubObjField2 = "Sub 2"; mainObj.Field4 = true; mainObj.Field8 = -1234567.890; serCtx.SerializeMetadata = true; mainObjSerMgr.Serialize(tw, mainObj, serCtx); tw.Flush(); tw.Close(); serialization = tw.ToString(); using (StringReader sr1 = new StringReader(serialization)) { IMainObject deserResult = mainObjSerMgr.Deserialize(sr1, serCtx2); IMainObjectSerializationContract ppp = deserResult as IMainObjectSerializationContract; ppp.Field1 = "Primo"; ppp.Field2 = "Coccodrillo"; ppp.Field4 = false; ppp.Field8 = 987.654; IValueDomAlignable <IValueUnit, IValueUnit> vDomAligner = deserResult as IValueDomAlignable <IValueUnit, IValueUnit>; if (vDomAligner != null) { vDomAligner.Align(); if (vDomAligner.GetContext(ref serCtx2)) { serCtx2.SerializeData = true; serCtx2.SerializeMetadata = true; tw = new StringWriter(); mainObjSerMgr.Serialize(tw, vDomAligner.Data, serCtx2); serialization = tw.ToString(); } } } MainObjectFactory mainFact = MainObjectFactory.Singleton; mainFact.InitDto.DateTimeField = DateTime.Now; mainFact.InitDto.Field1 = "Test"; mainFact.InitDto.Field2 = "Mario"; mainFact.InitDto.Field4 = false; mainFact.InitDto.Field8 = 9876.54; mainFact.InitDto.Field3.SubObjField1 = "Init Sub 1"; mainFact.InitDto.Field3.SubObjField2 = "Init Sub 2"; IMainObject k = mainFact.GetByDto(); } // End of Serialization1 ()
public static void loadScene() { string filename = Data.gameName; string dir = path + "\\" + filename; string load_string = ""; string filepath; int landscape_index = 0; filepath = dir + "\\scenes\\" + Data.sceneName; Debug.Log("loading file " + filepath); load_string = System.IO.File.ReadAllText(filepath); //clear the current data in game// //incase the file has nothing to load,return// if (load_string == "") { return; } ObjectInterface objInterface = GameObject.Find("GUI").GetComponent <ObjectInterface>(); load_string = load_string.Replace("\r", ""); string[] flags = load_string.Split('\n'); if (flags.Length == 0) { return; } for (int j = 0; j < flags.Length; j++) { string[] tokens = flags[j].Split('$'); if (tokens[0] == "#") { if (tokens[1] == "0") { continue; } landscape_index = Data.getFileIndex(tokens[1]); objInterface.placeLandscape(landscape_index); continue; } //retrieve the data and store in respective formats.// string name = tokens[0]; string scriptRef = tokens[1]; string objectType = tokens[2]; string model_name = tokens[3]; float posX = float.Parse(tokens[4]); float posY = float.Parse(tokens[5]); float posZ = float.Parse(tokens[6]); float rotX = float.Parse(tokens[7]); float rotY = float.Parse(tokens[8]); float rotZ = float.Parse(tokens[9]); float rotW = float.Parse(tokens[10]); float sclx = float.Parse(tokens[11]); float scly = float.Parse(tokens[12]); float sclz = float.Parse(tokens[13]); int model = Data.getFileIndex(model_name); //creating transform data from retrieved data.// Vector3 position = new Vector3(posX, posY, posZ); Quaternion rotation = new Quaternion(rotX, rotY, rotZ, rotW); Vector3 scale = new Vector3(sclx, scly, sclz); //pulling the script data from respective script files.// string script = System.IO.File.ReadAllText(dir + "\\" + scriptRef + ".txt"); //get objecttype and place the animal using object interface script.// ObjectType type = getObjectType(objectType); objInterface.placeObject(model, position, type); //setup rest of the data to initialize the object.// MainObject mainObject = Data.objects[Data.objects.Count - 1].GetComponent <MainObject>(); mainObject.script = script; mainObject.scriptRef = scriptRef; mainObject.nameO = name; mainObject.position = position; mainObject.rotation = rotation; mainObject.scale = scale; //set gameobjects parameters.// Data.objects[Data.objects.Count - 1].transform.position = position; Data.objects[Data.objects.Count - 1].transform.rotation = rotation; Data.objects[Data.objects.Count - 1].transform.localScale = scale; } Data.setAnimalsOnGround(); Data.activeObj = Data.objects.Count - 1; //updates the scene in game file string gameFilePath = dir + "\\_game"; System.IO.File.WriteAllText(gameFilePath, Data.sceneName); }
/* * public RigidNode(RigidNode_Base parent) : base(parent){ * * } */ public bool CreateMesh(string filePath, bool isMixAndMatch = false, float wheelMass = 1.0f) { //Debug.Log(filePath); BXDAMesh mesh = new BXDAMesh(); mesh.ReadFromFile(filePath); //if (!mesh.GUID.Equals(GUID)) //{ // Debug.Log("Returning false"); // return false; //} List <GameObject> meshObjects = new List <GameObject>(); Auxiliary.ReadMeshSet(mesh.meshes, delegate(int id, BXDAMesh.BXDASubMesh sub, Mesh meshu) { GameObject meshObject = new GameObject(MainObject.name + "_mesh"); meshObjects.Add(meshObject); meshObject.AddComponent <MeshFilter>().mesh = meshu; meshObject.AddComponent <MeshRenderer>(); Material[] materials = new Material[meshu.subMeshCount]; for (int i = 0; i < materials.Length; i++) { materials[i] = sub.surfaces[i].AsMaterial(true); } meshObject.GetComponent <MeshRenderer>().materials = materials; meshObject.transform.position = root.position; meshObject.transform.rotation = root.rotation; }, true); Vector3 com = mesh.physics.centerOfMass.AsV3(); ComOffset = com; Mesh[] colliders = new Mesh[mesh.colliders.Count]; Auxiliary.ReadMeshSet(mesh.colliders, delegate(int id, BXDAMesh.BXDASubMesh sub, Mesh meshu) { colliders[id] = meshu; }, true); MainObject.transform.position = root.position + ComOffset; MainObject.transform.rotation = root.rotation; foreach (GameObject meshObject in meshObjects) { meshObject.transform.parent = MainObject.transform; } if (!this.HasDriverMeta <WheelDriverMeta>() || this.GetDriverMeta <WheelDriverMeta>().type == WheelType.NOT_A_WHEEL) { BMultiShape hullShape = MainObject.AddComponent <BMultiShape>(); foreach (Mesh collider in colliders) { //Mesh m = AuxFunctions.GenerateCollisionMesh(collider, Vector3.zero, 0f/*CollisionMargin*/); //ConvexHullShape hull = new ConvexHullShape(Array.ConvertAll(m.vertices, x => x.ToBullet()), m.vertices.Length); //hull.Margin = CollisionMargin; //hullShape.AddHullShape(hull, BulletSharp.Math.Matrix.Translation(-ComOffset.ToBullet())); MainObject.AddComponent <Wireframe>().Init(collider, ComOffset); ConvexHullShape hull = new ConvexHullShape(Array.ConvertAll(collider.vertices, x => x.ToBullet()), collider.vertices.Length); hull.Margin = CollisionMargin; hullShape.AddShape(hull, BulletSharp.Math.Matrix.Translation(-ComOffset.ToBullet())); } MainObject.AddComponent <MeshRenderer>(); PhysicalProperties = mesh.physics; //Debug.Log(PhysicalProperties.centerOfMass); BRigidBody rigidBody = MainObject.AddComponent <BRigidBody>(); string jsonFile = Directory.GetParent(filePath).FullName + Path.DirectorySeparatorChar + "skeleton.json"; bool useJsonWeight = false; if (File.Exists(jsonFile)) { useJsonWeight = true; } float weight = mesh.physics.mass; if (useJsonWeight) { try { weight = (float)GetSkeletalJoint().weight; } catch (Exception e) { weight = mesh.physics.mass; } } rigidBody.mass = weight; rigidBody.friction = 0.25f; rigidBody.linearSleepingThreshold = LinearSleepingThreshold; rigidBody.angularSleepingThreshold = AngularSleepingThreshold; rigidBody.RemoveOnCollisionCallbackEventHandler(); foreach (BRigidBody rb in MainObject.transform.parent.GetComponentsInChildren <BRigidBody>()) { rigidBody.GetCollisionObject().SetIgnoreCollisionCheck(rb.GetCollisionObject(), true); } MainState mainState = StateMachine.SceneGlobal.FindState <MainState>(); if (mainState != null) { MainObject.AddComponent <BMultiCallbacks>().AddCallback(mainState.CollisionTracker); } } if (this.HasDriverMeta <WheelDriverMeta>() && this.GetDriverMeta <WheelDriverMeta>().type != WheelType.NOT_A_WHEEL && GetParent() == null) { BRigidBody rigidBody = MainObject.GetComponent <BRigidBody>(); if (isMixAndMatch) { rigidBody.mass += wheelMass; } rigidBody.GetCollisionObject().CollisionShape.CalculateLocalInertia(rigidBody.mass); } #region Free mesh foreach (var list in new List <BXDAMesh.BXDASubMesh>[] { mesh.meshes, mesh.colliders }) { foreach (BXDAMesh.BXDASubMesh sub in list) { sub.verts = null; sub.norms = null; foreach (BXDAMesh.BXDASurface surf in sub.surfaces) { surf.indicies = null; } } for (int i = 0; i < list.Count; i++) { list[i] = null; } } mesh = null; GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); #endregion return(true); }
private void ProcessMainObjects(ReadOnlyCollection <BusinessObject> oBOCObjects, FilterBase oUniqueCheckFilter) { foreach (var oObj in oBOCObjects) { foreach (var MainObject in _oSetting.InfoForReferenceObjectRules.MainObjectsInterface.Split('|').Select(x => x.Trim())) //Mainobject in XML { if (!oObj.SupportsInterface(MainObject.ToString())) //If not contains, Interface of Mainobject (Stair or Slab) { continue; } if (oObj is Stair && oObj.GetPropertyValue("IJNamedItem", "Name").ToString().Contains("Stair")) //Stair { var oStair = oObj as Stair; //Stair Object Matrix4X4 oMat = new Matrix4X4(oStair.Matrix); // StairMatrix (Global Axis -> Local Axis) Vector rotateVec = oMat.XAxis; //X Axis of StairMatrix : Rotate base on X Axis IMathServices oMathService = new Math3d(); Collection <BusinessObject> oColl = new Collection <BusinessObject>() { oStair }; var oRange = (oStair as IRange).Range; double dRadian = (oStair.GetPropertyValue("IJSPSCommonStairLadderProps", "Angle") as PropertyValueDouble).PropValue.Value; //Stair Angle double height = MiddleServiceProvider.UOMMgr.ParseUnit(UnitType.Distance, _oSetting.Clearance.Value); //Height of user set Position posSrc, posSrc2; double dMinDist; oMat.Rotate(dRadian, rotateVec); //Based on X Axis of Stair, Matrix will rotate by Angle OrientedRangeBox oOrientedRangeBox = oMathService.GetOrientedRangeBox(oColl, oMat.XAxis, oMat.YAxis); //Oriented Range Box of Stair //OriginXYZ <-> Y Axis Near surface minDistance and Position on surface oRange.GetFaceInGivenDirection(oMat.YAxis, true).DistanceBetween(new Point3d(oOrientedRangeBox.Origin.X, oOrientedRangeBox.Origin.Y, oOrientedRangeBox.Origin.Z), out dMinDist, out posSrc); //OriginXYZ <-> Y Axis Far surface minDIstance and Position on surface oRange.GetFaceInGivenDirection(oMat.YAxis, false).DistanceBetween(new Point3d(oOrientedRangeBox.Origin.X, oOrientedRangeBox.Origin.Y, oOrientedRangeBox.Origin.Z), out dMinDist, out posSrc2); double dJustMinDist = posSrc.DistanceToPoint(posSrc2); //posSrc <-> posSrc2 Distance double c = dJustMinDist / Math.Cos(dRadian); //Distance / cos = length of sloped stair Vector oTanVector = new Vector(oOrientedRangeBox.Sides[1]); //Tangent Vector of Oriented Range Box (Y Axis) oTanVector.Length = c; Position corner1 = new Position(posSrc); Position corner2 = new Position(posSrc).Offset(oOrientedRangeBox.Sides[0]); Position corner3 = new Position(posSrc).Offset(oOrientedRangeBox.Sides[0]).Offset(oTanVector); Position corner4 = new Position(posSrc.Offset(oTanVector)); //Corners of stair double dPostHeight = MiddleServiceProvider.UOMMgr.ParseUnit(UnitType.Distance, oStair.GetPropertyValue("IJUAStairTypeA", "PostHeight").ToString()); double dTopElev = Math.Max(Math.Max(corner1.Z, corner2.Z), Math.Max(corner3.Z, corner4.Z)); //Maximum elevation of bottom of stair double dHeight = (oRange.High.Z - dTopElev); // Top point of Handrail - bottom Elevation of Stair = Stair Height corner1.Z += dHeight; corner2.Z += dHeight; corner3.Z += dHeight; corner4.Z += dHeight; // + Stair Height Vector uVec = corner2.Subtract(corner1); //UVector of Symbol Vector vVec = corner3.Subtract(corner2); //Vvector of Symbol //uVec.Length=1.0; vVec.Length=1.0; OrientedRangeBox oOrientedRBHC = new OrientedRangeBox(new Position(corner1), // Creates Oritented RangeBox of Head Clearance uVec, vVec, new Vector(0, 0, height - dHeight)); //2.0m - Stair height = RBHC RangeBox RangeBox oExtendedRange = new RangeBox(new Position(oRange.Low), new Position(oRange.High.X, oRange.High.Y, oRange.High.Z + height)); // 2.0m is height value adjustable string subSelectQueryCriteria = GenericUtils.GetSQLQueryBasedOnObjectTypeViewCriteria("JDObject"); string sqlQuery = GenericUtils.GetSQLQueryForObjectsOverlappingRangeBox(oExtendedRange, subSelectQueryCriteria); SQLFilter oFilter = new SQLFilter(); oFilter.SetSQLFilterString(sqlQuery); ReadOnlyCollection <BusinessObject> oReadOnlyColl = oFilter.Apply(MiddleServiceProvider.SiteMgr.ActiveSite.ActivePlant.PlantModel); //SQLFilter for Searching Overlapping Object //Highlight object GraphicViewHiliter oHiliter = new GraphicViewHiliter(); oHiliter.Weight = 5; oHiliter.Color = ColorConstants.RGBYellow; oHiliter.LinePattern = HiliterBase.HiliterLinePattern.Dotted; Hiliter oHiliter2 = new Hiliter(); oHiliter2.Weight = 10; oHiliter2.Color = ColorConstants.RGBBlue; Hiliter oHiliter3 = new Hiliter(); oHiliter3.Weight = 3; oHiliter3.Color = ColorConstants.RGBWhite; Dictionary <string, List <BusinessObject> > oDic = new Dictionary <string, List <BusinessObject> >(); oDic["Overlap"] = new List <BusinessObject>(); oDic["Inside"] = new List <BusinessObject>(); ClientServiceProvider.SelectSet.SelectedObjects.Clear(); List <BusinessObject> refObjList = new List <BusinessObject>(); //BusinessObject List List <String> stringList = new List <String>(); //oid LIst foreach (var oObject in oReadOnlyColl) { if (!IsSupportInerface(oObject)) { refObjList.Add(oObject); stringList.Add(oObject.ObjectID); } else { continue; } OrientedRangeBox oObjectOrientedBox = oMathService.GetOrientedRangeBox(new Collection <BusinessObject>( new List <BusinessObject>() { oObject })); //OrientedRangeBox of the Object RangeBoxIntersectionType intersectionType = oOrientedRBHC.Intersects(oObjectOrientedBox); //Find Intersects b/w them if (intersectionType == RangeBoxIntersectionType.Overlap) { //ClientServiceProvider.SelectSet.SelectedObjects.Add(oObject); oDic["Overlap"].Add(oObject); //foreach (var oPlaTest in MakePlane3D6ByOrientedRangeBox(oPipeOrientedBox)) //{ // oHiliter3.HilitedObjects.Add(oPlaTest); //} } else if (intersectionType == RangeBoxIntersectionType.Inside) { //ClientServiceProvider.SelectSet.SelectedObjects.Add(oObject); oDic["Inside"].Add(oObject); //foreach (var oPlaTest in MakePlane3D6ByOrientedRangeBox(oPipeOrientedBox)) //{ // oHiliter2.HilitedObjects.Add(oPlaTest); //} } else { refObjList.Remove(oObject); } foreach (KeyValuePair <string, List <BusinessObject> > item in oDic) { if (item.Key.Equals("Overlap")) { foreach (var oBO in oDic[item.Key]) { oHiliter3.HilitedObjects.Add(oBO); } } else if (item.Key.Equals("Inside")) { foreach (var oBO in oDic[item.Key]) { oHiliter2.HilitedObjects.Add(oBO); } } } //Debug.Print(oObj.ObjectIDForQuery); } var oPlaColl = MakePlane3D6ByOrientedRangeBox(oOrientedRangeBox); var oPlaColl2 = MakePlane3D6ByOrientedRangeBox(oOrientedRBHC); foreach (var oPlane in oPlaColl2) { oHiliter.HilitedObjects.Add(oPlane); } if (refObjList.Count == 0) { CreateOrUpdateDefect(oObj, 1, false, "", null, null); } else { Dictionary <string, string> DefectDic = new Dictionary <string, string>() { { "distance", _oSetting.Clearance.Value } }; CreateOrUpdateDefect(oObj, 1, true, _oRuleDescriptionHelper.GetFullErrorDescription(1, DefectDic), refObjList, null); } } else if (oObj is Slab && oObj.GetPropertyValue("IJNamedItem", "Name").ToString().Contains("Stair")) { IMathServices oMathService = new Math3d(); var oSlab = oObj as Slab; //Matrix4X4 oMat = new Matrix4X4(oSlab.Matrix); Collection <BusinessObject> oCollection = new Collection <BusinessObject>() { oSlab }; // RangeBox 를 가져온다. RangeBox oRange = (oSlab as IRange).Range; // Calculate the distance value based on the unit recored on the configuration file double height = MiddleServiceProvider.UOMMgr.ParseUnit(UnitType.Distance, _oSetting.Clearance.Value); // 면적을 줄여준다. (20 mm) RangeBox nRange = new RangeBox(new Position(oRange.Low.X + allowanceXY, oRange.Low.Y + allowanceXY, oRange.High.Z + allowanceZ), new Position(oRange.High.X - allowanceXY, oRange.High.Y - allowanceXY, oRange.High.Z + height)); RangeBox testRange = new RangeBox(); OrientedRangeBox oOrientedRangeBox = oMathService.GetOrientedRangeBox(oCollection); oOrientedRangeBox.GetExtendedOrientedRangeBoxInGivenDirection(new Vector(0, 0, 1), height, out oOrientedRangeBox, out testRange); //JDObject(모든오브젝트)에 대한 Query 생성 string subQuery = GenericUtils.GetSQLQueryBasedOnObjectTypeViewCriteria("JDObject"); string fullQuery = GenericUtils.GetSQLQueryForObjectsOverlappingRangeBox(nRange, subQuery); //Excutes Query SQLFilter oFilter = new SQLFilter(); oFilter.SetSQLFilterString(fullQuery); var oColl = oFilter.Apply(); //Query에 걸리는 Object Collection List <BusinessObject> refObjList = new List <BusinessObject>(); //BusinessObject List List <String> stringList = new List <String>(); //Highlight object GraphicViewHiliter oHiliter = new GraphicViewHiliter(); oHiliter.Weight = 5; oHiliter.Color = ColorConstants.RGBYellow; oHiliter.LinePattern = HiliterBase.HiliterLinePattern.Dotted; Hiliter oHiliter2 = new Hiliter(); oHiliter2.Weight = 10; oHiliter2.Color = ColorConstants.RGBBlue; Hiliter oHiliter3 = new Hiliter(); oHiliter3.Weight = 3; oHiliter3.Color = ColorConstants.RGBWhite; Dictionary <string, List <BusinessObject> > oDic = new Dictionary <string, List <BusinessObject> >(); oDic["Overlap"] = new List <BusinessObject>(); oDic["Inside"] = new List <BusinessObject>(); ClientServiceProvider.SelectSet.SelectedObjects.Clear(); foreach (var oObject in oColl) { if (!IsSupportInerface(oObject)) { refObjList.Add(oObject); stringList.Add(oObject.ObjectID); } else { continue; } OrientedRangeBox oObjectOrientedBox = oMathService.GetOrientedRangeBox(new Collection <BusinessObject>( new List <BusinessObject>() { oObject })); //OrientedRangeBox of the Object RangeBoxIntersectionType intersectionType = oOrientedRangeBox.Intersects(oObjectOrientedBox); //Find Intersect b/w them if (intersectionType == RangeBoxIntersectionType.Overlap) { //ClientServiceProvider.SelectSet.SelectedObjects.Add(oObject); oDic["Overlap"].Add(oObject); //foreach (var oPlaTest in MakePlane3D6ByOrientedRangeBox(oPipeOrientedBox)) //{ // oHiliter3.HilitedObjects.Add(oPlaTest); //} } else if (intersectionType == RangeBoxIntersectionType.Inside) { //ClientServiceProvider.SelectSet.SelectedObjects.Add(oObject); oDic["Inside"].Add(oObject); //foreach (var oPlaTest in MakePlane3D6ByOrientedRangeBox(oPipeOrientedBox)) //{ // oHiliter2.HilitedObjects.Add(oPlaTest); //} } foreach (KeyValuePair <string, List <BusinessObject> > item in oDic) { if (item.Key.Equals("Overlap")) { foreach (var oBO in oDic[item.Key]) { oHiliter3.HilitedObjects.Add(oBO); } } else if (item.Key.Equals("Inside")) { foreach (var oBO in oDic[item.Key]) { oHiliter2.HilitedObjects.Add(oBO); } } } //Debug.Print(oObj.ObjectIDForQuery); } //var oPlaColl = MakePlane3D6ByOrientedRangeBox(oOrientedRangeBox); var oPlaColl2 = MakePlane3D6ByOrientedRangeBox(oOrientedRangeBox); foreach (var oPlane in oPlaColl2) { oHiliter.HilitedObjects.Add(oPlane); } if (refObjList.Count == 0) { CreateOrUpdateDefect(oObj, 1, false, "", null, null); } else { Dictionary <string, string> DefectDic = new Dictionary <string, string>() { { "distance", _oSetting.Clearance.Value } }; CreateOrUpdateDefect(oObj, 1, true, _oRuleDescriptionHelper.GetFullErrorDescription(1, DefectDic), refObjList, null); } } } } }
public Main() { InitializeComponent(); mainObjectContext = DemoData.LoadDemoData(); DataContext = mainObjectContext; }
public static ArtifactData GenerateArtifact(MainObject main) => new ArtifactData(main);
public void Delete() { repo.DeleteFunding(this); MainObject.UpdateActivityDateToNow(MainId); }
void compile() { Compiler.setCode(currentCode); Data.output = ""; if (Compiler.compile()) { Debug.Log("compilation succesfull"); GameObject obj = Data.objects[Data.activeObj]; if (obj.tag == "animal") { } else if (obj.tag == "train") { TrackBuilder tb; RollerCoaster rc = obj.GetComponent <RollerCoaster>(); MainObject mo = obj.GetComponent <MainObject>(); if (rc.tb != null) { rc.tb.reset(); //tb = rc.tb; } tb = new TrackBuilder(obj);; tb.setModel(mo.model); tb.setType(0); tb.generate(mo.script); rc.tb = tb; } else if (obj.tag == "wall") { WallBuilder wb; Wall wall = obj.GetComponent <Wall>(); MainObject mo = obj.GetComponent <MainObject>(); if (wall.wb != null) { wall.wb.reset(); //tb = rc.tb; } wb = new WallBuilder(obj); wb.setModel(mo.model); wb.generate(mo.script); wall.wb = wb; } else if (obj.tag == "graph") { GraphPlotter gp; Graph graph = obj.GetComponent <Graph>(); MainObject mo = obj.GetComponent <MainObject>(); if (graph.gp != null) { graph.gp.reset(); //tb = rc.tb; } gp = new GraphPlotter(obj); gp.generate(mo.script); graph.gp = gp; } } else { Debug.Log("compilation error:" + Compiler.getError()); Data.output += Compiler.getError() + "\n"; } }
// Use this for initialization void Start() { mainObject = GameObject.Find("MainObject"); playerScript = mainObject.GetComponent<MainObject>(); txt = GetComponent<Text>(); }
public void CreateJoint() { if (joint != null || GetSkeletalJoint() == null) { return; } switch (GetSkeletalJoint().GetJointType()) { case SkeletalJointType.ROTATIONAL: WheelType wheelType = WheelType.NOT_A_WHEEL; if (this.HasDriverMeta <WheelDriverMeta>()) { OrientWheelNormals(); wheelType = this.GetDriverMeta <WheelDriverMeta>().type; } RotationalJoint_Base rNode = (RotationalJoint_Base)GetSkeletalJoint(); BHingedConstraintEx hc = (BHingedConstraintEx)(joint = ConfigJoint <BHingedConstraintEx>(rNode.basePoint.AsV3() - ComOffset, rNode.axis.AsV3(), AxisType.X)); Vector3 rAxis = rNode.axis.AsV3().normalized; hc.axisInA = rAxis; hc.axisInB = rAxis; if (hc.setLimit = rNode.hasAngularLimit) { hc.lowLimitAngleRadians = rNode.currentAngularPosition - rNode.angularLimitHigh; hc.highLimitAngleRadians = rNode.currentAngularPosition - rNode.angularLimitLow; } hc.constraintType = BTypedConstraint.ConstraintType.constrainToAnotherBody; break; case SkeletalJointType.CYLINDRICAL: CylindricalJoint_Base cNode = (CylindricalJoint_Base)GetSkeletalJoint(); B6DOFConstraint bc = (B6DOFConstraint)(joint = ConfigJoint <B6DOFConstraint>(cNode.basePoint.AsV3() - ComOffset, cNode.axis.AsV3(), AxisType.X)); bc.linearLimitLower = new Vector3(cNode.linearLimitStart * 0.01f, 0f, 0f); bc.linearLimitUpper = new Vector3(cNode.linearLimitEnd * 0.01f, 0f, 0f); bc.constraintType = BTypedConstraint.ConstraintType.constrainToAnotherBody; break; case SkeletalJointType.LINEAR: LinearJoint_Base lNode = (LinearJoint_Base)GetSkeletalJoint(); Vector3 lAxis = lNode.axis.AsV3().normalized; // TODO: Figure out how to make a vertical slider? BSliderConstraint sc = (BSliderConstraint)(joint = ConfigJoint <BSliderConstraint>(lNode.basePoint.AsV3() - ComOffset, lNode.axis.AsV3(), AxisType.X)); if (lAxis.x < 0) { lAxis.x *= -1f; } if (lAxis.y < 0) { lAxis.y *= -1f; } if (lAxis.z < 0) { lAxis.z *= -1f; } sc.localConstraintAxisX = lAxis; sc.localConstraintAxisY = new Vector3(lAxis.y, lAxis.z, lAxis.x); sc.lowerLinearLimit = lNode.linearLimitLow * 0.01f; sc.upperLinearLimit = lNode.linearLimitHigh * 0.01f; sc.lowerAngularLimitRadians = 0f; sc.upperAngularLimitRadians = 0f; sc.constraintType = BTypedConstraint.ConstraintType.constrainToAnotherBody; bool b = this.HasDriverMeta <ElevatorDriverMeta>(); if (GetSkeletalJoint().cDriver != null) { if (GetSkeletalJoint().cDriver.GetDriveType().IsElevator()) { MainObject.GetComponent <BRigidBody>().mass *= 2f; } } break; } }