Exemple #1
0
        public void Update()
        {
            try {
                UpdatePosition();
                double  fontSize      = Math.Max((double)Height / 50, (double)6);
                double  fontSizeSmall = Math.Max((double)Height / 70, (double)6);
                Vector4 hitbox        = new Vector4(0, 0, 0, 0);

                var mouse = System.Windows.Forms.Form.MousePosition;
                if (mouse.X >= Left && mouse.X < Left + Width && mouse.Y >= Top && mouse.Y < Top + Height &&
                    System.Windows.Forms.Form.MouseButtons == System.Windows.Forms.MouseButtons.Middle)
                {
                    if (isDragging == false)
                    {
                        start = reader.ScreenToGame(new Vector2(mouse.X, mouse.Y));
                    }
                    isDragging = true;

                    Vector2 startScreen = reader.GameToScreen(start);
                    if (mouse.X < startScreen.X)
                    {
                        hitbox.X = mouse.X;
                    }
                    else
                    {
                        hitbox.X = startScreen.X;
                    }
                    if (mouse.Y < startScreen.Y)
                    {
                        hitbox.Y = mouse.Y;
                    }
                    else
                    {
                        hitbox.Y = startScreen.Y;
                    }

                    hitbox.W = (float)Math.Abs(mouse.X - startScreen.X);
                    hitbox.H = (float)Math.Abs(mouse.Y - startScreen.Y);

                    lastHitbox = reader.ScreenToGame(hitbox);
                    if (OnNewHitbox != null)
                    {
                        OnNewHitbox(this, new EventArgs());
                    }
                }
                else
                {
                    isDragging = false;
                }

                DrawRectangle(lastHitbox);

                OriInfo.FontSize = fontSize;
                Vector2       pos    = reader.ScreenToGame(new Vector2(mouse.X, mouse.Y));
                Vector2       oripos = reader.GetCameraTargetPosition();
                StringBuilder sb     = new StringBuilder();
                sb.AppendLine("Ori: " + oripos.ToString()).AppendLine("Mouse: " + pos.ToString());

                if (hitboxUI != null)
                {
                    sb.AppendLine("Hitbox: " + lastHitbox.ToString());
                }

                OriInfo.Text = sb.ToString();

                Canvas.SetLeft(OriInfo, Width - OriInfo.ActualWidth * 1.2);
                Canvas.SetTop(OriInfo, Height - OriInfo.ActualHeight * 1.3);
            } catch { }
        }