public override void Draw(GameTime gameTime, SpriteBatch sb) { base.Draw(gameTime, sb); float _width = Size.X / Cols; for (int _index = 1; _index < Cols; _index++) { GGraphics.DrawLine( ActualPosition.ToPoint() + new Point((int)_width * _index, 0), (int)Size.Y, 2, false, Color.White, Depth - StringBorderDepthAdd, sb ); } float _height = Size.Y / Rows; for (int _index = 1; _index < Rows; _index++) { GGraphics.DrawLine( ActualPosition.ToPoint() + new Point(0, (int)_height * _index), (int)Size.X, 2, true, Color.White, Depth - StringBorderDepthAdd, sb ); } }
/// <summary> /// IF the instance has allready been created, the instance created before will be given back, when calling this method. Ohterwise a new instance will be given back /// </summary> /// <param name="dhparam"></param> /// <returns></returns> public static InverseKinematics Instantiate(DHParameter dhparam, ActualPosition _ActualPosition) //static variables are shared between all class instances. { if (instance == null) //Prevents of Locking if the instance allready has been created. IF the instance has allready been created, this instance created before will be given back, when calling this method { lock (LockObj) //no new instance can be createt from any thread as long as the first one onlocks the object { if (instance == null) { instance = new InverseKinematics(dhparam, _ActualPosition); } } } return(instance); }
/// <summary> /// IF the instance has allready been created, the instance created before will be given back, when calling this method. Ohterwise a new instance will be given back /// </summary> /// <param name="dhparam"></param> /// <returns></returns> public static KinematicControl Instantiate(DHParameter dhparam, ActualPosition _ActualPosition) { if (instance == null) //Prevents of Locking if the instance allready has been created { lock (LockObj) //no new instance can be createt from any thread as long as the first one onlocks the object { if (instance == null) { instance = new KinematicControl(dhparam, _ActualPosition); } } } return(instance); }
public override void Draw(BaseScreen.Resources screenResources, SmartSpriteBatch spriteBatch, ScreenAbstractor screen, float opacity, FloatRectangle?clip = null, Texture2D bgTexture = null, Vector2?scrollOffset = null) { if (clip.HasValue && ParentPosition.HasValue) { clip = clip.Value.ConstrainTo(ParentPosition.Value); } clip = screen.Translate(clip); var t = Position.Value(); FloatRectangle tmp = screen.Translate(ActualPosition.AdjustForMargin(Margin)).Value; if (clip.HasValue) { if (tmp.Right < clip.Value.X || tmp.X > clip.Value.Right) { return; } } if (BlurAmount.Value() > 0) { Solids.GaussianBlur.DoBlur(bgTexture, BlurAmount.Value(), (BackgroundColor.Value().Value *opacity) * ((BlurAmount.Value() / Solids.MaxBlur)), tmp.ToRectangle, ScissorRect, clip, NoisePerc.Value()); } if (BackgroundColor.Value().HasValue&& FillTexture.Value() == null) { spriteBatch.DrawSolidRectangle(tmp, BackgroundColor.Value().Value *opacity, clip); } if (FillTexture.Value() != null) { using (new SmartSpriteBatchManager(Solids.Instance.SpriteBatch)) { spriteBatch.DrawTexturedRectangle(tmp, BackgroundColor.Value().Value *opacity, Solids.Instance.AssetLibrary.GetTexture(FillTexture.Value()), TilingMode.Value, clip); } } if (BrushSize.Value() > 0) { spriteBatch.DrawBorder(tmp, BorderColor.Value() * opacity, BrushSize.Value(), clip); } this.ActualSize = new Vector2(Position.Value().Width, Position.Value().Height).PadForMargin(Margin); SetChildrenOriginToMyOrigin(); }
void Update() { if (ShowPoints == true) { foreach (var item in Targets) { if (item.MappedHUDPoint == null) { NavigationPoint Preferred = OnScreenPresets.First().Point; foreach (var Point in OnScreenPresets) { if (Point.ID == item.TargetNavigationPointType) { Preferred = Point.Point; } } item.MappedHUDPoint = GameObject.Instantiate(Preferred, HUDPointsHolder.transform).GetComponent <NavigationPoint>(); if (item.MappedHUDPoint.Label != null) { item.MappedHUDPoint.Label.text = item.label; } } if (item.MappedHUDArrow == null) { NavigationPoint Preferred = OffScreenPresets.First().Point; foreach (var Point in OffScreenPresets) { if (Point.ID == item.TargetNavigationPointType) { Preferred = Point.Point; } } item.MappedHUDArrow = GameObject.Instantiate(Preferred, HUDPointsHolder.transform).GetComponent <NavigationPoint>(); if (item.MappedHUDPoint.Label != null) { item.MappedHUDArrow.Label.text = item.label; } } bool willShow = true; if (MaxPointDistance != -1) { if (item.OverrideMaxShowDistance != -2) { if (item.OverrideMaxShowDistance == -1) { if ((item.transform.position - TargetCamera.transform.position).magnitude > MaxPointDistance) { willShow = false; } } else { if ((item.transform.position - TargetCamera.transform.position).magnitude > item.OverrideMaxShowDistance) { willShow = false; } } } else { willShow = true; } } else { if (item.OverrideMaxShowDistance != -2) { if (item.OverrideMaxShowDistance != -1) { if ((item.transform.position - TargetCamera.transform.position).magnitude > item.OverrideMaxShowDistance) { willShow = false; } } } else { willShow = true; } } if (willShow == true) { foreach (var CulledID in CullingIDs) { if (item.TargetNavigationPointType == CulledID) { willShow = false; break; } } } if (item.Show == false || willShow == false) { if (item.MappedHUDPoint.gameObject.activeSelf == true) { item.MappedHUDPoint.gameObject.SetActive(false); } if (item.MappedHUDArrow.gameObject.activeSelf == true) { item.MappedHUDArrow.gameObject.SetActive(false); } continue; } else { var v = MapToCam(TargetCamera, item.transform.position); if (IsMappedObjVisible(v)) { if (item.MappedHUDPoint.gameObject.activeSelf == false) { item.MappedHUDPoint.gameObject.SetActive(true); } if (item.MappedHUDArrow.gameObject.activeSelf == true) { item.MappedHUDArrow.gameObject.SetActive(false); } var t = HUDPointsHolder.transform as RectTransform; v.Scale(new Vector3(t.rect.width, t.rect.height, 0)); item.MappedHUDPoint.transform.position = v; if (item.ShowDistance) { //Deal with label and distance. UpdateDistance(item, item.MappedHUDPoint); } else { if (item.MappedHUDPoint.Distance.gameObject.activeSelf) { item.MappedHUDPoint.Distance.gameObject.SetActive(false); } } } else { if (ShowArrows == true) { if (item.MappedHUDPoint.gameObject.activeSelf == true) { item.MappedHUDPoint.gameObject.SetActive(false); } if (item.MappedHUDArrow.gameObject.activeSelf == false && item.WillShowOffScreenPoint == true) { item.MappedHUDArrow.gameObject.SetActive(true); } if (item.WillShowOffScreenPoint == true) { { var t = HUDPointsHolder.transform as RectTransform; var HolderW = t.rect.width; var HolderH = t.rect.height; var location = v; if (location.z < 0) { location *= -1; } var RelateSystem2 = new Vector3(.5f, .5f, 0); //Center of the screen. location -= RelateSystem2; //Convert to relate to center of the screen. float Angle = Mathf.Atan2(location.y, location.x); //Angle of center. { var r = item.MappedHUDArrow.Icon.transform.rotation; r.eulerAngles = new Vector3(0, 0, Angle * Mathf.Rad2Deg); item.MappedHUDArrow.Icon.transform.rotation = r; } Vector3 ActualPosition; if (location.x > 0) { ActualPosition = new Vector3(RelateSystem2.x, location.y, 0); } else { ActualPosition = new Vector3(-RelateSystem2.x, location.y, 0); } if (location.y > RelateSystem2.y) { ActualPosition = new Vector3(location.x, RelateSystem2.y, 0); } else if (location.y < -RelateSystem2.y) { ActualPosition = new Vector3(location.x, -RelateSystem2.y, 0); } ActualPosition += RelateSystem2; ActualPosition.Scale(new Vector3(HolderW, HolderH, 0)); ActualPosition.x = Mathf.Clamp(ActualPosition.x, ArrowAreaPadding.Left, HolderW - ArrowAreaPadding.Right); ActualPosition.y = Mathf.Clamp(ActualPosition.y, ArrowAreaPadding.Down, HolderH - ArrowAreaPadding.Up); item.MappedHUDArrow.transform.position = ActualPosition; } if (item.ShowDistance) { //Deal with label and distance. UpdateDistance(item, item.MappedHUDArrow); } else { if (item.MappedHUDArrow.Distance.gameObject.activeSelf) { item.MappedHUDArrow.Distance.gameObject.SetActive(false); } } } } else { if (item.MappedHUDPoint.gameObject.activeSelf == true) { item.MappedHUDPoint.gameObject.SetActive(false); } if (item.MappedHUDArrow.gameObject.activeSelf == true) { item.MappedHUDArrow.gameObject.SetActive(false); } } } } } if (Disabled == true) { Disabled = false; } } else { if (Disabled == false) { Disabled = true; foreach (var item in Targets) { if (item.MappedHUDPoint == null) { NavigationPoint Preferred = OnScreenPresets.First().Point; foreach (var Point in OnScreenPresets) { if (Point.ID == item.TargetNavigationPointType) { Preferred = Point.Point; } } item.MappedHUDPoint = GameObject.Instantiate(Preferred, HUDPointsHolder.transform).GetComponent <NavigationPoint>(); if (item.MappedHUDPoint.Label != null) { item.MappedHUDPoint.Label.text = item.label; } } if (item.MappedHUDArrow == null) { NavigationPoint Preferred = OffScreenPresets.First().Point; foreach (var Point in OffScreenPresets) { if (Point.ID == item.TargetNavigationPointType) { Preferred = Point.Point; } } item.MappedHUDArrow = GameObject.Instantiate(Preferred, HUDPointsHolder.transform).GetComponent <NavigationPoint>(); if (item.MappedHUDPoint.Label != null) { item.MappedHUDArrow.Label.text = item.label; } } if (item.MappedHUDPoint.gameObject.activeSelf == true) { item.MappedHUDPoint.gameObject.SetActive(false); } if (item.MappedHUDArrow.gameObject.activeSelf == true) { item.MappedHUDArrow.gameObject.SetActive(false); } } } } }
private static object LockObj = new Object(); //this object can only be used from one Thread at the same time (UI-Thread OR Backgroundthread, but not both at a time, can use the same Instance of this Class) //Note that instead of locking on typeof(Singleton) as some versions of this implementation do, //Lock on the value of a static variable which is private to the class. Locking on objects //which other classes can access and lock on (such as the type of this Class) risks performance issues //and even deadlocks. Wherever possible, only lock on objects specifically created for the purpose of locking, or which document that they are //to be locked on for specific purposes (e.g. for waiting/pulsing a queue). //Usually such objects should be private to the class they are used in. //This helps to make writing thread-safe applications significantly easier. ///////////////////////////////DHParam belegung //int d1 = 0; //double d2 = 0; //double d3 = 0; //int d4 = 23; //double d5 = 0; //int d6 = 10; //double a1 = 0; //int a2 = 25; //int a3 = 0; //double a4 = 0; //int a5 = 0; //double a6 = 0; //double alpha1 = -Math.PI / 2; //double alpha2 = 0; //double alpha3 = Math.PI / 2; //double alpha4 = -Math.PI / 2; //double alpha5 = Math.PI / 2; //double alpha6 = 0; private InverseKinematics(DHParameter dhparam, ActualPosition _ActualPosition) : base(dhparam) { this.ActualPosition = _ActualPosition; }
private KinematicControl(DHParameter dhparam, ActualPosition _ActualPosition) { forewardkinematics = ForewardKinematics.Instantiate(dhparam); inversekinematics = InverseKinematics.Instantiate(dhparam, _ActualPosition); }
/// <summary> /// The KinematicControl Instnze will Handle the InverseKinematics and the ForewardKinematics /// </summary> /// <param name="dhparam"></param> /// <returns></returns> public static KinematicControl GetKinematicControl(DHParameter dhparam, ActualPosition _ActualPosition) { return(KinematicControl.Instantiate(dhparam, _ActualPosition)); }