public static Direction3 ToDirection3(Vector3 vec) { Direction3 dir = new Direction3(); if (vec.x > 0f) { dir.x = DIRECTION.RIGHT; } else if (vec.x < 0f) { dir.x = DIRECTION.LEFT; } else { dir.x = DIRECTION.ZERO; } if (vec.y > 0f) { dir.y = DIRECTION.UP; } else if (vec.y < 0f) { dir.y = DIRECTION.DOWN; } else { dir.y = DIRECTION.ZERO; } if (vec.z > 0f) { dir.z = DIRECTION.FRONT; } else if (vec.z < 0f) { dir.z = DIRECTION.BACK; } else { dir.z = DIRECTION.ZERO; } return(dir); }
/// <summary> Get the normal of the <see cref="AxisAlignedBox"/> at a specified <paramref name="position"/> </summary> /// <param name="position">The surface position to get the normal for</param> /// <returns>The normal at the specified <paramref name="position"/></returns> public Normal3 SurfaceNormal(Position3 position) { Direction3 direction = (position - Center) / (Position3.Origin + Size); Direction1 x = IDirection1.Abs(direction.X); Direction1 y = IDirection1.Abs(direction.Y); Direction1 z = IDirection1.Abs(direction.Z); Normal3 normal; if (x > y && x > z) { normal = direction.X > 0f ? Normal3.UnitX : -Normal3.UnitX; } else if (y > z) { normal = direction.Y > 0f ? Normal3.UnitY : -Normal3.UnitY; } else { normal = direction.Z > 0f ? Normal3.UnitZ : -Normal3.UnitZ; } return(normal); }
public Torch(Direction3 facing = Direction3.Up) { Facing = facing; }
public static Result ReadDXFTin(bool is3d, DxfFile dxfFile, string layer, string breaklinelayer, double minDist, bool breakline) { //TODO //use is3d is not requiered anymore! // double minDistSq = minDist * minDist; var result = new Result(); if (!UnitToMeter.TryGetValue(dxfFile.Header.DefaultDrawingUnits, out double scale)) { scale = 1.0; } //TIN Builder var tinB = Tin.CreateBuilder(true); Dictionary <int, Line3> breaklines = new Dictionary <int, Line3>(); //Dictionary für Punkte der Bruchkanten Logger logger = LogManager.GetCurrentClassLogger(); int index = 0; #region PNR - Counter int pnr = 0; #endregion foreach (var entity in dxfFile.Entities) { if (entity.Layer == layer && entity is Dxf3DFace face) { var p1 = Point3.Create(face.FirstCorner.X * scale, face.FirstCorner.Y * scale, face.FirstCorner.Z * scale); var p2 = Point3.Create(face.SecondCorner.X * scale, face.SecondCorner.Y * scale, face.SecondCorner.Z * scale); var p3 = Point3.Create(face.ThirdCorner.X * scale, face.ThirdCorner.Y * scale, face.ThirdCorner.Z * scale); var p4 = Point3.Create(face.FourthCorner.X * scale, face.FourthCorner.Y * scale, face.FourthCorner.Z * scale); if (Vector3.Norm2(p4 - p3) < minDistSq) { //Punkte hinzufügen & jeweils eine Punktnummer hochzählen tinB.AddPoint(pnr++, p1); tinB.AddPoint(pnr++, p2); tinB.AddPoint(pnr++, p3); //Schleife zum erzeugen des Dreiecks for (int i = pnr - 3; i < pnr; i++) { tinB.AddTriangle(i++, i++, i++); } } } if (entity.Layer == breaklinelayer && breakline == true) { switch (entity.EntityType) { /*case DxfEntityType.Vertex: //Punkt * var vtx = (DxfVertex)entity; * pp_bl.AddPoint(Point3.Create(vtx.Location.X, vtx.Location.Y, vtx.Location.Z)); * break;*/ case DxfEntityType.Line: //Linie var line = (DxfLine)entity; Point3 p1 = Point3.Create(line.P1.X * scale, line.P1.Y * scale, line.P1.Z * scale); Point3 p2 = Point3.Create(line.P2.X * scale, line.P2.Y * scale, line.P2.Z * scale); Vector3 v12 = Vector3.Create(p2); Direction3 d12 = Direction3.Create(v12, scale); Line3 l = Line3.Create(p1, d12); try { breaklines.Add(index, l); index++; } catch { index++; } break; /*case DxfEntityType.Polyline: //Bögen * var poly = (DxfPolyline)entity; * int last = -1; * foreach (var v in poly.Vertices) * { * int curr = pp_bl.AddPoint(Point3.Create(v.Location.X * scale, v.Location.Y * scale, v.Location.Z * scale)); * if (last >= 0) * { * pp_bl.FixEdge(last, curr); * } * last = curr; * } * break;*/ } } } /* ÜBERARBEITEN mit neuer Abfrage! * if(!tin.Points.Any() || !tin.FaceEdges.Any()) * { * result.Error = Properties.Resources.errNoLineData; * logger.Error("Error. No line data found"); * return result; * } */ //TIN aus TIN-Builder erzeugen Tin tin = tinB.ToTin(out var pointIndex2NumberMap, out var triangleIndex2NumberMap); //Result beschreiben result.Tin = tin; //Fehler für Bruchkanten abfangen lassen try { result.Breaklines = breaklines; logger.Info(breaklines.Count + " breaklines read"); } catch { logger.Error("Breaklines could not be processed."); } //logging logger.Info("Reading DXF-data successful"); logger.Info(result.Tin.Points.Count() + " points; " + result.Tin.NumTriangles + " triangels processed"); return(result); }
public Dispenser(Direction3 facing = Direction3.Down, bool isActivated = false) { Facing = facing; IsActivated = isActivated; }
public BlockEventArgs(int entityId, Vector3 position, Direction3 facing) : base() { EntityId = entityId; Position = position; Facing = facing; }
IEnumerator Rexar(int Layer, Collider2D other) { B1.SetActive(true); Tr1.position = Pos1; B1.layer = Layer; B1.GetComponent <Ball> ().Direction = Direction1; B2.SetActive(true); Tr2.position = Pos2; B2.layer = Layer; B2.GetComponent <Ball> ().Direction = Direction2; //Rb2 = other.GetComponent<Rigidbody2D> (); B3.SetActive(true); Tr3.position = Pos3; B3.layer = Layer; B3.GetComponent <Ball> ().Direction = Direction2; B4.SetActive(true); Tr4.position = Pos4; B4.layer = Layer; B4.GetComponent <Ball> ().Direction = Direction2; B5.SetActive(true); Tr5.position = Pos5; B5.layer = Layer; B5.GetComponent <Ball> ().Direction = Direction2; yield return(new WaitForSeconds(0.1f)); Rb1.Sleep(); B1.GetComponent <TrailRenderer> ().time = Mathf.Infinity; Rb2.Sleep(); B2.GetComponent <TrailRenderer> ().time = Mathf.Infinity; Rb3.Sleep(); B3.GetComponent <TrailRenderer> ().time = Mathf.Infinity; Rb4.Sleep(); B4.GetComponent <TrailRenderer> ().time = Mathf.Infinity; Rb5.Sleep(); B5.GetComponent <TrailRenderer> ().time = Mathf.Infinity; Tr1.position = Pos1; Tr2.position = Pos2; Tr3.position = Pos3; Tr4.position = Pos4; Tr5.position = Pos5; if (Direction1.Equals(1)) { Rb1.AddForce(V * new Vector2(200.0f, 0.0f)); } if (Direction1.Equals(2)) { Rb1.AddForce(V * new Vector2(0.0f, 200.0f)); } if (Direction1.Equals(3)) { Rb1.AddForce(V * new Vector2(-200.0f, 0.0f)); } if (Direction1.Equals(4)) { Rb1.AddForce(V * new Vector2(0.0f, -200.0f)); } if (Direction1.Equals(8)) { Rb1.AddForce(V * new Vector2(141.42f, -141.42f)); } if (Direction1.Equals(7)) { Rb1.AddForce(V * new Vector2(-141.42f, -141.42f)); } if (Direction1.Equals(6)) { Rb1.AddForce(V * new Vector2(-141.42f, 141.42f)); } if (Direction1.Equals(5)) { Rb1.AddForce(V * new Vector2(141.42f, 141.42f)); } if (Direction1.Equals(9)) { Rb1.AddForce(V * new Vector2(178.9869f, 89.24f)); } if (Direction1.Equals(10)) { Rb1.AddForce(V * new Vector2(-178.9869f, 89.24f)); } if (Direction1.Equals(11)) { Rb1.AddForce(V * new Vector2(-178.9869f, -89.24f)); } if (Direction1.Equals(12)) { Rb1.AddForce(V * new Vector2(178.9869f, -89.24f)); } if (Direction2.Equals(1)) { Rb2.AddForce(V * new Vector2(200.0f, 0.0f)); } if (Direction2.Equals(2)) { Rb2.AddForce(V * new Vector2(0.0f, 200.0f)); } if (Direction2.Equals(3)) { Rb2.AddForce(V * new Vector2(-200.0f, 0.0f)); } if (Direction2.Equals(4)) { Rb2.AddForce(V * new Vector2(0.0f, -200.0f)); } if (Direction2.Equals(6)) { Rb2.AddForce(V * new Vector2(141.42f, -141.42f)); } if (Direction2.Equals(7)) { Rb2.AddForce(V * new Vector2(-141.42f, -141.42f)); } if (Direction2.Equals(8)) { Rb2.AddForce(V * new Vector2(-141.42f, 141.42f)); } if (Direction2.Equals(5)) { Rb2.AddForce(V * new Vector2(141.42f, 141.42f)); } if (Direction2.Equals(9)) { Rb2.AddForce(V * new Vector2(178.9869f, 89.24f)); } if (Direction2.Equals(10)) { Rb2.AddForce(V * new Vector2(-178.9869f, 89.24f)); } if (Direction2.Equals(11)) { Rb2.AddForce(V * new Vector2(-178.9869f, -89.24f)); } if (Direction2.Equals(12)) { Rb2.AddForce(V * new Vector2(178.9869f, -89.24f)); } if (Direction3.Equals(1)) { Rb3.AddForce(V * new Vector2(200.0f, 0.0f)); } if (Direction3.Equals(2)) { Rb3.AddForce(V * new Vector2(0.0f, 200.0f)); } if (Direction3.Equals(3)) { Rb3.AddForce(V * new Vector2(-200.0f, 0.0f)); } if (Direction3.Equals(4)) { Rb3.AddForce(V * new Vector2(0.0f, -200.0f)); } if (Direction3.Equals(6)) { Rb3.AddForce(V * new Vector2(141.42f, -141.42f)); } if (Direction3.Equals(7)) { Rb3.AddForce(V * new Vector2(-141.42f, -141.42f)); } if (Direction3.Equals(8)) { Rb3.AddForce(V * new Vector2(-141.42f, 141.42f)); } if (Direction3.Equals(5)) { Rb3.AddForce(V * new Vector2(141.42f, 141.42f)); } if (Direction3.Equals(9)) { Rb1.AddForce(V * new Vector2(178.9869f, 89.24f)); } if (Direction3.Equals(10)) { Rb3.AddForce(V * new Vector2(-178.9869f, 89.24f)); } if (Direction3.Equals(11)) { Rb3.AddForce(V * new Vector2(-178.9869f, -89.24f)); } if (Direction3.Equals(12)) { Rb3.AddForce(V * new Vector2(178.9869f, -89.24f)); } if (Direction4.Equals(1)) { Rb4.AddForce(V * new Vector2(200.0f, 0.0f)); } if (Direction4.Equals(2)) { Rb4.AddForce(V * new Vector2(0.0f, 200.0f)); } if (Direction4.Equals(3)) { Rb4.AddForce(V * new Vector2(-200.0f, 0.0f)); } if (Direction4.Equals(4)) { Rb4.AddForce(V * new Vector2(0.0f, -200.0f)); } if (Direction4.Equals(6)) { Rb4.AddForce(V * new Vector2(141.42f, -141.42f)); } if (Direction4.Equals(7)) { Rb4.AddForce(V * new Vector2(-141.42f, -141.42f)); } if (Direction4.Equals(8)) { Rb4.AddForce(V * new Vector2(-141.42f, 141.42f)); } if (Direction4.Equals(5)) { Rb4.AddForce(V * new Vector2(141.42f, 141.42f)); } if (Direction4.Equals(9)) { Rb4.AddForce(V * new Vector2(178.9869f, 89.24f)); } if (Direction4.Equals(10)) { Rb4.AddForce(V * new Vector2(-178.9869f, 89.24f)); } if (Direction4.Equals(11)) { Rb4.AddForce(V * new Vector2(-178.9869f, -89.24f)); } if (Direction4.Equals(12)) { Rb4.AddForce(V * new Vector2(178.9869f, -89.24f)); } if (Direction5.Equals(1)) { Rb5.AddForce(V * new Vector2(200.0f, 0.0f)); } if (Direction5.Equals(2)) { Rb5.AddForce(V * new Vector2(0.0f, 200.0f)); } if (Direction5.Equals(3)) { Rb5.AddForce(V * new Vector2(-200.0f, 0.0f)); } if (Direction5.Equals(4)) { Rb5.AddForce(V * new Vector2(0.0f, -200.0f)); } if (Direction5.Equals(6)) { Rb5.AddForce(V * new Vector2(141.42f, -141.42f)); } if (Direction5.Equals(7)) { Rb5.AddForce(V * new Vector2(-141.42f, -141.42f)); } if (Direction5.Equals(8)) { Rb5.AddForce(V * new Vector2(-141.42f, 141.42f)); } if (Direction5.Equals(5)) { Rb5.AddForce(V * new Vector2(141.42f, 141.42f)); } if (Direction5.Equals(9)) { Rb5.AddForce(V * new Vector2(178.9869f, 89.24f)); } if (Direction5.Equals(10)) { Rb5.AddForce(V * new Vector2(-178.9869f, 89.24f)); } if (Direction5.Equals(11)) { Rb5.AddForce(V * new Vector2(-178.9869f, -89.24f)); } if (Direction5.Equals(12)) { Rb5.AddForce(V * new Vector2(178.9869f, -89.24f)); } B1.GetComponent <Ball> ().Direction = Direction1; B2.GetComponent <Ball> ().Direction = Direction2; B3.GetComponent <Ball> ().Direction = Direction3; B4.GetComponent <Ball> ().Direction = Direction4; B5.GetComponent <Ball> ().Direction = Direction5; other.GetComponent <Rigidbody2D>().Sleep(); }
public void MovePlayer(Direction3 dir) { ClientCore.Instance.SendCommand <MoveCommand, Direction3>(new Coflnet.SourceReference(), dir); }
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); //initalisieren des Loggers in diesem Reader public static Result ReadPostGIS(bool is3d, double minDist, string Host, int Port, string User, string Password, string DBname, string schema, string tintable, string tincolumn, string tinidcolumn, int tinid, bool postgis_bl, string bl_column, string bl_table, string bl_tinid) { double scale = 1.0; var result = new Result(); // var tinB = Tin.CreateBuilder(true); Dictionary <int, Line3> breaklines = new Dictionary <int, Line3>(); try { //prepare string for database connection string connString = string.Format( "Host={0};Port={1};Username={2};Password={3};Database={4};", Host, Port, User, Password, DBname ); //TIN Request using (var conn = new NpgsqlConnection(connString)) { //open database connection conn.Open(); NpgsqlConnection.GlobalTypeMapper.UseLegacyPostgis(); //ÜBERARBEITEN ggf. weitere Request-Möglichkeiten??? //select request for tin without breaklines via TIN ID string tin_select = "SELECT " + "ST_AsEWKT(" + tincolumn + ") as wkt FROM " + schema + "." + tintable + " WHERE " + tinidcolumn + " = " + tinid; //select request for breaklines via TIN ID + JOIN string bl_select = null; if (postgis_bl == true) { bl_select = "SELECT ST_AsEWKT(" + bl_table + "." + bl_column + ") FROM " + schema + "." + bl_table + " JOIN " + schema + "." + tintable + " ON (" + bl_table + "." + bl_tinid + " = " + tintable + "." + tinidcolumn + ") WHERE " + tintable + "." + tinidcolumn + " = " + tinid; } //TIN abfragen using (var command = new NpgsqlCommand(tin_select, conn)) { var reader = command.ExecuteReader(); Logger.Info("The following REQUEST have been sent: \n" + tin_select); while (reader.Read()) { //read column --> as WKT string geom_string = (reader.GetValue(0)).ToString(); //Split - CRS & TIN string[] geom_split = geom_string.Split(';'); //String for EPSG - Code --> Weiterverarbeitung??? string tin_epsg = geom_split[0]; //Gesamtes TIN string tin_gesamt = geom_split[1]; //Split für den Anfang des TINs char[] trim = { 'T', 'I', 'N', '(' }; tin_gesamt = tin_gesamt.TrimStart(trim); //Split für jedes Dreieck string[] separator = { ")),((" }; string[] tin_string = tin_gesamt.Split(separator, System.StringSplitOptions.RemoveEmptyEntries); //Jedes Dreieck durchlaufen int pnr = 0; //initalisieren foreach (string face in tin_string) { //Punkte - Split über Komma string[] face_points = face.Split(','); //Split über Leerzeichen //FirstCorner string[] P1 = face_points[0].Split(' '); double P1X = Convert.ToDouble(P1[0], CultureInfo.InvariantCulture); double P1Y = Convert.ToDouble(P1[1], CultureInfo.InvariantCulture); double P1Z = Convert.ToDouble(P1[2], CultureInfo.InvariantCulture); //P1 var p1 = Point3.Create(P1X * scale, P1Y * scale, P1Z * scale); //SecoundCorner string[] P2 = face_points[1].Split(' '); double P2X = Convert.ToDouble(P2[0], CultureInfo.InvariantCulture); double P2Y = Convert.ToDouble(P2[1], CultureInfo.InvariantCulture); double P2Z = Convert.ToDouble(P2[2], CultureInfo.InvariantCulture); //P2 var p2 = Point3.Create(P2X * scale, P2Y * scale, P2Z * scale); //ThirdCorner string[] P3 = face_points[2].Split(' '); double P3X = Convert.ToDouble(P3[0], CultureInfo.InvariantCulture); double P3Y = Convert.ToDouble(P3[1], CultureInfo.InvariantCulture); double P3Z = Convert.ToDouble(P3[2], CultureInfo.InvariantCulture); //P3 var p3 = Point3.Create(P3X * scale, P3Y * scale, P3Z * scale); //Punkte hinzufügen & jeweils eine Punktnummer hochzählen tinB.AddPoint(pnr++, p1); tinB.AddPoint(pnr++, p2); tinB.AddPoint(pnr++, p3); //Schleife zum erzeugen des Dreiecks for (int i = pnr - 3; i < pnr; i++) { tinB.AddTriangle(i++, i++, i++); } } } conn.Close(); } //TIN aus TIN-Builder erzeugen Tin tin = tinB.ToTin(out var pointIndex2NumberMap, out var triangleIndex2NumberMap); //Result beschreiben result.Tin = tin; if (postgis_bl == true) { conn.Open(); //Bruchkanten abfragen int index_poly = 0; int index = 0; using (var command = new NpgsqlCommand(bl_select, conn)) { var reader = command.ExecuteReader(); Logger.Info("The following REQUEST have been sent: \n" + bl_select); while (reader.Read()) { string polyline_string = (reader.GetValue(0)).ToString(); string[] poly_split = polyline_string.Split(';'); //Gesamte Polyline string poly_gesamt = poly_split[1]; //Split für den Anfang des TINs char[] trim = { 'L', 'I', 'N', 'E', 'S', 'T', 'R', 'I', 'N', 'G', '(' }; poly_gesamt = poly_gesamt.TrimStart(trim); char[] trimEnd = { ')' }; poly_gesamt = poly_gesamt.TrimEnd(trimEnd); //Split für jeden Punkt string[] separator = { "," }; string[] polyline = poly_gesamt.Split(separator, System.StringSplitOptions.RemoveEmptyEntries); //Jeden Punkt in der Polyline durchlaufen int i = 0; int j = 1; do { string[] point_start_values = polyline[i].Split(' '); double p1X = Convert.ToDouble(point_start_values[0], CultureInfo.InvariantCulture); double p1Y = Convert.ToDouble(point_start_values[1], CultureInfo.InvariantCulture); double p1Z = Convert.ToDouble(point_start_values[2], CultureInfo.InvariantCulture); Point3 p1 = Point3.Create(p1X * scale, p1Y * scale, p1Z * scale); string[] point_end_values = polyline[j].Split(' '); double p2X = Convert.ToDouble(point_end_values[0], CultureInfo.InvariantCulture); double p2Y = Convert.ToDouble(point_end_values[1], CultureInfo.InvariantCulture); double p2Z = Convert.ToDouble(point_end_values[2], CultureInfo.InvariantCulture); Point3 p2 = Point3.Create(p2X * scale, p2Y * scale, p2Z * scale); Vector3 v12 = Vector3.Create(p2); Direction3 d12 = Direction3.Create(v12, scale); Line3 l = Line3.Create(p1, d12); try { breaklines.Add(index, l); //Breakline hinzufügen index++; } catch { index++; } i++; j++; } while (j < polyline.Length); index_poly++; } result.Breaklines = breaklines; } //close database connection conn.Close(); } Logger.Info("All database connections have been disconnected."); Logger.Info("Reading PostGIS successful"); Logger.Info(result.Tin.Points.Count() + " points; " + result.Tin.NumTriangles + " triangels processed"); } } catch (Exception e) { // Console.WriteLine(e.ToString()); Logger.Error("Database connection failed!"); } Console.ReadLine(); return(result); }
IEnumerator Rexar(int Layer, Collider2D other) { B1.SetActive(true); Tr1.position = Pos1; B1.layer = Layer; B1.GetComponent <Ball> ().Direction = Direction1; B2.SetActive(true); Tr2.position = Pos2; B2.layer = Layer; B2.GetComponent <Ball> ().Direction = Direction2; //Rb2 = other.GetComponent<Rigidbody2D> (); B3.SetActive(true); Tr3.position = Pos3; B3.layer = Layer; B3.GetComponent <Ball> ().Direction = Direction2; B4.SetActive(true); Tr4.position = Pos4; B4.layer = Layer; B4.GetComponent <Ball> ().Direction = Direction2; yield return(new WaitForSeconds(0.1f)); if (isChange) { if (Layer.Equals(8)) { //Debug.Log ("AAA"); for (int i = 0; i < 4; i++) { Change [i].color = new Color(0.0f, 0.0f, 0.0f, 1.0f); } } else if (Layer.Equals(9)) { for (int i = 0; i < 4; i++) { Change [i].color = new Color(230 / 255f, 0.0f, 18 / 255f, 1.0f); } } else if (Layer.Equals(10)) { for (int i = 0; i < 4; i++) { Change [i].color = new Color(0.0f, 153 / 255f, 68 / 255f, 1.0f); } } else if (Layer.Equals(11)) { for (int i = 0; i < 4; i++) { Change [i].color = new Color(249 / 255f, 230 / 255f, 47 / 255f, 1.0f); } } else if (Layer.Equals(12)) { for (int i = 0; i < 4; i++) { Change [i].color = new Color(0.0f, 71 / 255f, 157 / 255f, 1.0f); } } else if (Layer.Equals(13)) { for (int i = 0; i < 4; i++) { Change [i].color = new Color(228 / 255f, 0.0f, 180 / 255f, 1.0f); } } else if (Layer.Equals(14)) { for (int i = 0; i < 4; i++) { Change [i].color = new Color(0.0f, 160 / 255f, 233 / 255f, 1.0f); } } else if (Layer.Equals(15)) { for (int i = 0; i < 4; i++) { Change [i].color = new Color(1.0f, 1.0f, 1.0f, 1.0f); } } } Rb1.Sleep(); B1.GetComponent <TrailRenderer> ().time = Mathf.Infinity; Rb2.Sleep(); B2.GetComponent <TrailRenderer> ().time = Mathf.Infinity; Rb3.Sleep(); B3.GetComponent <TrailRenderer> ().time = Mathf.Infinity; Rb4.Sleep(); B4.GetComponent <TrailRenderer> ().time = Mathf.Infinity; Tr1.position = Pos1; Tr2.position = Pos2; Tr3.position = Pos3; Tr4.position = Pos4; if (Direction1.Equals(1)) { Rb1.AddForce(V * new Vector2(200.0f, 0.0f)); } if (Direction1.Equals(2)) { Rb1.AddForce(V * new Vector2(0.0f, 200.0f)); } if (Direction1.Equals(3)) { Rb1.AddForce(V * new Vector2(-200.0f, 0.0f)); } if (Direction1.Equals(4)) { Rb1.AddForce(V * new Vector2(0.0f, -200.0f)); } if (Direction1.Equals(8)) { Rb1.AddForce(V * new Vector2(141.42f, -141.42f)); } if (Direction1.Equals(7)) { Rb1.AddForce(V * new Vector2(-141.42f, -141.42f)); } if (Direction1.Equals(6)) { Rb1.AddForce(V * new Vector2(-141.42f, 141.42f)); } if (Direction1.Equals(5)) { Rb1.AddForce(V * new Vector2(141.42f, 141.42f)); } if (Direction1.Equals(9)) { Rb1.AddForce(V * new Vector2(178.9869f, 89.24f)); } if (Direction1.Equals(10)) { Rb1.AddForce(V * new Vector2(-178.9869f, 89.24f)); } if (Direction1.Equals(11)) { Rb1.AddForce(V * new Vector2(-178.9869f, -89.24f)); } if (Direction1.Equals(12)) { Rb1.AddForce(V * new Vector2(178.9869f, -89.24f)); } if (Direction1.Equals(13)) { Rb1.AddForce(V * new Vector2(89.24f, 178.9869f)); Tr1.position = Pos1; } if (Direction1.Equals(14)) { Rb1.AddForce(V * new Vector2(-89.24f, 178.9869f)); Tr1.position = Pos1; } if (Direction1.Equals(15)) { Rb1.AddForce(V * new Vector2(-89.24f, -178.9869f)); Tr1.position = Pos1; } if (Direction1.Equals(16)) { Rb1.AddForce(V * new Vector2(89.24f, -178.9869f)); Tr1.position = Pos1; } if (Direction2.Equals(1)) { Rb2.AddForce(V * new Vector2(200.0f, 0.0f)); } if (Direction2.Equals(2)) { Rb2.AddForce(V * new Vector2(0.0f, 200.0f)); } if (Direction2.Equals(3)) { Rb2.AddForce(V * new Vector2(-200.0f, 0.0f)); } if (Direction2.Equals(4)) { Rb2.AddForce(V * new Vector2(0.0f, -200.0f)); } if (Direction2.Equals(6)) { Rb2.AddForce(V * new Vector2(141.42f, -141.42f)); } if (Direction2.Equals(7)) { Rb2.AddForce(V * new Vector2(-141.42f, -141.42f)); } if (Direction2.Equals(8)) { Rb2.AddForce(V * new Vector2(-141.42f, 141.42f)); } if (Direction2.Equals(5)) { Rb2.AddForce(V * new Vector2(141.42f, 141.42f)); } if (Direction2.Equals(9)) { Rb2.AddForce(V * new Vector2(178.9869f, 89.24f)); } if (Direction2.Equals(10)) { Rb2.AddForce(V * new Vector2(-178.9869f, 89.24f)); } if (Direction2.Equals(11)) { Rb2.AddForce(V * new Vector2(-178.9869f, -89.24f)); } if (Direction2.Equals(12)) { Rb2.AddForce(V * new Vector2(178.9869f, -89.24f)); } if (Direction2.Equals(13)) { Rb2.AddForce(V * new Vector2(89.24f, 178.9869f)); Tr2.position = Pos2; } if (Direction2.Equals(14)) { Rb2.AddForce(V * new Vector2(-89.24f, 178.9869f)); Tr2.position = Pos2; } if (Direction2.Equals(15)) { Rb2.AddForce(V * new Vector2(-89.24f, -178.9869f)); Tr2.position = Pos2; } if (Direction2.Equals(16)) { Rb2.AddForce(V * new Vector2(89.24f, -178.9869f)); Tr2.position = Pos2; } if (Direction3.Equals(1)) { Rb3.AddForce(V * new Vector2(200.0f, 0.0f)); } if (Direction3.Equals(2)) { Rb3.AddForce(V * new Vector2(0.0f, 200.0f)); } if (Direction3.Equals(3)) { Rb3.AddForce(V * new Vector2(-200.0f, 0.0f)); } if (Direction3.Equals(4)) { Rb3.AddForce(V * new Vector2(0.0f, -200.0f)); } if (Direction3.Equals(6)) { Rb3.AddForce(V * new Vector2(141.42f, -141.42f)); } if (Direction3.Equals(7)) { Rb3.AddForce(V * new Vector2(-141.42f, -141.42f)); } if (Direction3.Equals(8)) { Rb3.AddForce(V * new Vector2(-141.42f, 141.42f)); } if (Direction3.Equals(5)) { Rb3.AddForce(V * new Vector2(141.42f, 141.42f)); } if (Direction3.Equals(9)) { Rb1.AddForce(V * new Vector2(178.9869f, 89.24f)); } if (Direction3.Equals(10)) { Rb3.AddForce(V * new Vector2(-178.9869f, 89.24f)); } if (Direction3.Equals(11)) { Rb3.AddForce(V * new Vector2(-178.9869f, -89.24f)); } if (Direction3.Equals(12)) { Rb3.AddForce(V * new Vector2(178.9869f, -89.24f)); } if (Direction3.Equals(13)) { Rb3.AddForce(V * new Vector2(89.24f, 178.9869f)); Tr3.position = Pos3; } if (Direction3.Equals(14)) { Rb3.AddForce(V * new Vector2(-89.24f, 178.9869f)); Tr3.position = Pos3; } if (Direction3.Equals(15)) { Rb3.AddForce(V * new Vector2(-89.24f, -178.9869f)); Tr3.position = Pos3; } if (Direction3.Equals(16)) { Rb3.AddForce(V * new Vector2(89.24f, -178.9869f)); Tr3.position = Pos3; } if (Direction4.Equals(1)) { Rb4.AddForce(V * new Vector2(200.0f, 0.0f)); } if (Direction4.Equals(2)) { Rb4.AddForce(V * new Vector2(0.0f, 200.0f)); } if (Direction4.Equals(3)) { Rb4.AddForce(V * new Vector2(-200.0f, 0.0f)); } if (Direction4.Equals(4)) { Rb4.AddForce(V * new Vector2(0.0f, -200.0f)); } if (Direction4.Equals(6)) { Rb4.AddForce(V * new Vector2(141.42f, -141.42f)); } if (Direction4.Equals(7)) { Rb4.AddForce(V * new Vector2(-141.42f, -141.42f)); } if (Direction4.Equals(8)) { Rb4.AddForce(V * new Vector2(-141.42f, 141.42f)); } if (Direction4.Equals(5)) { Rb4.AddForce(V * new Vector2(141.42f, 141.42f)); } if (Direction4.Equals(9)) { Rb4.AddForce(V * new Vector2(178.9869f, 89.24f)); } if (Direction4.Equals(10)) { Rb4.AddForce(V * new Vector2(-178.9869f, 89.24f)); } if (Direction4.Equals(11)) { Rb4.AddForce(V * new Vector2(-178.9869f, -89.24f)); } if (Direction4.Equals(12)) { Rb4.AddForce(V * new Vector2(178.9869f, -89.24f)); } if (Direction4.Equals(13)) { Rb4.AddForce(V * new Vector2(89.24f, 178.9869f)); Tr4.position = Pos4; } if (Direction4.Equals(14)) { Rb4.AddForce(V * new Vector2(-89.24f, 178.9869f)); Tr4.position = Pos4; } if (Direction4.Equals(15)) { Rb4.AddForce(V * new Vector2(-89.24f, -178.9869f)); Tr4.position = Pos4; } if (Direction4.Equals(16)) { Rb4.AddForce(V * new Vector2(89.24f, -178.9869f)); Tr4.position = Pos4; } B1.GetComponent <Ball> ().Direction = Direction1; B2.GetComponent <Ball> ().Direction = Direction2; B3.GetComponent <Ball> ().Direction = Direction3; B4.GetComponent <Ball> ().Direction = Direction4; other.GetComponent <Rigidbody2D>().Sleep(); }