Пример #1
0
        public void ToGridCoord_Test()
        {
            var g    = GetGrid();
            var data = new Vector2Decimal(10, 10);

            Assert.That(g.ToGridCoord(data), Is.EqualTo(new UnityEngine.Vector2Int(100, 100)));
        }
Пример #2
0
        public Vector2Decimal[] ReadFile(string path)
        {
            var separator = new[] { ',' };
            var content   = File.ReadAllLines(path);
            var result    = new Vector2Decimal[content.Length];

            for (var i = 0; i < content.Length; i++)
            {
                var split = content[i].Split(separator);
                if (split.Length != 2)
                {
                    throw new SerializationException($"Invalid data at line {i}");
                }

                if (!Decimal.TryParse(split[0], NumberStyles.Any, CultureInfo.InvariantCulture, out var x) ||
                    !Decimal.TryParse(split[1], NumberStyles.Any, CultureInfo.InvariantCulture, out var y))
                {
                    throw new SerializationException($"Invalid data at line {i}");
                }

                result[i] = new Vector2Decimal(x, y);
            }

            return(result);
        }
Пример #3
0
        public void ToGridCoordPositiveStart_Test()
        {
            var g = GetGrid();

            g.MoveStartX(5);
            var data = new Vector2Decimal(10, 10);

            Assert.That(g.ToGridCoord(data), Is.EqualTo(new UnityEngine.Vector2Int(50, 100)));
        }
Пример #4
0
        public void ToGridCoord_Width_ScaleX_MoveStart_Test()
        {
            var g = GetGrid();

            g.ScaleUpX(-1);   // PpuX = 90, ExponentX = 1, UnitCost = 10, PixelCost =
            g.MoveStartX(-1); // StartX = -10.0
            var data = new Vector2Decimal(10, 10);

            Assert.That(g.ToGridCoord(data), Is.EqualTo(new UnityEngine.Vector2Int(180, 100)));
        }