コード例 #1
0
        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);
        }
コード例 #2
0
        private void Move(object data)
        {
            PositionProfile positionProfile = (PositionProfile)data;

            this.PositionProfile = positionProfile;
            this.SetPosition(this.parentBounds);
        }
コード例 #3
0
        /// <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;
        }
コード例 #4
0
 /// <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;
 }
コード例 #5
0
ファイル: Textbox.cs プロジェクト: TRushton95/Frames
        /// <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());
        }
コード例 #6
0
 /// <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;
 }
コード例 #7
0
ファイル: Button.cs プロジェクト: TRushton95/Frames
 /// <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;
 }
コード例 #8
0
        /// <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;
        }
コード例 #9
0
        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);
        }
コード例 #10
0
ファイル: Container.cs プロジェクト: TRushton95/Frames
 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;
 }
コード例 #11
0
 /// <summary>
 /// Initialises a new instance of the <see cref="ImageGraphics"/> class.
 /// </summary>
 public ImageGraphics(Texture2D texture, PositionProfile positionProfile)
     : base(positionProfile)
 {
     this.Texture = texture;
 }
コード例 #12
0
 /// <summary>
 /// Initialises a new instance of the <see cref="BaseBody"/> class.
 /// </summary>
 public BaseBody(PositionProfile positionProfile)
 {
     this.PositionProfile = positionProfile;
 }
コード例 #13
0
        /// <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;
        }
コード例 #14
0
ファイル: Icon.cs プロジェクト: TRushton95/Frames
 /// <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;
 }
コード例 #15
0
ファイル: Textbox.cs プロジェクト: TRushton95/Frames
 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;
 }
コード例 #16
0
 /// <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;
 }
コード例 #17
0
ファイル: BaseComponent.cs プロジェクト: TRushton95/Frames
 /// <summary>
 /// Initialises a new instance of the <see cref="BaseComponent"/> class.
 /// </summary>
 public BaseComponent(PositionProfile positionProfile)
     : base(positionProfile)
 {
 }