コード例 #1
0
        static public OffsetCoord CubeToRoffset(int shift, CubeCoord cube)
        {
            int col = cube.q + (cube.r + shift * (cube.r & 1)) / 2;
            int row = cube.r;

            return(new OffsetCoord(col, row));
        }
コード例 #2
0
ファイル: GameMap.cs プロジェクト: Foxengton/MapEditor
        private string DrawPath(int Index)
        {
            string  FinalPath = string.Empty;
            CellMap Loc;

            CubeCoord coord = _Location.ToCube();

            for (int i = 0; i < 6; i++)
            {
                if ((Loc = CellMap.Find(_LocationList, coord.Neighbor(i).ToAxial())).ID != null)
                {
                    if (Loc.Properties[Index] != "")
                    {
                        FinalPath += i + 1;
                    }
                }
            }

            if (Index == 1)
            {
                return("Road" + FinalPath);
            }
            else
            {
                return("River" + FinalPath);
            }
        }
コード例 #3
0
        public Point HexToPixel(CubeCoord cube, Point offset)
        {
            Orientation M = orientation;
            int         x = (int)Math.Round((M.f0 * cube.q + M.f1 * cube.r) * size.Width);
            int         y = (int)Math.Round((M.f2 * cube.q + M.f3 * cube.r) * size.Height);

            return(new Point(x + offset.X, y + offset.Y));
        }
コード例 #4
0
ファイル: GameMap.cs プロジェクト: Foxengton/MapEditor
        private void MapBox_MouseMove(object sender, MouseEventArgs e)
        {
            CubeCoord Location_ = _GridType.PixelToHex(new PointF(e.X, e.Y), _StartPos).Add(_Location.ToCube());

            int Distance = _Location.ToCube().Distance(Location_);

            CoordinatesText.Text = $"Дистанция: {Distance}";
        }
コード例 #5
0
        public bool Equals(CubeCoord other)
        {
            if (q == other.q && r == other.r)
            {
                return(true);
            }

            return(false);
        }
コード例 #6
0
        static public List <CubeCoord> HexLinedraw(CubeCoord a, CubeCoord b)
        {
            int              N       = a.Distance(b);
            FractionalCoord  a_nudge = new FractionalCoord(a.q + 0.000001F, a.r + 0.000001F, a.s - 0.000002F);
            FractionalCoord  b_nudge = new FractionalCoord(b.q + 0.000001F, b.r + 0.000001F, b.s - 0.000002F);
            List <CubeCoord> results = new List <CubeCoord> {
            };
            float step = 1F / Math.Max(N, 1);

            for (int i = 0; i <= N; i++)
            {
                results.Add(a_nudge.HexLerp(b_nudge, step * i).ToCube());
            }
            return(results);
        }
コード例 #7
0
        public PointF[] DrawPolygon(CubeCoord cube, Point offset)
        {
            Orientation M = orientation;

            PointF[] corners = new PointF[6];
            PointF   center  = HexToPixel(cube, offset);

            for (int i = 0; i < 6; i++)
            {
                double angle   = 2.0 * Math.PI * (M.start_angle - i) / 6.0;
                PointF offset_ = new PointF(size.Width * (float)Math.Cos(angle), size.Height * (float)Math.Sin(angle));
                corners[i] = new PointF(center.X + offset_.X, center.Y + offset_.Y);
            }

            return(corners);
        }
コード例 #8
0
        public AxialCoord[] СubeRing(AxialCoord center, int Radius)
        {
            AxialCoord[] Coords = new AxialCoord[Radius * 6];

            CubeCoord cube = new CubeCoord().Neighbor(4).Scale(Radius).Add(center.ToCube());

            int Index = 0;

            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < Radius; j++)
                {
                    Coords[Index] = new AxialCoord(cube.q, cube.r);

                    cube = cube.Neighbor(i);
                    Index++;
                }
            }

            return(Coords);
        }
コード例 #9
0
 public int Distance(CubeCoord b) => Subtract(b).Length();
コード例 #10
0
 public CubeCoord Subtract(CubeCoord other) => new CubeCoord(q - other.q, r - other.r, s - other.s);
コード例 #11
0
 public CubeCoord Add(CubeCoord other) => new CubeCoord(q + other.q, r + other.r, s + other.s);