public void TestCollisionBottomEdgeBallTest() { var gameArea = new GameArea(); var ball = new Ball(); var bottomEdge = new BottomEdge(GameArea.MaxX, GameArea.MaxY); ball.PositionX = GameArea.MaxX; ball.PositionY = GameArea.MaxY; Assert.AreEqual(true, gameArea.AreCollided(bottomEdge, ball)); }
// Use this for initialization void Start() { Mesh mesh = new Mesh(); float xLeft = LeftVertex.transform.position.x; float xRight = RightVertex.transform.position.x; // Create vertices Vector3[] vertices = new Vector3[4]; vertices[0] = new Vector3(xLeft, BottomEdge.CalculateYCoord(xLeft), 1); vertices[1] = new Vector3(xRight, BottomEdge.CalculateYCoord(xRight), 1); vertices[2] = new Vector3(xLeft, TopEdge.CalculateYCoord(xLeft), 1); vertices[3] = new Vector3(xRight, TopEdge.CalculateYCoord(xRight), 1); mesh.vertices = vertices; // Create triangles int[] triangles = { 0, 2, 1, 2, 3, 1 }; mesh.triangles = triangles; // Create normals Vector3[] normals = new Vector3[4]; normals[0] = -Vector3.forward; normals[1] = -Vector3.forward; normals[2] = -Vector3.forward; normals[3] = -Vector3.forward; mesh.normals = normals; // Create UVs Vector2[] uv = new Vector2[4]; uv[0] = new Vector2(0, 0); uv[1] = new Vector2(1, 0); uv[2] = new Vector2(0, 1); uv[3] = new Vector2(1, 1); mesh.uv = uv; // Assign collider GetComponent <MeshCollider>().sharedMesh = mesh; // Assign mesh GetComponent <MeshFilter>().mesh = mesh; // Create material GetComponent <MeshRenderer>().material = new Material(Shader.Find("Unlit/Transparent")); // Random color color = Random.ColorHSV(0, 1, 0.3f, 0.3f, 1, 1); }
internal RelativeLayoutResults(RectTransform transform, RelativeLayoutParams other) { Transform = transform ?? throw new ArgumentNullException(nameof(transform)); if (other != null) { BottomEdge.CopyFrom(other.BottomEdge); TopEdge.CopyFrom(other.TopEdge); RightEdge.CopyFrom(other.RightEdge); LeftEdge.CopyFrom(other.LeftEdge); Insets = other.Insets ?? ZERO; OverrideSize = other.OverrideSize; } else { Insets = ZERO; } BottomParams = LeftParams = TopParams = RightParams = null; PreferredWidth = PreferredHeight = 0.0f; UseSizeDeltaX = UseSizeDeltaY = false; }
/*_________________________________________________________Обработка_событий_______________________________________________________*/ #region Event handles private void JuliaEditor_Load(object sender, EventArgs e) { LeftEdgeEdit.Text = LeftEdge.ToString(); RightEdgeEdit.Text = RightEdge.ToString(); TopEdgeEdit.Text = TopEdge.ToString(); BottomEdgeEdit.Text = BottomEdge.ToString(); RealPartEdit.Text = RealPart.ToString(); ImaginePartEdit.Text = ImaginePart.ToString(); LeftEdgeEdit.KeyPress += FormEventHandlers.OnlyNumeric; RightEdgeEdit.KeyPress += FormEventHandlers.OnlyNumeric; TopEdgeEdit.KeyPress += FormEventHandlers.OnlyNumeric; BottomEdgeEdit.KeyPress += FormEventHandlers.OnlyNumeric; RealPartEdit.KeyPress += FormEventHandlers.OnlyNumeric; ImaginePartEdit.KeyPress += FormEventHandlers.OnlyNumeric; EditDescriptor.SetToolTip(LeftEdgeLabel, FractalGlobalDescriptions.LeftEdgeOf2DFractal); EditDescriptor.SetToolTip(LeftEdgeEdit, "Здесь необходимо вводить левую границу двухмерного фрактала джулии (десятиричное представления числа).\n" + FractalGlobalDescriptions.LeftEdgeOf2DFractal); EditDescriptor.SetToolTip(RightEdgeLabel, FractalGlobalDescriptions.RightEdgeOf2DFractal); EditDescriptor.SetToolTip(RightEdgeEdit, "Здесь необходимо вводить правую границу двухмерного фрактала джулии (десятиричной представления числа, в качестве разделителей на дроную часть используйте \",\" или \".\").\n" + FractalGlobalDescriptions.RightEdgeOf2DFractal); GlobalTemplates.SetTemplate(MainPanelOfJuliaEditor, "Шрифт окна для ввода фрактала джулии"); }
void Update() { TitleBar.sizeDelta = TitleBar.sizeDelta.YChangedTo(DefaultTitleBarHeight); BackgroundImage.color = DefaultBackgroundColor; TitleText.text = FrontPage.Title; if (!Application.isPlaying) { return; } if (WindowContainer == null) { The.WindowContainer.AddWindow(this); } if (!IsOpen) { gameObject.SetActive(false); return; } else { foreach (Window subwindow in Subwindows) { subwindow.IsOpen = true; } } if (IsSubwindow) { IsMaximized = false; IsMinimized = ParentWindow.IsMinimized; } if (InputUtility.IsMouseLeftPressed && IsTouched) { MoveToFront(); } if (!IsGrabbed) { resize_grab_type = ResizeGrabType.None; if (!IsMaximized && IsTouched) { if (LeftEdge.IsPointedAt()) { resize_grab_type = ResizeGrabType.Left; } else if (BottomLeftCorner.IsPointedAt()) { resize_grab_type = ResizeGrabType.BottomLeft; } else if (BottomEdge.IsPointedAt()) { resize_grab_type = ResizeGrabType.Bottom; } else if (BottomRightCorner.IsPointedAt()) { resize_grab_type = ResizeGrabType.BottomRight; } else if (RightEdge.IsPointedAt()) { resize_grab_type = ResizeGrabType.Right; } } } switch (resize_grab_type) { case ResizeGrabType.Left: The.Cursor.ChangeCursorImage(The.Cursor.LeftHorizontalResizeImage); break; case ResizeGrabType.Right: The.Cursor.ChangeCursorImage(The.Cursor.RightHorizontalResizeImage); break; case ResizeGrabType.BottomLeft: The.Cursor.ChangeCursorImage(The.Cursor.PositiveDiagonalResizeImage); break; case ResizeGrabType.BottomRight: The.Cursor.ChangeCursorImage(The.Cursor.NegativeDiagonalResizeImage); break; case ResizeGrabType.Bottom: The.Cursor.ChangeCursorImage(The.Cursor.VerticalResizeImage); break; } if (InputUtility.WasMouseLeftPressed && IsTouched && (resize_grab_type != ResizeGrabType.None || TitleBar.IsPointedAt())) { IsGrabbed = true; grab_offset = PixelPosition - The.Cursor.PixelPointedAt; } if (IsGrabbed && InputUtility.WasMouseLeftReleased) { IsGrabbed = false; } if (IsGrabbed) { if (resize_grab_type == ResizeGrabType.None) { Vector2Int new_position = The.Cursor.PixelPointedAt + grab_offset; if (new_position != PixelPosition) { IsMaximized = false; } natural_position = new_position; } else { Vector2Int new_position = natural_position, new_size = natural_size; int top_edge_height = natural_position.y + natural_size.y; Vector2Int displaced_position = The.Cursor.PixelPointedAt; Vector2Int displacement = displaced_position - natural_position; if ((resize_grab_type == ResizeGrabType.Left || resize_grab_type == ResizeGrabType.BottomLeft) && displaced_position.x <= (natural_position.x + natural_size.x - MinimumSize.x)) { new_position.x = displaced_position.x; new_size.x += -displacement.x; } else if (resize_grab_type == ResizeGrabType.Right || resize_grab_type == ResizeGrabType.BottomRight) { new_size.x = displaced_position.x - natural_position.x + 1; } if (resize_grab_type == ResizeGrabType.BottomLeft || resize_grab_type == ResizeGrabType.Bottom || resize_grab_type == ResizeGrabType.BottomRight) { new_size.y = (natural_position.y + natural_size.y) - displaced_position.y + 1; } natural_position = new_position; natural_size = new_size; natural_size.x = Mathf.Max(natural_size.x, MinimumSize.x); natural_size.y = Mathf.Max(natural_size.y, MinimumSize.y); natural_position.y += top_edge_height - (natural_position.y + natural_size.y); } } if (IsMaximized) { RectTransform.sizeDelta = new Vector2(The.Style.MonitorResolution.x, The.Style.MonitorResolution.y - The.Taskbar.Height); RectTransform.anchoredPosition = new Vector2(0, The.Taskbar.Height); } else { RectTransform.sizeDelta = new Vector2(natural_size.x, natural_size.y); RectTransform.anchoredPosition = new Vector2(natural_position.x, natural_position.y); } if (IsMinimized) { CanvasGroup.alpha = 0; } else { CanvasGroup.alpha = 1; } }