From 26319fd4360c4df52de1fbaae26aef64968507e7 Mon Sep 17 00:00:00 2001 From: Pavel Kurkutov Date: Fri, 30 Apr 2021 17:50:02 +0000 Subject: [PATCH] [Bot] Automated ReSharper CLT update --- .../Common/TestCases/HexHelperTestCases.cs | 29 ++++++++++++++----- Zilon.Core/Zilon.Core/Common/HexHelper.cs | 6 +++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Zilon.Core/Zilon.Core.Tests/Common/TestCases/HexHelperTestCases.cs b/Zilon.Core/Zilon.Core.Tests/Common/TestCases/HexHelperTestCases.cs index d6a12b3f6..635de5c24 100644 --- a/Zilon.Core/Zilon.Core.Tests/Common/TestCases/HexHelperTestCases.cs +++ b/Zilon.Core/Zilon.Core.Tests/Common/TestCases/HexHelperTestCases.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using NUnit.Framework; @@ -10,16 +11,28 @@ public static IEnumerable TestCases { get { - static float sqrt(float a) => (float)System.Math.Sqrt(a); + static float sqrt(float a) + { + return (float)Math.Sqrt(a); + } - static int round(float a) => (int)System.Math.Round(a, System.MidpointRounding.ToEven); + static int round(float a) + { + return (int)Math.Round(a, MidpointRounding.ToEven); + } // Step left is pointy top hex width on x-axis. // Step depends on hex size (radius of covered round). - static int stepLeft(float size) => round(size * sqrt(3)); + static int stepLeft(float size) + { + return round(size * sqrt(3)); + } // Step top is vertical spacing between hex. - static int stepTop(float size) => round(size * 2 * 3f / 4f); + static int stepTop(float size) + { + return round(size * 2 * 3f / 4f); + } // Params: // world x coordinate @@ -31,8 +44,10 @@ public static IEnumerable TestCases yield return new TestCaseData(stepLeft(50), 0, 50).Returns(new OffsetCoords(1, 0)); yield return new TestCaseData(stepLeft(50) / 2, stepTop(50), 50).Returns(new OffsetCoords(0, 1)); - yield return new TestCaseData(stepLeft(50) + stepLeft(50) / 2, stepTop(50), 50).Returns(new OffsetCoords(1, 1)); - yield return new TestCaseData(3 * stepLeft(50) + stepLeft(50) / 2, stepTop(50), 50).Returns(new OffsetCoords(3, 1)); + yield return new TestCaseData(stepLeft(50) + stepLeft(50) / 2, stepTop(50), 50).Returns( + new OffsetCoords(1, 1)); + yield return new TestCaseData(3 * stepLeft(50) + stepLeft(50) / 2, stepTop(50), 50).Returns( + new OffsetCoords(3, 1)); yield return new TestCaseData(0, 2 * stepTop(50), 50).Returns(new OffsetCoords(0, 2)); diff --git a/Zilon.Core/Zilon.Core/Common/HexHelper.cs b/Zilon.Core/Zilon.Core/Common/HexHelper.cs index 2d9ab981d..dbcae546e 100644 --- a/Zilon.Core/Zilon.Core/Common/HexHelper.cs +++ b/Zilon.Core/Zilon.Core/Common/HexHelper.cs @@ -63,7 +63,11 @@ public static AxialCoords ConvertWorldToAxial(int worldX, int worldY, int size) { // see https://habr.com/ru/post/319644/ - static float sqrt(float a) => (float)Math.Sqrt(a); + static float sqrt(float a) + { + return (float)Math.Sqrt(a); + } + var q = (sqrt(3) / 3f * worldX - worldY / 3f) / size; var r = (2f / 3f * worldY) / size; var axialCoords = new AxialCoords(q, r);