private PositionProfile projectedCurrentProfile; // Adds the (x,y) distance required to move to the destination profile offset to arrive at correct anchor. #endregion #region Constructors public MovementTransition( Vector2 startPosition, Vector2 finalPosition, PositionProfile destinationProfile, float distancePerSeconds, Callback callback) : base(callback) { this.StartPosition = startPosition; this.FinalPosition = finalPosition; this.DestinationProfile = destinationProfile; this.Speed = distancePerSeconds; Vector2 delta = this.FinalPosition - this.StartPosition; float distance = (float)Math.Sqrt((delta.X * delta.X) + (delta.Y * delta.Y)); this.runtime = distance / this.Speed; this.projectedCurrentProfile = new PositionProfile( this.DestinationProfile.HorizontalAlign, this.DestinationProfile.VerticalAlign, this.DestinationProfile.OffsetX - (int)delta.X, this.DestinationProfile.OffsetY - (int)delta.Y); }
private void Move(object data) { PositionProfile positionProfile = (PositionProfile)data; this.PositionProfile = positionProfile; this.SetPosition(this.parentBounds); }
/// <summary> /// Gets the coordinates of the UI component based on its parent's location /// </summary> protected void SetCoordinates(Rectangle parent) { Vector2 coords = PositionProfile.GetPosition(GetBounds(), parent); posX = (int)coords.X; posY = (int)coords.Y; }
/// <summary> /// Initialises an instance of the <see cref="Frame"/> class. /// </summary> public Frame(int width, int height, Color color, PositionProfile positionProfile, Border border = null) : base(positionProfile) { this.Width = width; this.Height = height; this.Color = color; this.Border = border; }
/// <summary> /// Sets the y offset of the text within the textbox. /// </summary> private void SetTextOffsetY(int offsety) { PositionProfile positionProfile = PositionFactory.TopCenter(); positionProfile.OffsetY = offsety; this.textGraphics.PositionProfile = positionProfile; this.textGraphics.Initialise(this.GetContentBounds()); }
/// <summary> /// Initialises an instance of the <see cref="BaseElement"/> class. /// </summary> public BaseElement(string name, int width, int height, Border border, PositionProfile positionProfile) : base(positionProfile) { this.Name = name; this.Width = width; this.Height = height; this.Border = border == null ? Border.Default : border; }
/// <summary> /// Initialises an instance of the <see cref="Button"/> class. /// </summary> public Button(string name, int width, int height, Border border, PositionProfile positionProfile, string text, SpriteFont font, Color frameColor, Color textColor, Color frameHoverColor, Color textHoverColor) : base(name, width, height, border, positionProfile) { this.Text = text; this.Font = font; this.FrameColor = frameColor; this.TextColor = textColor; this.FrameHoverColor = frameHoverColor; this.TextHoverColor = textHoverColor; }
/// <remark> /// Need to tackle initiating identical/opposite time transitions while one is already running causing troughs/peaks of speed /// </remark> public void AddMovementTransition(PositionProfile destinationProfile, OnFinish onFinish = null) { Vector2 destinationPosition = destinationProfile.CalculatePosition(this.parentBounds, this.GetSize()); if (movementTransition != null && movementTransition.Done) { movementTransition?.Stop(); } movementTransition = new MovementTransition(this.GetPosition(), destinationPosition, destinationProfile, TransitionSpeed.Fast, Move); movementTransition.OnFinish = onFinish; }
protected override void InternalUpdate(GameTime gameTime) { if (this.totalElapsedTime >= this.runtime * 1000) { this.Done = true; this.Callback.Invoke(this.DestinationProfile); return; } Vector2 delta = this.FinalPosition - this.StartPosition; Vector2 speedComponents = delta / this.runtime; float elapsedSeconds = (float)this.totalElapsedTime / 1000; Vector2 offset = this.projectedCurrentProfile.Offset + Vector2.Multiply(speedComponents, elapsedSeconds); PositionProfile data = new PositionProfile(this.DestinationProfile.HorizontalAlign, this.DestinationProfile.VerticalAlign, (int)offset.X, (int)offset.Y); this.Callback.Invoke(data); }
public Container(string name, int width, int height, Border border, Color color, PositionProfile positionProfile, List <BaseElement> children) : base(name, width, height, border, positionProfile) { this.Color = color; this.Children = children; }
/// <summary> /// Initialises a new instance of the <see cref="ImageGraphics"/> class. /// </summary> public ImageGraphics(Texture2D texture, PositionProfile positionProfile) : base(positionProfile) { this.Texture = texture; }
/// <summary> /// Initialises a new instance of the <see cref="BaseBody"/> class. /// </summary> public BaseBody(PositionProfile positionProfile) { this.PositionProfile = positionProfile; }
/// <summary> /// Initialises a new instance of the <see cref="TextGraphics"/> class. /// </summary> public TextGraphics(string text, SpriteFont font, Color color, int maxWidth, FontFlow fontFlow, PositionProfile positionProfile) : base(positionProfile) { this.Text = text; this.Font = font; this.Color = color; this.MaxWidth = maxWidth; this.FontFlow = fontFlow; this.displayText = text; }
/// <summary> /// Initialises a new instance of the <see cref="Icon"/> class. /// </summary> public Icon(string name, Border border, PositionProfile positionProfile, Texture2D texture, Texture2D hoverTexture = null) : base(name, texture.Width, texture.Height, border, positionProfile) { this.Texture = texture; this.HoverTexture = hoverTexture; }
public Textbox(string name, string text, SpriteFont font, int width, int height, Border border, PositionProfile positionProfile) : base(name, width, height, border, positionProfile) { this.Text = text; this.Font = font; }
/// <summary> /// Initialises a new instance of the <see cref="Text"/> class. /// </summary> public Text(string name, string value, SpriteFont font, Color color, int maxWidth, FontFlow fontFlow, Border border, PositionProfile positionProfile) : base(name, 0, 0, border, positionProfile) { this.Value = value; this.Font = font; this.Color = color; this.MaxWidth = maxWidth; this.FontFlow = fontFlow; }
/// <summary> /// Initialises a new instance of the <see cref="BaseComponent"/> class. /// </summary> public BaseComponent(PositionProfile positionProfile) : base(positionProfile) { }