public Jank(DisplayName name, Screw screw, Level level, Reward reward) { Name = name; Screw = screw; Level = level; Reward = reward; }
private void button1_Click(object sender, EventArgs e) { switch (tabControl1.SelectedIndex) { case 0: Screw s = screwSizes[screwDiams.SelectedIndex]; s.Length = screwLen[screwLength.SelectedIndex]; s.Draw(UFSession.GetUFSession(), path + "screw" + System.IO.Directory.EnumerateFiles(path).Where(f => f.Contains("screw")).ToList().Count); break; case 1: PushScrew ps = pScrewSizes[pScrewDiams.SelectedIndex]; ps.Length = pScrewLen[pScrewLength.SelectedIndex]; ps.Draw(UFSession.GetUFSession(), path + "p_screw" + System.IO.Directory.EnumerateFiles(path).Where(f => f.Contains("p_screw")).ToList().Count); break; case 2: Nut n = nutSizes[nutDiams.SelectedIndex]; n.Draw(UFSession.GetUFSession(), path + "nut" + System.IO.Directory.EnumerateFiles(path).Where(f => f.Contains("nut")).ToList().Count); break; default: break; } }
/// <summary> /// 解析数据,并调用事件处理程序 /// </summary> private void Decode() { var data = new Result(); // 计算扭矩 var digitCount = 7; float scale; for (int i = 0; i < digitCount; i++) { int temp; int.TryParse(((char)_data[i + 6]).ToString(), out temp); scale = (float)Math.Pow(10, digitCount - i - 1); data.Torque += temp * scale; } scale = (float)Math.Pow(0.1, 4); data.Torque *= scale; // 计算角度 digitCount = 4; for (int i = 0; i < digitCount; i++) { int temp; int.TryParse(((char)_data[i + 13]).ToString(), out temp); scale = (float)Math.Pow(10, digitCount - i - 1); data.Angle += (int)(temp * scale); } // 计算工作结果 data.Qualified = _data[17] == 0x42; // 调用事件处理程序 Screw?.Invoke(data); }
private Point3 getFarestPoint(Screw screw) { Point3 pt = screw.aplicationPoint.toPoint3(); Double countUp = 0, countDown = 0; Point3[] ptsAround = this.figure.getPtsAround(pt); if (ptsAround == null) { return(null); } int[] indPtsAround = new int[] { this.figure.IndexOf(ptsAround[0]), this.figure.IndexOf(ptsAround[1]) }; int lenFig = this.figure.Count; int idown = indPtsAround.Min(); int iup = indPtsAround.Max(); countUp += screw.aplicationPoint.substract(this.figure[iup].toVector()).getNorm(); countDown += screw.aplicationPoint.substract(this.figure[idown].toVector()).getNorm(); while (idown != iup) { if (countUp > countDown) { this.incraseCount(ref idown, ref countDown, lenFig, -1); } else { this.incraseCount(ref iup, ref countUp, lenFig, 1); } } return(this.figure[idown]); }
protected virtual void OnTriggerExit(Collider collider) { if (collider.gameObject.name == "Screw") { currentScrewComponent = null; screwTip.GetComponent <Renderer>().material.color = Color.gray; } }
protected virtual void OnTriggerEnter(Collider collider) { if (collider.gameObject.GetComponent <Screw>()) { currentScrewComponent = collider.gameObject.GetComponent <Screw>(); screwTip.GetComponent <Renderer>().material.color = Color.red; } }
public RotaryEngine(int power, int fuelConsumption) { Power = power; FuelConsumption = fuelConsumption; Screw = new Screw() { PaddlesCount = 4 }; }
private void OnTriggerEnter(Collider other) { Screw screw; if (other.TryGetComponent(out screw)) { selectedScrew = screw; } }
void Start() { paused = false; screw = null; _cursorControls = GameObject.FindObjectOfType <CursorControls>(); _collider = GetComponent <Collider2D>(); }
private void OnUnscrew(Screw screw) { this._screwsRemoved.Add(screw); if (this.screws.Count == this._screwsRemoved.Count) { this.cap.transform.parent = null; this.cap.isKinematic = false; } }
private void OnTriggerExit(Collider other) { if (selectedScrew) { if (other.gameObject == selectedScrew.gameObject) { selectedScrew = null; } } }
public Figure calculateDeformation(Point3 ptStart, Point3 ptEnd, Screw screw, Screw screwPtStart, bool firstStep) { if (!firstStep) { return(normalDeformation(ptStart, ptEnd, screwPtStart)); } else { return(curbDeformation(ptStart, ptEnd, screw)); } }
private Figure curbDeformation(Point3 ptStart, Point3 ptEnd, Screw screw) { float distPtStartPtEnd = ptEnd.toVector().substract(ptStart.toVector()).getNorm(); float lScrew = screw.aplicationPoint.substract(ptStart.toVector()).getNorm(); Figure figure = new Figure(); if (distPtStartPtEnd < 2) { return(figure); } Projector projector = new Projector(Projector.getUsualBase()); projector.constructFinalBase(ptEnd.toVector().substract(ptStart.toVector()), ptStart.toVector()); FloatVector ptStartFinalBase = projector.projectToFinalBase(ptStart.toVector()) , ptEndFinalBase = projector.projectToFinalBase(ptEnd.toVector()); Screw screwFinalBase = screw.project(projector, true); float l = distPtStartPtEnd; float k = lScrew; FunctionPolynomial ftcStartY = this.getDeformationFunctionY(l, k, screwFinalBase.N, screwFinalBase.Y, true, 2); //FunctionPolynomial ftcStartZ = this.getDeformationFunctionZ(l, k, screwFinalBase.M, screwFinalBase.Z, true, 2); FunctionPolynomial ftcEndY = this.getDeformationFunctionY(l, k, screwFinalBase.N, screwFinalBase.Y, false, 2); //FunctionPolynomial ftcEndZ = this.getDeformationFunctionZ(l, k, screwFinalBase.M, screwFinalBase.Z, false, 2); FloatVector pointResult = ptStartFinalBase.vectorWhithAllCoordinatesEquals(0); float X = ptStartFinalBase[0]; do { pointResult = ptStartFinalBase.vectorWhithAllCoordinatesEquals(0); //pointResult[0] = X; if (X == 999) { ; } if (X < lScrew) { pointResult[1] = ftcStartY.calcY(X) / (this.E * this.IGz); //pointResult[2] = ftcStartZ.calcY(X) / (this.E * this.IGz); } else { pointResult[1] = ftcEndY.calcY(X) / (this.E * this.IGz); //pointResult[2] = ftcEndZ.calcY(X) / (this.E * this.IGz); } X += 1; figure.Add(projector.projectToOriginalBase(pointResult, false).toPoint3()); }while (X <= ptEndFinalBase[0]); return(figure); }
private void OnTriggerEnter(Collider other) { // when a srew is in range cache it if (other.CompareTag("Screw")) { Screw screw = other.GetComponent <Screw>(); if (screwType == screw.screwType) { screwInRange = screw; } } }
public void test1() { Figure figureTest = new Figure(); figureTest.readFile(); Screw screwTest = new Screw(new float[] { 500, 500, 0, 0, 0, 0 }, figureTest[0].toVector()); float Igz = (float)(3.14 * Math.Pow(5, 3)) / 64; UI_Library.Code.RDMengine.RDMengine engineTest = new UI_Library.Code.RDMengine.RDMengine(figureTest, 500, Igz); engineTest.applyScrew(screwTest); Figure figureResult = engineTest.figure; }
public void OnUnscrew(Screw screw) { foreach (var s in Screws) { if (s.IsScrewed()) { return; } } // All screws have been unscrewed Free(); }
public TurbopropEngine(int power, int fuelConsumption) { Power = power; FuelConsumption = fuelConsumption; Screw = new Screw() { PaddlesCount = 4 }; Turbine = new Turbine() { Pressure = 100 }; }
public void applyScrew(Screw screw) { Point3[] ptsAround = this.figure.getPtsAround(screw.aplicationPoint.toPoint3()); if (ptsAround == null) { throw new NotInFigureExeption(); } FloatVector directorPtAround = ptsAround[1].toVector().substract(ptsAround[0].toVector()).normalize(); FloatVector ptOnFigure = ptsAround[0].toVector().add(directorPtAround.multiplyByScalar(screw.aplicationPoint.scalarProduct(directorPtAround))); Screw screwOnFigure = Screw.fromWrenchAndTwist(screw.getWrench(), screw.getTwist(), ptOnFigure); List <Figure> listMoves = new List <Figure>(); listMoves.Add(this.calculateDeformation(ptsAround[0], ptsAround[1], screwOnFigure, null, true)); Point3 ptmax = this.getFarestPoint(screwOnFigure); int i = 0; int[] posPtsAround = new int[] { Array.IndexOf(this.figure.ToArray(), ptsAround[0]), Array.IndexOf(this.figure.ToArray(), ptsAround[1]) }; int increment = posPtsAround[0] < posPtsAround[1] ? 1 : -1; bool endLeft = false, endRight = false; int nbBoucles = 1; List <Point3[]> ptsUsedToCalc = new List <Point3[]>(); ptsUsedToCalc.Add(ptsAround); while (!endLeft || !endRight) { Point3 ptStart, ptEnd; foreach (bool right in new bool[] { true, false }) { int indRef = right ? 1 : 0; ptStart = this.getPt(true, right, posPtsAround[indRef], nbBoucles, increment, this.figure); ptEnd = this.getPt(false, right, posPtsAround[indRef], nbBoucles, increment, this.figure); ptsUsedToCalc.Add(new Point3[] { ptStart, ptEnd }); listMoves.Add((right ? endRight : endLeft) ? null : this.calculateDeformation(ptStart, ptEnd, null, screwOnFigure.changeApplicationPoint(ptStart.toVector()), false)); if (ptEnd == ptmax) { if (right) { endRight = true; } else { endLeft = true; } } } ; i += 2; nbBoucles++; } this.figure = this.getNewFigure(this.figure, listMoves, ptsUsedToCalc, ptmax); }
public Match(Nut _nut, Screw _screw) { Nut = _nut; Screw = _screw; if (_nut.Diameter == _screw.Diameter) { Diameter = _nut.Diameter; } else { throw new Exception("Error"); } }
public void Initializer() { //TODO: CREATE THIS BETTER Nuts = new Nut[NutsQuantity]; Screws = new Screw[ScrewQuantity]; for (var a = 0; a < NutsQuantity; a++) { Nuts[a] = new Nut(new Random().Next(minDiameterSize, maxDiameterSize)); } for (var a = 0; a < ScrewQuantity; a++) { Screws[a] = new Screw(new Random().Next(minDiameterSize, maxDiameterSize)); } }
private void OnTriggerExit(Collider other) { // clear cache when screw exits if (other.CompareTag("Screw")) { Screw screw = other.GetComponent <Screw>(); if (screwType == screw.screwType) { if (screw == screwInRange) { screwInRange = null; } } } }
private Figure normalDeformation(Point3 ptStart, Point3 ptEnd, Screw screwPtStart) { float distPtStartPtEnd = ptEnd.toVector().substract(ptStart.toVector()).getNorm(); Figure figure = new Figure(); if (distPtStartPtEnd < 2) { return(figure); } Projector projector = new Projector(Projector.getUsualBase()); projector.constructFinalBase(ptEnd.toVector().substract(ptStart.toVector()), ptStart.toVector()); FloatVector ptStartFinalBase = projector.projectToFinalBase(ptStart.toVector()) , ptEndFinalBase = projector.projectToFinalBase(ptEnd.toVector()); Screw screwPtStartFinalBase = screwPtStart.project(projector, true); float l = distPtStartPtEnd; FunctionPolynomial ftcY = this.getDeformationFunctionY(l, 0, screwPtStartFinalBase.N, screwPtStartFinalBase.Y, true, 0); //FunctionPolynomial ftcZ = this.getDeformationFunctionZ(l, 0, screwPtStartFinalBase.M, - screwPtStartFinalBase.Z, true, 0); FloatVector pointResult = ptStartFinalBase.vectorWhithAllCoordinatesEquals(0); float X = ptStartFinalBase[0]; do { if (X == 1) { ; } if (X == 1000) { ; } if (X == 2000) { ; } pointResult = ptStartFinalBase.vectorWhithAllCoordinatesEquals(0); //pointResult[0] = X; pointResult[1] = ftcY.calcY(X) / (this.E * this.IGz); //pointResult[2] = ftcZ.calcY(X)/ (this.E * this.IGz); X += 1; figure.Add(projector.projectToOriginalBase(pointResult, false).toPoint3()); }while (X <= ptEndFinalBase[0]); return(figure); }
public void CheckDetailTrashTest() { IDetail bolt = new Bolt(1, 1, 2); for (int i = 0; i < 100; i++) { if (checkerContainer.CheckDetail(bolt)) { Assert.IsTrue(checkerContainer.CheckDetail(bolt)); break; } } IDetail screw = new Screw(1, 1, 2); for (int i = 0; i < 100; i++) { if (checkerContainer.CheckDetail(bolt)) { Assert.IsTrue(checkerContainer.CheckDetail(screw)); break; } } IDetail nail = new Nail(1, 1, 2); for (int i = 0; i < 100; i++) { if (checkerContainer.CheckDetail(bolt)) { Assert.IsTrue(checkerContainer.CheckDetail(nail)); break; } } IDetail wheel = new Wheel(1, 1, 2); for (int i = 0; i < 100; i++) { if (checkerContainer.CheckDetail(bolt)) { Assert.IsTrue(checkerContainer.CheckDetail(wheel)); break; } } }
public void GetDetailEqualOfTypesTest() { Bolt bolt = new Bolt(); Assert.AreEqual(bolt.GetType(), checkerContainer.CreateDetail(new Bolt()).GetType()); Screw screw = new Screw(); Assert.AreEqual(screw.GetType(), checkerContainer.CreateDetail(new Screw()).GetType()); Nail nail = new Nail(); Assert.AreEqual(nail.GetType(), checkerContainer.CreateDetail(new Nail()).GetType()); Wheel wheel = new Wheel(); Assert.AreEqual(wheel.GetType(), checkerContainer.CreateDetail(new Wheel()).GetType()); }
public void CheckDetailTest() { IDetail bolt = new Bolt(0.5, 0.5, 3); Assert.IsTrue(checkerContainer.CheckDetail(bolt)); IDetail screw = new Screw(0.2, 0.3, 4); Assert.IsTrue(checkerContainer.CheckDetail(screw)); IDetail nail = new Nail(0.2, 0.3, 4); Assert.IsTrue(checkerContainer.CheckDetail(nail)); IDetail wheel = new Wheel(10, 4, 10); Assert.IsTrue(checkerContainer.CheckDetail(wheel)); }
public void PlaceScrew() { if (paused || screw != null) { return; } _collider.enabled = false; _cursorControls.MouseExit(); var obj = Instantiate(screwPrefab, transform); screw = obj.GetComponent <Screw>(); var sounds = Util.GetSoundManager(); screw.screwSound = sounds.screwSound; screw.screwDoneSound = sounds.screwDoneSound; }
public void TestMethod2() { Figure figure = new Figure(); figure.Add(new Point2(0, 0)); figure.Add(new Point2(2000, 0)); figure.Add(new Point2(2000, 2000)); figure.Add(new Point2(0, 2000)); RDMengine engine = new RDMengine(figure, 1, 1); Screw screw = new Screw(new float[] { 0, (float)(-5.0 * Math.Pow(10, -6)), 0, 0, 0, 0 }, new Point2(0, 1000).toVector()); /*Assert.AreEqual( * engine.getDeformationFunctionY(2000, 1000, 0, (float)(-5.0 * Math.Pow(10, -8)), true, 2).calcY(1000), * engine.getDeformationFunctionY(2000, 1000, 0, (float)(-5.0 * Math.Pow(10, -8)), false, 2).calcY(1000) * );*/ Figure results1 = engine.calculateDeformation(figure[0], figure[1], screw, null, true); show(results1); screw = screw.changeApplicationPoint(figure[1].toVector()); Figure results2 = engine.calculateDeformation(figure[0], figure[1], null, screw, true); }
private void OnTriggerEnter(Collider collision) { //too soon if (Time.time < screwingTime) { if (audioSource) { //audioSource.PlayOneShot(hammerHit, 0.7F); } return; } if (!ScrewDriver) { ScrewDriver = GetComponentInParent <PlayerScrewdriver>(); } if (ScrewDriver && ScrewDriver.IsScrewingIn) { Screw screw = collision.GetComponentInParent <Screw>(); if (screw) { if (audioSource) { // audioSource.PlayOneShot(hammerHit, 0.7F); } // screwingTime = Time.time + 0.25f; // screw.screwingTime(); if (screwEffect) { var newEffect = Instantiate(screwEffect, transform.position, Quaternion.identity); // Destroy(newEffect, 2f); } } } }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var jsonObject = JObject.Load(reader); var material = default(Material); var materialTypeString = jsonObject["MaterialType"].Value <string>(); var materialType = EnumsNET.Enums.Parse <MaterialType>(materialTypeString); switch (materialType) { case MaterialType.Lumber: material = new Lumber(); break; case MaterialType.SteelSection: material = new SteelSection(); break; case MaterialType.ConnectorPlate: material = new ConnectorPlate(); break; case MaterialType.Hanger: material = new Hanger(); break; case MaterialType.Screw: material = new Screw(); break; case MaterialType.Unknown: material = new Material(); break; } serializer.Populate(jsonObject.CreateReader(), material); return(material); }
private void CheckHit() { if (selectedScrew) { if (selectedScrew.screwModel.localPosition.x <= 0.15f) { DrillDown(); ScrewDown(); } else { entryScrew = true; selectedScrew.DisableScrew(); screwsList.Remove(selectedScrew); selectedScrew = null; if (!selectedScrew) { colliderCollision = false; } } } }
string Screw.Framework.Kernel.Json.IJson.Serialize(Screw.Framework.Kernel.Json.Value input) { return ""; }
string Screw.Framework.Kernel.Json.IJson.Serialize(Screw.Framework.Kernel.Json.Value input) { if (!pass) { pass = true; return ""; } var response = (Screw.Framework.Kernel.Json.Object)input; Assert.AreEqual ("request identifier", ((Screw.Framework.Kernel.Json.String)response.Properties ["id"]).Value); Assert.IsInstanceOf <Screw.Framework.Kernel.Json.Null> (response.Properties ["error"]); result = response.Properties ["result"]; return "output json string"; }