public void Move() { Vector3 totalVelocity = velocity; if (inOrbit) { Vector3 orbitalSpeed = GetComponent <Orbit>().GetOrbitingAround().GetComponent <Body>().GetVelocity(); totalVelocity += orbitalSpeed; } this.transform.position += totalVelocity * scaleManager.GetTime() * Time.fixedDeltaTime; }
/// <summary> /// Отображение шины в аналоговом виде /// </summary> /// <param name="canvas"></param> /// <param name="iter"></param> /// <param name="DataPres"></param> /// <param name="GetValue"></param> protected void RenderAnalogBus <T>(Canvas canvas, IValueIterator iter, VectorDataRepresentation DataPres, GetValueDelegateFromTime <T> GetValueFromTime, GetValueDelegateFromIterator <T> GetValueFromIterator) where T : IConvertible { canvas.Children.Clear(); Polyline polyLine = new Polyline(); polyLine.Stroke = Brushes.Black; polyLine.StrokeThickness = 1; if (scaleManager.VisibleTimeDiapasone < (scaleManager.Width * 5.0)) { iter.SetCurrentIndexByKey(scaleManager.VisibleStartTime); double min = GetValueFromTime(ScaleManager.VisibleStartTime, DataPres).ToDouble(CultureInfo.InvariantCulture); double max = min; double value = 0; double height = canvas.ActualHeight; iter.SetCurrentIndexByKey(scaleManager.VisibleStartTime); value = GetValueFromTime(ScaleManager.VisibleStartTime, DataPres).ToDouble(CultureInfo.InvariantCulture); polyLine.Points.Add(new Point(0, Convert.ToDouble(value))); //Рисование начала диаграммы UInt64 x1 = 0, x2 = 0; x1 = scaleManager.VisibleStartTime; UInt64 MinimumVisibleChange = scaleManager.MinimumVisibleChange * 2; iter.SetCurrentIndexByKey(scaleManager.VisibleStartTime); x2 = iter.LastEvent; if (x2 > scaleManager.VisibleEndTime) { x2 = scaleManager.VisibleEndTime; } if (x2 < scaleManager.VisibleStartTime) { x2 = scaleManager.VisibleStartTime; } while (true) { value = GetValueFromIterator(iter, DataPres).ToDouble(CultureInfo.InvariantCulture); if (min > value) { min = value; } if (max < value) { max = value; } polyLine.Points.Add(new Point(scaleManager.GetOffset(x1), Convert.ToDouble(value))); polyLine.Points.Add(new Point(scaleManager.GetOffset(x2), Convert.ToDouble(value))); iter.MoveNext(); x1 = x2; x2 = iter.LastEvent; if ((iter.LastEvent >= scaleManager.VisibleEndTime) || (iter.IsEndOfIteration == true)) { value = GetValueFromTime(ScaleManager.VisibleEndTime, DataPres).ToDouble(CultureInfo.InvariantCulture); if (min > value) { min = value; } if (max < value) { max = value; } polyLine.Points.Add(new Point(scaleManager.GetOffset(x1), Convert.ToDouble(value))); polyLine.Points.Add(new Point(scaleManager.GetOffset(x2), Convert.ToDouble(value))); break; } if (x2 > scaleManager.VisibleEndTime) { x2 = scaleManager.VisibleEndTime; } if (x2 < scaleManager.VisibleStartTime) { x2 = scaleManager.VisibleStartTime; } } double DeltaY = (max != min) ? (height / Convert.ToDouble(max - min)) : 1; for (int i = 0; i < polyLine.Points.Count; i++) { Point point = polyLine.Points[i]; point.Y = (Convert.ToDouble(max) - point.Y) * DeltaY; polyLine.Points[i] = point; } } else { iter.SetCurrentIndexByKey(scaleManager.VisibleStartTime); double min = GetValueFromTime(ScaleManager.VisibleStartTime, DataPres).ToDouble(CultureInfo.InvariantCulture); double max = min; double value = 0; double height = canvas.ActualHeight; for (double x = 0; x < scaleManager.Width; x++) { UInt64 time = scaleManager.GetTime(x); iter.SetCurrentIndexByKey(time); value = GetValueFromIterator(iter, DataPres).ToDouble(CultureInfo.InvariantCulture); if (min > value) { min = value; } if (max < value) { max = value; } polyLine.Points.Add(new Point(x, Convert.ToDouble(value))); } double DeltaY = (max != min) ? (height / Convert.ToDouble(max - min)) : 1; for (int i = 0; i < polyLine.Points.Count; i++) { Point point = polyLine.Points[i]; point.Y = (Convert.ToDouble(max) - point.Y) * DeltaY; polyLine.Points[i] = point; } } canvas.Children.Add(polyLine); }