// Token: 0x06000B69 RID: 2921 RVA: 0x000347BC File Offset: 0x00032BBC private IEnumerator Start() { List <Vector3> splinePoints = new List <Vector3>(); int i = 1; object arg = "Sphere"; int num; i = (num = i) + 1; GameObject obj = GameObject.Find(arg + num); while (obj != null) { splinePoints.Add(obj.transform.position); object arg2 = "Sphere"; i = (num = i) + 1; obj = GameObject.Find(arg2 + num); } VectorLine line = new VectorLine("Spline", new List <Vector3>(this.segments + 1), 2f, LineType.Continuous); line.MakeSpline(splinePoints.ToArray(), this.segments, this.doLoop); line.Draw3D(); do { for (float dist = 0f; dist < 1f; dist += Time.deltaTime * this.speed) { this.cube.position = line.GetPoint3D01(dist); yield return(null); } }while (this.doLoop); yield break; }
IEnumerator Start() { var splinePoints = new List <Vector3>(); var i = 1; var obj = GameObject.Find("Sphere" + (i++)); while (obj != null) { splinePoints.Add(obj.transform.position); obj = GameObject.Find("Sphere" + (i++)); } var line = new VectorLine("Spline", new List <Vector3>(segments + 1), 2.0f, LineType.Continuous); line.MakeSpline(splinePoints.ToArray(), segments, doLoop); line.Draw3D(); // Make the cube "ride" the spline at a constant speed do { for (var dist = 0.0f; dist < 1.0f; dist += Time.deltaTime * speed) { cube.position = line.GetPoint3D01(dist); yield return(null); } } while (doLoop); }
void Start() { VectorLine.SetEndCap("arrow", EndCap.Front, lineTex, frontTex); VectorLine.SetEndCap("arrow2", EndCap.Both, lineTex2, frontTex, backTex); VectorLine.SetEndCap("rounded", EndCap.Mirror, lineTex3, capTex); var line1 = new VectorLine("Arrow", new List <Vector2>(50), 30.0f, LineType.Continuous, Joins.Weld); line1.useViewportCoords = true; var splinePoints = new Vector2[] { new Vector2(.1f, .15f), new Vector2(.3f, .5f), new Vector2(.5f, .6f), new Vector2(.7f, .5f), new Vector2(.9f, .15f) }; line1.MakeSpline(splinePoints); line1.endCap = "arrow"; line1.Draw(); var line2 = new VectorLine("Arrow2", new List <Vector2>(50), 40.0f, LineType.Continuous, Joins.Weld); line2.useViewportCoords = true; splinePoints = new Vector2[] { new Vector2(.1f, .85f), new Vector2(.3f, .5f), new Vector2(.5f, .4f), new Vector2(.7f, .5f), new Vector2(.9f, .85f) }; line2.MakeSpline(splinePoints); line2.endCap = "arrow2"; line2.continuousTexture = true; line2.Draw(); var line3 = new VectorLine("Rounded", new List <Vector2> { new Vector2(.1f, .5f), new Vector2(.9f, .5f) }, 20.0f); line3.useViewportCoords = true; line3.endCap = "rounded"; line3.Draw(); }
void Start() { var splinePoints = new List <Vector3>(); var i = 1; var obj = GameObject.Find("Sphere" + (i++)); while (obj != null) { splinePoints.Add(obj.transform.position); obj = GameObject.Find("Sphere" + (i++)); } if (usePoints) { var dotLine = new VectorLine("Spline", new List <Vector3>(segments + 1), 2.0f, LineType.Points); dotLine.MakeSpline(splinePoints.ToArray(), segments, loop); dotLine.Draw(); } else { var spline = new VectorLine("Spline", new List <Vector3>(segments + 1), 2.0f, LineType.Continuous); spline.MakeSpline(splinePoints.ToArray(), segments, loop); spline.Draw3D(); } }
IEnumerator Start() { var splinePoints = new List <Vector2>(); var i = 1; var obj = GameObject.Find("Sphere" + (i++)); while (obj != null) { splinePoints.Add(Camera.main.WorldToScreenPoint(obj.transform.position)); obj = GameObject.Find("Sphere" + (i++)); } var line = new VectorLine("Spline", new List <Vector2>(segments + 1), 2.0f, LineType.Continuous); line.MakeSpline(splinePoints.ToArray(), segments, loop); line.Draw(); // Make the cube "ride" the spline at a constant speed do { for (var dist = 0.0f; dist < 1.0f; dist += Time.deltaTime * speed) { var splinePoint = line.GetPoint01(dist); cube.position = Camera.main.ScreenToWorldPoint(new Vector3(splinePoint.x, splinePoint.y, 10.0f)); yield return(null); } } while (loop); }
public void SetupTable(int n) { if (TableUI == TableObjects[n]) { return; } for (int i = 0; i < TableObjects.Length; i++) { if (i != n) { TableObjects[i].SetActive(false); } } TableUI = TableObjects[n]; TableObj = TableUI.Child[0].transform.gameObject; //TableObj.transform.SetParent(GameManager.Module.transform); Seat = new _Seat[TableUI.Child.Length - 1]; List <Vector2> splinepoints = new List <Vector2>(); for (int i = 0; i < Seat.Length; i++) { Seat[i] = new _Seat(); Seat[i].Index = i; Seat[i].Object = TableUI.Child[i + 1].transform.gameObject; Vector3 p = TableUI.Child[i + 1].transform.position + TableUI.Child[i + 1].transform.forward * 1.7F; splinepoints.Add(new Vector2(p.x, p.y)); } VectorLine.Destroy(ref Movement); Movement = new VectorLine("Movement Path", new List <Vector2>(mvmt_segments + 1), 4.0F, LineType.Continuous); Movement.MakeSpline(splinepoints.ToArray(), mvmt_segments, 0, true); //Movement.Draw(); }
public void UpdateLine() { if (myLine != null) { myLine.drawStart = currentPoint; //Si el waypoint actual no es el final... if (followPoints.Count > 0) { //myLine = new VectorLine("Line", followPoints, 2.0f,LineType.Continuous,Joins.Weld); // C# myLine.MakeSpline(followPoints.ToArray(), followPoints.Count); if (_Data.userType == UserController.UserType.Azul) { myLine.SetColor(Color.blue); } if (_Data.userType == UserController.UserType.Amarillo) { myLine.SetColor(Color.yellow); } if (_Data.userType == UserController.UserType.Green) { myLine.SetColor(Color.green); } if (_Data.userType == UserController.UserType.Rojo) { myLine.SetColor(Color.red); } myLine.Draw(); } } }
// Token: 0x06000B67 RID: 2919 RVA: 0x00034550 File Offset: 0x00032950 private IEnumerator Start() { List <Vector2> splinePoints = new List <Vector2>(); int i = 1; var arg = "Sphere"; int num; i = (num = i) + 1; GameObject obj = GameObject.Find(arg + num); while (obj != null) { splinePoints.Add(Camera.main.WorldToScreenPoint(obj.transform.position)); var arg2 = "Sphere"; i = (num = i) + 1; obj = GameObject.Find(arg2 + num); } VectorLine line = new VectorLine("Spline", new List <Vector2>(this.segments + 1), 2f, LineType.Continuous); line.MakeSpline(splinePoints.ToArray(), this.segments, this.loop); line.Draw(); do { for (float dist = 0f; dist < 1f; dist += Time.deltaTime * this.speed) { Vector2 splinePoint = line.GetPoint01(dist); this.cube.position = Camera.main.ScreenToWorldPoint(new Vector3(splinePoint.x, splinePoint.y, 10f)); yield return(null); } }while (this.loop); yield break; }
private void Start() { List <Vector3> vector3List = new List <Vector3>(); int num1 = 1; int num2 = num1 + 1; // ISSUE: variable of a boxed type __Boxed <int> local = (ValueType)num1; for (GameObject gameObject = GameObject.Find("Sphere" + (object)local); Object.op_Inequality((Object)gameObject, (Object)null); gameObject = GameObject.Find("Sphere" + (object)num2++)) { vector3List.Add(gameObject.get_transform().get_position()); } if (this.usePoints) { VectorLine vectorLine = new VectorLine("Spline", new List <Vector3>(this.segments + 1), 2f, (LineType)2); vectorLine.MakeSpline(vector3List.ToArray(), this.segments, this.loop); vectorLine.Draw(); } else { VectorLine vectorLine = new VectorLine("Spline", new List <Vector3>(this.segments + 1), 2f, (LineType)0); vectorLine.MakeSpline(vector3List.ToArray(), this.segments, this.loop); vectorLine.Draw3D(); } }
private void Start() { VectorLine.SetEndCap("arrow", (EndCap)0, new Texture2D[2] { this.lineTex, this.frontTex }); VectorLine.SetEndCap("arrow2", (EndCap)1, new Texture2D[3] { this.lineTex2, this.frontTex, this.backTex }); VectorLine.SetEndCap("rounded", (EndCap)2, new Texture2D[2] { this.lineTex3, this.capTex }); VectorLine vectorLine1 = new VectorLine("Arrow", new List <Vector2>(50), 30f, (LineType)0, (Joins)1); vectorLine1.set_useViewportCoords(true); Vector2[] vector2Array1 = new Vector2[5] { new Vector2(0.1f, 0.15f), new Vector2(0.3f, 0.5f), new Vector2(0.5f, 0.6f), new Vector2(0.7f, 0.5f), new Vector2(0.9f, 0.15f) }; vectorLine1.MakeSpline(vector2Array1); vectorLine1.set_endCap("arrow"); vectorLine1.Draw(); VectorLine vectorLine2 = new VectorLine("Arrow2", new List <Vector2>(50), 40f, (LineType)0, (Joins)1); vectorLine2.set_useViewportCoords(true); Vector2[] vector2Array2 = new Vector2[5] { new Vector2(0.1f, 0.85f), new Vector2(0.3f, 0.5f), new Vector2(0.5f, 0.4f), new Vector2(0.7f, 0.5f), new Vector2(0.9f, 0.85f) }; vectorLine2.MakeSpline(vector2Array2); vectorLine2.set_endCap("arrow2"); vectorLine2.set_continuousTexture(true); vectorLine2.Draw(); List <Vector2> vector2List = new List <Vector2>(); vector2List.Add(new Vector2(0.1f, 0.5f)); vector2List.Add(new Vector2(0.9f, 0.5f)); VectorLine vectorLine3 = new VectorLine("Rounded", vector2List, 20f); vectorLine3.set_useViewportCoords(true); vectorLine3.set_endCap("rounded"); vectorLine3.Draw(); }
// Token: 0x06000B15 RID: 2837 RVA: 0x00031AC0 File Offset: 0x0002FEC0 private void Start() { VectorLine.SetEndCap("arrow", EndCap.Front, new Texture2D[] { this.lineTex, this.frontTex }); VectorLine.SetEndCap("arrow2", EndCap.Both, new Texture2D[] { this.lineTex2, this.frontTex, this.backTex }); VectorLine.SetEndCap("rounded", EndCap.Mirror, new Texture2D[] { this.lineTex3, this.capTex }); VectorLine vectorLine = new VectorLine("Arrow", new List <Vector2>(50), 30f, LineType.Continuous, Joins.Weld); vectorLine.useViewportCoords = true; Vector2[] splinePoints = new Vector2[] { new Vector2(0.1f, 0.15f), new Vector2(0.3f, 0.5f), new Vector2(0.5f, 0.6f), new Vector2(0.7f, 0.5f), new Vector2(0.9f, 0.15f) }; vectorLine.MakeSpline(splinePoints); vectorLine.endCap = "arrow"; vectorLine.Draw(); VectorLine vectorLine2 = new VectorLine("Arrow2", new List <Vector2>(50), 40f, LineType.Continuous, Joins.Weld); vectorLine2.useViewportCoords = true; splinePoints = new Vector2[] { new Vector2(0.1f, 0.85f), new Vector2(0.3f, 0.5f), new Vector2(0.5f, 0.4f), new Vector2(0.7f, 0.5f), new Vector2(0.9f, 0.85f) }; vectorLine2.MakeSpline(splinePoints); vectorLine2.endCap = "arrow2"; vectorLine2.continuousTexture = true; vectorLine2.Draw(); new VectorLine("Rounded", new List <Vector2> { new Vector2(0.1f, 0.5f), new Vector2(0.9f, 0.5f) }, 20f) { useViewportCoords = true, endCap = "rounded" }.Draw(); }
private VectorLine Create3DLine(List <Vector3> points, int segmentsT, float width, LineType lineType) { segmentsT = (int)(segmentsT * LocationHistoryManager.Instance.LineSetting.SegmentPower); //VectorLine: exceeded maximum vertex count of 65534 for ""...use fewer points (maximum is 16383 points for continuous lines and points, and 32767 points for discrete lines) VectorLine line = new VectorLine("Spline", new List <Vector3>(segmentsT + 1), width, lineType); lines.Add(line); //line.lineColors line.color = color; line.MakeSpline(points.ToArray(), segmentsT, pathLoop); return(line); }
void Start() { startIndex = -visibleLineSegments; endIndex = 0; // Make Vector2 array where the size is the number of segments plus one, since we'll use a continuous line var linePoints = new List <Vector2>(segments + 1); // Make a VectorLine object using the above points, with a width of 30 pixels line = new VectorLine("Spline", linePoints, lineTexture, 30.0f, LineType.Continuous, Joins.Weld); var sw = Screen.width / 5; var sh = Screen.height / 3; line.MakeSpline(new Vector2[] { new Vector2(sw, sh), new Vector2(sw * 2, sh * 2), new Vector2(sw * 3, sh * 2), new Vector2(sw * 4, sh) }); }
void CreateHillLine() { splinePoints[0] = new Vector2(-0.02f, Random.Range(0.1f, 0.6f)); var x = 0.0f; var distance = 1.0f / (numberOfHills * 2); int i; for (i = 1; i < splinePoints.Length; i += 2) { x += distance; splinePoints[i] = new Vector2(x, Random.Range(0.3f, 0.7f)); x += distance; splinePoints[i + 1] = new Vector2(x, Random.Range(0.1f, 0.6f)); } splinePoints[i - 1] = new Vector2(1.02f, Random.Range(0.1f, 0.6f)); hills.MakeSpline(splinePoints); hills.Draw(); }
void Start() { startIndex = -visibleLineSegments; endIndex = 0; // Make Vector3 array where the size is the number of segments plus one, since we'll use a continuous line var linePoints = new List <Vector3>(segments + 1); // Make a VectorLine object using the above points, with a width of 2 pixels line = new VectorLine("LeadIn", linePoints, 2.0f, LineType.Continuous, Joins.Weld); line.texture = Manager.use.lineTexture; line.material = Manager.use.lineMaterial; line.color = Manager.use.colorNormal; line.capLength = Manager.use.capLength; var x = -22; var y = -15; line.MakeSpline(new Vector3[] { new Vector3(x, y, 10), new Vector3(x, y, 200) }); }
List<GameObject> planets; //destination objects, the earth and moon #endregion Fields #region Methods public void PlotTrajectory(Vector3 start, Vector3 startVelocity, float timestep, float maxTime) { //Vector2[] curvePoints = new Vector2[(int)Mathf.Ceil(maxTime/timestep+1)]; List<Vector2> curvePoints = new List<Vector2> (); Vector3 prev = start; for (int i = 1; ; i++) { float t = timestep * i; if (t > maxTime) break; Vector2 pos = PlotTrajectoryAtTime(start, startVelocity, t); if (Physics.Linecast(prev, pos)) break; Debug.DrawLine(prev, pos, Color.red); Debug.Log(pos); curvePoints.Add(Camera.main.WorldToViewportPoint(pos)); //curvePoints.Add(pos); prev = pos; } line = new VectorLine("Spline", new List<Vector2>(curvePoints.Count+1), 2.0f, LineType.Continuous, Joins.Weld); //line.useViewportCoords = true; //Vector2[] curvePoints = new Vector2[(int)Mathf.Ceil(maxTime / timestep + 1)] if (curvePoints.Count > 0) { Debug.Log(curvePoints.Count); line.MakeSpline(curvePoints.ToArray()); line.continuousTexture = true; line.Draw(); } /* VectorLine line2 = new VectorLine("Arrow2", new List<Vector2>(50), 40.0f, LineType.Continuous, Joins.Weld); line2.useViewportCoords = true; Vector2[] splinePoints = new Vector2[] { new Vector2(0.1f, 0.85f), new Vector2(0.3f, 0.5f), new Vector2(0.5f, 0.4f), new Vector2(0.7f, 0.5f), new Vector2(0.9f, 0.85f) }; line2.MakeSpline(curvePoints.ToArray()); //line2.endCap = "arrow2"; line2.continuousTexture = true; line2.Draw(); */ }
// Token: 0x06000B65 RID: 2917 RVA: 0x00034434 File Offset: 0x00032834 private void Start() { List <Vector3> list = new List <Vector3>(); int num = 1; GameObject gameObject = GameObject.Find("Sphere" + num++); while (gameObject != null) { list.Add(gameObject.transform.position); gameObject = GameObject.Find("Sphere" + num++); } if (this.usePoints) { VectorLine vectorLine = new VectorLine("Spline", new List <Vector3>(this.segments + 1), 2f, LineType.Points); vectorLine.MakeSpline(list.ToArray(), this.segments, this.loop); vectorLine.Draw(); } else { VectorLine vectorLine2 = new VectorLine("Spline", new List <Vector3>(this.segments + 1), 2f, LineType.Continuous); vectorLine2.MakeSpline(list.ToArray(), this.segments, this.loop); vectorLine2.Draw3D(); } }
/// <summary> /// DisplayContour - Display the contour points, adjust camera position, invert points for correct display. /// </summary> /// <param name="contour"></param> /// <param name="blobNumber"></param> public void DisplayContour(PXCMPointI32[] contour, int blobNumber) { /* Funky Vectrosity camera flip issue*/ VectorLine.SetCamera(this.GetComponent <Camera>()); Camera cam = VectorLine.GetCamera(); cam.transform.position = new Vector3(cam.transform.position.x * -1, cam.transform.position.y * -1, cam.transform.position.z); if (blobLine != null) { VectorLine.Destroy(ref blobLine); } /* can't be cache since the contour length changes based on whats tracked*/ Vector2[] splinePoints = new Vector2[contour.Length]; for (int i = 0; i < contour.Length; i++) { splinePoints[i] = new Vector2(contour[i].x * -1, contour[i].y * -1); } blobLine = new VectorLine("BlobContourPoints", new Vector2[contour.Length + 1], null, 2.0f, LineType.Continuous); blobLine.MakeSpline(splinePoints); blobLine.Draw(); }
private bool collided = false; //fwe190102 IEnumerator Start() { //create a cube with a joint to ride the spline GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.AddComponent <Rigidbody>(); cube.AddComponent <HingeJoint>(); Rigidbody cuberb = cube.GetComponent <Rigidbody>(); HingeJoint joint = cube.GetComponent <HingeJoint>(); //cube has to have a rigidbody that is kinematic for physics to work cuberb.isKinematic = true; //configure joint JointLimits lim = joint.limits; lim.min = -1f; lim.max = 1f; lim.bounciness = 0; lim.bounceMinVelocity = 0; joint.limits = lim; joint.useLimits = true; joint.axis = Vector3.forward; joint.breakForce = 1000000.0f; joint.breakTorque = 1000000.0f; joint.enablePreprocessing = true; //connect EnemyShip to joint Rigidbody rb = GetComponent <Rigidbody>(); joint.connectedBody = rb; cube.GetComponent <MeshRenderer>().enabled = showPoints; var splinePoints = new List <Vector3>(); var i = 1; var obj = GameObject.Find("Sphere" + (i++)); while (obj != null) { splinePoints.Add(obj.transform.position); obj.GetComponent <MeshRenderer>().enabled = showPoints; obj = GameObject.Find("Sphere" + (i++)); } var sline = new VectorLine("Spline", new List <Vector3>(segments + 1), 2.0f, LineType.Continuous); sline.MakeSpline(splinePoints.ToArray(), segments, doLoop); if (showSpline) { sline.Draw3D(); } var line = new VectorLine("EnemyShip", LineData.use.ship1Points, Manager.use.lineWidth) //var line = new VectorLine("EnemyShip", LineData.use.ship2Points, Manager.use.lineWidth) //var line = new VectorLine("EnemyShip", LineData.use.ship3Points, Manager.use.lineWidth) //var line = new VectorLine("EnemyShip", LineData.use.ship4Points, Manager.use.lineWidth) { material = Manager.use.lineMaterial, texture = Manager.use.lineTexture, color = Manager.use.colorNormal, capLength = Manager.use.capLength, drawTransform = cube.transform }; // Make VectorManager lines be drawn in the scene instead of as an overlay VectorManager.useDraw3D = true; // Make this transform have the vector line object that's defined above // This object is a rigid body, so the vector object will do exactly what this object does VectorManager.ObjectSetup(gameObject, line, Visibility.Dynamic, Brightness.None); // Make the EnemyShip "ride" the spline at a constant speed do { for (var dist = 0.0f; dist < 1.0f; dist += Time.deltaTime * speed) { cube.transform.position = sline.GetPoint3D01(dist); cube.transform.LookAt(sline.GetPoint3D01(dist + 0.001f)); //line.Draw3D(); yield return(null); } } while (doLoop); }
public static PathDisplay getPathLine(Path path) { Debug.Log("drawPath numba J"); // Debug.Log("awkward length " + path.getPathLength()); float usable_ap = mech.current_ap; float max_ap = mech.max_ap; if(path != null) { Vector3[] path_spots = new Vector3[path.getPathLength()]; Color[] path_colors = new Color[path_spots.Length-1]; float[] path_widths = new float[path_spots.Length-1]; int i = 0; int this_turns_travelable = -1; List<VectorLine> spots = new List<VectorLine>(); foreach(HexData path_pos in path.getTraverseOrderList()) { // path_spots[i] = Camera.mainCamera.WorldToScreenPoint((hexManagerS.CoordsGameTo3D(path_pos.x, path_pos.z))); path_spots[i] = ((hexManagerS.CoordsGameTo3D(path_pos.x, path_pos.z) + y_adj_line)); if(i != 0) { path_colors[i-1] = getColorFromCost(path_pos.traversal_cost); usable_ap-=path_pos.traversal_cost; if(usable_ap >= 0) { path_widths[i-1] = usable_ap/max_ap * max_path_width/2 + max_path_width/2; } else { usable_ap = 1; if(this_turns_travelable == -1) this_turns_travelable = i-1; path_widths[i-1] = 2; path_colors[i-1] = enginePlayerS.disable_color; // break; } // var circle = new VectorLine("Circle", new Vector3[30], path_colors[i-1], null, 10F, LineType.Continuous, Joins.Weld); // circle.MakeCircle(path_spots[i], Vector3.up, .3F); // spots.Add(circle); VectorLine outline = outlineHex(path_pos); outline.SetColor(path_colors[i-1]); outline.lineWidth = usable_ap/max_ap * max_path_width/2 + max_path_width/4; spots.Add (outline); } Debug.Log(path_spots[i] + " | " + path_pos.traversal_cost); i++; } Array.Resize(ref path_spots, i+1); Array.Resize(ref path_colors, i); Array.Resize(ref path_widths, i); // for(int vc = 0; vc < lineColors.Length; ++vc) // lineColors[vc] = Color.red; //// lineColors[vc] = new Color(UnityEngine.Random.Range(0,255), UnityEngine.Random.Range(0,255), UnityEngine.Random.Range(0,255)); // VectorLine.SetLine (Color.green, path_spots); // VectorLine.Destroy(ref player_route); player_route = new VectorLine("Line", path_spots, path_colors, null, 5F, LineType.Continuous, Joins.Weld); // player_route.MakeCircle(path_spots[3], Vector3.up, 2F, 10); player_route.SetColorsSmooth(path_colors); player_route.SetWidths(path_widths); player_route.MakeSpline(path_spots); player_route.smoothWidth = true; // if(this_turns_travelable != -1) // { // var circle = new VectorLine("Circle", new Vector3[30], null, 10F, LineType.Continuous, Joins.Weld); // circle.MakeCircle(path_spots[this_turns_travelable], Vector3.up, .3F); // // } // // VectorLine rings = new VectorLine("Ring1", new Vector2[8], Color.white, null, 10F, LineType.Continuous); // // rings.MakeCircle(path_spots[3], Vector3.up, 8F); // rings.Draw3DAuto(); return new PathDisplay(spots, player_route, new List<Color>(path_colors), new List<float>(path_widths)); // player_route.Draw3DAuto(); } return null; }
private void drawFundamentalDiagram(Rect position) { pc.playing = false; InfoText it = GameObject.Find("InfoText").GetComponent <InfoText> (); if (it.diagram) { it.removeDiagram(); } fundamentalDiagramLines = new List <VectorLine> (); PedestrianLoader pl = GameObject.Find("PedestrianLoader").GetComponent <PedestrianLoader> (); float maxSpeed = float.MinValue; float maxDensity = float.MinValue; List <Vector2> points = new List <Vector2> (); foreach (GameObject p in pl.pedestirans) { Pedestrian ped = p.GetComponent <Pedestrian>(); if (p.hideFlags != HideFlags.HideInHierarchy) { float speed = ped.getSpeed(); float density = ped.getDensity(); maxSpeed = Mathf.Max(speed, maxSpeed); maxDensity = Mathf.Max(density, maxDensity); points.Add(new Vector2(density, speed)); } } if (points.Count == 0) { fundamental = false; return; } VectorPoints.SetCamera(GameObject.Find("Flycam").GetComponent <Camera>()); //trendline int steps = 5; float stepper = maxDensity / steps; float[] avgSpeed = new float [steps]; int[] avgNumber = new int [steps]; for (int i = 0; i < points.Count; i++) { int j = (int)(points[i].y / stepper); if (j < avgNumber.Length) { avgNumber[j]++; avgSpeed[j] = avgSpeed[j] + points[i].x; } } List <Vector2> l = new List <Vector2> (); for (int i = 0; i < steps; i++) { avgSpeed[i] = avgSpeed[i] / avgNumber[i]; Vector2 a = new Vector2((i * stepper + (i + 1) * stepper) / 2, avgSpeed[i]); if (avgSpeed[i] > 0) { l.Add(new Vector2(a.x * position.width / maxDensity + position.x, a.y * position.height / maxSpeed + position.y)); } } VectorLine line; if (l.Count > 1) { line = new VectorLine("spline", new Vector2[l.Count], null, 1, LineType.Continuous); line.SetColor(Color.red); line.MakeSpline(l.ToArray()); line.depth = 99; line.Draw(); fundamentalDiagramLines.Add(line); } //data points for (int i = 0; i < points.Count; i++) { points[i] = new Vector2(points[i].x * position.width / maxDensity + position.x, points[i].y * position.height / maxSpeed + position.y); } fundamentalDiagramPoints = new Vectrosity.VectorPoints("Data", points.ToArray(), Color.white, null, 3); fundamentalDiagramPoints.depth = 99; fundamentalDiagramPoints.Draw(); //frame line = VectorLine.SetLine(new Color(1f, 1f, 1f, 0.5f), new Vector2[] { new Vector2(position.x - 6, position.y - 2), new Vector2(position.x - 6, position.y + 9 + position.height), new Vector2(position.x + 5 + position.width, position.y + 9 + position.height), new Vector2(position.x + 5 + position.width, position.y - 2), new Vector2(position.x - 6, position.y - 2) }); line.depth = 2; line.Draw(); fundamentalDiagramLines.Add(line); //lines yLabels = new List <Label> (); float scaleFactor = 0.5f; int numberOfLines = (int)(maxSpeed * (1 / scaleFactor)); if (numberOfLines > 0) { for (int i = 1; i <= numberOfLines; i++) { float hy = position.y + i * (position.height / (maxSpeed * (1 / scaleFactor))); line = VectorLine.SetLine(new Color(1f, 1f, 1f, 0.5f), new Vector2[] { new Vector2(position.x - 5, hy), new Vector2(position.x + 5 + position.width, hy) }); line.depth = 1; line.Draw(); fundamentalDiagramLines.Add(line); yLabels.Add(new Label(new Rect(position.x - 28, Screen.height - hy - 12, 20, 25), "" + i * scaleFactor)); } } //lines xLabels = new List <Label> (); scaleFactor = 0.5f; numberOfLines = (int)(maxDensity * (1 / scaleFactor)); if (numberOfLines > 0) { for (int i = 1; i <= numberOfLines; i++) { float hx = position.x + i * (position.width / (maxDensity * (1 / scaleFactor))); line = VectorLine.SetLine(new Color(1f, 1f, 1f, 0.5f), new Vector2[] { new Vector2(hx, position.y - 2), new Vector2(hx, position.y + 8 + position.height) }); line.depth = 1; line.Draw(); fundamentalDiagramLines.Add(line); xLabels.Add(new Label(new Rect(Screen.width - position.x - position.width + hx - 44, Screen.height - position.y, 28, 28), "" + i * scaleFactor)); } } //background line = VectorLine.SetLine(new Color(0, 0, 0, 0.7f), new Vector2[] { new Vector2(position.x - 6, position.y + (position.height + 6) / 2), new Vector2(position.x + position.width + 6, position.y + (position.height + 6) / 2) }); line.lineWidth = position.height + 12; line.Draw(); fundamentalDiagramLines.Add(line); }
public IEnumerator Get(string url) { using (UnityWebRequest www = UnityWebRequest.Get(url)) { yield return(www.SendWebRequest()); if (www.isNetworkError) { Debug.Log(www.error); } else { if (www.isDone) { result = @System.Text.Encoding.UTF8.GetString(www.downloadHandler.data); globe = GameObject.Find("/earth/Icosphere"); var N = JSON.Parse(result); // assign the length of all the to-from Array into an integer (118, on 03/09 evening) length = Int32.Parse(N["length"].Value); System.Random random = new System.Random(); x = random.Next(0, length); y = random.Next(0, length); z = random.Next(0, length); // Debug.Log($"plane number {x}"); for (int i = 0; i < length; i++) { //bool hasCCto = countryCodes.Contains(N["data"]); //bool hasCCfrom = countryCodes.Contains(N["data"][i]["from"]["country"]["cc"]); //if (hasCCto && hasCCfrom) { Airplane instance = Instantiate(prefabs[0]); Transform p = instance.transform; p.parent = globe.transform; //p.localPosition = new Vector3(-2.999408f, -2.960107f - i, -.1357397f); instance.ccTo = N["data"][i]["to"]["country"]["cc"]; instance.ccFrom = N["data"][i]["from"]["country"]["cc"]; instance.countryName = N["data"][i]["to"]["country"]["name"]; instance.flag = N["data"][i]["to"]["country"]["flag"]; instance.language = N["data"][i]["to"]["country"]["languages"][0]["name"]; instance.greeting = N["data"][i]["to"]["country"]["greeting"]; instance.animal = N["data"][i]["to"]["country"]["animal"]; WatsonTextToSpeech.greeting = N["data"][i]["to"]["country"]["greeting"]; // instance.greeting = Encoding.UTF8.GetString(Encoding.Convert(Encoding.Unicode, Encoding.UTF8, Encoding.Unicode.GetBytes($"{greet}"))); departure = GameObject.FindGameObjectWithTag($"{instance.ccFrom}"); arrival = GameObject.FindGameObjectWithTag($"{instance.ccTo}"); if (departure != null && arrival != null) { Vector3 midpoint = (departure.transform.position + arrival.transform.position) * 0.5f; float dist = Vector3.Distance(departure.transform.position, arrival.transform.position); p.position = Vector3.MoveTowards(midpoint, globe.transform.position, dist * -0.4f); p.LookAt(Vector3.MoveTowards(arrival.transform.position, globe.transform.position, -2f)); //p.localRotation = Quaternion.Euler(208.305f, -2.268005f, -48.89499f); //p.localScale = new Vector3(0.3f, 0.3f, 0.3f); //change plane texture to flag texture of destination country instance.GetComponent <MeshRenderer>().material.mainTexture = Resources.Load(instance.ccTo) as Texture2D; var splinePoints = new List <Vector3>(); splinePoints.Add(departure.transform.localPosition); splinePoints.Add(p.localPosition); splinePoints.Add(arrival.transform.localPosition); spline = new VectorLine("Spline", new List <Vector3>(segments + 1), 3.0f, LineType.Continuous); //LineType.Discrete //spline.SetColor(new Color(204, 0, 82)); spline.MakeSpline(splinePoints.ToArray(), segments, loop); //spline.MakeSpline(splinePoints.ToArray()); //spline.textureScale = 1.0f; spline.drawTransform = globe.transform; airplanes.Add(instance); //Material lineMat = Resources.Load("ArcLine", typeof(Material)) as Material; //spline.material = lineMat; spline.Draw3DAuto(); //} } } load.SetActive(false); UI.SetActive(true); hunt = GameObject.Find("/UIComponents/ScavengerHunt/huntImg"); // hunt.GetComponent<ScavengerHunt>().language = N["data"][x]["to"]["country"]["languages"][0]["name"]; hunt.GetComponent <ScavengerHunt>().countryname1 = N["data"][y]["to"]["country"]["name"]; hunt.GetComponent <ScavengerHunt>().animal = N["data"][y]["to"]["country"]["animal"]; answerOne.countryCode = N["data"][y]["to"]["country"]["cc"]; hunt.GetComponent <ScavengerHunt>().countryname3 = N["data"][z]["to"]["country"]["name"]; hunt.GetComponent <ScavengerHunt>().flag = N["data"][z]["to"]["country"]["cc"]; ScavengerHunt.CC = N["data"][z]["to"]["country"]["cc"]; answerThree.countryCode = N["data"][z]["to"]["country"]["cc"]; while (N["data"][x]["to"]["country"]["languages"][0]["name"].Value == "English" || N["data"][x]["to"]["country"]["languages"][0]["name"].Value == "Spanish") { x = random.Next(0, length); } hunt.GetComponent <ScavengerHunt>().language = N["data"][x]["to"]["country"]["languages"][0]["name"]; hunt.GetComponent <ScavengerHunt>().countryname2 = N["data"][x]["to"]["country"]["name"]; answerTwo.countryCode = N["data"][x]["to"]["country"]["cc"]; } else { Debug.Log("Error: Could not get data"); } } } }
IEnumerator CreatePath() { Pathway.transform.position = Pathway_init; MoveSpeed_actual = MoveSpeed; Safeway_Threshold_actual = Safeway_Threshold; int checks = 0; while (TargetGrand == null || TargetGrand.Data.Fitness.Ratio > 0.6F) { int r = Random.Range(0, GameManager.instance.Grands.Length); TargetGrand = GameManager.instance.Grands[r].GrandObj; checks++; if (checks > 10) { break; } } if (TargetGrand == null) { TargetGrand = GameManager.Generator.Generate(0); } TargetGrand_Face = GameManager.Generator.GenerateNewFace(TargetGrand.Data); MOB[1].T.rotation = Quaternion.Euler(face_rotation_x, 0, 0); MOB[1].T.localPosition = Vector3.zero; MOB[1].AddChild(TargetGrand_Face); TargetGrand_Face.transform.localPosition = Vector3.up * 4; BalancePoint = Vector3.zero; EndPoint.position = StartPoint.position - StartPoint.up * TotalDistance; MOB[0][0].transform.localScale = new Vector3(19.5F, TotalDistance / 3, 1.0F); MiddlePoints = new Transform[PathPoints]; Velocity = EndPoint.position - StartPoint.position; Velocity.Normalize(); CrossVelocity = Vector3.Cross(Velocity, -Vector3.forward).normalized; float pathrate = 0.9F / PathPoints; for (int i = 0; i < PathPoints; i++) { GameObject g = new GameObject("Path Point " + i); MiddlePoints[i] = g.transform; MiddlePoints[i].position = Vector3.Lerp(StartPoint.position, EndPoint.position, Mathf.Clamp(pathrate + (pathrate * i), 0.0F, 1.0F)); MiddlePoints[i].position += CrossVelocity * ((Random.value - Random.value) * 10); MiddlePoints[i].SetParent(MOB[0].transform); } List <float> splinewidths = new List <float>(); List <Vector3> splinepoints = new List <Vector3>(); splinepoints.Add(StartPoint.localPosition); splinewidths.Add(Safeway_Threshold); for (int i = 0; i < MiddlePoints.Length; i++) { splinepoints.Add(MiddlePoints[i].localPosition); splinewidths.Add(Safeway_Threshold / i + 1); } splinepoints.Add(EndPoint.localPosition); splinewidths.Add(0.0F); VectorLine.Destroy(ref Safeway); int mvmt_segments = 10 + MiddlePoints.Length * 10; Safeway = new VectorLine("Safeway Path", new List <Vector3>(mvmt_segments + 1), Safeway_Threshold_actual * 1.2F, LineType.Continuous); Safeway.MakeSpline(splinepoints.ToArray(), mvmt_segments, 0, false); Safeway.drawTransform = MOB[0].transform; Safeway.SetColor(PathColor); Safeway.joins = Joins.Fill; int objnum = 20 + MiddlePoints.Length * 5; PathInstances = new FOBJ[objnum]; float point = 0.0F; float objratio = 0.9F / objnum; for (int i = 0; i < objnum; i++) { PathInstances[i] = (FOBJ)Instantiate(PathPrefabs[Random.Range(0, PathPrefabs.Length)]); MOB[0].AddChild(PathInstances[i]); point += Random.Range(objratio / 1.5F, objratio * 1.5F); Vector3 pos = Safeway.GetPoint3D01(point); Vector3 nextpos = Safeway.GetPoint3D01(point + 0.1F); Vector3 vel = (nextpos - pos).normalized; Vector3 cross = Vector3.Cross(vel, -Vector3.forward).normalized; float xd = cross.x * Safeway_Threshold_actual / 10; pos.x += Random.value > 0.5F ? xd : -xd; PathInstances[i].T.position = pos; PathInstances[i].T.LookAt(pos + vel); PathInstances[i].T.rotation *= Quaternion.Euler(0, 90, 90); } Safeway.Draw3D(); VectorLine.SetCamera3D(Camera.main); VectorManager.useDraw3D = true; yield return(null); }